Commit d7717cf1 authored by Jason Crain's avatar Jason Crain Committed by Carlos Garcia Campos

cairo: Scale radial pattern

Scale the radial pattern because cairo/pixman do not work well with a
very large or small scaled matrix.  See cairo bug #81657.

bug #22098
parent 9ef565d0
......@@ -963,18 +963,32 @@ GBool CairoOutputDev::axialShadedSupportExtend(GfxState *state, GfxAxialShading
GBool CairoOutputDev::radialShadedFill(GfxState *state, GfxRadialShading *shading, double sMin, double sMax) {
double x0, y0, r0, x1, y1, r1;
double dx, dy, dr;
cairo_matrix_t matrix;
double scale;
shading->getCoords(&x0, &y0, &r0, &x1, &y1, &r1);
dx = x1 - x0;
dy = y1 - y0;
dr = r1 - r0;
// Cairo/pixman do not work well with a very large or small scaled
// matrix. See cairo bug #81657.
//
// As a workaround, scale the pattern by the average of the vertical
// and horizontal scaling of the current transformation matrix.
cairo_get_matrix(cairo, &matrix);
scale = (sqrt(matrix.xx * matrix.xx + matrix.yx * matrix.yx)
+ sqrt(matrix.xy * matrix.xy + matrix.yy * matrix.yy)) / 2;
cairo_matrix_init_scale(&matrix, scale, scale);
cairo_pattern_destroy(fill_pattern);
fill_pattern = cairo_pattern_create_radial (x0 + sMin * dx,
y0 + sMin * dy,
r0 + sMin * dr,
x0 + sMax * dx,
y0 + sMax * dy,
r0 + sMax * dr);
fill_pattern = cairo_pattern_create_radial ((x0 + sMin * dx) * scale,
(y0 + sMin * dy) * scale,
(r0 + sMin * dr) * scale,
(x0 + sMax * dx) * scale,
(y0 + sMax * dy) * scale,
(r0 + sMax * dr) * scale);
cairo_pattern_set_matrix(fill_pattern, &matrix);
if (shading->getExtend0() && shading->getExtend1())
cairo_pattern_set_extend (fill_pattern, CAIRO_EXTEND_PAD);
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment