[Libreoffice-commits] core.git: drawinglayer/source

Bartosz Kosiorek (via logerrit) logerrit at kemper.freedesktop.org
Mon Apr 1 11:56:13 UTC 2019


 drawinglayer/source/tools/emfpbrush.cxx      |   24 ++++++++++----------
 drawinglayer/source/tools/emfpbrush.hxx      |    2 -
 drawinglayer/source/tools/emfphelperdata.cxx |   32 +++++++++++++--------------
 3 files changed, 29 insertions(+), 29 deletions(-)

New commits:
commit 4a215887a845452f984c5453de883b538f660ad4
Author:     Bartosz Kosiorek <gang65 at poczta.onet.pl>
AuthorDate: Mon Apr 1 11:41:20 2019 +0200
Commit:     Bartosz Kosiorek <gang65 at poczta.onet.pl>
CommitDate: Mon Apr 1 13:55:50 2019 +0200

    tdf#103859 EMF+ Add transparency support for linear gradients
    
    Change-Id: I2a3c21b936bc765f152be5bb8064b9d13aabaa07
    Reviewed-on: https://gerrit.libreoffice.org/69927
    Tested-by: Jenkins
    Reviewed-by: Bartosz Kosiorek <gang65 at poczta.onet.pl>

diff --git a/drawinglayer/source/tools/emfpbrush.cxx b/drawinglayer/source/tools/emfpbrush.cxx
index 5e4cdaadae5d..2f860273f50b 100644
--- a/drawinglayer/source/tools/emfpbrush.cxx
+++ b/drawinglayer/source/tools/emfpbrush.cxx
@@ -45,10 +45,10 @@ namespace emfplushelper
         : type(0)
         , additionalFlags(0)
         , wrapMode(0)
-        , areaX(0.0)
-        , areaY(0.0)
-        , areaWidth(0.0)
-        , areaHeight(0.0)
+        , firstPointX(0.0)
+        , firstPointY(0.0)
+        , secondPointX(0.0)
+        , secondPointY(0.0)
         , hasTransformation(false)
         , blendPoints(0)
         , blendFactors(nullptr)
@@ -110,8 +110,8 @@ namespace emfplushelper
                 s.ReadUInt32(color);
                 solidColor = ::Color(0xff - (color >> 24), (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff);
                 SAL_INFO("drawinglayer", "EMF+\tcenter color: 0x" << std::hex << color << std::dec);
-                s.ReadFloat(areaX).ReadFloat(areaY);
-                SAL_INFO("drawinglayer", "EMF+\tcenter point: " << areaX << "," << areaY);
+                s.ReadFloat(firstPointX).ReadFloat(firstPointY);
+                SAL_INFO("drawinglayer", "EMF+\tcenter point: " << firstPointX << "," << firstPointY);
                 s.ReadInt32(surroundColorsNumber);
                 SAL_INFO("drawinglayer", "EMF+\t number of surround colors: " << surroundColorsNumber);
 
@@ -153,8 +153,8 @@ namespace emfplushelper
                     s.Seek(pos + pathLength);
 
                     const ::basegfx::B2DRectangle aBounds(::basegfx::utils::getRange(path->GetPolygon(rR, false)));
-                    areaWidth = aBounds.getWidth();
-                    areaHeight = aBounds.getHeight();
+                    secondPointX = aBounds.getWidth();
+                    secondPointY = aBounds.getHeight();
                     SAL_INFO("drawinglayer", "EMF+\t polygon bounding box: " << aBounds.getMinX() << "," << aBounds.getMinY() << " " << aBounds.getWidth() << "x" << aBounds.getHeight());
                 }
                 else
@@ -170,8 +170,8 @@ namespace emfplushelper
                     s.Seek(pos + 8 * boundaryPointCount);
 
                     const ::basegfx::B2DRectangle aBounds(::basegfx::utils::getRange(path->GetPolygon(rR, false)));
-                    areaWidth = aBounds.getWidth();
-                    areaHeight = aBounds.getHeight();
+                    secondPointX = aBounds.getWidth();
+                    secondPointY = aBounds.getHeight();
                     SAL_INFO("drawinglayer", "EMF+\t polygon bounding box: " << aBounds.getMinX() << "," << aBounds.getMinY() << " " << aBounds.getWidth() << "x" << aBounds.getHeight());
                 }
 
