From eaf29af7eeceae7489d1af465b97ac9d52a83934 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Wed, 21 Mar 2012 13:34:32 +0000 Subject: [PATCH] bitmap-pixbuf: Fix the bitmap loader on Quartz The code for loading a CoglBitmap from a file was missed when upgrading to the new cogl_bitmap_new_for_data function in commit d18b59d9e6 so it wouldn't compile. This changes it to use _cogl_bitmap_new_with_malloc_buffer to allocate the buffer. https://bugzilla.gnome.org/show_bug.cgi?id=672533 Reviewed-by: Robert Bragg (cherry picked from commit 5b785dd441a83024333e0a2f2b83d067f891194f) --- cogl/cogl-bitmap-pixbuf.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/cogl/cogl-bitmap-pixbuf.c b/cogl/cogl-bitmap-pixbuf.c index 025a940e1..3fa8b500b 100644 --- a/cogl/cogl-bitmap-pixbuf.c +++ b/cogl/cogl-bitmap-pixbuf.c @@ -68,6 +68,9 @@ _cogl_bitmap_from_file (const char *filename, guint8 *out_data; CGColorSpaceRef color_space; CGContextRef bitmap_context; + CoglBitmap *bmp; + + _COGL_GET_CONTEXT (ctx, NULL); g_assert (filename != NULL); g_assert (error == NULL || *error == NULL); @@ -123,8 +126,13 @@ _cogl_bitmap_from_file (const char *filename, } /* allocate buffer big enough to hold pixel data */ - rowstride = 4 * width; - out_data = g_malloc0 (height * rowstride); + bmp = _cogl_bitmap_new_with_malloc_buffer (ctx, + width, height, + COGL_PIXEL_FORMAT_ARGB_8888); + rowstride = cogl_bitmap_get_rowstride (bmp); + out_data = _cogl_bitmap_map (bmp, + COGL_BUFFER_ACCESS_WRITE, + COGL_BUFFER_MAP_HINT_DISCARD); /* render to buffer */ color_space = CGColorSpaceCreateWithName (kCGColorSpaceGenericRGB); @@ -143,13 +151,10 @@ _cogl_bitmap_from_file (const char *filename, CGImageRelease (image); CGContextRelease (bitmap_context); + _cogl_bitmap_unmap (bmp); + /* store bitmap info */ - return _cogl_bitmap_new_from_data (out_data, - COGL_PIXEL_FORMAT_ARGB_8888, - width, height, - rowstride, - (CoglBitmapDestroyNotify) g_free, - NULL); + return bmp; } #elif defined(USE_GDKPIXBUF)