incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1376444 - in /incubator/ooo/trunk/main: drawinglayer/inc/drawinglayer/primitive2d/svggradientprimitive2d.hxx drawinglayer/source/primitive2d/svggradientprimitive2d.cxx svgio/source/svgreader/svgstyleattributes.cxx
Date Thu, 23 Aug 2012 11:37:59 GMT
Author: alg
Date: Thu Aug 23 11:37:58 2012
New Revision: 1376444

URL: http://svn.apache.org/viewvc?rev=1376444&view=rev
Log:
#120616# Corrected SVG gradient primitive and it's decomposition

Modified:
    incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/svggradientprimitive2d.hxx
    incubator/ooo/trunk/main/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx
    incubator/ooo/trunk/main/svgio/source/svgreader/svgstyleattributes.cxx

Modified: incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/svggradientprimitive2d.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/svggradientprimitive2d.hxx?rev=1376444&r1=1376443&r2=1376444&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/svggradientprimitive2d.hxx
(original)
+++ incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/svggradientprimitive2d.hxx
Thu Aug 23 11:37:58 2012
@@ -113,6 +113,11 @@ namespace drawinglayer
             bool                        mbSingleEntry : 1;
             bool                        mbFullyOpaque : 1;
 
+            // true = interpret in unit coordinate system -> object aspect ratio will
scale result
+            // false = interpret in object coordinate system -> object aspect ratio will
not scale result
+            // (related to SVG's gradientUnits (userSpaceOnUse|objectBoundingBox)
+            bool                        mbUseUnitCoordinates : 1;
+
         protected:
             /// local helpers
             Primitive2DSequence createSingleGradientEntryFill() const;
@@ -147,12 +152,14 @@ namespace drawinglayer
                 const basegfx::B2DPolyPolygon& rPolyPolygon,
                 const SvgGradientEntryVector& rGradientEntries,
                 const basegfx::B2DPoint& rStart,
+                bool bUseUnitCoordinates,
                 SpreadMethod aSpreadMethod = Spread_pad);
 
             /// data read access
             const basegfx::B2DPolyPolygon& getPolyPolygon() const { return maPolyPolygon;
}
             const SvgGradientEntryVector& getGradientEntries() const { return maGradientEntries;
}
             const basegfx::B2DPoint& getStart() const { return maStart; }
+            bool getUseUnitCoordinates() const { return mbUseUnitCoordinates; }
             SpreadMethod getSpreadMethod() const { return maSpreadMethod; }
 
             /// compare operator
@@ -195,6 +202,7 @@ namespace drawinglayer
                 const SvgGradientEntryVector& rGradientEntries,
                 const basegfx::B2DPoint& rStart,
                 const basegfx::B2DPoint& rEnd,
+                bool bUseUnitCoordinates,
                 SpreadMethod aSpreadMethod = Spread_pad);
             virtual ~SvgLinearGradientPrimitive2D();
 
@@ -262,6 +270,7 @@ namespace drawinglayer
                 const SvgGradientEntryVector& rGradientEntries,
                 const basegfx::B2DPoint& rStart,
                 double fRadius,
+                bool bUseUnitCoordinates,
                 SpreadMethod aSpreadMethod = Spread_pad,
                 const basegfx::B2DPoint* pFocal = 0);
             virtual ~SvgRadialGradientPrimitive2D();

Modified: incubator/ooo/trunk/main/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx?rev=1376444&r1=1376443&r2=1376444&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx Thu
Aug 23 11:37:58 2012
@@ -288,6 +288,7 @@ namespace drawinglayer
             const basegfx::B2DPolyPolygon& rPolyPolygon,
             const SvgGradientEntryVector& rGradientEntries,
             const basegfx::B2DPoint& rStart,
+            bool bUseUnitCoordinates,
             SpreadMethod aSpreadMethod)
         :   maPolyPolygon(rPolyPolygon),
             maGradientEntries(rGradientEntries),
