[mutter] cogl/gl-framebuffer: Check Y-flipped-ness instead of framebuffer type
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] cogl/gl-framebuffer: Check Y-flipped-ness instead of framebuffer type
- Date: Sat, 30 Jan 2021 09:39:51 +0000 (UTC)
commit 6b5d7f45cb142b95ee5225ddc25e57502ae5b7d3
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Tue Oct 20 11:57:34 2020 +0200
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>
cogl/cogl/cogl-framebuffer-private.h | 10 ++++++++++
cogl/cogl/cogl-framebuffer.c | 2 +-
cogl/cogl/driver/gl/cogl-framebuffer-gl.c | 20 ++++++--------------
3 files changed, 17 insertions(+), 15 deletions(-)
---
diff --git a/cogl/cogl/cogl-framebuffer-private.h b/cogl/cogl/cogl-framebuffer-private.h
index 0c9af2d92b..f4edadd89d 100644
--- a/cogl/cogl/cogl-framebuffer-private.h
+++ b/cogl/cogl/cogl-framebuffer-private.h
@@ -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 */
diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c
index 41194829c7..16324a0adb 100644
--- a/cogl/cogl/cogl-framebuffer.c
+++ b/cogl/cogl/cogl-framebuffer.c
@@ -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);
diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
index 6e807fa714..de5ed30d92 100644
--- a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
+++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
@@ -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)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]