cogl-bitmap: Add a public accessor for the underlying pixel buffer

This adds a small cogl_bitmap_get_buffer public function. Note that
this can return NULL if the bitmap was not created with a pixel
buffer. It might be nice to change this eventually so that all bitmaps
have a pixel buffer.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
Neil Roberts 2012-02-25 20:28:50 +00:00
parent 7114588884
commit 76c2bd8420
2 changed files with 24 additions and 0 deletions

View File

@ -330,6 +330,15 @@ cogl_bitmap_get_rowstride (CoglBitmap *bitmap)
return bitmap->rowstride;
}
CoglPixelBuffer *
cogl_bitmap_get_buffer (CoglBitmap *bitmap)
{
while (bitmap->shared_bmp)
bitmap = bitmap->shared_bmp;
return COGL_PIXEL_BUFFER (bitmap->buffer);
}
GQuark
cogl_bitmap_error_quark (void)
{

View File

@ -31,6 +31,7 @@
#include <cogl/cogl-types.h>
#include <cogl/cogl-buffer.h>
#include <cogl/cogl-context.h>
#include <cogl/cogl-pixel-buffer.h>
G_BEGIN_DECLS
@ -174,6 +175,20 @@ cogl_bitmap_get_height (CoglBitmap *bitmap);
int
cogl_bitmap_get_rowstride (CoglBitmap *bitmap);
/**
* cogl_bitmap_get_buffer:
* @bitmap: A #CoglBitmap
*
* Return value: the #CoglPixelBuffer that this buffer uses for
* storage. Note that if the bitmap was created with
* cogl_bitmap_new_from_file() then it will not actually be using a
* pixel buffer and this function will return %NULL.
* Stability: unstable
* Since: 1.10
*/
CoglPixelBuffer *
cogl_bitmap_get_buffer (CoglBitmap *bitmap);
#endif /* COGL_ENABLE_EXPERIMENTAL_API */
/**