mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 13:11:13 +00:00
gpu: Make sure textures used as image are mipmapped
When getting a texture as image, we were always returning the texture unconditionally. However, we want to mipmap textures when the scale factor is too large, and this code path did not do that. The same codepath on the GL renderer doesn't do that either, so the test is disabled for it.
This commit is contained in:
parent
ab37fed974
commit
31a907be35
@ -1420,6 +1420,22 @@ gsk_gpu_node_processor_add_border_node (GskGpuNodeProcessor *self,
|
||||
colors);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
texture_node_should_mipmap (GskRenderNode *node,
|
||||
GskGpuFrame *frame,
|
||||
const graphene_vec2_t *scale)
|
||||
{
|
||||
GdkTexture *texture;
|
||||
|
||||
texture = gsk_texture_node_get_texture (node);
|
||||
|
||||
if (!gsk_gpu_frame_should_optimize (frame, GSK_GPU_OPTIMIZE_MIPMAP))
|
||||
return FALSE;
|
||||
|
||||
return gdk_texture_get_width (texture) > 2 * node->bounds.size.width * graphene_vec2_get_x (scale) ||
|
||||
gdk_texture_get_height (texture) > 2 * node->bounds.size.height * graphene_vec2_get_y (scale);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gpu_node_processor_add_texture_node (GskGpuNodeProcessor *self,
|
||||
GskRenderNode *node)
|
||||
@ -1448,9 +1464,7 @@ gsk_gpu_node_processor_add_texture_node (GskGpuNodeProcessor *self,
|
||||
}
|
||||
}
|
||||
|
||||
if (gsk_gpu_frame_should_optimize (self->frame, GSK_GPU_OPTIMIZE_MIPMAP) &&
|
||||
(gdk_texture_get_width (texture) > 2 * node->bounds.size.width * graphene_vec2_get_x (&self->scale) ||
|
||||
gdk_texture_get_height (texture) > 2 * node->bounds.size.height * graphene_vec2_get_y (&self->scale)))
|
||||
if (texture_node_should_mipmap (node, self->frame, &self->scale))
|
||||
{
|
||||
guint32 descriptor;
|
||||
|
||||
@ -1504,6 +1518,9 @@ gsk_gpu_get_texture_node_as_image (GskGpuFrame *frame,
|
||||
gint64 timestamp = gsk_gpu_frame_get_timestamp (frame);
|
||||
GskGpuImage *image;
|
||||
|
||||
if (texture_node_should_mipmap (node, frame, scale))
|
||||
return gsk_gpu_get_node_as_image_via_offscreen (frame, clip_bounds, scale, node, out_bounds);
|
||||
|
||||
image = gsk_gpu_cache_lookup_texture_image (gsk_gpu_device_get_cache (device), texture, timestamp);
|
||||
if (image == NULL)
|
||||
image = gsk_gpu_frame_upload_texture (frame, FALSE, texture);
|
||||
|
33
testsuite/gsk/compare/texture-offscreen-mipmap-nogl.node
Normal file
33
testsuite/gsk/compare/texture-offscreen-mipmap-nogl.node
Normal file
@ -0,0 +1,33 @@
|
||||
texture {
|
||||
bounds: 0 0 25 25;
|
||||
texture: "texture1" url("data:image/png;base64,\
|
||||
iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAACkElEQVR4nO3XoQHDMBAEwXMqcP9V\
|
||||
qoMEBDtgUcAMWyb2uuts7/ucbdu5722b1vrb1855/8NDtP7Hfg14dPliaf3cLgj8YINobYNAY4No\
|
||||
bYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNA\
|
||||
Y4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4No\
|
||||
bYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNA\
|
||||
Y4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4No\
|
||||
bYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNA\
|
||||
Y4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4No\
|
||||
bYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNA\
|
||||
Y4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4No\
|
||||
bYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNA\
|
||||
Y4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4NobYNAY4No\
|
||||
bYNAY4No/aM/Uzkk29ZNdeQAAAAASUVORK5CYII=\
|
||||
");
|
||||
}
|
||||
color-matrix {
|
||||
child: texture {
|
||||
bounds: 25 0 25 25;
|
||||
texture: "texture1";
|
||||
}
|
||||
}
|
||||
color-matrix {
|
||||
child: debug {
|
||||
message: "magic bugfix";
|
||||
child: texture {
|
||||
bounds: 50 0 25 25;
|
||||
texture: "texture1";
|
||||
}
|
||||
}
|
||||
}
|
BIN
testsuite/gsk/compare/texture-offscreen-mipmap-nogl.png
Normal file
BIN
testsuite/gsk/compare/texture-offscreen-mipmap-nogl.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 141 B |
@ -171,6 +171,7 @@ compare_render_tests = [
|
||||
'text-mixed-color-nocairo',
|
||||
'text-mixed-color-colrv1',
|
||||
'texture-coords',
|
||||
'texture-offscreen-mipmap-nogl',
|
||||
'texture-scale-filters-nocairo',
|
||||
'texture-scale-magnify-10000x',
|
||||
'texture-scale-magnify-rotate',
|
||||
|
Loading…
Reference in New Issue
Block a user