[gtk/fix-downscaled-textures] ngl: Avoid huge intermediate textures



commit 8d603dfe99001aafd346aa2ab7b16bc8d1e0a0f9
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Apr 2 19:33:44 2021 -0400

    ngl: Avoid huge intermediate textures
    
    Instead of rendering the unclipped child to a texture
    (and risking blowing the texture size limit, and bad
    downscaling), just render the clipped region, and live
    with the fact that we can't cache the rendered texture.
    
    This avoid bad artifacts when scrolling long textviews
    in rounded clips.

 gsk/ngl/gsknglrenderjob.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
---
diff --git a/gsk/ngl/gsknglrenderjob.c b/gsk/ngl/gsknglrenderjob.c
index 890983f07d..0bd6c94b68 100644
--- a/gsk/ngl/gsknglrenderjob.c
+++ b/gsk/ngl/gsknglrenderjob.c
@@ -1498,21 +1498,14 @@ gsk_ngl_render_job_visit_clipped_child (GskNglRenderJob       *job,
     }
   else
     {
-      GskRoundedRect scaled_clip;
       GskNglRenderOffscreen offscreen = {0};
 
-      offscreen.bounds = &child->bounds;
+      offscreen.bounds = clip;
       offscreen.force_offscreen = TRUE;
-      offscreen.reset_clip = FALSE;
-
-      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);
+      offscreen.reset_clip = TRUE;
+      offscreen.do_not_cache = TRUE;
 
-      gsk_ngl_render_job_push_clip (job, &scaled_clip);
       gsk_ngl_render_job_visit_node_with_offscreen (job, child, &offscreen);
-      gsk_ngl_render_job_pop_clip (job);
 
       g_assert (offscreen.texture_id);
 
@@ -1522,7 +1515,7 @@ gsk_ngl_render_job_visit_clipped_child (GskNglRenderJob       *job,
                                            GL_TEXTURE_2D,
                                            GL_TEXTURE0,
                                            offscreen.texture_id);
-      gsk_ngl_render_job_draw_offscreen_rect (job, &child->bounds);
+      gsk_ngl_render_job_draw_offscreen_rect (job, clip);
       gsk_ngl_render_job_end_draw (job);
     }
 }


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