@@ -296,7 +297,8 @@ namespace drawinglayer
             mbPreconditionsChecked(false),
             mbCreatesContent(false),
             mbSingleEntry(false),
-            mbFullyOpaque(true)
+            mbFullyOpaque(true),
+            mbUseUnitCoordinates(bUseUnitCoordinates)
         {
         }
 
@@ -307,6 +309,7 @@ namespace drawinglayer
             return (getPolyPolygon() == rCompare.getPolyPolygon()
                 && getGradientEntries() == rCompare.getGradientEntries()
                 && getStart() == rCompare.getStart()
+                && getUseUnitCoordinates() == rCompare.getUseUnitCoordinates()
                 && getSpreadMethod() == rCompare.getSpreadMethod());
         }
 
@@ -398,20 +401,37 @@ namespace drawinglayer
                     basegfx::tools::createScaleTranslateB2DHomMatrix(
                         fPolyWidth, fPolyHeight, 
                         aPolyRange.getMinX(), aPolyRange.getMinY()));
-
-                // get start, end in object coordinates
-                const basegfx::B2DPoint aStart(aObjectTransform * getStart());
-                const basegfx::B2DPoint aEnd(aObjectTransform * getEnd());
-
-                // create transform from unit vector [0.0 .. 1.0] along the X-Axis to given

-                // gradient vector in object coordinates defined by Start, End
-                const basegfx::B2DVector aVector(aEnd - aStart);
-                const double fVectorLength(aVector.getLength());
                 basegfx::B2DHomMatrix aUnitGradientToObject;
+                static bool bInterpretAbsolute(true);
 
-                aUnitGradientToObject.scale(fVectorLength, 1.0);
-                aUnitGradientToObject.rotate(atan2(aVector.getY(), aVector.getX()));
-                aUnitGradientToObject.translate(aStart.getX(), aStart.getY());
+                if(getUseUnitCoordinates())
+                {
+                    // interpret in unit coordinate system -> object aspect ratio will
scale result
+                    // create unit transform from unit vector [0.0 .. 1.0] along the X-Axis
to given 
+                    // gradient vector defined by Start,End
+                    const basegfx::B2DVector aVector(getEnd() - getStart());
+                    const double fVectorLength(aVector.getLength());
+                    basegfx::B2DHomMatrix aUnitGradientToGradient;
+
+                    aUnitGradientToGradient.scale(fVectorLength, 1.0);
+                    aUnitGradientToGradient.rotate(atan2(aVector.getY(), aVector.getX()));
+                    aUnitGradientToGradient.translate(getStart().getX(), getStart().getY());
+
+                    // create full transform from unit gradient coordinates to object coordinates
+                    // including the SvgGradient transformation
+                    aUnitGradientToObject = aObjectTransform * aUnitGradientToGradient;
+                }
+                else
+                {
+                    // interpret in object coordinate system -> object aspect ratio will
not scale result
+                    const basegfx::B2DPoint aStart(aObjectTransform * getStart());
+                    const basegfx::B2DPoint aEnd(aObjectTransform * getEnd());
+                    const basegfx::B2DVector aVector(aEnd - aStart);
+
+                    aUnitGradientToObject.scale(aVector.getLength(), 1.0);
+                    aUnitGradientToObject.rotate(atan2(aVector.getY(), aVector.getX()));
+                    aUnitGradientToObject.translate(aStart.getX(), aStart.getY());
+                }
 
                 // create inverse from it
                 basegfx::B2DHomMatrix aObjectToUnitGradient(aUnitGradientToObject);
@@ -535,9 +555,10 @@ namespace drawinglayer
             const SvgGradientEntryVector& rGradientEntries,
             const basegfx::B2DPoint& rStart,
             const basegfx::B2DPoint& rEnd,
+            bool bUseUnitCoordinates,
             SpreadMethod aSpreadMethod)
         :   BufferedDecompositionPrimitive2D(),
-            SvgGradientHelper(rPolyPolygon, rGradientEntries, rStart, aSpreadMethod),
+            SvgGradientHelper(rPolyPolygon, rGradientEntries, rStart, bUseUnitCoordinates,
aSpreadMethod),
             maEnd(rEnd)
         {
         }
