mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
bitmap: ret CoglError from _new_with_malloc_buffer
_cogl_bitmap_new_with_malloc_buffer() now takes a CoglError for throwing exceptional errors and all callers have been updated to pass through any application error pointer as appropriate. Reviewed-by: Neil Roberts <neil@linux.intel.com> (cherry picked from commit 67cad9c0eb5e2650b75aff16abde49f23aabd0cc)
This commit is contained in:
parent
07d47eadd3
commit
da9f5e6179
@ -488,7 +488,10 @@ _cogl_bitmap_convert (CoglBitmap *src_bmp,
|
||||
|
||||
dst_bmp = _cogl_bitmap_new_with_malloc_buffer (ctx,
|
||||
width, height,
|
||||
dst_format);
|
||||
dst_format,
|
||||
error);
|
||||
if (!dst_bmp)
|
||||
return NULL;
|
||||
|
||||
if (!_cogl_bitmap_convert_into_bitmap (src_bmp, dst_bmp, error))
|
||||
{
|
||||
|
@ -69,6 +69,7 @@ struct _CoglBitmap
|
||||
* @width: width of the bitmap in pixels
|
||||
* @height: height of the bitmap in pixels
|
||||
* @format: the format of the pixels the array will store
|
||||
* @error: A #CoglError for catching exceptional errors or %NULL
|
||||
*
|
||||
* This is equivalent to cogl_bitmap_new_with_size() except that it
|
||||
* allocated the buffer using g_malloc() instead of creating a
|
||||
@ -84,7 +85,8 @@ CoglBitmap *
|
||||
_cogl_bitmap_new_with_malloc_buffer (CoglContext *context,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
CoglPixelFormat format);
|
||||
CoglPixelFormat format,
|
||||
CoglError **error);
|
||||
|
||||
/* The idea of this function is that it will create a bitmap that
|
||||
shares the actual data with another bitmap. This is needed for the
|
||||
|
@ -89,7 +89,10 @@ _cogl_bitmap_copy (CoglBitmap *src_bmp,
|
||||
dst_bmp =
|
||||
_cogl_bitmap_new_with_malloc_buffer (src_bmp->context,
|
||||
width, height,
|
||||
src_format);
|
||||
src_format,
|
||||
error);
|
||||
if (!dst_bmp)
|
||||
return NULL;
|
||||
|
||||
if (!_cogl_bitmap_copy_subregion (src_bmp,
|
||||
dst_bmp,
|
||||
@ -194,14 +197,24 @@ CoglBitmap *
|
||||
_cogl_bitmap_new_with_malloc_buffer (CoglContext *context,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
CoglPixelFormat format)
|
||||
CoglPixelFormat format,
|
||||
CoglError **error)
|
||||
{
|
||||
static CoglUserDataKey bitmap_free_key;
|
||||
int bpp = _cogl_pixel_format_get_bytes_per_pixel (format);
|
||||
int rowstride = ((width * bpp) + 3) & ~3;
|
||||
uint8_t *data = g_malloc (rowstride * height);
|
||||
uint8_t *data = g_try_malloc (rowstride * height);
|
||||
CoglBitmap *bitmap;
|
||||
|
||||
if (!data)
|
||||
{
|
||||
_cogl_set_error (error,
|
||||
COGL_SYSTEM_ERROR,
|
||||
COGL_SYSTEM_ERROR_NO_MEMORY,
|
||||
"Failed to allocate memory for bitmap");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bitmap = cogl_bitmap_new_for_data (context,
|
||||
width, height,
|
||||
format,
|
||||
|
@ -1613,7 +1613,11 @@ _cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
|
||||
|
||||
tmp_bmp = _cogl_bitmap_new_with_malloc_buffer (ctx,
|
||||
width, height,
|
||||
read_format);
|
||||
read_format,
|
||||
error);
|
||||
if (!tmp_bmp)
|
||||
goto EXIT;
|
||||
|
||||
bpp = _cogl_pixel_format_get_bytes_per_pixel (read_format);
|
||||
rowstride = cogl_bitmap_get_rowstride (tmp_bmp);
|
||||
|
||||
|
@ -405,7 +405,10 @@ cogl_texture_3d_new_from_data (CoglContext *context,
|
||||
bitmap = _cogl_bitmap_new_with_malloc_buffer (context,
|
||||
width,
|
||||
depth * height,
|
||||
format);
|
||||
format,
|
||||
error);
|
||||
if (!bitmap)
|
||||
return NULL;
|
||||
|
||||
bmp_data = _cogl_bitmap_map (bitmap,
|
||||
COGL_BUFFER_ACCESS_WRITE,
|
||||
|
@ -659,7 +659,10 @@ do_texture_draw_and_read (CoglFramebuffer *fb,
|
||||
rect_bmp = _cogl_bitmap_new_with_malloc_buffer
|
||||
(ctx,
|
||||
width, height,
|
||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE);
|
||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
||||
error);
|
||||
if (!rect_bmp)
|
||||
return FALSE;
|
||||
|
||||
if (!_cogl_framebuffer_read_pixels_into_bitmap
|
||||
(fb,
|
||||
@ -787,7 +790,14 @@ _cogl_texture_draw_and_read (CoglTexture *texture,
|
||||
_cogl_bitmap_new_with_malloc_buffer (ctx,
|
||||
target_width,
|
||||
target_height,
|
||||
COGL_PIXEL_FORMAT_RGBA_8888);
|
||||
COGL_PIXEL_FORMAT_RGBA_8888,
|
||||
error);
|
||||
if (!alpha_bmp)
|
||||
{
|
||||
_cogl_bitmap_unmap (target_bmp);
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
|
||||
/* Draw alpha values into RGB channels */
|
||||
cogl_pipeline_set_layer_combine (ctx->texture_download_pipeline,
|
||||
@ -1112,9 +1122,17 @@ cogl_texture_get_data (CoglTexture *texture,
|
||||
rowstride,
|
||||
data);
|
||||
else
|
||||
target_bmp = _cogl_bitmap_new_with_malloc_buffer (ctx,
|
||||
tex_width, tex_height,
|
||||
closest_format);
|
||||
{
|
||||
target_bmp = _cogl_bitmap_new_with_malloc_buffer (ctx,
|
||||
tex_width, tex_height,
|
||||
closest_format,
|
||||
&ignore_error);
|
||||
if (!target_bmp)
|
||||
{
|
||||
cogl_error_free (ignore_error);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
tg_data.target_bits = _cogl_bitmap_map (target_bmp, COGL_BUFFER_ACCESS_WRITE,
|
||||
COGL_BUFFER_MAP_HINT_DISCARD,
|
||||
|
@ -205,7 +205,11 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
|
||||
slice_bmp =
|
||||
_cogl_bitmap_new_with_malloc_buffer (ctx,
|
||||
width, height,
|
||||
source_format);
|
||||
source_format,
|
||||
error);
|
||||
if (!slice_bmp)
|
||||
return FALSE;
|
||||
|
||||
if (!_cogl_bitmap_copy_subregion (source_bmp,
|
||||
slice_bmp,
|
||||
src_x, src_y,
|
||||
@ -387,7 +391,10 @@ _cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx,
|
||||
bmp = _cogl_bitmap_new_with_malloc_buffer (ctx,
|
||||
bmp_width,
|
||||
height,
|
||||
source_bmp_format);
|
||||
source_bmp_format,
|
||||
error);
|
||||
if (!bmp)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < depth; i++)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user