Use cogl_read_pixels in the cogl texture draw-and-read fallback

The fallback for when glGetTexImage is not available draws parts of
the texture to the framebuffer and uses glReadPixels to extract the
data. However it was using cogl_rectangle to draw and then immediately
using raw glReadPixels to fetch the data. This won't cause a journal
flush so the rectangle won't necessarily have hit the framebuffer
yet. Instead it now uses cogl_read_pixels which does flush the
journal.
This commit is contained in:
Neil Roberts 2010-07-08 18:29:12 +01:00
parent 475a72fd94
commit f8d1955ab7

View File

@ -970,13 +970,12 @@ do_texture_draw_and_read (CoglHandle handle,
rect_bmp.data = g_malloc (rect_bmp.rowstride * rect_bmp.data = g_malloc (rect_bmp.rowstride *
rect_bmp.height); rect_bmp.height);
_cogl_texture_driver_prep_gl_for_pixels_download (rect_bmp.rowstride, cogl_read_pixels (viewport[0], viewport[1],
bpp);
GE( glReadPixels (viewport[0], viewport[1],
rect_bmp.width, rect_bmp.width,
rect_bmp.height, rect_bmp.height,
GL_RGBA, GL_UNSIGNED_BYTE, COGL_READ_PIXELS_COLOR_BUFFER,
rect_bmp.data) ); COGL_PIXEL_FORMAT_RGBA_8888_PRE,
rect_bmp.data);
/* Copy to target bitmap */ /* Copy to target bitmap */
_cogl_bitmap_copy_subregion (&rect_bmp, _cogl_bitmap_copy_subregion (&rect_bmp,
@ -1023,8 +1022,8 @@ _cogl_texture_draw_and_read (CoglHandle handle,
viewport[2] <= 0 || viewport[3] <= 0) viewport[2] <= 0 || viewport[3] <= 0)
return FALSE; return FALSE;
/* Setup orthographic projection into current viewport (0,0 in bottom-left /* Setup orthographic projection into current viewport (0,0 in top-left
* corner to draw the texture upside-down so we match the way glReadPixels * corner to draw the texture upside-down so we match the way cogl_read_pixels
* works) * works)
*/ */
@ -1033,7 +1032,7 @@ _cogl_texture_draw_and_read (CoglHandle handle,
_cogl_matrix_stack_load_identity (projection_stack); _cogl_matrix_stack_load_identity (projection_stack);
_cogl_matrix_stack_ortho (projection_stack, _cogl_matrix_stack_ortho (projection_stack,
0, (float)(viewport[2]), 0, (float)(viewport[2]),
0, (float)(viewport[3]), (float)(viewport[3]), 0,
(float)(0), (float)(0),
(float)(100)); (float)(100));