diff --git a/gsk/gl/gskgldriver.c b/gsk/gl/gskgldriver.c index 5c0eb02c68..ecb08b4f5b 100644 --- a/gsk/gl/gskgldriver.c +++ b/gsk/gl/gskgldriver.c @@ -946,7 +946,10 @@ gsk_gl_driver_load_texture (GskGLDriver *self, t->has_mipmap = TRUE; } - return t->texture_id; + if (!ensure_mipmap || t->has_mipmap) + return t->texture_id; + + gdk_texture_clear_render_data (texture); } if (GDK_IS_DMABUF_TEXTURE (texture) && !ensure_mipmap) diff --git a/gsk/gl/gskgldriverprivate.h b/gsk/gl/gskgldriverprivate.h index 21d21a2b48..bad825b5e6 100644 --- a/gsk/gl/gskgldriverprivate.h +++ b/gsk/gl/gskgldriverprivate.h @@ -202,6 +202,7 @@ gsk_gl_driver_get_texture_by_id (GskGLDriver *self, * gsk_gl_driver_lookup_texture: * @self: a `GskGLDriver` * @key: the key for the texture + * @has_mipmap: (out): Return location for whether the texture has a mipmap * * Looks up a texture in the texture cache by @key. * @@ -211,7 +212,8 @@ gsk_gl_driver_get_texture_by_id (GskGLDriver *self, */ static inline guint gsk_gl_driver_lookup_texture (GskGLDriver *self, - const GskTextureKey *key) + const GskTextureKey *key, + gboolean *has_mipmap) { gpointer id; @@ -222,6 +224,9 @@ gsk_gl_driver_lookup_texture (GskGLDriver *self, if (texture != NULL) texture->last_used_in_frame = self->current_frame_id; + if (has_mipmap) + *has_mipmap = texture ? texture->has_mipmap : FALSE; + return GPOINTER_TO_UINT (id); } diff --git a/gsk/gl/gskglrenderjob.c b/gsk/gl/gskglrenderjob.c index a3e7c315ba..a19840eba1 100644 --- a/gsk/gl/gskglrenderjob.c +++ b/gsk/gl/gskglrenderjob.c @@ -1190,7 +1190,7 @@ gsk_gl_render_job_visit_as_fallback (GskGLRenderJob *job, key.scale_x = scale_x; key.scale_y = scale_y; - texture_id = gsk_gl_driver_lookup_texture (job->driver, &key); + texture_id = gsk_gl_driver_lookup_texture (job->driver, &key, NULL); if (texture_id != 0) goto done; @@ -2216,7 +2216,7 @@ gsk_gl_render_job_visit_blurred_inset_shadow_node (GskGLRenderJob *job, key.scale_x = scale_x; key.scale_y = scale_y; - blurred_texture_id = gsk_gl_driver_lookup_texture (job->driver, &key); + blurred_texture_id = gsk_gl_driver_lookup_texture (job->driver, &key, NULL); if (blurred_texture_id == 0) { @@ -3216,7 +3216,7 @@ gsk_gl_render_job_visit_blur_node (GskGLRenderJob *job, key.scale_x = job->scale_x; key.scale_y = job->scale_y; - offscreen.texture_id = gsk_gl_driver_lookup_texture (job->driver, &key); + offscreen.texture_id = gsk_gl_driver_lookup_texture (job->driver, &key, NULL); cache_texture = offscreen.texture_id == 0; blur_node (job, @@ -3771,6 +3771,8 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job, float u0, u1, v0, v1; GskTextureKey key; guint texture_id; + gboolean need_mipmap; + gboolean has_mipmap; gsk_gl_render_job_untransform_bounds (job, &job->current_clip->rect.bounds, &clip_rect); @@ -3783,9 +3785,11 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job, key.scale_x = 1.; key.scale_y = 1.; - texture_id = gsk_gl_driver_lookup_texture (job->driver, &key); + need_mipmap = (filter == GSK_SCALING_FILTER_TRILINEAR); - if (texture_id != 0) + texture_id = gsk_gl_driver_lookup_texture (job->driver, &key, &has_mipmap); + + if (texture_id != 0 && (!need_mipmap || has_mipmap)) goto render_texture; viewport = GRAPHENE_RECT_INIT (0, 0, @@ -3816,7 +3820,7 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job, { gpointer sync; - texture_id = gsk_gl_driver_load_texture (job->driver, texture, filter == GSK_SCALING_FILTER_TRILINEAR); + texture_id = gsk_gl_driver_load_texture (job->driver, texture, need_mipmap); if (GDK_IS_GL_TEXTURE (texture) && texture_id == gdk_gl_texture_get_id (GDK_GL_TEXTURE (texture))) sync = gdk_gl_texture_get_sync (GDK_GL_TEXTURE (texture)); @@ -3853,7 +3857,7 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job, GskGLTextureSlice *slices = NULL; guint n_slices = 0; - gsk_gl_driver_slice_texture (job->driver, texture, filter == GSK_SCALING_FILTER_TRILINEAR, &slices, &n_slices); + gsk_gl_driver_slice_texture (job->driver, texture, need_mipmap, &slices, &n_slices); if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit))) { @@ -4352,7 +4356,7 @@ gsk_gl_render_job_visit_node_with_offscreen (GskGLRenderJob *job, } /* Check if we've already cached the drawn texture. */ - cached_id = gsk_gl_driver_lookup_texture (job->driver, &key); + cached_id = gsk_gl_driver_lookup_texture (job->driver, &key, NULL); if (cached_id != 0) { diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h index e79eceff87..f34a42a3b4 100644 --- a/gtk/gtkenums.h +++ b/gtk/gtkenums.h @@ -681,7 +681,7 @@ typedef enum { GtkOrdering gtk_ordering_from_cmpfunc (int cmpfunc_result); #else /** - * gtk_ordering_from_cmpfunc: + * gtk_ordering_from_cmpfunc: (skip) * @cmpfunc_result: Result of a comparison function * * Converts the result of a `GCompareFunc` like strcmp() to a diff --git a/gtk/gtksorter.c b/gtk/gtksorter.c index 21c1a713dd..c07b39d1f5 100644 --- a/gtk/gtksorter.c +++ b/gtk/gtksorter.c @@ -372,7 +372,7 @@ gtk_sorter_changed_with_keys (GtkSorter *self, */ #ifdef __GI_SCANNER__ /** - * gtk_ordering_from_cmpfunc: + * gtk_ordering_from_cmpfunc: (skip) * @cmpfunc_result: Result of a comparison function * * Converts the result of a `GCompareFunc` like strcmp() to a