mirror of
https://github.com/brl/mutter.git
synced 2025-02-16 21:34:09 +00:00
bitmap-pixbuf: Fix the CoglBitmap wrapper for the STB fallback
The fallback code using stb-image.c was missed out in the upgrade to cogl_bitmap_new_for_data from commit d18b59d9e6 so it wouldn't compile. Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
parent
7f287dda85
commit
2d1623313c
@ -268,12 +268,15 @@ CoglBitmap *
|
|||||||
_cogl_bitmap_from_file (const char *filename,
|
_cogl_bitmap_from_file (const char *filename,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
static CoglUserDataKey bitmap_data_key;
|
||||||
CoglBitmap *bmp;
|
CoglBitmap *bmp;
|
||||||
int stb_pixel_format;
|
int stb_pixel_format;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
guint8 *pixels;
|
guint8 *pixels;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NULL);
|
||||||
|
|
||||||
_COGL_RETURN_VAL_IF_FAIL (error == NULL || *error == NULL, FALSE);
|
_COGL_RETURN_VAL_IF_FAIL (error == NULL || *error == NULL, FALSE);
|
||||||
|
|
||||||
/* Load from file using stb */
|
/* Load from file using stb */
|
||||||
@ -284,14 +287,14 @@ _cogl_bitmap_from_file (const char *filename,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Store bitmap info */
|
/* Store bitmap info */
|
||||||
bmp = _cogl_bitmap_new_from_data (g_memdup (pixels, height * width * 4),
|
bmp = cogl_bitmap_new_for_data (ctx,
|
||||||
COGL_PIXEL_FORMAT_RGBA_8888,
|
width, height,
|
||||||
width, height,
|
COGL_PIXEL_FORMAT_RGBA_8888,
|
||||||
width * 4,
|
width * 4, /* rowstride */
|
||||||
(CoglBitmapDestroyNotify) g_free,
|
pixels);
|
||||||
NULL);
|
/* Register a destroy function so the pixel data will be freed
|
||||||
|
automatically when the bitmap object is destroyed */
|
||||||
free (pixels);
|
cogl_object_set_user_data (COGL_OBJECT (bmp), &bitmap_data_key, pixels, free);
|
||||||
|
|
||||||
return bmp;
|
return bmp;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user