Add a public cogl_framebuffer_read_pixels_into_bitmap
This adds a public function to read pixels from a framebuffer into a CoglBitmap. This replaces the internal function _cogl_read_pixels_with_rowstride because a CoglBitmap contains a rowstride so it can be used for the same purpose. A CoglBitmap already has public API to make one that points to a CoglPixelBuffer so this function can be used to read pixels into a PBO. It also avoids the need to push the framebuffer on to the context's stack so it provides a function which can be used in the 2.0 API after the stack is removed. Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
@ -1015,6 +1015,7 @@ get_texture_bits_via_offscreen (CoglTexture *texture,
|
||||
{
|
||||
CoglOffscreen *offscreen;
|
||||
CoglFramebuffer *framebuffer;
|
||||
CoglBitmap *bitmap;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, FALSE);
|
||||
|
||||
@ -1031,19 +1032,17 @@ get_texture_bits_via_offscreen (CoglTexture *texture,
|
||||
|
||||
framebuffer = COGL_FRAMEBUFFER (offscreen);
|
||||
|
||||
if (!cogl_framebuffer_allocate (framebuffer, NULL))
|
||||
{
|
||||
cogl_object_unref (framebuffer);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
cogl_push_framebuffer (framebuffer);
|
||||
|
||||
_cogl_read_pixels_with_rowstride (x, y, width, height,
|
||||
COGL_READ_PIXELS_COLOR_BUFFER,
|
||||
dst_format, dst_bits, dst_rowstride);
|
||||
|
||||
cogl_pop_framebuffer ();
|
||||
bitmap = _cogl_bitmap_new_from_data (dst_bits,
|
||||
dst_format,
|
||||
width, height,
|
||||
dst_rowstride,
|
||||
NULL, /* destroy_fn */
|
||||
NULL /* destroy_fn_data */);
|
||||
cogl_framebuffer_read_pixels_into_bitmap (framebuffer,
|
||||
x, y,
|
||||
COGL_READ_PIXELS_COLOR_BUFFER,
|
||||
bitmap);
|
||||
cogl_object_unref (bitmap);
|
||||
|
||||
cogl_object_unref (framebuffer);
|
||||
|
||||
|
Reference in New Issue
Block a user