2009-04-27 10:48:12 -04:00
|
|
|
/*
|
|
|
|
* Cogl
|
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* A Low Level GPU Graphics and Utilities API
|
2009-04-27 10:48:12 -04:00
|
|
|
*
|
|
|
|
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
* obtaining a copy of this software and associated documentation
|
|
|
|
* files (the "Software"), to deal in the Software without
|
|
|
|
* restriction, including without limitation the rights to use, copy,
|
|
|
|
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
* of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2009-04-27 10:48:12 -04:00
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
2009-04-27 10:48:12 -04:00
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
2010-03-01 07:56:10 -05:00
|
|
|
*
|
|
|
|
*
|
2009-04-27 10:48:12 -04:00
|
|
|
*/
|
|
|
|
|
2009-02-23 07:47:02 -05:00
|
|
|
#ifndef __COGL_DEBUG_H__
|
|
|
|
#define __COGL_DEBUG_H__
|
|
|
|
|
2010-06-21 10:36:46 -04:00
|
|
|
#include "cogl-profile.h"
|
2011-04-15 10:39:14 -04:00
|
|
|
#include "cogl-flags.h"
|
2011-11-24 11:09:16 -05:00
|
|
|
#include "cogl-util.h"
|
2010-06-21 10:36:46 -04:00
|
|
|
|
2009-02-23 07:47:02 -05:00
|
|
|
#include <glib.h>
|
|
|
|
|
2012-11-22 13:01:10 -05:00
|
|
|
COGL_BEGIN_DECLS
|
2009-02-23 07:47:02 -05:00
|
|
|
|
|
|
|
typedef enum {
|
2011-01-24 09:28:00 -05:00
|
|
|
COGL_DEBUG_SLICING,
|
|
|
|
COGL_DEBUG_OFFSCREEN,
|
|
|
|
COGL_DEBUG_DRAW,
|
|
|
|
COGL_DEBUG_PANGO,
|
|
|
|
COGL_DEBUG_RECTANGLES,
|
2012-04-16 09:14:10 -04:00
|
|
|
COGL_DEBUG_OBJECT,
|
2011-01-24 09:28:00 -05:00
|
|
|
COGL_DEBUG_BLEND_STRINGS,
|
|
|
|
COGL_DEBUG_DISABLE_BATCHING,
|
|
|
|
COGL_DEBUG_DISABLE_VBOS,
|
|
|
|
COGL_DEBUG_DISABLE_PBOS,
|
|
|
|
COGL_DEBUG_JOURNAL,
|
|
|
|
COGL_DEBUG_BATCHING,
|
|
|
|
COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM,
|
|
|
|
COGL_DEBUG_MATRICES,
|
|
|
|
COGL_DEBUG_ATLAS,
|
|
|
|
COGL_DEBUG_DUMP_ATLAS_IMAGE,
|
|
|
|
COGL_DEBUG_DISABLE_ATLAS,
|
2011-03-30 11:39:38 -04:00
|
|
|
COGL_DEBUG_DISABLE_SHARED_ATLAS,
|
2011-01-24 09:28:00 -05:00
|
|
|
COGL_DEBUG_OPENGL,
|
|
|
|
COGL_DEBUG_DISABLE_TEXTURING,
|
|
|
|
COGL_DEBUG_DISABLE_ARBFP,
|
|
|
|
COGL_DEBUG_DISABLE_FIXED,
|
|
|
|
COGL_DEBUG_DISABLE_GLSL,
|
|
|
|
COGL_DEBUG_SHOW_SOURCE,
|
|
|
|
COGL_DEBUG_DISABLE_BLENDING,
|
|
|
|
COGL_DEBUG_TEXTURE_PIXMAP,
|
|
|
|
COGL_DEBUG_BITMAP,
|
|
|
|
COGL_DEBUG_DISABLE_NPOT_TEXTURES,
|
|
|
|
COGL_DEBUG_WIREFRAME,
|
|
|
|
COGL_DEBUG_DISABLE_SOFTWARE_CLIP,
|
|
|
|
COGL_DEBUG_DISABLE_PROGRAM_CACHES,
|
|
|
|
COGL_DEBUG_DISABLE_FAST_READ_PIXEL,
|
2011-01-24 11:36:56 -05:00
|
|
|
COGL_DEBUG_CLIPPING,
|
2010-11-05 08:28:33 -04:00
|
|
|
COGL_DEBUG_WINSYS,
|
Re-design the matrix stack using a graph of ops
This re-designs the matrix stack so we now keep track of each separate
operation such as rotating, scaling, translating and multiplying as
immutable, ref-counted nodes in a graph.
Being a "graph" here means that different transformations composed of
a sequence of linked operation nodes may share nodes.
The first node in a matrix-stack is always a LOAD_IDENTITY operation.
As an example consider if an application where to draw three rectangles
A, B and C something like this:
cogl_framebuffer_scale (fb, 2, 2, 2);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_translate (fb, 10, 0, 0);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_rotate (fb, 45, 0, 0, 1);
cogl_framebuffer_draw_rectangle (...); /* A */
cogl_framebuffer_pop_matrix(fb);
cogl_framebuffer_draw_rectangle (...); /* B */
cogl_framebuffer_pop_matrix(fb);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_set_modelview_matrix (fb, &mv);
cogl_framebuffer_draw_rectangle (...); /* C */
cogl_framebuffer_pop_matrix(fb);
That would result in a graph of nodes like this:
LOAD_IDENTITY
|
SCALE
/ \
SAVE LOAD
| |
TRANSLATE RECTANGLE(C)
| \
SAVE RECTANGLE(B)
|
ROTATE
|
RECTANGLE(A)
Each push adds a SAVE operation which serves as a marker to rewind too
when a corresponding pop is issued and also each SAVE node may also
store a cached matrix representing the composition of all its ancestor
nodes. This means if we repeatedly need to resolve a real CoglMatrix
for a given node then we don't need to repeat the composition.
Some advantages of this design are:
- A single pointer to any node in the graph can now represent a
complete, immutable transformation that can be logged for example
into a journal. Previously we were storing a full CoglMatrix in
each journal entry which is 16 floats for the matrix itself as well
as space for flags and another 16 floats for possibly storing a
cache of the inverse. This means that we significantly reduce
the size of the journal when drawing lots of primitives and we also
avoid copying over 128 bytes per entry.
- It becomes much cheaper to check for equality. In cases where some
(unlikely) false negatives are allowed simply comparing the pointers
of two matrix stack graph entries is enough. Previously we would use
memcmp() to compare matrices.
- It becomes easier to do comparisons of transformations. By looking
for the common ancestry between nodes we can determine the operations
that differentiate the transforms and use those to gain a high level
understanding of the differences. For example we use this in the
journal to be able to efficiently determine when two rectangle
transforms only differ by some translation so that we can perform
software clipping.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit f75aee93f6b293ca7a7babbd8fcc326ee6bf7aef)
2012-02-20 10:59:48 -05:00
|
|
|
COGL_DEBUG_PERFORMANCE,
|
2011-01-24 09:28:00 -05:00
|
|
|
|
|
|
|
COGL_DEBUG_N_FLAGS
|
2009-02-23 07:47:02 -05:00
|
|
|
} CoglDebugFlags;
|
|
|
|
|
2012-05-17 09:51:43 -04:00
|
|
|
extern GHashTable *_cogl_debug_instances;
|
2011-10-31 10:19:10 -04:00
|
|
|
#define COGL_DEBUG_N_LONGS COGL_FLAGS_N_LONGS_FOR_SIZE (COGL_DEBUG_N_FLAGS)
|
2011-01-24 09:28:00 -05:00
|
|
|
|
2011-11-24 11:09:16 -05:00
|
|
|
/* _cogl_debug_flags currently needs to exported outside of the shared
|
|
|
|
library for cogl-pango. The special COGL_EXPORT macro is needed to
|
|
|
|
get this to work when building with MSVC */
|
|
|
|
COGL_EXPORT extern unsigned long _cogl_debug_flags[COGL_DEBUG_N_LONGS];
|
|
|
|
|
2011-01-24 09:28:00 -05:00
|
|
|
#define COGL_DEBUG_ENABLED(flag) \
|
2011-04-15 10:39:14 -04:00
|
|
|
COGL_FLAGS_GET (_cogl_debug_flags, flag)
|
2011-01-24 09:28:00 -05:00
|
|
|
|
|
|
|
#define COGL_DEBUG_SET_FLAG(flag) \
|
2011-04-15 10:39:14 -04:00
|
|
|
COGL_FLAGS_SET (_cogl_debug_flags, flag, TRUE)
|
2011-01-24 09:28:00 -05:00
|
|
|
|
|
|
|
#define COGL_DEBUG_CLEAR_FLAG(flag) \
|
2011-04-15 10:39:14 -04:00
|
|
|
COGL_FLAGS_SET (_cogl_debug_flags, flag, FALSE)
|
2011-01-24 09:28:00 -05:00
|
|
|
|
2009-02-23 07:47:02 -05:00
|
|
|
#ifdef __GNUC__
|
2010-06-21 10:36:46 -04:00
|
|
|
#define COGL_NOTE(type,x,a...) G_STMT_START { \
|
2011-01-24 09:28:00 -05:00
|
|
|
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_##type))) { \
|
2010-06-21 10:36:46 -04:00
|
|
|
_cogl_profile_trace_message ("[" #type "] " G_STRLOC " & " x, ##a); \
|
2010-05-03 14:41:17 -04:00
|
|
|
} } G_STMT_END
|
2009-02-23 07:47:02 -05:00
|
|
|
|
|
|
|
#else
|
2010-06-21 10:36:46 -04:00
|
|
|
#define COGL_NOTE(type,...) G_STMT_START { \
|
2011-07-18 08:52:45 -04:00
|
|
|
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_##type))) { \
|
2010-06-21 10:36:46 -04:00
|
|
|
char *_fmt = g_strdup_printf (__VA_ARGS__); \
|
|
|
|
_cogl_profile_trace_message ("[" #type "] " G_STRLOC " & %s", _fmt);\
|
|
|
|
g_free (_fmt); \
|
2010-05-03 14:41:17 -04:00
|
|
|
} } G_STMT_END
|
2009-02-23 07:47:02 -05:00
|
|
|
|
|
|
|
#endif /* __GNUC__ */
|
|
|
|
|
2011-06-14 17:33:44 -04:00
|
|
|
void
|
|
|
|
_cogl_debug_check_environment (void);
|
|
|
|
|
2011-08-03 13:15:54 -04:00
|
|
|
void
|
|
|
|
_cogl_parse_debug_string (const char *value,
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
CoglBool enable,
|
|
|
|
CoglBool ignore_help);
|
2011-08-03 13:15:54 -04:00
|
|
|
|
2012-11-22 13:01:10 -05:00
|
|
|
COGL_END_DECLS
|
2009-02-23 07:47:02 -05:00
|
|
|
|
|
|
|
#endif /* __COGL_DEBUG_H__ */
|
2009-05-10 19:40:41 -04:00
|
|
|
|