mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
cogl/gl-framebuffer: Check Y-flipped-ness instead of framebuffer type
In a few places coordinates were flipped if driven framebuffer was or wasn't a CoglOffscreen. Change this to use the existing Y-flipped-ness class vfunc. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
This commit is contained in:
parent
102aa59ce3
commit
6b5d7f45cb
@ -310,4 +310,14 @@ cogl_framebuffer_get_journal (CoglFramebuffer *framebuffer);
|
||||
CoglFramebufferDriver *
|
||||
cogl_framebuffer_get_driver (CoglFramebuffer *framebuffer);
|
||||
|
||||
/**
|
||||
* cogl_framebuffer_is_y_flipped:
|
||||
* @framebuffer: a #CoglFramebuffer
|
||||
*
|
||||
* Returns %TRUE if the Y coordinate 0 means the bottom of the framebuffer, and
|
||||
* %FALSE if the Y coordinate means the top.
|
||||
*/
|
||||
gboolean
|
||||
cogl_framebuffer_is_y_flipped (CoglFramebuffer *framebuffer);
|
||||
|
||||
#endif /* __COGL_FRAMEBUFFER_PRIVATE_H */
|
||||
|
@ -1577,7 +1577,7 @@ cogl_framebuffer_read_pixels (CoglFramebuffer *framebuffer,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gboolean
|
||||
cogl_framebuffer_is_y_flipped (CoglFramebuffer *framebuffer)
|
||||
{
|
||||
return COGL_FRAMEBUFFER_GET_CLASS (framebuffer)->is_y_flipped (framebuffer);
|
||||
|
@ -77,9 +77,8 @@ cogl_gl_framebuffer_flush_viewport_state (CoglGlFramebuffer *gl_framebuffer)
|
||||
/* Convert the Cogl viewport y offset to an OpenGL viewport y offset
|
||||
* NB: OpenGL defines its window and viewport origins to be bottom
|
||||
* left, while Cogl defines them to be top left.
|
||||
* NB: We render upside down to offscreen framebuffers so we don't
|
||||
* need to convert the y offset in this case. */
|
||||
if (COGL_IS_OFFSCREEN (framebuffer))
|
||||
*/
|
||||
if (cogl_framebuffer_is_y_flipped (framebuffer))
|
||||
gl_viewport_y = viewport_y;
|
||||
else
|
||||
gl_viewport_y =
|
||||
@ -441,12 +440,9 @@ cogl_gl_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver *driver,
|
||||
COGL_FRAMEBUFFER_STATE_BIND);
|
||||
|
||||
/* The y coordinate should be given in OpenGL's coordinate system
|
||||
* so 0 is the bottom row
|
||||
*
|
||||
* NB: all offscreen rendering is done upside down so no conversion
|
||||
* is necissary in this case.
|
||||
* so 0 is the bottom row.
|
||||
*/
|
||||
if (!COGL_IS_OFFSCREEN (framebuffer))
|
||||
if (!cogl_framebuffer_is_y_flipped (framebuffer))
|
||||
y = framebuffer_height - y - height;
|
||||
|
||||
required_format = ctx->driver_vtable->pixel_format_to_gl (ctx,
|
||||
@ -455,11 +451,9 @@ cogl_gl_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver *driver,
|
||||
&gl_format,
|
||||
&gl_type);
|
||||
|
||||
/* NB: All offscreen rendering is done upside down so there is no need
|
||||
* to flip in this case... */
|
||||
if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_MESA_PACK_INVERT) &&
|
||||
(source & COGL_READ_PIXELS_NO_FLIP) == 0 &&
|
||||
!COGL_IS_OFFSCREEN (framebuffer))
|
||||
!cogl_framebuffer_is_y_flipped (framebuffer))
|
||||
{
|
||||
if (ctx->driver == COGL_DRIVER_GLES2)
|
||||
gl_pack_enum = GL_PACK_REVERSE_ROW_ORDER_ANGLE;
|
||||
@ -614,9 +608,7 @@ cogl_gl_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver *driver,
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
/* NB: All offscreen rendering is done upside down so there is no need
|
||||
* to flip in this case... */
|
||||
if (!COGL_IS_OFFSCREEN (framebuffer) &&
|
||||
if (!cogl_framebuffer_is_y_flipped (framebuffer) &&
|
||||
(source & COGL_READ_PIXELS_NO_FLIP) == 0 &&
|
||||
!pack_invert_set)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user