Kaydet (Commit) fcb00ac8 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

support opacity for widget definition draw SVGs

This opacity influences the whole shape (stroke and fill).

Change-Id: I82e10e07dbf2f321805b55a5f4831a513e52dab8
Reviewed-on: https://gerrit.libreoffice.org/70292
Tested-by: Jenkins
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 48429e07
...@@ -62,6 +62,7 @@ public: ...@@ -62,6 +62,7 @@ public:
double mnRy; double mnRy;
double mnStrokeWidth; double mnStrokeWidth;
double mnOpacity;
std::shared_ptr<basegfx::BColor> mpFillColor; std::shared_ptr<basegfx::BColor> mpFillColor;
std::shared_ptr<basegfx::BColor> mpStrokeColor; std::shared_ptr<basegfx::BColor> mpStrokeColor;
...@@ -71,6 +72,7 @@ public: ...@@ -71,6 +72,7 @@ public:
, mnRx(1.0) , mnRx(1.0)
, mnRy(1.0) , mnRy(1.0)
, mnStrokeWidth(1.0) , mnStrokeWidth(1.0)
, mnOpacity(1.0)
{ {
} }
}; };
...@@ -81,6 +83,7 @@ public: ...@@ -81,6 +83,7 @@ public:
basegfx::B2DPolyPolygon maPolyPolygon; basegfx::B2DPolyPolygon maPolyPolygon;
double mnStrokeWidth; double mnStrokeWidth;
double mnOpacity;
std::shared_ptr<basegfx::BColor> mpFillColor; std::shared_ptr<basegfx::BColor> mpFillColor;
std::shared_ptr<basegfx::BColor> mpStrokeColor; std::shared_ptr<basegfx::BColor> mpStrokeColor;
...@@ -88,6 +91,7 @@ public: ...@@ -88,6 +91,7 @@ public:
: DrawBase(DrawCommandType::Path) : DrawBase(DrawCommandType::Path)
, maPolyPolygon(rPolyPolygon) , maPolyPolygon(rPolyPolygon)
, mnStrokeWidth(1.0) , mnStrokeWidth(1.0)
, mnOpacity(1.0)
{ {
} }
}; };
......
...@@ -74,7 +74,7 @@ uno::Reference<io::XInputStream> TestParsing::parseSvg(const OUString& aSource) ...@@ -74,7 +74,7 @@ uno::Reference<io::XInputStream> TestParsing::parseSvg(const OUString& aSource)
void TestParsing::testSimpleRectangle() void TestParsing::testSimpleRectangle()
{ {
OUString aSvgFile = "/svgio/qa/cppunit/data/Rect.svg"; OUString aSvgFile = "/svgio/qa/cppunit/data/VisiotorTest-Rect.svg";
OUString aUrl = m_directories.getURLFromSrc(aSvgFile); OUString aUrl = m_directories.getURLFromSrc(aSvgFile);
OUString aPath = m_directories.getPathFromSrc(aSvgFile); OUString aPath = m_directories.getPathFromSrc(aSvgFile);
...@@ -102,6 +102,7 @@ void TestParsing::testSimpleRectangle() ...@@ -102,6 +102,7 @@ void TestParsing::testSimpleRectangle()
CPPUNIT_ASSERT_EQUAL(sal_Int32(0xff0000), sal_Int32(Color(*pDrawRect->mpStrokeColor))); CPPUNIT_ASSERT_EQUAL(sal_Int32(0xff0000), sal_Int32(Color(*pDrawRect->mpStrokeColor)));
CPPUNIT_ASSERT(bool(pDrawRect->mpFillColor)); CPPUNIT_ASSERT(bool(pDrawRect->mpFillColor));
CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00cc00), sal_Int32(Color(*pDrawRect->mpFillColor))); CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00cc00), sal_Int32(Color(*pDrawRect->mpFillColor)));
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.1, pDrawRect->mnOpacity, 1E-12);
} }
void TestParsing::testPath() void TestParsing::testPath()
...@@ -133,6 +134,7 @@ void TestParsing::testPath() ...@@ -133,6 +134,7 @@ void TestParsing::testPath()
CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), sal_Int32(Color(*pDrawPath->mpStrokeColor))); CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), sal_Int32(Color(*pDrawPath->mpStrokeColor)));
CPPUNIT_ASSERT(bool(pDrawPath->mpFillColor)); CPPUNIT_ASSERT(bool(pDrawPath->mpFillColor));
CPPUNIT_ASSERT_EQUAL(sal_Int32(0x007aff), sal_Int32(Color(*pDrawPath->mpFillColor))); CPPUNIT_ASSERT_EQUAL(sal_Int32(0x007aff), sal_Int32(Color(*pDrawPath->mpFillColor)));
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.1, pDrawPath->mnOpacity, 1E-12);
} }
CPPUNIT_TEST_SUITE_REGISTRATION(TestParsing); CPPUNIT_TEST_SUITE_REGISTRATION(TestParsing);
......
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
...@@ -74,6 +74,8 @@ void SvgDrawVisitor::visit(svgio::svgreader::SvgNode const& rNode) ...@@ -74,6 +74,8 @@ void SvgDrawVisitor::visit(svgio::svgreader::SvgNode const& rNode)
pRectangle->mnStrokeWidth pRectangle->mnStrokeWidth
= rRectNode.getSvgStyleAttributes()->getStrokeWidth().getNumber(); = rRectNode.getSvgStyleAttributes()->getStrokeWidth().getNumber();
pRectangle->mnOpacity = rRectNode.getSvgStyleAttributes()->getOpacity().getNumber();
const basegfx::BColor* pFillColor = rRectNode.getSvgStyleAttributes()->getFill(); const basegfx::BColor* pFillColor = rRectNode.getSvgStyleAttributes()->getFill();
if (pFillColor) if (pFillColor)
pRectangle->mpFillColor = std::make_shared<basegfx::BColor>(*pFillColor); pRectangle->mpFillColor = std::make_shared<basegfx::BColor>(*pFillColor);
...@@ -97,6 +99,8 @@ void SvgDrawVisitor::visit(svgio::svgreader::SvgNode const& rNode) ...@@ -97,6 +99,8 @@ void SvgDrawVisitor::visit(svgio::svgreader::SvgNode const& rNode)
pDrawPath->mnStrokeWidth pDrawPath->mnStrokeWidth
= rPathNode.getSvgStyleAttributes()->getStrokeWidth().getNumber(); = rPathNode.getSvgStyleAttributes()->getStrokeWidth().getNumber();
pDrawPath->mnOpacity = rPathNode.getSvgStyleAttributes()->getOpacity().getNumber();
const basegfx::BColor* pFillColor = rPathNode.getSvgStyleAttributes()->getFill(); const basegfx::BColor* pFillColor = rPathNode.getSvgStyleAttributes()->getFill();
if (pFillColor) if (pFillColor)
pDrawPath->mpFillColor = std::make_shared<basegfx::BColor>(*pFillColor); pDrawPath->mpFillColor = std::make_shared<basegfx::BColor>(*pFillColor);
......
...@@ -186,14 +186,15 @@ void drawFromDrawCommands(gfx::DrawRoot const& rDrawRoot, SalGraphics& rGraphics ...@@ -186,14 +186,15 @@ void drawFromDrawCommands(gfx::DrawRoot const& rDrawRoot, SalGraphics& rGraphics
rGraphics.SetLineColor(); rGraphics.SetLineColor();
rGraphics.SetFillColor(Color(*rRectangle.mpFillColor)); rGraphics.SetFillColor(Color(*rRectangle.mpFillColor));
rGraphics.DrawPolyPolygon(basegfx::B2DHomMatrix(), rGraphics.DrawPolyPolygon(basegfx::B2DHomMatrix(),
basegfx::B2DPolyPolygon(aB2DPolygon), 0.0f, nullptr); basegfx::B2DPolyPolygon(aB2DPolygon),
1.0 - rRectangle.mnOpacity, nullptr);
} }
if (rRectangle.mpStrokeColor) if (rRectangle.mpStrokeColor)
{ {
rGraphics.SetLineColor(Color(*rRectangle.mpStrokeColor)); rGraphics.SetLineColor(Color(*rRectangle.mpStrokeColor));
rGraphics.SetFillColor(); rGraphics.SetFillColor();
rGraphics.DrawPolyLine( rGraphics.DrawPolyLine(
basegfx::B2DHomMatrix(), aB2DPolygon, 0.0f, basegfx::B2DHomMatrix(), aB2DPolygon, 1.0 - rRectangle.mnOpacity,
basegfx::B2DVector(rRectangle.mnStrokeWidth, rRectangle.mnStrokeWidth), basegfx::B2DVector(rRectangle.mnStrokeWidth, rRectangle.mnStrokeWidth),
basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false, basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false,
nullptr); nullptr);
...@@ -230,7 +231,8 @@ void drawFromDrawCommands(gfx::DrawRoot const& rDrawRoot, SalGraphics& rGraphics ...@@ -230,7 +231,8 @@ void drawFromDrawCommands(gfx::DrawRoot const& rDrawRoot, SalGraphics& rGraphics
{ {
rGraphics.SetLineColor(); rGraphics.SetLineColor();
rGraphics.SetFillColor(Color(*rPath.mpFillColor)); rGraphics.SetFillColor(Color(*rPath.mpFillColor));
rGraphics.DrawPolyPolygon(basegfx::B2DHomMatrix(), aPolyPolygon, 0.0f, nullptr); rGraphics.DrawPolyPolygon(basegfx::B2DHomMatrix(), aPolyPolygon,
1.0 - rPath.mnOpacity, nullptr);
} }
if (rPath.mpStrokeColor) if (rPath.mpStrokeColor)
{ {
...@@ -239,7 +241,7 @@ void drawFromDrawCommands(gfx::DrawRoot const& rDrawRoot, SalGraphics& rGraphics ...@@ -239,7 +241,7 @@ void drawFromDrawCommands(gfx::DrawRoot const& rDrawRoot, SalGraphics& rGraphics
for (auto const& rPolygon : aPolyPolygon) for (auto const& rPolygon : aPolyPolygon)
{ {
rGraphics.DrawPolyLine( rGraphics.DrawPolyLine(
basegfx::B2DHomMatrix(), rPolygon, 0.0f, basegfx::B2DHomMatrix(), rPolygon, 1.0 - rPath.mnOpacity,
basegfx::B2DVector(rPath.mnStrokeWidth, rPath.mnStrokeWidth), basegfx::B2DVector(rPath.mnStrokeWidth, rPath.mnStrokeWidth),
basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false, basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false,
nullptr); nullptr);
......
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