Commit Graph

10 Commits

Author SHA1 Message Date
Neil Roberts
4f6fe6f0e2 Fixes for --disable-glib
This fixes some problems which were stopping --disable-glib from
working properly:

• A lot of the public headers were including glib.h. This shouldn't be
  necessary because the API doesn't expose any glib types. Otherwise
  any apps would require glib in order to get the header.

• The public headers were using G_BEGIN_DECLS. There is now a
  replacement macro called COGL_BEGIN_DECLS which is defined in
  cogl-types.h.

• A similar fix has been done for G_GNUC_NULL_TERMINATED and
  G_GNUC_DEPRECATED.

• The CFLAGS were not including $(builddir)/deps/glib which was
  preventing it finding the generated glibconfig.h when building out
  of tree.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 4138b3141c2f39cddaea3d72bfc04342ed5092d0)
2013-01-22 17:48:05 +00:00
Robert Bragg
54735dec84 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-08-06 14:27:39 +01:00
Chun-wei Fan
1be2cdab21 cogl-bitmask.h: Eliminate compiler warning
Both _cogl_bitmask_set_flags and _cogl_bitmask_set_flags_array have void
return types, so just execute _cogl_bitmask_set_flags_array without
returning that to elimate a compiler warning.

https://bugzilla.gnome.org/show_bug.cgi?id=665722

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-12-07 12:08:15 +00:00
Neil Roberts
f23b12a886 cogl-bitmask: Add _cogl_bitmask_popcount
This returns a population count of all the bits that are set in the
bitmask.

There is now also a _cogl_bitmask_popcount_upto which counts the
number of bits set up to but not including the given bit index. This
will be useful to determine the number of uniform overrides to skip if
we tightly pack the values in an array.

The test-bitmask test has been modified to check these two functions.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:32:11 +00:00
Neil Roberts
4e760d51f1 cogl-bitmask: Add _cogl_bitmask_set_flags
This adds a _cogl_bitmask_set_flags function which can be used to copy
the values from a CoglBitmask to an array of unsigned longs which can
be used with the COGL_FLAGS_* macros. The values are or'd in so that
in can be used multiple times to combine multiple bitmasks.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:32:11 +00:00
Neil Roberts
dbc31b70cc cogl-bitmask: Add a return value for the foreach callback
The foreach callback can now return FALSE to stop the iteration.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:21:31 +00:00
Neil Roberts
93321d9b89 cogl-bitmask: Use longs instead of ints
Instead of storing only 31 bits in the pointer for a CoglBitmask, it
now assumes it can store a whole unsigned long minus the one bit used
to mark whether it has been converted to a GArray or not. This works
on the assumption that we can cast an unsigned long to a pointer and
back without losing information which I think should be true for any
platforms that Cogl is interested in. This has the advantage that on
64-bit architectures we can store 63 bits before we have to resort to
using a GArray at no extra cost. The values in the GArray are now
stored as unsigned longs as well on the assumption that it is more
efficient to load and store data in chunks of longs rather than ints.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 15:43:25 +00:00
Neil Roberts
4a7762d6d7 cogl-context: Store winsys features in an array of unsigned ints
Previously the mask of available winsys features was stored in a
CoglBitmask. That isn't the ideal type to use for this because it is
intended for a growable array of bits so it can allocate extra memory
if there are more than 31 flags set. For the winsys feature flags the
highest used bit is known at compile time so it makes sense to
allocate a fixed array instead. This is conceptually similar to the
CoglDebugFlags which are stored in an array of integers with macros to
test a bit in the array. This moves the macros used for CoglDebugFlags
to cogl-flags.h and makes them more generic so they can be shared with
CoglContext.
2011-04-20 18:20:10 +01:00
Neil Roberts
e38e9e0355 cogl-vertex-attribute: Use glVertexAttribPointer on GLES2
When the GLES2 wrapper is removed we can't use the fixed function API
such as glColorPointer to set the builtin attributes. Instead the GLSL
progend now maintains a cache of attribute locations that are queried
with glGetAttribLocation. The code that previously maintained a cache
of the enabled texture coord arrays has been modified to also cache
the enabled vertex attributes under GLES2. The vertex attribute API is
now the only place that is using this cache so it has been moved into
cogl-vertex-attribute.c
2010-12-13 17:28:29 +00:00
Neil Roberts
4fb784d111 cogl: Add an internal CoglBitmask type
This implements a growable array of bits called CoglBitmask. The
CoglBitmask is intended to be cheap if less than 32 bits are used. If
more bits are required it will allocate a GArray. The type is meant to
be allocated on the stack but because it can require additional
resources it also has a destroy function.

http://bugzilla.openedhand.com/show_bug.cgi?id=2132
2010-05-24 16:10:56 +01:00