gsk: Pass scale as float to the command queue
authorMatthias Clasen <mclasen@redhat.com>
Sun, 2 Apr 2023 02:48:38 +0000 (22:48 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 2 Apr 2023 13:06:56 +0000 (09:06 -0400)
gsk/gl/gskglcommandqueue.c
gsk/gl/gskglcommandqueueprivate.h
gsk/gl/gskglrenderjob.c

index 3d2998e43dd17a108b026c7f34b2df238d8bdbe0..f186c79fb8c7974aea55f546104fd8d20efd23c9 100644 (file)
@@ -993,7 +993,7 @@ gsk_gl_command_queue_sort_batches (GskGLCommandQueue *self)
  * gsk_gl_command_queue_execute:
  * @self: a `GskGLCommandQueue`
  * @surface_height: the height of the backing surface
- * @scale_factor: the scale factor of the backing surface
+ * @scale: the scale of the backing surface
  * @scissor: (nullable): the scissor clip if any
  * @default_framebuffer: the default framebuffer id if not zero
  *
@@ -1009,7 +1009,7 @@ gsk_gl_command_queue_sort_batches (GskGLCommandQueue *self)
 void
 gsk_gl_command_queue_execute (GskGLCommandQueue    *self,
                               guint                 surface_height,
-                              guint                 scale_factor,
+                              float                 scale,
                               const cairo_region_t *scissor,
                               guint                 default_framebuffer)
 {
@@ -1097,10 +1097,10 @@ gsk_gl_command_queue_execute (GskGLCommandQueue    *self,
       g_assert (cairo_region_num_rectangles (scissor) == 1);
       cairo_region_get_rectangle (scissor, 0, &r);
 
-      scissor_test.origin.x = r.x * scale_factor;
-      scissor_test.origin.y = surface_height - (r.height * scale_factor) - (r.y * scale_factor);
-      scissor_test.size.width = r.width * scale_factor;
-      scissor_test.size.height = r.height * scale_factor;
+      scissor_test.origin.x = (int) floor (r.x * scale);
+      scissor_test.origin.y = (int) floor (surface_height - (r.height * scale) - (r.y * scale));
+      scissor_test.size.width = (int) ceil (r.width * scale);
+      scissor_test.size.height = (int) ceil (r.height * scale);
     }
 
   next_batch_index = self->head_batch_index;
index c946eb9803431553795fb621dd5a5eb4ec97dcb0..fd72f68aff554e42f5d3683b91b934f3207bd782 100644 (file)
@@ -288,7 +288,7 @@ void                gsk_gl_command_queue_begin_frame          (GskGLCommandQueue
 void                gsk_gl_command_queue_end_frame            (GskGLCommandQueue    *self);
 void                gsk_gl_command_queue_execute              (GskGLCommandQueue    *self,
                                                                guint                 surface_height,
-                                                               guint                 scale_factor,
+                                                               float                 scale,
                                                                const cairo_region_t *scissor,
                                                                guint                 default_framebuffer);
 int                 gsk_gl_command_queue_upload_texture       (GskGLCommandQueue    *self,
index b68a8278aadac2fae064a9e36e69f8f094f72853..48a30f81434a963c5bdfb79b10874e823a3866c4 100644 (file)
@@ -4322,14 +4322,14 @@ gsk_gl_render_job_render (GskGLRenderJob *job,
                           GskRenderNode  *root)
 {
   G_GNUC_UNUSED gint64 start_time;
-  guint scale_factor;
+  float scale;
   guint surface_height;
 
   g_return_if_fail (job != NULL);
   g_return_if_fail (root != NULL);
   g_return_if_fail (GSK_IS_GL_DRIVER (job->driver));
 
-  scale_factor = MAX (job->scale_x, job->scale_y);
+  scale = MAX (job->scale_x, job->scale_y);
   surface_height = job->viewport.size.height;
 
   gsk_gl_command_queue_make_current (job->command_queue);
@@ -4360,7 +4360,7 @@ gsk_gl_render_job_render (GskGLRenderJob *job,
   start_time = GDK_PROFILER_CURRENT_TIME;
   gsk_gl_command_queue_make_current (job->command_queue);
   gdk_gl_context_push_debug_group (job->command_queue->context, "Executing command queue");
-  gsk_gl_command_queue_execute (job->command_queue, surface_height, scale_factor, job->region, job->default_framebuffer);
+  gsk_gl_command_queue_execute (job->command_queue, surface_height, scale, job->region, job->default_framebuffer);
   gdk_gl_context_pop_debug_group (job->command_queue->context);
   gdk_profiler_add_mark (start_time, GDK_PROFILER_CURRENT_TIME-start_time, "Execute GL command queue", "");
 }