summaryrefslogtreecommitdiff
path: root/gsk
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2019-05-18 13:45:19 +0200
committerTimm Bäder <mail@baedert.org>2019-05-18 13:47:59 +0200
commit63267a2f70033dd7750136781b854ad1e630b472 (patch)
tree6401b49dc82f27cfb1159315339f5ef710744bc7 /gsk
parenta9fb528a60a97ee45209938ad5f0e6c4d08093dd (diff)
downloadgtk+-63267a2f70033dd7750136781b854ad1e630b472.tar.gz
gl renderer: Render fallback nodes upside down
We stuff both gl-drawn and cairo-drawn textures into the same cache, so we can't really assume that we need to draw any of them flipped or not. Fix this by drawing fallback stuff upside down and then using upside-down vertex data for everything. Fixes #1897
Diffstat (limited to 'gsk')
-rw-r--r--gsk/gl/gskglrenderer.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index c39ea993b5..8551d031d9 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -430,9 +430,12 @@ rounded_rect_to_floats (GskGLRenderer *self,
static inline void
render_fallback_node (GskGLRenderer *self,
GskRenderNode *node,
- RenderOpBuilder *builder,
- const GskQuadVertex *vertex_data)
+ RenderOpBuilder *builder)
{
+ const float min_x = builder->dx + node->bounds.origin.x;
+ const float min_y = builder->dy + node->bounds.origin.y;
+ const float max_x = min_x + node->bounds.size.width;
+ const float max_y = min_y + node->bounds.size.height;
const float scale = ops_get_scale (builder);
const int surface_width = ceilf (node->bounds.size.width) * scale;
const int surface_height = ceilf (node->bounds.size.height) * scale;
@@ -440,6 +443,16 @@ render_fallback_node (GskGLRenderer *self,
cairo_t *cr;
int cached_id;
int texture_id;
+ const GskQuadVertex offscreen_vertex_data[GL_N_VERTICES] = {
+ { { min_x, min_y }, { 0, 1 }, },
+ { { min_x, max_y }, { 0, 0 }, },
+ { { max_x, min_y }, { 1, 1 }, },
+
+ { { max_x, max_y }, { 1, 0 }, },
+ { { min_x, max_y }, { 0, 0 }, },
+ { { max_x, min_y }, { 1, 1 }, },
+ };
+
if (surface_width <= 0 ||
surface_height <= 0)
@@ -451,7 +464,7 @@ render_fallback_node (GskGLRenderer *self,
{
ops_set_program (builder, &self->blit_program);
ops_set_texture (builder, cached_id);
- ops_draw (builder, vertex_data);
+ ops_draw (builder, offscreen_vertex_data);
return;
}
@@ -461,8 +474,10 @@ render_fallback_node (GskGLRenderer *self,
cairo_surface_set_device_scale (surface, scale, scale);
cr = cairo_create (surface);
+ /* We draw upside down here, so it matches what GL does. */
cairo_save (cr);
- cairo_translate (cr, -node->bounds.origin.x, -node->bounds.origin.y);
+ cairo_scale (cr, 1, -1);
+ cairo_translate (cr, -node->bounds.origin.x, ceilf (-node->bounds.origin.y - node->bounds.size.height));
gsk_render_node_draw (node, cr);
cairo_restore (cr);
@@ -496,7 +511,7 @@ render_fallback_node (GskGLRenderer *self,
ops_set_program (builder, &self->blit_program);
ops_set_texture (builder, texture_id);
- ops_draw (builder, vertex_data);
+ ops_draw (builder, offscreen_vertex_data);
}
static inline void
@@ -1330,7 +1345,7 @@ render_inset_shadow_node (GskGLRenderer *self,
/* TODO: Implement blurred inset shadows as well */
if (gsk_inset_shadow_node_get_blur_radius (node) > 0)
{
- render_fallback_node (self, node, builder, vertex_data);
+ render_fallback_node (self, node, builder);
return;
}
@@ -1775,7 +1790,7 @@ render_shadow_node (GskGLRenderer *self,
if (shadow->radius > 0)
{
- render_fallback_node (self, node, builder, vertex_data);
+ render_fallback_node (self, node, builder);
return;
}
}
@@ -2670,7 +2685,7 @@ gsk_gl_renderer_add_render_ops (GskGLRenderer *self,
case GSK_CAIRO_NODE:
default:
{
- render_fallback_node (self, node, builder, vertex_data);
+ render_fallback_node (self, node, builder);
}
}
}