mirror of
https://github.com/brl/mutter.git
synced 2025-06-14 01:09:30 +00:00
bitmap: Add a function to convert into an existing buffer
This adds _cogl_bitmap_convert_into_bitmap which is the same as _cogl_bitmap_convert except that it writes into an existing bitmap instead of allocating a new one. _cogl_bitmap_convert now just allocates a buffer and calls the new function. This is used in _cogl_read_pixels to avoid allocating a second intermediate buffer when the pixel format to store in is not GL_RGBA. Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
@ -128,7 +128,7 @@ _cogl_bitmap_copy (CoglBitmap *src_bmp)
|
||||
return dst_bmp;
|
||||
}
|
||||
|
||||
void
|
||||
gboolean
|
||||
_cogl_bitmap_copy_subregion (CoglBitmap *src,
|
||||
CoglBitmap *dst,
|
||||
int src_x,
|
||||
@ -142,9 +142,12 @@ _cogl_bitmap_copy_subregion (CoglBitmap *src,
|
||||
guint8 *dstdata;
|
||||
int bpp;
|
||||
int line;
|
||||
gboolean succeeded = FALSE;
|
||||
|
||||
/* Intended only for fast copies when format is equal! */
|
||||
g_assert (src->format == dst->format);
|
||||
g_assert ((src->format & ~COGL_PREMULT_BIT) ==
|
||||
(dst->format & ~COGL_PREMULT_BIT));
|
||||
|
||||
bpp = _cogl_pixel_format_get_bytes_per_pixel (src->format);
|
||||
|
||||
if ((srcdata = _cogl_bitmap_map (src, COGL_BUFFER_ACCESS_READ, 0)))
|
||||
@ -161,11 +164,15 @@ _cogl_bitmap_copy_subregion (CoglBitmap *src,
|
||||
dstdata += dst->rowstride;
|
||||
}
|
||||
|
||||
succeeded = TRUE;
|
||||
|
||||
_cogl_bitmap_unmap (dst);
|
||||
}
|
||||
|
||||
_cogl_bitmap_unmap (src);
|
||||
}
|
||||
|
||||
return succeeded;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
Reference in New Issue
Block a user