[gtk/wip/chergert/glproto: 469/493] bring over various bugfixes from GL renderer




commit 3b84952305924abaea1e12538378c08bbef54d99
Author: Christian Hergert <chergert redhat com>
Date:   Tue Feb 16 15:32:17 2021 -0800

    bring over various bugfixes from GL renderer

 gsk/next/gskglrenderjob.c | 48 +++++++++++++++++++++++------------------------
 1 file changed, 23 insertions(+), 25 deletions(-)
---
diff --git a/gsk/next/gskglrenderjob.c b/gsk/next/gskglrenderjob.c
index b1cc731734..1bd7c597c4 100644
--- a/gsk/next/gskglrenderjob.c
+++ b/gsk/next/gskglrenderjob.c
@@ -1402,8 +1402,8 @@ gsk_gl_render_job_visit_clipped_child (GskGLRenderJob        *job,
       offscreen.bounds = &child->bounds;
       offscreen.force_offscreen = TRUE;
 
-      scaled_clip = GSK_ROUNDED_RECT_INIT (clip->origin.x * job->scale_x,
-                                           clip->origin.y * job->scale_y,
+      scaled_clip = GSK_ROUNDED_RECT_INIT ((job->offset_x + clip->origin.x) * job->scale_x,
+                                           (job->offset_y + clip->origin.y) * job->scale_y,
                                            clip->size.width * job->scale_x,
                                            clip->size.height * job->scale_y);
 
@@ -1501,11 +1501,6 @@ gsk_gl_render_job_visit_rounded_clip_node (GskGLRenderJob      *job,
     {
       GskGLRenderOffscreen offscreen = {0};
 
-      transformed_clip.bounds.origin.x = clip->bounds.origin.x * scale_x;
-      transformed_clip.bounds.origin.y = clip->bounds.origin.y * scale_y;
-      transformed_clip.bounds.size.width = clip->bounds.size.width * scale_x;
-      transformed_clip.bounds.size.height = clip->bounds.size.height * scale_y;
-
       offscreen.bounds = &node->bounds;
       offscreen.force_offscreen = TRUE;
 
@@ -3450,8 +3445,8 @@ gsk_gl_render_job_visit_node_with_offscreen (GskGLRenderJob       *job,
       return TRUE;
     }
 
-  float width = offscreen->bounds->size.width;
-  float height = offscreen->bounds->size.height;
+  float scaled_width;
+  float scaled_height;
   float scale_x = job->scale_x;
   float scale_y = job->scale_y;
 
@@ -3464,31 +3459,32 @@ gsk_gl_render_job_visit_node_with_offscreen (GskGLRenderJob       *job,
   {
     int max_texture_size = job->command_queue->max_texture_size;
 
-    width = ceilf (width * scale_x);
-    if (width > max_texture_size)
+    scaled_width = ceilf (offscreen->bounds->size.width * scale_x);
+    if (scaled_width > max_texture_size)
       {
-        scale_x *= (float)max_texture_size / width;
-        width = max_texture_size;
+        scale_x *= (float)max_texture_size / scaled_width;
+        scaled_width = max_texture_size;
       }
 
-    height = ceilf (height * scale_y);
-    if (height > max_texture_size)
+    scaled_height = ceilf (offscreen->bounds->size.height * scale_y);
+    if (scaled_height > max_texture_size)
       {
-        scale_y *= (float)max_texture_size / height;
-        height = max_texture_size;
+        scale_y *= (float)max_texture_size / scaled_height;
+        scaled_height = max_texture_size;
       }
   }
 
   GskGLRenderTarget *render_target;
   graphene_matrix_t prev_projection;
   graphene_rect_t prev_viewport;
+  graphene_rect_t viewport;
   float offset_x = job->offset_x;
   float offset_y = job->offset_y;
   float prev_alpha;
   guint prev_fbo;
 
   if (!gsk_next_driver_create_render_target (job->driver,
-                                             width, height,
+                                             scaled_width, scaled_height,
                                              filter, filter,
                                              &render_target))
     g_assert_not_reached ();
@@ -3509,16 +3505,18 @@ gsk_gl_render_job_visit_node_with_offscreen (GskGLRenderJob       *job,
                                           render_target->framebuffer_id);
     }
 
-  gsk_gl_render_job_set_viewport (job,
-                                  &GRAPHENE_RECT_INIT (offscreen->bounds->origin.x * scale_x,
-                                                       offscreen->bounds->origin.y * scale_y,
-                                                       width, height),
-                                  &prev_viewport);
+  gsk_gl_render_job_transform_bounds (job, offscreen->bounds, &viewport);
+  /* Code above will scale the size with the scale we use in the render ops,
+   * but for the viewport size, we need our own size limited by the texture size */
+  viewport.size.width = scaled_width;
+  viewport.size.height = scaled_height;
+
+  gsk_gl_render_job_set_viewport (job, &viewport, &prev_viewport);
   gsk_gl_render_job_set_projection_from_rect (job, &job->viewport, &prev_projection);
   gsk_gl_render_job_set_modelview (job, gsk_transform_scale (NULL, scale_x, scale_y));
   prev_alpha = gsk_gl_render_job_set_alpha (job, 1.0f);
-  job->offset_x = 0;
-  job->offset_y = 0;
+  job->offset_x = offset_x;
+  job->offset_y = offset_y;
 
   prev_fbo = gsk_gl_command_queue_bind_framebuffer (job->command_queue, render_target->framebuffer_id);
   gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]