2009-04-27 10:48:12 -04:00
|
|
|
/*
|
|
|
|
* Cogl
|
|
|
|
*
|
|
|
|
* An object oriented GL/GLES Abstraction/Utility Layer
|
|
|
|
*
|
|
|
|
* Copyright (C) 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 07:56:10 -05:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*
|
2009-04-27 10:48:12 -04:00
|
|
|
*/
|
|
|
|
|
2009-02-23 07:47:02 -05:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2010-02-17 09:38:11 -05:00
|
|
|
#include <stdlib.h>
|
2009-02-23 07:47:02 -05:00
|
|
|
|
2013-04-27 21:42:24 -04:00
|
|
|
#include "cogl-i18n-private.h"
|
2011-06-14 17:33:44 -04:00
|
|
|
#include "cogl-private.h"
|
2009-02-23 07:47:02 -05:00
|
|
|
#include "cogl-debug.h"
|
2012-03-06 13:21:28 -05:00
|
|
|
#include "cogl1-context.h"
|
2009-02-23 07:47:02 -05:00
|
|
|
|
2010-12-03 07:01:18 -05: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 09:38:11 -05: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 09:14:10 -04:00
|
|
|
{ "object", COGL_DEBUG_OBJECT },
|
2010-02-17 09:38:11 -05: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 11:03:11 -05:00
|
|
|
{ "draw", COGL_DEBUG_DRAW },
|
2010-02-17 13:45:08 -05:00
|
|
|
{ "opengl", COGL_DEBUG_OPENGL },
|
2009-04-17 10:10:55 -04:00
|
|
|
{ "pango", COGL_DEBUG_PANGO },
|
2010-05-26 12:14:53 -04:00
|
|
|
{ "show-source", COGL_DEBUG_SHOW_SOURCE},
|
2010-05-25 13:56:14 -04:00
|
|
|
{ "offscreen", COGL_DEBUG_OFFSCREEN },
|
2010-07-15 08:02:23 -04:00
|
|
|
{ "texture-pixmap", COGL_DEBUG_TEXTURE_PIXMAP },
|
2011-01-24 11:36:56 -05:00
|
|
|
{ "bitmap", COGL_DEBUG_BITMAP },
|
2012-02-07 11:53:12 -05: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 10:59:48 -05:00
|
|
|
{ "winsys", COGL_DEBUG_WINSYS },
|
|
|
|
{ "performance", COGL_DEBUG_PERFORMANCE }
|
2010-02-17 09:38:11 -05: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 11:00:18 -04:00
|
|
|
{ "rectangles", COGL_DEBUG_RECTANGLES },
|
2009-06-05 08:50:00 -04:00
|
|
|
{ "disable-batching", COGL_DEBUG_DISABLE_BATCHING },
|
2009-06-16 20:59:28 -04:00
|
|
|
{ "disable-vbos", COGL_DEBUG_DISABLE_VBOS },
|
2010-07-05 20:30:25 -04:00
|
|
|
{ "disable-pbos", COGL_DEBUG_DISABLE_PBOS },
|
2009-10-26 07:01:33 -04:00
|
|
|
{ "disable-software-transform", COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM },
|
2010-01-21 10:34:19 -05:00
|
|
|
{ "dump-atlas-image", COGL_DEBUG_DUMP_ATLAS_IMAGE },
|
2010-04-26 05:01:43 -04:00
|
|
|
{ "disable-atlas", COGL_DEBUG_DISABLE_ATLAS },
|
2011-03-30 11:39:38 -04:00
|
|
|
{ "disable-shared-atlas", COGL_DEBUG_DISABLE_SHARED_ATLAS },
|
2010-04-26 05:01:43 -04:00
|
|
|
{ "disable-texturing", COGL_DEBUG_DISABLE_TEXTURING},
|
|
|
|
{ "disable-arbfp", COGL_DEBUG_DISABLE_ARBFP},
|
2010-11-24 12:29:00 -05:00
|
|
|
{ "disable-fixed", COGL_DEBUG_DISABLE_FIXED},
|
2010-04-08 07:21:04 -04:00
|
|
|
{ "disable-glsl", COGL_DEBUG_DISABLE_GLSL},
|
2010-11-05 10:55:46 -04:00
|
|
|
{ "disable-blending", COGL_DEBUG_DISABLE_BLENDING},
|
2010-11-16 08:06:08 -05:00
|
|
|
{ "disable-npot-textures", COGL_DEBUG_DISABLE_NPOT_TEXTURES},
|
2010-11-10 09:02:31 -05:00
|
|
|
{ "wireframe", COGL_DEBUG_WIREFRAME},
|
2010-12-03 07:01:18 -05:00
|
|
|
{ "disable-software-clip", COGL_DEBUG_DISABLE_SOFTWARE_CLIP},
|
2011-01-20 09:41:51 -05:00
|
|
|
{ "disable-program-caches", COGL_DEBUG_DISABLE_PROGRAM_CACHES},
|
|
|
|
{ "disable-fast-read-pixel", COGL_DEBUG_DISABLE_FAST_READ_PIXEL}
|
2009-02-23 07:47:02 -05:00
|
|
|
};
|
2010-02-17 09:38:11 -05:00
|
|
|
static const int n_cogl_behavioural_debug_keys =
|
|
|
|
G_N_ELEMENTS (cogl_behavioural_debug_keys);
|
2009-02-23 07:47:02 -05:00
|
|
|
|
2011-10-31 10:19:10 -04:00
|
|
|
unsigned long _cogl_debug_flags[COGL_DEBUG_N_LONGS];
|
2011-06-10 13:44:09 -04:00
|
|
|
GHashTable *_cogl_debug_instances;
|
2009-02-23 07:47:02 -05:00
|
|
|
|
2011-01-24 09:28:00 -05: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 16:56:40 -04:00
|
|
|
CoglBool enable,
|
2011-01-24 09:28:00 -05:00
|
|
|
const GDebugKey *keys,
|
|
|
|
unsigned int nkeys)
|
|
|
|
{
|
2011-10-31 10:19:10 -04:00
|
|
|
int long_num, key_num;
|
2011-01-24 09:28:00 -05: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 16:56:40 -04: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 09:28:00 -05:00
|
|
|
|
2011-10-31 10:19:10 -04:00
|
|
|
for (long_num = 0; long_num < COGL_DEBUG_N_LONGS; long_num++)
|
2011-01-24 09:28:00 -05:00
|
|
|
{
|
2011-10-31 10:19:10 -04:00
|
|
|
int int_num;
|
|
|
|
|
|
|
|
for (int_num = 0;
|
|
|
|
int_num < sizeof (unsigned long) / sizeof (unsigned int);
|
|
|
|
int_num++)
|
2011-01-24 09:28:00 -05:00
|
|
|
{
|
2011-10-31 10:19:10 -04: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 09:28:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-03 13:15:54 -04:00
|
|
|
void
|
2010-02-17 09:38:11 -05: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 16:56:40 -04:00
|
|
|
CoglBool enable,
|
|
|
|
CoglBool ignore_help)
|
2010-02-17 09:38:11 -05:00
|
|
|
{
|
|
|
|
if (ignore_help && strcmp (value, "help") == 0)
|
2011-01-24 09:28:00 -05:00
|
|
|
return;
|
2010-02-17 09:38:11 -05: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 09:28:00 -05: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 09:38:11 -05:00
|
|
|
}
|
2011-12-09 12:17:51 -05:00
|
|
|
else if (g_ascii_strcasecmp (value, "help") == 0)
|
2010-02-17 09:38:11 -05:00
|
|
|
{
|
2011-09-10 04:52:48 -04:00
|
|
|
g_printerr ("\n\n%28s\n", _("Supported debug values:"));
|
2010-06-21 10:36:46 -04:00
|
|
|
#define OPT(MASK_NAME, GROUP, NAME, NAME_FORMATTED, DESCRIPTION) \
|
2011-09-10 04:52:48 -04:00
|
|
|
g_printerr ("%28s %s\n", NAME ":", g_dgettext (GETTEXT_PACKAGE, \
|
|
|
|
DESCRIPTION));
|
2010-06-21 10:36:46 -04:00
|
|
|
#include "cogl-debug-options.h"
|
2011-09-10 04:52:48 -04:00
|
|
|
g_printerr ("\n%28s\n", _("Special debug values:"));
|
2010-06-21 10:36:46 -04:00
|
|
|
OPT (IGNORED, "ignored", "all", "ignored", \
|
2011-09-10 04:52:48 -04:00
|
|
|
N_("Enables all non-behavioural debug options"));
|
2010-06-21 10:36:46 -04:00
|
|
|
OPT (IGNORED, "ignored", "verbose", "ignored", \
|
2011-09-10 04:52:48 -04:00
|
|
|
N_("Enables all non-behavioural debug options"));
|
2010-02-17 09:38:11 -05:00
|
|
|
#undef OPT
|
2012-07-31 11:30:33 -04: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 09:38:11 -05:00
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-24 09:28:00 -05: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 09:38:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-14 17:33:44 -04: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 16:56:40 -04:00
|
|
|
static CoglBool
|
2009-02-23 07:47:02 -05: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 16:56:40 -04:00
|
|
|
void *user_data)
|
2009-02-23 07:47:02 -05:00
|
|
|
{
|
2011-01-24 09:28:00 -05:00
|
|
|
_cogl_parse_debug_string (value,
|
|
|
|
TRUE /* enable the flags */,
|
|
|
|
FALSE /* don't ignore help */);
|
2009-02-23 07:47:02 -05: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 16:56:40 -04:00
|
|
|
static CoglBool
|
2009-02-23 07:47:02 -05: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-09 20:57:32 -05: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 16:56:40 -04:00
|
|
|
void *user_data)
|
2009-02-23 07:47:02 -05:00
|
|
|
{
|
2011-01-24 09:28:00 -05:00
|
|
|
_cogl_parse_debug_string (value,
|
|
|
|
FALSE, /* disable the flags */
|
|
|
|
TRUE /* ignore help */);
|
2009-02-23 07:47:02 -05:00
|
|
|
return TRUE;
|
|
|
|
}
|
2010-02-17 09:38:11 -05:00
|
|
|
#endif /* COGL_ENABLE_DEBUG */
|
2009-02-23 07:47:02 -05:00
|
|
|
|
|
|
|
static GOptionEntry cogl_args[] = {
|
2010-03-01 21:07:40 -05:00
|
|
|
#ifdef COGL_ENABLE_DEBUG
|
2009-02-23 07:47:02 -05:00
|
|
|
{ "cogl-debug", 0, 0, G_OPTION_ARG_CALLBACK, cogl_arg_debug_cb,
|
2010-10-05 03:03:19 -04:00
|
|
|
N_("Cogl debugging flags to set"), "FLAGS" },
|
2009-02-23 07:47:02 -05:00
|
|
|
{ "cogl-no-debug", 0, 0, G_OPTION_ARG_CALLBACK, cogl_arg_no_debug_cb,
|
2010-10-05 03:03:19 -04:00
|
|
|
N_("Cogl debugging flags to unset"), "FLAGS" },
|
2010-03-01 21:07:40 -05:00
|
|
|
#endif /* COGL_ENABLE_DEBUG */
|
2009-02-23 07:47:02 -05:00
|
|
|
{ NULL, },
|
|
|
|
};
|
|
|
|
|
2011-06-14 17:33:44 -04:00
|
|
|
void
|
|
|
|
_cogl_debug_check_environment (void)
|
2009-02-23 07:47:02 -05:00
|
|
|
{
|
|
|
|
const char *env_string;
|
|
|
|
|
|
|
|
env_string = g_getenv ("COGL_DEBUG");
|
|
|
|
if (env_string != NULL)
|
|
|
|
{
|
2011-01-24 09:28:00 -05:00
|
|
|
_cogl_parse_debug_string (env_string,
|
|
|
|
TRUE /* enable the flags */,
|
|
|
|
FALSE /* don't ignore help */);
|
2009-02-23 07:47:02 -05:00
|
|
|
env_string = NULL;
|
|
|
|
}
|
2011-08-03 13:15:54 -04: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 17:33:44 -04: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 16:56:40 -04:00
|
|
|
static CoglBool
|
|
|
|
pre_parse_hook (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
void *data,
|
|
|
|
GError **error)
|
2011-06-14 17:33:44 -04:00
|
|
|
{
|
|
|
|
_cogl_init ();
|
2009-02-23 07:47:02 -05:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-06-14 17:33:44 -04:00
|
|
|
/* XXX: GOption based library initialization is not reliable because the
|
|
|
|
* GOption API has no way to represent dependencies between libraries.
|
|
|
|
*/
|
2009-02-23 07:47:02 -05:00
|
|
|
GOptionGroup *
|
|
|
|
cogl_get_option_group (void)
|
|
|
|
{
|
|
|
|
GOptionGroup *group;
|
|
|
|
|
|
|
|
group = g_option_group_new ("cogl",
|
2010-10-05 03:03:19 -04:00
|
|
|
_("Cogl Options"),
|
|
|
|
_("Show Cogl options"),
|
2009-02-23 07:47:02 -05:00
|
|
|
NULL, NULL);
|
|
|
|
|
|
|
|
g_option_group_set_parse_hooks (group, pre_parse_hook, NULL);
|
|
|
|
g_option_group_add_entries (group, cogl_args);
|
|
|
|
g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);
|
|
|
|
|
|
|
|
return group;
|
|
|
|
}
|