2009-04-27 14:48:12 +00:00
|
|
|
/*
|
|
|
|
* Cogl
|
|
|
|
*
|
2014-02-22 01:28:54 +00:00
|
|
|
* A Low Level GPU Graphics and Utilities API
|
2009-04-27 14:48:12 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Intel Corporation.
|
|
|
|
*
|
2014-02-22 01:28:54 +00: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 14:48:12 +00:00
|
|
|
*
|
2014-02-22 01:28:54 +00:00
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
2009-04-27 14:48:12 +00:00
|
|
|
*
|
2014-02-22 01:28:54 +00: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 12:56:10 +00:00
|
|
|
*
|
|
|
|
*
|
2009-04-27 14:48:12 +00:00
|
|
|
*/
|
|
|
|
|
2009-02-23 12:47:02 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2010-02-17 14:38:11 +00:00
|
|
|
#include <stdlib.h>
|
2009-02-23 12:47:02 +00:00
|
|
|
|
2013-04-28 01:42:24 +00:00
|
|
|
#include "cogl-i18n-private.h"
|
2011-06-14 21:33:44 +00:00
|
|
|
#include "cogl-private.h"
|
2009-02-23 12:47:02 +00:00
|
|
|
#include "cogl-debug.h"
|
2012-03-06 18:21:28 +00:00
|
|
|
#include "cogl1-context.h"
|
2009-02-23 12:47:02 +00:00
|
|
|
|
2010-12-03 12:01:18 +00:00
|
|
|
/* XXX: If you add a debug option, please also add an option
|
|
|
|
* definition to cogl-debug-options.h. This will enable us - for
|
|
|
|
* example - to emit a "help" description for the option.
|
2010-02-17 14:38:11 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* NB: Only these options get enabled if COGL_DEBUG=all is
|
|
|
|
* used since they don't affect the behaviour of Cogl they
|
|
|
|
* simply print out verbose information */
|
|
|
|
static const GDebugKey cogl_log_debug_keys[] = {
|
2012-04-16 13:14:10 +00:00
|
|
|
{ "object", COGL_DEBUG_OBJECT },
|
2010-02-17 14:38:11 +00:00
|
|
|
{ "slicing", COGL_DEBUG_SLICING },
|
|
|
|
{ "atlas", COGL_DEBUG_ATLAS },
|
|
|
|
{ "blend-strings", COGL_DEBUG_BLEND_STRINGS },
|
|
|
|
{ "journal", COGL_DEBUG_JOURNAL },
|
|
|
|
{ "batching", COGL_DEBUG_BATCHING },
|
|
|
|
{ "matrices", COGL_DEBUG_MATRICES },
|
2009-02-28 16:03:11 +00:00
|
|
|
{ "draw", COGL_DEBUG_DRAW },
|
2010-02-17 18:45:08 +00:00
|
|
|
{ "opengl", COGL_DEBUG_OPENGL },
|
2009-04-17 14:10:55 +00:00
|
|
|
{ "pango", COGL_DEBUG_PANGO },
|
2010-05-26 16:14:53 +00:00
|
|
|
{ "show-source", COGL_DEBUG_SHOW_SOURCE},
|
2010-05-25 17:56:14 +00:00
|
|
|
{ "offscreen", COGL_DEBUG_OFFSCREEN },
|
2010-07-15 12:02:23 +00:00
|
|
|
{ "texture-pixmap", COGL_DEBUG_TEXTURE_PIXMAP },
|
2011-01-24 16:36:56 +00:00
|
|
|
{ "bitmap", COGL_DEBUG_BITMAP },
|
2012-02-07 16:53:12 +00:00
|
|
|
{ "clipping", COGL_DEBUG_CLIPPING },
|
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
|
|
|
{ "winsys", COGL_DEBUG_WINSYS },
|
|
|
|
{ "performance", COGL_DEBUG_PERFORMANCE }
|
2010-02-17 14:38:11 +00:00
|
|
|
};
|
|
|
|
static const int n_cogl_log_debug_keys =
|
|
|
|
G_N_ELEMENTS (cogl_log_debug_keys);
|
|
|
|
|
|
|
|
static const GDebugKey cogl_behavioural_debug_keys[] = {
|
2009-05-19 15:00:18 +00:00
|
|
|
{ "rectangles", COGL_DEBUG_RECTANGLES },
|
2009-06-05 12:50:00 +00:00
|
|
|
{ "disable-batching", COGL_DEBUG_DISABLE_BATCHING },
|
2009-06-17 00:59:28 +00:00
|
|
|
{ "disable-vbos", COGL_DEBUG_DISABLE_VBOS },
|
2010-07-06 00:30:25 +00:00
|
|
|
{ "disable-pbos", COGL_DEBUG_DISABLE_PBOS },
|
2009-10-26 11:01:33 +00:00
|
|
|
{ "disable-software-transform", COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM },
|
2010-01-21 15:34:19 +00:00
|
|
|
{ "dump-atlas-image", COGL_DEBUG_DUMP_ATLAS_IMAGE },
|
2010-04-26 09:01:43 +00:00
|
|
|
{ "disable-atlas", COGL_DEBUG_DISABLE_ATLAS },
|
2011-03-30 15:39:38 +00:00
|
|
|
{ "disable-shared-atlas", COGL_DEBUG_DISABLE_SHARED_ATLAS },
|
2010-04-26 09:01:43 +00:00
|
|
|
{ "disable-texturing", COGL_DEBUG_DISABLE_TEXTURING},
|
|
|
|
{ "disable-arbfp", COGL_DEBUG_DISABLE_ARBFP},
|
2010-11-24 17:29:00 +00:00
|
|
|
{ "disable-fixed", COGL_DEBUG_DISABLE_FIXED},
|
2010-04-08 11:21:04 +00:00
|
|
|
{ "disable-glsl", COGL_DEBUG_DISABLE_GLSL},
|
2010-11-05 14:55:46 +00:00
|
|
|
{ "disable-blending", COGL_DEBUG_DISABLE_BLENDING},
|
2010-11-16 13:06:08 +00:00
|
|
|
{ "disable-npot-textures", COGL_DEBUG_DISABLE_NPOT_TEXTURES},
|
2010-11-10 14:02:31 +00:00
|
|
|
{ "wireframe", COGL_DEBUG_WIREFRAME},
|
2010-12-03 12:01:18 +00:00
|
|
|
{ "disable-software-clip", COGL_DEBUG_DISABLE_SOFTWARE_CLIP},
|
2011-01-20 14:41:51 +00:00
|
|
|
{ "disable-program-caches", COGL_DEBUG_DISABLE_PROGRAM_CACHES},
|
|
|
|
{ "disable-fast-read-pixel", COGL_DEBUG_DISABLE_FAST_READ_PIXEL}
|
2009-02-23 12:47:02 +00:00
|
|
|
};
|
2010-02-17 14:38:11 +00:00
|
|
|
static const int n_cogl_behavioural_debug_keys =
|
|
|
|
G_N_ELEMENTS (cogl_behavioural_debug_keys);
|
2009-02-23 12:47:02 +00:00
|
|
|
|
2011-10-31 14:19:10 +00:00
|
|
|
unsigned long _cogl_debug_flags[COGL_DEBUG_N_LONGS];
|
2011-06-10 17:44:09 +00:00
|
|
|
GHashTable *_cogl_debug_instances;
|
2009-02-23 12:47:02 +00:00
|
|
|
|
2011-01-24 14:28:00 +00:00
|
|
|
static void
|
|
|
|
_cogl_parse_debug_string_for_keys (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,
|
2011-01-24 14:28:00 +00:00
|
|
|
const GDebugKey *keys,
|
|
|
|
unsigned int nkeys)
|
|
|
|
{
|
2011-10-31 14:19:10 +00:00
|
|
|
int long_num, key_num;
|
2011-01-24 14:28:00 +00:00
|
|
|
|
|
|
|
/* g_parse_debug_string expects the value field in GDebugKey to be a
|
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
|
|
|
mask in an unsigned int but the flags are stored in an array of
|
|
|
|
multiple longs so we need to build a separate array for each
|
|
|
|
possible unsigned int */
|
2011-01-24 14:28:00 +00:00
|
|
|
|
2011-10-31 14:19:10 +00:00
|
|
|
for (long_num = 0; long_num < COGL_DEBUG_N_LONGS; long_num++)
|
2011-01-24 14:28:00 +00:00
|
|
|
{
|
2011-10-31 14:19:10 +00:00
|
|
|
int int_num;
|
|
|
|
|
|
|
|
for (int_num = 0;
|
|
|
|
int_num < sizeof (unsigned long) / sizeof (unsigned int);
|
|
|
|
int_num++)
|
2011-01-24 14:28:00 +00:00
|
|
|
{
|
2011-10-31 14:19:10 +00:00
|
|
|
GDebugKey keys_for_int[sizeof (unsigned int) * 8];
|
|
|
|
int nkeys_for_int = 0;
|
|
|
|
|
|
|
|
for (key_num = 0; key_num < nkeys; key_num++)
|
|
|
|
{
|
|
|
|
int long_index = COGL_FLAGS_GET_INDEX (keys[key_num].value);
|
|
|
|
int int_index = (keys[key_num].value %
|
|
|
|
(sizeof (unsigned long) * 8) /
|
|
|
|
(sizeof (unsigned int) * 8));
|
|
|
|
|
|
|
|
if (long_index == long_num && int_index == int_num)
|
|
|
|
{
|
|
|
|
keys_for_int[nkeys_for_int] = keys[key_num];
|
|
|
|
keys_for_int[nkeys_for_int].value =
|
|
|
|
COGL_FLAGS_GET_MASK (keys[key_num].value) >>
|
|
|
|
(int_num * sizeof (unsigned int) * 8);
|
|
|
|
nkeys_for_int++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nkeys_for_int > 0)
|
|
|
|
{
|
|
|
|
unsigned long mask =
|
|
|
|
((unsigned long) g_parse_debug_string (value,
|
|
|
|
keys_for_int,
|
|
|
|
nkeys_for_int)) <<
|
|
|
|
(int_num * sizeof (unsigned int) * 8);
|
|
|
|
|
|
|
|
if (enable)
|
|
|
|
_cogl_debug_flags[long_num] |= mask;
|
|
|
|
else
|
|
|
|
_cogl_debug_flags[long_num] &= ~mask;
|
|
|
|
}
|
2011-01-24 14:28:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-03 17:15:54 +00:00
|
|
|
void
|
2010-02-17 14:38:11 +00:00
|
|
|
_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)
|
2010-02-17 14:38:11 +00:00
|
|
|
{
|
|
|
|
if (ignore_help && strcmp (value, "help") == 0)
|
2011-01-24 14:28:00 +00:00
|
|
|
return;
|
2010-02-17 14:38:11 +00:00
|
|
|
|
|
|
|
/* We don't want to let g_parse_debug_string handle "all" because
|
|
|
|
* literally enabling all the debug options wouldn't be useful to
|
|
|
|
* anyone; instead the all option enables all non behavioural
|
|
|
|
* options.
|
|
|
|
*/
|
|
|
|
if (strcmp (value, "all") == 0 ||
|
|
|
|
strcmp (value, "verbose") == 0)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < n_cogl_log_debug_keys; i++)
|
2011-01-24 14:28:00 +00:00
|
|
|
if (enable)
|
|
|
|
COGL_DEBUG_SET_FLAG (cogl_log_debug_keys[i].value);
|
|
|
|
else
|
|
|
|
COGL_DEBUG_CLEAR_FLAG (cogl_log_debug_keys[i].value);
|
2010-02-17 14:38:11 +00:00
|
|
|
}
|
2011-12-09 17:17:51 +00:00
|
|
|
else if (g_ascii_strcasecmp (value, "help") == 0)
|
2010-02-17 14:38:11 +00:00
|
|
|
{
|
2011-09-10 08:52:48 +00:00
|
|
|
g_printerr ("\n\n%28s\n", _("Supported debug values:"));
|
2010-06-21 14:36:46 +00:00
|
|
|
#define OPT(MASK_NAME, GROUP, NAME, NAME_FORMATTED, DESCRIPTION) \
|
2016-04-11 15:06:57 +00:00
|
|
|
g_printerr ("%28s %s\n", NAME ":", DESCRIPTION);
|
2010-06-21 14:36:46 +00:00
|
|
|
#include "cogl-debug-options.h"
|
2011-09-10 08:52:48 +00:00
|
|
|
g_printerr ("\n%28s\n", _("Special debug values:"));
|
2010-06-21 14:36:46 +00:00
|
|
|
OPT (IGNORED, "ignored", "all", "ignored", \
|
2011-09-10 08:52:48 +00:00
|
|
|
N_("Enables all non-behavioural debug options"));
|
2010-06-21 14:36:46 +00:00
|
|
|
OPT (IGNORED, "ignored", "verbose", "ignored", \
|
2011-09-10 08:52:48 +00:00
|
|
|
N_("Enables all non-behavioural debug options"));
|
2010-02-17 14:38:11 +00:00
|
|
|
#undef OPT
|
2012-07-31 15:30:33 +00:00
|
|
|
|
|
|
|
g_printerr ("\n"
|
|
|
|
"%28s\n"
|
|
|
|
" COGL_DISABLE_GL_EXTENSIONS: %s\n"
|
|
|
|
" COGL_OVERRIDE_GL_VERSION: %s\n",
|
|
|
|
_("Additional environment variables:"),
|
|
|
|
_("Comma-separated list of GL extensions to pretend are "
|
|
|
|
"disabled"),
|
|
|
|
_("Override the GL version that Cogl will assume the driver "
|
|
|
|
"supports"));
|
2010-02-17 14:38:11 +00:00
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-24 14:28:00 +00:00
|
|
|
_cogl_parse_debug_string_for_keys (value,
|
|
|
|
enable,
|
|
|
|
cogl_log_debug_keys,
|
|
|
|
n_cogl_log_debug_keys);
|
|
|
|
_cogl_parse_debug_string_for_keys (value,
|
|
|
|
enable,
|
|
|
|
cogl_behavioural_debug_keys,
|
|
|
|
n_cogl_behavioural_debug_keys);
|
2010-02-17 14:38:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-14 21:33:44 +00:00
|
|
|
#ifdef COGL_ENABLE_DEBUG
|
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
|
|
|
static CoglBool
|
2009-02-23 12:47:02 +00:00
|
|
|
cogl_arg_debug_cb (const char *key,
|
|
|
|
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
|
|
|
void *user_data)
|
2009-02-23 12:47:02 +00:00
|
|
|
{
|
2011-01-24 14:28:00 +00:00
|
|
|
_cogl_parse_debug_string (value,
|
|
|
|
TRUE /* enable the flags */,
|
|
|
|
FALSE /* don't ignore help */);
|
2009-02-23 12:47:02 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
static CoglBool
|
2009-02-23 12:47:02 +00:00
|
|
|
cogl_arg_no_debug_cb (const char *key,
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-10 01:57:32 +00:00
|
|
|
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
|
|
|
void *user_data)
|
2009-02-23 12:47:02 +00:00
|
|
|
{
|
2011-01-24 14:28:00 +00:00
|
|
|
_cogl_parse_debug_string (value,
|
|
|
|
FALSE, /* disable the flags */
|
|
|
|
TRUE /* ignore help */);
|
2009-02-23 12:47:02 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2010-02-17 14:38:11 +00:00
|
|
|
#endif /* COGL_ENABLE_DEBUG */
|
2009-02-23 12:47:02 +00:00
|
|
|
|
|
|
|
static GOptionEntry cogl_args[] = {
|
2010-03-02 02:07:40 +00:00
|
|
|
#ifdef COGL_ENABLE_DEBUG
|
2009-02-23 12:47:02 +00:00
|
|
|
{ "cogl-debug", 0, 0, G_OPTION_ARG_CALLBACK, cogl_arg_debug_cb,
|
2010-10-05 07:03:19 +00:00
|
|
|
N_("Cogl debugging flags to set"), "FLAGS" },
|
2009-02-23 12:47:02 +00:00
|
|
|
{ "cogl-no-debug", 0, 0, G_OPTION_ARG_CALLBACK, cogl_arg_no_debug_cb,
|
2010-10-05 07:03:19 +00:00
|
|
|
N_("Cogl debugging flags to unset"), "FLAGS" },
|
2010-03-02 02:07:40 +00:00
|
|
|
#endif /* COGL_ENABLE_DEBUG */
|
2009-02-23 12:47:02 +00:00
|
|
|
{ NULL, },
|
|
|
|
};
|
|
|
|
|
2011-06-14 21:33:44 +00:00
|
|
|
void
|
|
|
|
_cogl_debug_check_environment (void)
|
2009-02-23 12:47:02 +00:00
|
|
|
{
|
|
|
|
const char *env_string;
|
|
|
|
|
|
|
|
env_string = g_getenv ("COGL_DEBUG");
|
|
|
|
if (env_string != NULL)
|
|
|
|
{
|
2011-01-24 14:28:00 +00:00
|
|
|
_cogl_parse_debug_string (env_string,
|
|
|
|
TRUE /* enable the flags */,
|
|
|
|
FALSE /* don't ignore help */);
|
2009-02-23 12:47:02 +00:00
|
|
|
env_string = NULL;
|
|
|
|
}
|
2011-08-03 17:15:54 +00:00
|
|
|
|
|
|
|
env_string = g_getenv ("COGL_NO_DEBUG");
|
|
|
|
if (env_string != NULL)
|
|
|
|
{
|
|
|
|
_cogl_parse_debug_string (env_string,
|
|
|
|
FALSE /* disable the flags */,
|
|
|
|
FALSE /* don't ignore help */);
|
|
|
|
env_string = NULL;
|
|
|
|
}
|
2011-06-14 21:33:44 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
static CoglBool
|
|
|
|
pre_parse_hook (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
void *data,
|
|
|
|
GError **error)
|
2011-06-14 21:33:44 +00:00
|
|
|
{
|
|
|
|
_cogl_init ();
|
2009-02-23 12:47:02 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-06-14 21:33:44 +00:00
|
|
|
/* XXX: GOption based library initialization is not reliable because the
|
|
|
|
* GOption API has no way to represent dependencies between libraries.
|
|
|
|
*/
|
2009-02-23 12:47:02 +00:00
|
|
|
GOptionGroup *
|
|
|
|
cogl_get_option_group (void)
|
|
|
|
{
|
|
|
|
GOptionGroup *group;
|
|
|
|
|
|
|
|
group = g_option_group_new ("cogl",
|
2010-10-05 07:03:19 +00:00
|
|
|
_("Cogl Options"),
|
|
|
|
_("Show Cogl options"),
|
2009-02-23 12:47:02 +00:00
|
|
|
NULL, NULL);
|
|
|
|
|
|
|
|
g_option_group_set_parse_hooks (group, pre_parse_hook, NULL);
|
|
|
|
g_option_group_add_entries (group, cogl_args);
|
|
|
|
|
|
|
|
return group;
|
|
|
|
}
|