@@ -242,8 +242,8 @@ namespace emfplushelper
             {
                 s.ReadUInt32(additionalFlags).ReadInt32(wrapMode);
                 SAL_INFO("drawinglayer", "EMF+\tlinear gradient, additional flags: 0x" << std::hex << additionalFlags << std::dec);
-                s.ReadFloat(areaX).ReadFloat(areaY).ReadFloat(areaWidth).ReadFloat(areaHeight);
-                SAL_INFO("drawinglayer", "EMF+\tarea: " << areaX << "," << areaY << " - " << areaWidth << "x" << areaHeight);
+                s.ReadFloat(firstPointX).ReadFloat(firstPointY).ReadFloat(secondPointX).ReadFloat(secondPointY);
+                SAL_INFO("drawinglayer", "EMF+\tFirst gradinet point: " << firstPointX << ":" << firstPointY << ", second gradient point " << secondPointX << ":" << secondPointY);
                 sal_uInt32 color;
                 s.ReadUInt32(color);
                 solidColor = ::Color(0xff - (color >> 24), (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff);
diff --git a/drawinglayer/source/tools/emfpbrush.hxx b/drawinglayer/source/tools/emfpbrush.hxx
index 283ff304abf3..ef5a8a43976a 100644
--- a/drawinglayer/source/tools/emfpbrush.hxx
+++ b/drawinglayer/source/tools/emfpbrush.hxx
@@ -101,7 +101,7 @@ namespace emfplushelper
 
         /* linear gradient */
         sal_Int32 wrapMode;
-        float areaX, areaY, areaWidth, areaHeight;
+        float firstPointX, firstPointY, secondPointX, secondPointY;
         ::Color secondColor; // first color is stored in solidColor;
         basegfx::B2DHomMatrix brush_transformation;
         bool hasTransformation;
diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx
index 518920afaed2..58cb38dc21c9 100644
--- a/drawinglayer/source/tools/emfphelperdata.cxx
+++ b/drawinglayer/source/tools/emfphelperdata.cxx
@@ -591,18 +591,18 @@ namespace emfplushelper
                 ::basegfx::B2DHomMatrix aTextureTransformation;
 
                 if (brush->hasTransformation) {
-                   aTextureTransformation *= brush->brush_transformation;
-                }
+                   aTextureTransformation = brush->brush_transformation;
 
-                // adjust aTextureTransformation for our world space:
-                // -> revert the mapping -> apply the transformation -> map back
-                basegfx::B2DHomMatrix aInvertedMapTrasform(maMapTransform);
-                aInvertedMapTrasform.invert();
-                aTextureTransformation =  maMapTransform * aTextureTransformation * aInvertedMapTrasform;
+                   // adjust aTextureTransformation for our world space:
+                   // -> revert the mapping -> apply the transformation -> map back
+                   basegfx::B2DHomMatrix aInvertedMapTrasform(maMapTransform);
+                   aInvertedMapTrasform.invert();
+                   aTextureTransformation =  maMapTransform * aTextureTransformation * aInvertedMapTrasform;
+                }
 
                 // select the stored colors
-                basegfx::BColor aStartColor =  brush->solidColor.getBColor();
-                basegfx::BColor aEndColor =  brush->secondColor.getBColor();
+                const basegfx::BColor aStartColor = brush->solidColor.getBColor();
+                const basegfx::BColor aEndColor = brush->secondColor.getBColor();
                 drawinglayer::primitive2d::SvgGradientEntryVector aVector;
 
                 if (brush->blendPositions)
@@ -655,13 +655,13 @@ namespace emfplushelper
                 {
                     if (brush->type == BrushTypeLinearGradient)
                     {
-                        aVector.emplace_back(0.0, aStartColor, 1. );
-                        aVector.emplace_back(1.0, aEndColor, 1. );
+                        aVector.emplace_back(0.0, aStartColor, (255 - brush->solidColor.GetTransparency()) / 255.0);
+                        aVector.emplace_back(1.0, aEndColor, (255 - brush->secondColor.GetTransparency()) / 255.0);
                     }
                     else // again, here reverse
                     {
-                        aVector.emplace_back(0.0, aEndColor, 1. );
-                        aVector.emplace_back(1.0, aStartColor, 1. );
+                        aVector.emplace_back(0.0, aEndColor, (255 - brush->secondColor.GetTransparency()) / 255.0);
+                        aVector.emplace_back(1.0, aStartColor, (255 - brush->solidColor.GetTransparency()) / 255.0);
                     }
                 }
 
@@ -675,9 +675,9 @@ namespace emfplushelper
 
                 if (brush->type == BrushTypeLinearGradient)
                 {
-                    basegfx::B2DPoint aStartPoint = Map(brush->areaX,brush->areaY);
+                    basegfx::B2DPoint aStartPoint = Map(brush->firstPointX, brush->firstPointY);
                     aStartPoint = aPolygonTransformation * aStartPoint;
-                    basegfx::B2DPoint aEndPoint = Map(brush->areaX + brush->areaWidth, brush->areaY + brush->areaHeight);
+                    basegfx::B2DPoint aEndPoint = Map(brush->firstPointX + brush->secondPointX, brush->firstPointY + brush->secondPointY);
                     aEndPoint = aPolygonTransformation * aEndPoint;
 
                     // create the same one used for SVG
@@ -693,7 +693,7 @@ namespace emfplushelper
                 }
                 else // BrushTypePathGradient
                 {
-                    basegfx::B2DPoint aCenterPoint = Map(brush->areaX,brush->areaY);
+                    basegfx::B2DPoint aCenterPoint = Map(brush->firstPointX, brush->firstPointY);
                     aCenterPoint = aPolygonTransformation * aCenterPoint;
 
                     // create the same one used for SVG


More information about the Libreoffice-commits mailing list