From 76c2bd8420a7e1db2a6a6fa61b7c24dc44ad3684 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Sat, 25 Feb 2012 20:28:50 +0000 Subject: [PATCH] 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 --- cogl/cogl-bitmap.c | 9 +++++++++ cogl/cogl-bitmap.h | 15 +++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/cogl/cogl-bitmap.c b/cogl/cogl-bitmap.c index f297d93de..4d263055c 100644 --- a/cogl/cogl-bitmap.c +++ b/cogl/cogl-bitmap.c @@ -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) { diff --git a/cogl/cogl-bitmap.h b/cogl/cogl-bitmap.h index 934715ce8..3787d921b 100644 --- a/cogl/cogl-bitmap.h +++ b/cogl/cogl-bitmap.h @@ -31,6 +31,7 @@ #include #include #include +#include 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 */ /**