gsk: Be more careful when slicing
authorMatthias Clasen <mclasen@redhat.com>
Fri, 17 Mar 2023 04:50:01 +0000 (00:50 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 17 Mar 2023 04:50:01 +0000 (00:50 -0400)
We can only reuse existing slices if they
have the right filtering.

gsk/gl/gskgldriver.c
gsk/gl/gskgldriverprivate.h

index fced165505e54ac590dfad744074c3a40cea5a7f..af3d8e3b93d5c6631f1fac146e0021e304b4364d 100644 (file)
@@ -760,7 +760,8 @@ gsk_gl_driver_load_texture (GskGLDriver *self,
     }
 
   /* The download_texture() call may have switched the GL context. Make sure
-   * the right context is at work again. */
+   * the right context is at work again.
+   */
   gdk_gl_context_make_current (context);
 
   width = gdk_texture_get_width (texture);
@@ -1227,9 +1228,13 @@ gsk_gl_driver_add_texture_slices (GskGLDriver        *self,
 
   n_slices = cols * rows;
 
-  if ((t = gdk_texture_get_render_data (texture, self)))
+  t = gdk_texture_get_render_data (texture, self);
+
+  if (t)
     {
-      if (t->n_slices == n_slices)
+      if (t->n_slices == n_slices &&
+          t->min_filter == min_filter &&
+          t->mag_filter == mag_filter)
         {
           *out_slices = t->slices;
           *out_n_slices = t->n_slices;
@@ -1281,7 +1286,7 @@ gsk_gl_driver_add_texture_slices (GskGLDriver        *self,
   t = gsk_gl_texture_new (0,
                           tex_width, tex_height,
                           GL_RGBA8,
-                          GL_NEAREST, GL_NEAREST,
+                          min_filter, mag_filter,
                           self->current_frame_id);
 
   /* Use gsk_gl_texture_free() as destroy notify here since we are
index e1f30c2d2df0b1d8f9e8d5b40abd4e05a573654e..11cfbe4d52684df9ef63899ef51bff5ca2345555 100644 (file)
@@ -241,14 +241,16 @@ gsk_gl_driver_slice_texture (GskGLDriver        *self,
 {
   GskGLTexture *t;
 
-  if ((t = gdk_texture_get_render_data (texture, self)))
+  t = gdk_texture_get_render_data (texture, self);
+
+  if (t && t->slices &&
+      t->min_filter == min_filter &&
+      t->mag_filter == mag_filter &&
+      min_cols == 0 && min_rows == 0)
     {
-      if (min_cols == 0 && min_rows == 0 && t->slices)
-        {
-          *out_slices = t->slices;
-          *out_n_slices = t->n_slices;
-          return;
-        }
+      *out_slices = t->slices;
+      *out_n_slices = t->n_slices;
+      return;
     }
 
   gsk_gl_driver_add_texture_slices (self, texture, min_filter, mag_filter, min_cols, min_rows, out_slices, out_n_slices);