@@ -715,16 +736,31 @@ namespace drawinglayer
                     basegfx::tools::createScaleTranslateB2DHomMatrix(
                         fPolyWidth, fPolyHeight, 
                         aPolyRange.getMinX(), aPolyRange.getMinY()));
+                basegfx::B2DHomMatrix aUnitGradientToObject;
+                static bool bInterpretAbsolute(true);
 
-                // create unit transform from unit vector to given linear gradient vector
-                basegfx::B2DHomMatrix aUnitGradientToGradient;
+                if(getUseUnitCoordinates())
+                {
+                    // interpret in unit coordinate system -> object aspect ratio will
scale result
+                    // create unit transform from unit vector to given linear gradient vector
+                    basegfx::B2DHomMatrix aUnitGradientToGradient;
+
+                    aUnitGradientToGradient.scale(getRadius(), getRadius());
+                    aUnitGradientToGradient.translate(getStart().getX(), getStart().getY());
 
-                aUnitGradientToGradient.scale(getRadius(), getRadius());
-                aUnitGradientToGradient.translate(getStart().getX(), getStart().getY());
+                    // create full transform from unit gradient coordinates to object coordinates
+                    // including the SvgGradient transformation
+                    aUnitGradientToObject = aObjectTransform * aUnitGradientToGradient;
+                }
+                else
+                {
+                    // interpret in object coordinate system -> object aspect ratio will
not scale result
+                    const double fRadius((aObjectTransform * basegfx::B2DVector(getRadius(),
0.0)).getLength());
+                    const basegfx::B2DPoint aStart(aObjectTransform * getStart());
 
-                // create full transform from unit gradient coordinates to object coordinates
-                // including the SvgGradient transformation
-                basegfx::B2DHomMatrix aUnitGradientToObject(aObjectTransform * aUnitGradientToGradient);
+                    aUnitGradientToObject.scale(fRadius, fRadius);
+                    aUnitGradientToObject.translate(aStart.getX(), aStart.getY());
+                }
 
                 // create inverse from it
                 basegfx::B2DHomMatrix aObjectToUnitGradient(aUnitGradientToObject);
@@ -797,10 +833,11 @@ namespace drawinglayer
             const SvgGradientEntryVector& rGradientEntries,
             const basegfx::B2DPoint& rStart,
             double fRadius,
+            bool bUseUnitCoordinates,
             SpreadMethod aSpreadMethod,
             const basegfx::B2DPoint* pFocal)
         :   BufferedDecompositionPrimitive2D(),
-            SvgGradientHelper(rPolyPolygon, rGradientEntries, rStart, aSpreadMethod),
+            SvgGradientHelper(rPolyPolygon, rGradientEntries, rStart, bUseUnitCoordinates,
aSpreadMethod),
             mfRadius(fRadius),
             maFocal(rStart),
             maFocalVector(0.0, 0.0),

Modified: incubator/ooo/trunk/main/svgio/source/svgreader/svgstyleattributes.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svgio/source/svgreader/svgstyleattributes.cxx?rev=1376444&r1=1376443&r2=1376444&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svgio/source/svgreader/svgstyleattributes.cxx (original)
+++ incubator/ooo/trunk/main/svgio/source/svgreader/svgstyleattributes.cxx Thu Aug 23 11:37:58
2012
@@ -370,6 +370,7 @@ namespace svgio
                             aSvgGradientEntryVector,
                             aStart,
                             aEnd,
+                            userSpaceOnUse != rFillGradient.getGradientUnits(),
                             rFillGradient.getSpreadMethod()));
                 }
                 else
@@ -430,6 +431,7 @@ namespace svgio
                             aSvgGradientEntryVector,
                             aStart,
                             fRadius,
+                            userSpaceOnUse != rFillGradient.getGradientUnits(),
                             rFillGradient.getSpreadMethod(),
                             bFocal ? &aFocal : 0));
                 }



Mime
View raw message