cogl-bitmap: Encapsulate the CoglBitmap even internally
authorNeil Roberts <neil@linux.intel.com>
Wed, 7 Jul 2010 17:44:16 +0000 (18:44 +0100)
committerNeil Roberts <neil@linux.intel.com>
Thu, 15 Jul 2010 16:24:01 +0000 (17:24 +0100)
commitfc12c42a83084b9d3acd1ed5a1b3dd34057f54d8
tree599539d19eaa11f0b5b9e9a3826c4857cc907909
parentfd886d9fc265dabd454e0dd3d13ea34d29211112
cogl-bitmap: Encapsulate the CoglBitmap even internally

The CoglBitmap struct is now only defined within cogl-bitmap.c so that
all of its members can now only be accessed with accessor
functions. To get to the data pointer for the bitmap image you must
first call _cogl_bitmap_map and later call _cogl_bitmap_unmap. The map
function takes the same arguments as cogl_pixel_array_map so that
eventually we can make a bitmap optionally internally divert to a
pixel array.

There is a _cogl_bitmap_new_from_data function which constructs a new
bitmap object and takes ownership of the data pointer. The function
gets passed a destroy callback which gets called when the bitmap is
freed. This is similar to how gdk_pixbuf_new_from_data
works. Alternatively NULL can be passed for the destroy function which
means that the caller will manage the life of the pointer (but must
guarantee that it stays alive at least until the bitmap is
freed). This mechanism is used instead of the old approach of creating
a CoglBitmap struct on the stack and manually filling in the
members. It could also later be used to create a CoglBitmap that owns
a GdkPixbuf ref so that we don't necessarily have to copy the
GdkPixbuf data when converting to a bitmap.

There is also _cogl_bitmap_new_shared. This creates a bitmap using a
reference to another CoglBitmap for the data. This is a bit of a hack
but it is needed by the atlas texture backend which wants to divert
the set_region virtual to another texture but it needs to override the
format of the bitmap to ignore the premult flag.
19 files changed:
clutter/cogl/cogl/cogl-atlas-texture-private.h
clutter/cogl/cogl/cogl-atlas-texture.c
clutter/cogl/cogl/cogl-bitmap-fallback.c
clutter/cogl/cogl/cogl-bitmap-pixbuf.c
clutter/cogl/cogl/cogl-bitmap-private.h
clutter/cogl/cogl/cogl-bitmap.c
clutter/cogl/cogl/cogl-texture-2d-private.h
clutter/cogl/cogl/cogl-texture-2d-sliced-private.h
clutter/cogl/cogl/cogl-texture-2d-sliced.c
clutter/cogl/cogl/cogl-texture-2d.c
clutter/cogl/cogl/cogl-texture-3d-private.h
clutter/cogl/cogl/cogl-texture-3d.c
clutter/cogl/cogl/cogl-texture-private.h
clutter/cogl/cogl/cogl-texture-rectangle-private.h
clutter/cogl/cogl/cogl-texture-rectangle.c
clutter/cogl/cogl/cogl-texture.c
clutter/cogl/cogl/cogl.c
clutter/cogl/cogl/driver/gl/cogl-texture-driver.c
clutter/cogl/cogl/driver/gles/cogl-texture-driver.c