[gtk/fix-negative-scales] ngl: Handle negative scales




commit 1c90bb522e7e722bcac4bd391c1631efe9eef58a
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jul 15 16:40:13 2021 -0400

    ngl: Handle negative scales
    
    Scale factors can be negative, but we were not
    looking out for that, triggering an assertion when
    trying to create a render target with negative
    width of height. Avoid that.
    
    Fixes: #4096

 gsk/ngl/gsknglrenderjob.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/gsk/ngl/gsknglrenderjob.c b/gsk/ngl/gsknglrenderjob.c
index 3f36d506ab..72efcae92a 100644
--- a/gsk/ngl/gsknglrenderjob.c
+++ b/gsk/ngl/gsknglrenderjob.c
@@ -3725,19 +3725,23 @@ gsk_ngl_render_job_visit_node_with_offscreen (GskNglRenderJob       *job,
   {
     int max_texture_size = job->command_queue->max_texture_size;
 
-    scaled_width = ceilf (offscreen->bounds->size.width * job->scale_x);
+    scaled_width = ceilf (offscreen->bounds->size.width * fabs (job->scale_x));
     if (scaled_width > max_texture_size)
       {
         downscale_x = (float)max_texture_size / scaled_width;
         scaled_width = max_texture_size;
       }
+    if (job->scale_x < 0)
+      downscale_x = -downscale_x;
 
-    scaled_height = ceilf (offscreen->bounds->size.height * job->scale_y);
+    scaled_height = ceilf (offscreen->bounds->size.height * fabs (job->scale_y));
     if (scaled_height > max_texture_size)
       {
         downscale_y = (float)max_texture_size / scaled_height;
         scaled_height = max_texture_size;
       }
+    if (job->scale_y < 0)
+      downscale_y = -downscale_y;
   }
 
   GskNglRenderTarget *render_target;


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