Kaydet (Commit) 4a215887 authored tarafından Bartosz Kosiorek's avatar Bartosz Kosiorek

tdf#103859 EMF+ Add transparency support for linear gradients

Change-Id: I2a3c21b936bc765f152be5bb8064b9d13aabaa07
Reviewed-on: https://gerrit.libreoffice.org/69927
Tested-by: Jenkins
Reviewed-by: 's avatarBartosz Kosiorek <gang65@poczta.onet.pl>
üst c1fc31b1
...@@ -45,10 +45,10 @@ namespace emfplushelper ...@@ -45,10 +45,10 @@ namespace emfplushelper
: type(0) : type(0)
, additionalFlags(0) , additionalFlags(0)
, wrapMode(0) , wrapMode(0)
, areaX(0.0) , firstPointX(0.0)
, areaY(0.0) , firstPointY(0.0)
, areaWidth(0.0) , secondPointX(0.0)
, areaHeight(0.0) , secondPointY(0.0)
, hasTransformation(false) , hasTransformation(false)
, blendPoints(0) , blendPoints(0)
, blendFactors(nullptr) , blendFactors(nullptr)
...@@ -110,8 +110,8 @@ namespace emfplushelper ...@@ -110,8 +110,8 @@ namespace emfplushelper
s.ReadUInt32(color); s.ReadUInt32(color);
solidColor = ::Color(0xff - (color >> 24), (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff); 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); SAL_INFO("drawinglayer", "EMF+\tcenter color: 0x" << std::hex << color << std::dec);
s.ReadFloat(areaX).ReadFloat(areaY); s.ReadFloat(firstPointX).ReadFloat(firstPointY);
SAL_INFO("drawinglayer", "EMF+\tcenter point: " << areaX << "," << areaY); SAL_INFO("drawinglayer", "EMF+\tcenter point: " << firstPointX << "," << firstPointY);
s.ReadInt32(surroundColorsNumber); s.ReadInt32(surroundColorsNumber);
SAL_INFO("drawinglayer", "EMF+\t number of surround colors: " << surroundColorsNumber); SAL_INFO("drawinglayer", "EMF+\t number of surround colors: " << surroundColorsNumber);
...@@ -153,8 +153,8 @@ namespace emfplushelper ...@@ -153,8 +153,8 @@ namespace emfplushelper
s.Seek(pos + pathLength); s.Seek(pos + pathLength);
const ::basegfx::B2DRectangle aBounds(::basegfx::utils::getRange(path->GetPolygon(rR, false))); const ::basegfx::B2DRectangle aBounds(::basegfx::utils::getRange(path->GetPolygon(rR, false)));
areaWidth = aBounds.getWidth(); secondPointX = aBounds.getWidth();
areaHeight = aBounds.getHeight(); secondPointY = aBounds.getHeight();
SAL_INFO("drawinglayer", "EMF+\t polygon bounding box: " << aBounds.getMinX() << "," << aBounds.getMinY() << " " << aBounds.getWidth() << "x" << aBounds.getHeight()); SAL_INFO("drawinglayer", "EMF+\t polygon bounding box: " << aBounds.getMinX() << "," << aBounds.getMinY() << " " << aBounds.getWidth() << "x" << aBounds.getHeight());
} }
else else
...@@ -170,8 +170,8 @@ namespace emfplushelper ...@@ -170,8 +170,8 @@ namespace emfplushelper
s.Seek(pos + 8 * boundaryPointCount); s.Seek(pos + 8 * boundaryPointCount);
const ::basegfx::B2DRectangle aBounds(::basegfx::utils::getRange(path->GetPolygon(rR, false))); const ::basegfx::B2DRectangle aBounds(::basegfx::utils::getRange(path->GetPolygon(rR, false)));
areaWidth = aBounds.getWidth(); secondPointX = aBounds.getWidth();
areaHeight = aBounds.getHeight(); secondPointY = aBounds.getHeight();
SAL_INFO("drawinglayer", "EMF+\t polygon bounding box: " << aBounds.getMinX() << "," << aBounds.getMinY() << " " << aBounds.getWidth() << "x" << 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 ...@@ -242,8 +242,8 @@ namespace emfplushelper
{ {
s.ReadUInt32(additionalFlags).ReadInt32(wrapMode); s.ReadUInt32(additionalFlags).ReadInt32(wrapMode);
SAL_INFO("drawinglayer", "EMF+\tlinear gradient, additional flags: 0x" << std::hex << additionalFlags << std::dec); SAL_INFO("drawinglayer", "EMF+\tlinear gradient, additional flags: 0x" << std::hex << additionalFlags << std::dec);
s.ReadFloat(areaX).ReadFloat(areaY).ReadFloat(areaWidth).ReadFloat(areaHeight); s.ReadFloat(firstPointX).ReadFloat(firstPointY).ReadFloat(secondPointX).ReadFloat(secondPointY);
SAL_INFO("drawinglayer", "EMF+\tarea: " << areaX << "," << areaY << " - " << areaWidth << "x" << areaHeight); SAL_INFO("drawinglayer", "EMF+\tFirst gradinet point: " << firstPointX << ":" << firstPointY << ", second gradient point " << secondPointX << ":" << secondPointY);
sal_uInt32 color; sal_uInt32 color;
s.ReadUInt32(color); s.ReadUInt32(color);
solidColor = ::Color(0xff - (color >> 24), (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff); solidColor = ::Color(0xff - (color >> 24), (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff);
......
...@@ -101,7 +101,7 @@ namespace emfplushelper ...@@ -101,7 +101,7 @@ namespace emfplushelper
/* linear gradient */ /* linear gradient */
sal_Int32 wrapMode; sal_Int32 wrapMode;
float areaX, areaY, areaWidth, areaHeight; float firstPointX, firstPointY, secondPointX, secondPointY;
::Color secondColor; // first color is stored in solidColor; ::Color secondColor; // first color is stored in solidColor;
basegfx::B2DHomMatrix brush_transformation; basegfx::B2DHomMatrix brush_transformation;
bool hasTransformation; bool hasTransformation;
......
...@@ -591,18 +591,18 @@ namespace emfplushelper ...@@ -591,18 +591,18 @@ namespace emfplushelper
::basegfx::B2DHomMatrix aTextureTransformation; ::basegfx::B2DHomMatrix aTextureTransformation;
if (brush->hasTransformation) { if (brush->hasTransformation) {
aTextureTransformation *= brush->brush_transformation; aTextureTransformation = brush->brush_transformation;
}
// adjust aTextureTransformation for our world space: // adjust aTextureTransformation for our world space:
// -> revert the mapping -> apply the transformation -> map back // -> revert the mapping -> apply the transformation -> map back
basegfx::B2DHomMatrix aInvertedMapTrasform(maMapTransform); basegfx::B2DHomMatrix aInvertedMapTrasform(maMapTransform);
aInvertedMapTrasform.invert(); aInvertedMapTrasform.invert();
aTextureTransformation = maMapTransform * aTextureTransformation * aInvertedMapTrasform; aTextureTransformation = maMapTransform * aTextureTransformation * aInvertedMapTrasform;
}
// select the stored colors // select the stored colors
basegfx::BColor aStartColor = brush->solidColor.getBColor(); const basegfx::BColor aStartColor = brush->solidColor.getBColor();
basegfx::BColor aEndColor = brush->secondColor.getBColor(); const basegfx::BColor aEndColor = brush->secondColor.getBColor();
drawinglayer::primitive2d::SvgGradientEntryVector aVector; drawinglayer::primitive2d::SvgGradientEntryVector aVector;
if (brush->blendPositions) if (brush->blendPositions)
...@@ -655,13 +655,13 @@ namespace emfplushelper ...@@ -655,13 +655,13 @@ namespace emfplushelper
{ {
if (brush->type == BrushTypeLinearGradient) if (brush->type == BrushTypeLinearGradient)
{ {
aVector.emplace_back(0.0, aStartColor, 1. ); aVector.emplace_back(0.0, aStartColor, (255 - brush->solidColor.GetTransparency()) / 255.0);
aVector.emplace_back(1.0, aEndColor, 1. ); aVector.emplace_back(1.0, aEndColor, (255 - brush->secondColor.GetTransparency()) / 255.0);
} }
else // again, here reverse else // again, here reverse
{ {
aVector.emplace_back(0.0, aEndColor, 1. ); aVector.emplace_back(0.0, aEndColor, (255 - brush->secondColor.GetTransparency()) / 255.0);
aVector.emplace_back(1.0, aStartColor, 1. ); aVector.emplace_back(1.0, aStartColor, (255 - brush->solidColor.GetTransparency()) / 255.0);
} }
} }
...@@ -675,9 +675,9 @@ namespace emfplushelper ...@@ -675,9 +675,9 @@ namespace emfplushelper
if (brush->type == BrushTypeLinearGradient) if (brush->type == BrushTypeLinearGradient)
{ {
basegfx::B2DPoint aStartPoint = Map(brush->areaX,brush->areaY); basegfx::B2DPoint aStartPoint = Map(brush->firstPointX, brush->firstPointY);
aStartPoint = aPolygonTransformation * aStartPoint; 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; aEndPoint = aPolygonTransformation * aEndPoint;
// create the same one used for SVG // create the same one used for SVG
...@@ -693,7 +693,7 @@ namespace emfplushelper ...@@ -693,7 +693,7 @@ namespace emfplushelper
} }
else // BrushTypePathGradient else // BrushTypePathGradient
{ {
basegfx::B2DPoint aCenterPoint = Map(brush->areaX,brush->areaY); basegfx::B2DPoint aCenterPoint = Map(brush->firstPointX, brush->firstPointY);
aCenterPoint = aPolygonTransformation * aCenterPoint; aCenterPoint = aPolygonTransformation * aCenterPoint;
// create the same one used for SVG // create the same one used for SVG
......
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