summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-07-16 11:59:47 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-07-16 11:59:47 +0000
commita663b8c3134f3245758d0c40dc0696842d33350c (patch)
treed60458a5bbce0f50134525bc78abdbe07960423d
parentf66fa16bd1affbc41863dab9b75e6262b5e9cd21 (diff)
parent8390363abefc3d0c27f39370fbd02b44083a2a10 (diff)
downloadgtk+-a663b8c3134f3245758d0c40dc0696842d33350c.tar.gz
Merge branch 'fix-negative-scales' into 'master'
ngl: Handle negative scales Closes #4096 See merge request GNOME/gtk!3755
-rw-r--r--gsk/ngl/gsknglrenderjob.c8
-rw-r--r--testsuite/gsk/compare/scale-textures-negative-ngl.node48
-rw-r--r--testsuite/gsk/compare/scale-textures-negative-ngl.pngbin0 -> 265 bytes
-rw-r--r--testsuite/gsk/meson.build1
4 files changed, 55 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;
diff --git a/testsuite/gsk/compare/scale-textures-negative-ngl.node b/testsuite/gsk/compare/scale-textures-negative-ngl.node
new file mode 100644
index 0000000000..fbf1d8205e
--- /dev/null
+++ b/testsuite/gsk/compare/scale-textures-negative-ngl.node
@@ -0,0 +1,48 @@
+transform {
+ transform: scale(1, 1);
+ child: opacity {
+ opacity: 0.6;
+ child: container {
+ texture {
+ bounds: 0 0 50 50;
+ texture: url("data:,<svg width='50' height='50'><rect x='25' y='25' width='25' height='25' fill='red'/></svg>");
+ }
+ }
+ }
+}
+transform {
+ transform: scale(1, -1);
+ child: opacity {
+ opacity: 0.6;
+ child: container {
+ texture {
+ bounds: 0 0 50 50;
+ texture: url("data:,<svg width='50' height='50'><rect x='25' y='25' width='25' height='25' fill='lime'/></svg>");
+ }
+ }
+ }
+}
+transform {
+ transform: scale(-1, -1);
+ child: opacity {
+ opacity: 0.6;
+ child: container {
+ texture {
+ bounds: 0 0 50 50;
+ texture: url("data:,<svg width='50' height='50'><rect x='25' y='25' width='25' height='25' fill='blue'/></svg>");
+ }
+ }
+ }
+}
+transform {
+ transform: scale(-1, 1);
+ child: opacity {
+ opacity: 0.6;
+ child: container {
+ texture {
+ bounds: 0 0 50 50;
+ texture: url("data:,<svg width='50' height='50'><rect x='25' y='25' width='25' height='25' fill='yellow'/></svg>");
+ }
+ }
+ }
+}
diff --git a/testsuite/gsk/compare/scale-textures-negative-ngl.png b/testsuite/gsk/compare/scale-textures-negative-ngl.png
new file mode 100644
index 0000000000..8624e6c403
--- /dev/null
+++ b/testsuite/gsk/compare/scale-textures-negative-ngl.png
Binary files differ
diff --git a/testsuite/gsk/meson.build b/testsuite/gsk/meson.build
index 4bdfc8ceaf..e6901e5ef9 100644
--- a/testsuite/gsk/meson.build
+++ b/testsuite/gsk/meson.build
@@ -69,6 +69,7 @@ compare_render_tests = [
'outset_shadow_rounded_top',
'outset_shadow_simple',
'scaled-cairo',
+ 'scale-textures-negative-ngl',
'scale-up-down',
'shadow-in-opacity',
'texture-url',