2009-04-27 14:48:12 +00:00
|
|
|
/*
|
|
|
|
* Cogl
|
|
|
|
*
|
|
|
|
* An object oriented GL/GLES Abstraction/Utility Layer
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2010-03-01 12:56:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*
|
2009-04-27 14:48:12 +00:00
|
|
|
*/
|
|
|
|
|
2009-02-23 12:47:02 +00:00
|
|
|
#ifndef __COGL_DEBUG_H__
|
|
|
|
#define __COGL_DEBUG_H__
|
|
|
|
|
2010-06-21 14:36:46 +00:00
|
|
|
#include "cogl-profile.h"
|
2011-04-15 14:39:14 +00:00
|
|
|
#include "cogl-flags.h"
|
2011-11-24 16:09:16 +00:00
|
|
|
#include "cogl-util.h"
|
2010-06-21 14:36:46 +00:00
|
|
|
|
2009-02-23 12:47:02 +00:00
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
typedef enum {
|
2011-01-24 14:28:00 +00:00
|
|
|
COGL_DEBUG_SLICING,
|
|
|
|
COGL_DEBUG_OFFSCREEN,
|
|
|
|
COGL_DEBUG_DRAW,
|
|
|
|
COGL_DEBUG_PANGO,
|
|
|
|
COGL_DEBUG_RECTANGLES,
|
2012-04-16 13:14:10 +00:00
|
|
|
COGL_DEBUG_OBJECT,
|
2011-01-24 14:28:00 +00: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 15:39:38 +00:00
|
|
|
COGL_DEBUG_DISABLE_SHARED_ATLAS,
|
2011-01-24 14:28:00 +00: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 16:36:56 +00:00
|
|
|
COGL_DEBUG_CLIPPING,
|
2010-11-05 12:28:33 +00: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 15:59:48 +00:00
|
|
|
COGL_DEBUG_PERFORMANCE,
|
2011-01-24 14:28:00 +00:00
|
|
|
|
|
|
|
COGL_DEBUG_N_FLAGS
|
2009-02-23 12:47:02 +00:00
|
|
|
} CoglDebugFlags;
|
|
|
|
|
|
|
|
#ifdef COGL_ENABLE_DEBUG
|
|
|
|
|
2011-10-31 14:19:10 +00:00
|
|
|
#define COGL_DEBUG_N_LONGS COGL_FLAGS_N_LONGS_FOR_SIZE (COGL_DEBUG_N_FLAGS)
|
2011-01-24 14:28:00 +00:00
|
|
|
|
2011-11-24 16:09:16 +00: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-06-10 17:44:09 +00:00
|
|
|
extern GHashTable *_cogl_debug_instances;
|
2011-01-24 14:28:00 +00:00
|
|
|
|
|
|
|
#define COGL_DEBUG_ENABLED(flag) \
|
2011-04-15 14:39:14 +00:00
|
|
|
COGL_FLAGS_GET (_cogl_debug_flags, flag)
|
2011-01-24 14:28:00 +00:00
|
|
|
|
|
|
|
#define COGL_DEBUG_SET_FLAG(flag) \
|
2011-04-15 14:39:14 +00:00
|
|
|
COGL_FLAGS_SET (_cogl_debug_flags, flag, TRUE)
|
2011-01-24 14:28:00 +00:00
|
|
|
|
|
|
|
#define COGL_DEBUG_CLEAR_FLAG(flag) \
|
2011-04-15 14:39:14 +00:00
|
|
|
COGL_FLAGS_SET (_cogl_debug_flags, flag, FALSE)
|
2011-01-24 14:28:00 +00:00
|
|
|
|
2009-02-23 12:47:02 +00:00
|
|
|
#ifdef __GNUC__
|
2010-06-21 14:36:46 +00:00
|
|
|
#define COGL_NOTE(type,x,a...) G_STMT_START { \
|
2011-01-24 14:28:00 +00:00
|
|
|
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_##type))) { \
|
2010-06-21 14:36:46 +00:00
|
|
|
_cogl_profile_trace_message ("[" #type "] " G_STRLOC " & " x, ##a); \
|
2010-05-03 18:41:17 +00:00
|
|
|
} } G_STMT_END
|
2009-02-23 12:47:02 +00:00
|
|
|
|
|
|
|
#else
|
2010-06-21 14:36:46 +00:00
|
|
|
#define COGL_NOTE(type,...) G_STMT_START { \
|
2011-07-18 12:52:45 +00:00
|
|
|
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_##type))) { \
|
2010-06-21 14:36:46 +00:00
|
|
|
char *_fmt = g_strdup_printf (__VA_ARGS__); \
|
|
|
|
_cogl_profile_trace_message ("[" #type "] " G_STRLOC " & %s", _fmt);\
|
|
|
|
g_free (_fmt); \
|
2010-05-03 18:41:17 +00:00
|
|
|
} } G_STMT_END
|
2009-02-23 12:47:02 +00:00
|
|
|
|
|
|
|
#endif /* __GNUC__ */
|
|
|
|
|
|
|
|
#else /* !COGL_ENABLE_DEBUG */
|
|
|
|
|
2009-07-27 23:40:29 +00:00
|
|
|
#define COGL_NOTE(type,...) G_STMT_START {} G_STMT_END
|
2009-02-23 12:47:02 +00:00
|
|
|
|
2011-01-24 14:28:00 +00:00
|
|
|
#define COGL_DEBUG_ENABLED(flag) FALSE
|
|
|
|
|
|
|
|
#define COGL_DEBUG_SET_FLAG(flag) \
|
|
|
|
G_STMT_START { } G_STMT_END
|
2009-02-23 12:47:02 +00:00
|
|
|
|
2011-01-24 14:28:00 +00:00
|
|
|
#define COGL_DEBUG_CLEAR_FLAG(flag) \
|
|
|
|
G_STMT_START { } G_STMT_END
|
|
|
|
|
|
|
|
#endif /* COGL_ENABLE_DEBUG */
|
2009-02-23 12:47:02 +00:00
|
|
|
|
2011-06-14 21:33:44 +00:00
|
|
|
void
|
|
|
|
_cogl_debug_check_environment (void);
|
|
|
|
|
2011-08-03 17:15:54 +00: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 20:56:40 +00:00
|
|
|
CoglBool enable,
|
|
|
|
CoglBool ignore_help);
|
2011-08-03 17:15:54 +00:00
|
|
|
|
2009-02-23 12:47:02 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __COGL_DEBUG_H__ */
|
2009-05-10 23:40:41 +00:00
|
|
|
|