[cairo-commit] 4 commits - src/cairo-pdf-surface.c src/cairo-ps-surface.c
Adrian Johnson
ajohnson at kemper.freedesktop.org
Thu Oct 14 21:56:51 PDT 2010
src/cairo-pdf-surface.c | 32 +++++++++++++++-----------------
src/cairo-ps-surface.c | 22 ++--------------------
2 files changed, 17 insertions(+), 37 deletions(-)
New commits:
commit 22cdb7041f4ecbcac708583bc195d13934be6cf7
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Wed Oct 13 19:23:45 2010 +1030
PS: Remove radial gradient fallback
when one circle not inside the other. Pixman now follows the PDF
specification.
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 1b091db..4e8aa0a 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -1737,28 +1737,13 @@ _gradient_pattern_supported (cairo_ps_surface_t *surface,
extend = cairo_pattern_get_extend ((cairo_pattern_t *) pattern);
- /* Radial gradients are currently only supported when one circle
- * is inside the other. */
+ /* Radial gradients are currently only supported with EXTEND_NONE
+ * and EXTEND_PAD. */
if (pattern->type == CAIRO_PATTERN_TYPE_RADIAL) {
- double x1, y1, x2, y2, r1, r2, d;
- cairo_radial_pattern_t *radial = (cairo_radial_pattern_t *) pattern;
-
if (extend == CAIRO_EXTEND_REPEAT ||
extend == CAIRO_EXTEND_REFLECT) {
return FALSE;
}
-
- x1 = _cairo_fixed_to_double (radial->c1.x);
- y1 = _cairo_fixed_to_double (radial->c1.y);
- r1 = _cairo_fixed_to_double (radial->r1);
- x2 = _cairo_fixed_to_double (radial->c2.x);
- y2 = _cairo_fixed_to_double (radial->c2.y);
- r2 = _cairo_fixed_to_double (radial->r2);
-
- d = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
- if (d > fabs(r2 - r1)) {
- return FALSE;
- }
}
surface->ps_level_used = CAIRO_PS_LEVEL_3;
commit d3655e04b2e27bacdeeddbaf0c4a212b9b93b6ee
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Wed Oct 13 19:20:07 2010 +1030
PDF: Remove radial gradient fallback
when one circle not inside the other. Pixman now follows the PDF
specification.
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 3179048..d8de9b9 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -5350,27 +5350,12 @@ _gradient_pattern_supported (const cairo_pattern_t *pattern)
/* Radial gradients are currently only supported with EXTEND_NONE
- * and EXTEND_PAD and when one circle is inside the other. */
+ * and EXTEND_PAD. */
if (pattern->type == CAIRO_PATTERN_TYPE_RADIAL) {
- double x1, y1, x2, y2, r1, r2, d;
- cairo_radial_pattern_t *radial = (cairo_radial_pattern_t *) pattern;
-
if (extend == CAIRO_EXTEND_REPEAT ||
extend == CAIRO_EXTEND_REFLECT) {
return FALSE;
}
-
- x1 = _cairo_fixed_to_double (radial->c1.x);
- y1 = _cairo_fixed_to_double (radial->c1.y);
- r1 = _cairo_fixed_to_double (radial->r1);
- x2 = _cairo_fixed_to_double (radial->c2.x);
- y2 = _cairo_fixed_to_double (radial->c2.y);
- r2 = _cairo_fixed_to_double (radial->r2);
-
- d = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
- if (d > fabs(r2 - r1)) {
- return FALSE;
- }
}
return TRUE;
commit 34d929962413136ac127245c4347df5c6a5387b3
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Thu Oct 14 19:32:51 2010 +1030
PS: Remove redundant code
The test for zero stops is now in gstate.
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 1ab5cb6..1b091db 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -1727,9 +1727,6 @@ _gradient_pattern_supported (cairo_ps_surface_t *surface,
if (surface->ps_level == CAIRO_PS_LEVEL_2)
return FALSE;
- if (gradient->n_stops == 0)
- return TRUE;
-
/* Alpha gradients are only supported (by flattening the alpha)
* if there is no variation in the alpha across the gradient. */
alpha = gradient->stops[0].color.alpha_short;
commit 7a17ef31760c49b81fd2890814f5b2aeb8c6b3a3
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Thu Oct 14 19:28:13 2010 +1030
PDF: Fix regression in EXTEND_NONE gradients
The test for opaque gradients in _cairo_pdf_surface_add_pdf_pattern()
must be identical to the test in
_cairo_pdf_surface_emit_pattern_stops() other wise the PDF file will
reference a smask that does not exist.
The _cairo_pattern_is_opaque() test is too strict for PDF as PDF can
draw EXTEND_NONE gradients with opaque color stops without requiring a
smask.
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 6e377fa..3179048 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -1204,6 +1204,18 @@ _cairo_pdf_surface_add_source_surface (cairo_pdf_surface_t *surface,
return status;
}
+static cairo_bool_t
+_gradient_stops_are_opaque (const cairo_gradient_pattern_t *gradient)
+{
+ unsigned int i;
+
+ for (i = 0; i < gradient->n_stops; i++)
+ if (! CAIRO_COLOR_IS_OPAQUE (&gradient->stops[i].color))
+ return FALSE;
+
+ return TRUE;
+}
+
static cairo_status_t
_cairo_pdf_surface_add_pdf_pattern (cairo_pdf_surface_t *surface,
const cairo_pattern_t *pattern,
@@ -1237,7 +1249,8 @@ _cairo_pdf_surface_add_pdf_pattern (cairo_pdf_surface_t *surface,
if (pattern->type == CAIRO_PATTERN_TYPE_LINEAR ||
pattern->type == CAIRO_PATTERN_TYPE_RADIAL)
{
- if (_cairo_pattern_is_opaque (pattern, extents) == FALSE) {
+ cairo_gradient_pattern_t *gradient = (cairo_gradient_pattern_t *) pattern;
+ if (! _gradient_stops_are_opaque (gradient)) {
pdf_pattern.gstate_res = _cairo_pdf_surface_new_object (surface);
if (pdf_pattern.gstate_res.id == 0) {
cairo_pattern_destroy (pdf_pattern.pattern);
More information about the cairo-commit
mailing list