From 1b553478f6e0a0fa5c333409cb81f603aff0e8a3 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 19 Dec 2016 23:30:02 +0100 Subject: [PATCH] cssimageradial: Handle "partial" gradients correctly When the first/last color stop is not at 0%/100%, we need to start the repeating at their offsets and not at 0%/100%. Attached reftest demonstrates the problem. --- gtk/gtkcssimageradial.c | 2 +- testsuite/reftests/Makefile.am | 3 +++ .../repeating-radial-gradient-at-beginning.css | 11 +++++++++++ .../repeating-radial-gradient-at-beginning.ref.ui | 11 +++++++++++ .../repeating-radial-gradient-at-beginning.ui | 10 ++++++++++ 5 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 testsuite/reftests/repeating-radial-gradient-at-beginning.css create mode 100644 testsuite/reftests/repeating-radial-gradient-at-beginning.ref.ui create mode 100644 testsuite/reftests/repeating-radial-gradient-at-beginning.ui diff --git a/gtk/gtkcssimageradial.c b/gtk/gtkcssimageradial.c index e22d9b805b..585d136d2c 100644 --- a/gtk/gtkcssimageradial.c +++ b/gtk/gtkcssimageradial.c @@ -163,7 +163,7 @@ gtk_css_image_radial_draw (GtkCssImage *image, gtk_css_image_radial_get_start_end (radial, radius, &start, &end); - pattern = cairo_pattern_create_radial (0, 0, 0, 0, 0, radius); + pattern = cairo_pattern_create_radial (0, 0, radius * start, 0, 0, radius * end); if (yscale != 1.0) { cairo_matrix_init_scale (&matrix, 1.0, 1.0 / yscale); diff --git a/testsuite/reftests/Makefile.am b/testsuite/reftests/Makefile.am index c0c1beab68..2dbca1209c 100644 --- a/testsuite/reftests/Makefile.am +++ b/testsuite/reftests/Makefile.am @@ -377,6 +377,9 @@ testdata = \ quit-mnemonic.css \ quit-mnemonic.ref.ui \ quit-mnemonic.ui \ + repeating-radial-gradient-at-beginning.css \ + repeating-radial-gradient-at-beginning.ref.ui \ + repeating-radial-gradient-at-beginning.ui \ reset-to-defaults.css \ revealer-extra-size.ref.ui \ revealer-extra-size.ui \ diff --git a/testsuite/reftests/repeating-radial-gradient-at-beginning.css b/testsuite/reftests/repeating-radial-gradient-at-beginning.css new file mode 100644 index 0000000000..0f4dd2eef6 --- /dev/null +++ b/testsuite/reftests/repeating-radial-gradient-at-beginning.css @@ -0,0 +1,11 @@ +window { + background: repeating-radial-gradient(red 50%, blue, red); +} + +#reference { + background-image: radial-gradient(red, blue, red), repeating-radial-gradient(red 50%, blue, red); + background-size: 50% 50%, 100% 100%; + background-repeat: no-repeat; + background-position: center; +} + diff --git a/testsuite/reftests/repeating-radial-gradient-at-beginning.ref.ui b/testsuite/reftests/repeating-radial-gradient-at-beginning.ref.ui new file mode 100644 index 0000000000..3f0f3f1d4a --- /dev/null +++ b/testsuite/reftests/repeating-radial-gradient-at-beginning.ref.ui @@ -0,0 +1,11 @@ + + + + + 64 + 32 + False + popup + reference + + diff --git a/testsuite/reftests/repeating-radial-gradient-at-beginning.ui b/testsuite/reftests/repeating-radial-gradient-at-beginning.ui new file mode 100644 index 0000000000..a6c83b876a --- /dev/null +++ b/testsuite/reftests/repeating-radial-gradient-at-beginning.ui @@ -0,0 +1,10 @@ + + + + + 64 + 32 + False + popup + +