[lasem] svg_view: avoid cairo errors due to not invertible pattern matrix.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [lasem] svg_view: avoid cairo errors due to not invertible pattern matrix.
- Date: Tue, 12 Jun 2012 21:15:21 +0000 (UTC)
commit c6177203accded62272efc7eae99949a4a910f70
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Tue Jun 12 23:14:27 2012 +0200
svg_view: avoid cairo errors due to not invertible pattern matrix.
src/lsmsvgview.c | 10 +++
tests/data/svg/misc/not-invertible-matrix.svg | 95 +++++++++++++++++++++++++
2 files changed, 105 insertions(+), 0 deletions(-)
---
diff --git a/src/lsmsvgview.c b/src/lsmsvgview.c
index 4acdc2a..09c2b44 100644
--- a/src/lsmsvgview.c
+++ b/src/lsmsvgview.c
@@ -262,6 +262,8 @@ lsm_svg_view_create_surface_pattern (LsmSvgView *view,
cairo_surface_t *surface;
cairo_pattern_t *pattern;
cairo_matrix_t matrix;
+ cairo_matrix_t inv_matrix;
+ cairo_status_t status;
double x1, y1, x2, y2;
double device_width, device_height;
double x_scale, y_scale;
@@ -332,6 +334,14 @@ lsm_svg_view_create_surface_pattern (LsmSvgView *view,
cairo_matrix_translate (&matrix, -viewport->x, -viewport->y);
}
+ inv_matrix = matrix;
+ status = cairo_matrix_invert (&inv_matrix);
+
+ if (status != CAIRO_STATUS_SUCCESS) {
+ lsm_debug_render ("[LsmSvgView::create_surface_pattern] Not invertible matrix");
+ return FALSE;
+ }
+
cairo_pattern_set_matrix (view->pattern_data->pattern, &matrix);
cairo_pattern_set_extend (view->pattern_data->pattern, CAIRO_EXTEND_REPEAT);
diff --git a/tests/data/svg/misc/not-invertible-matrix.svg b/tests/data/svg/misc/not-invertible-matrix.svg
new file mode 100755
index 0000000..7a2e77f
--- /dev/null
+++ b/tests/data/svg/misc/not-invertible-matrix.svg
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">
+
+<!--======================================================================-->
+<!--= Copyright 2000 World Wide Web Consortium, (Massachusetts =-->
+<!--= Institute of Technology, Institut National de Recherche en =-->
+<!--= Informatique et en Automatique, Keio University). All Rights =-->
+<!--= Reserved. See http://www.w3.org/Consortium/Legal/. =-->
+<!--======================================================================-->
+<!-- =====================================================================-->
+<!-- -->
+<!-- gradPatt-transform-BE-09.svg -->
+<!-- renamed for 1.1 suite to pservers-grad-06-b.svg -->
+<!-- -->
+<!-- Test that the viewer can handle the gradientTransform and -->
+<!-- the patternTransform attribute on gradients and patterns -->
+<!-- respectively. -->
+<!-- -->
+<!-- Author : Haroon Sheikh 08-Mar-2000 -->
+<!-- Revised for 1.1 : Jun Fujisawa 19-Feb-2002 -->
+<!-- -->
+<!-- History: -->
+<!-- 09-Mar-2000, HSS: Serial#1 created. -->
+<!-- 02-Jun-2000, DJ: Fixed gradientTransform to patternTransform. -->
+<!-- 03-Aug-2000, LH=" update DOCTYPE for CR DTD, 20000802" ser# . -->
+<!-- 16-Aug-2000, LH="rename" ser#3. -->
+<!-- -->
+<!-- =====================================================================-->
+<!--======================================================================-->
+<!--= Note. After October 2000, revision history is kept as CVS 'commit' =-->
+<!--= log messages, and therefore is no longer in the preceding preamble.=-->
+<!--======================================================================-->
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="svg-root" viewBox="0 0 480 360" width="100%" height="100%" version="1.1" baseProfile="basic">
+ <SVGTestCase xmlns="http://www.w3.org/2000/02/svg/testsuite/description/">
+ <OperatorScript version="$Revision: 1.7 $" testname="pservers-grad-06-b.svg">
+ <Paragraph>
+ Test that the viewer can handle the gradientTransform and the patternTransform
+ attribute on gradients and patterns respectively.
+ </Paragraph>
+ <Paragraph>
+ From top-down the appearance of objects is as follows.
+ </Paragraph>
+ <Paragraph>
+ The top rectangle has a linear gradient whose coordinate system has been scaled down by
+ a half. So the gradient travelling from left to righ (from blue to red to lime) should
+ only occuply the left half the rectangle.
+ </Paragraph>
+ <Paragraph>
+ The next rectangle has radial gradient that has been translated to the center and skewed
+ in the positive X direction by 45 degrees. Therefore the gradient should appear
+ ellipltical and rotated around the center.
+ </Paragraph>
+ <Paragraph>
+ The last row contains a rectangle with pattern on the fill. The transformation on the
+ pattern moves the coordinate system to the top left of the rectangle and then scales it
+ by a factor of 2 and then skew's it in the X direction by 45 degrees. The pattern
+ consists of a 2 by 2 array of colored rectangles.
+ </Paragraph>
+ <Paragraph>
+ The rendered picture should match the reference image exactly, except for possible
+ variations in the labelling text (per CSS2 rules).
+ </Paragraph>
+ </OperatorScript>
+ </SVGTestCase>
+ <title id="test-title">pservers-grad-06-b</title>
+ <desc id="test-desc">Test that the viewer can handle the gradientTransform and the patternTransform attribute on gradients and patterns respectively.</desc>
+ <!--======================================================================-->
+ <!--Content of Test Case follows... =====================-->
+ <!--======================================================================-->
+ <g id="test-body-content">
+ <!-- ====================================================================== -->
+ <!-- Linear Gradient with gradientTransforms -->
+ <!-- ====================================================================== -->
+ <linearGradient id="Grad1" gradientUnits="userSpaceOnUse" x1="0" y1="0" x2="430" y2="0" gradientTransform="matrix (0 0 0 0 0 0)">
+ <stop stop-color="blue" offset="0"/>
+ <stop stop-color="red" offset="0.5"/>
+ <stop stop-color="lime" offset="1"/>
+ </linearGradient>
+ <rect x="20" y="20" width="440" height="50" fill="url(#Grad1)"/>
+ <text font-family="Arial" font-size="30" x="20" y="100">matrix(0 0 0 0 0 0) on gradient</text>
+ <!-- ====================================================================== -->
+ <!-- Pattern filled rectangles with a patternTransform. -->
+ <!-- ====================================================================== -->
+ <pattern patternUnits="userSpaceOnUse" id="Pat3" x="0" y="0" width="20" height="20" patternTransform="matrix(0 0 0 0 0 0)">
+ <rect x="0" y="0" width="10" height="10" fill="red"/>
+ <rect x="10" y="0" width="10" height="10" fill="green"/>
+ <rect x="0" y="10" width="10" height="10" fill="blue"/>
+ <rect x="10" y="10" width="10" height="10" fill="yellow"/>
+ </pattern>
+ <rect x="20" y="210" width="440" height="50" fill="url(#Pat3)"/>
+ <text font-family="Arial" font-size="30" x="20" y="290">matrix(0 0 0 0 0 0) on pattern</text>
+ </g>
+ <text id="revision" x="10" y="340" font-size="40" stroke="none" fill="black">$Revision: 1.7 $</text>
+ <rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000000"/>
+</svg>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]