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 <robert@linux.intel.com>

(cherry picked from commit 5b785dd441a83024333e0a2f2b83d067f891194f)
This commit is contained in:
Neil Roberts 2012-03-21 13:34:32 +00:00 committed by Robert Bragg
parent d2a5d6f361
commit eaf29af7ee

View File

@ -68,6 +68,9 @@ _cogl_bitmap_from_file (const char *filename,
guint8 *out_data; guint8 *out_data;
CGColorSpaceRef color_space; CGColorSpaceRef color_space;
CGContextRef bitmap_context; CGContextRef bitmap_context;
CoglBitmap *bmp;
_COGL_GET_CONTEXT (ctx, NULL);
g_assert (filename != NULL); g_assert (filename != NULL);
g_assert (error == NULL || *error == 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 */ /* allocate buffer big enough to hold pixel data */
rowstride = 4 * width; bmp = _cogl_bitmap_new_with_malloc_buffer (ctx,
out_data = g_malloc0 (height * rowstride); 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 */ /* render to buffer */
color_space = CGColorSpaceCreateWithName (kCGColorSpaceGenericRGB); color_space = CGColorSpaceCreateWithName (kCGColorSpaceGenericRGB);
@ -143,13 +151,10 @@ _cogl_bitmap_from_file (const char *filename,
CGImageRelease (image); CGImageRelease (image);
CGContextRelease (bitmap_context); CGContextRelease (bitmap_context);
_cogl_bitmap_unmap (bmp);
/* store bitmap info */ /* store bitmap info */
return _cogl_bitmap_new_from_data (out_data, return bmp;
COGL_PIXEL_FORMAT_ARGB_8888,
width, height,
rowstride,
(CoglBitmapDestroyNotify) g_free,
NULL);
} }
#elif defined(USE_GDKPIXBUF) #elif defined(USE_GDKPIXBUF)