diff options
author | Armin Le Grand <alg@apache.org> | 2012-10-02 08:23:25 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-06-11 10:32:54 +0100 |
commit | 385bb4547359027bca6d5158e00e541f094b277e (patch) | |
tree | a160b457cc7f649669e5eaddf9b8731ebe64e910 /drawinglayer/source/processor2d/vclhelpergradient.cxx | |
parent | 0de49e5d365a0ca3e667bcdd68630296b5e840d6 (diff) |
Resolves: #i120604# unified and secured gradient tooling for primitives
(cherry picked from commit 05785d283e718aab182a5ea848de72e4a4b2efe3)
Conflicts:
basegfx/inc/basegfx/tools/gradienttools.hxx
basegfx/source/tools/gradienttools.cxx
cppcanvas/source/mtfrenderer/implrenderer.cxx
drawinglayer/inc/drawinglayer/primitive2d/fillgradientprimitive2d.hxx
drawinglayer/inc/drawinglayer/texture/texture.hxx
drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx
drawinglayer/source/processor2d/vclhelpergradient.cxx
Change-Id: I21f94e7b4eede094171a83a009ae19213e77f22c
Unname unused argument to prevent warnings.
(cherry picked from commit f7d4af835cf308bc9ece6fd84cbd14ba5be0adcd)
Change-Id: I44381f1e417c39dfbd1d4051079bbd09f0c61848
Diffstat (limited to 'drawinglayer/source/processor2d/vclhelpergradient.cxx')
-rw-r--r-- | drawinglayer/source/processor2d/vclhelpergradient.cxx | 116 |
1 files changed, 48 insertions, 68 deletions
diff --git a/drawinglayer/source/processor2d/vclhelpergradient.cxx b/drawinglayer/source/processor2d/vclhelpergradient.cxx index 71c263d7ef5e..245e85084fcd 100644 --- a/drawinglayer/source/processor2d/vclhelpergradient.cxx +++ b/drawinglayer/source/processor2d/vclhelpergradient.cxx @@ -56,86 +56,78 @@ namespace drawinglayer void impDrawGradientToOutDevSimple( OutputDevice& rOutDev, const basegfx::B2DPolyPolygon& rTargetForm, - const ::std::vector< basegfx::B2DHomMatrix >& rMatrices, - const ::std::vector< basegfx::BColor >& rColors, + const std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries, + const basegfx::BColor& rOutmostColor, const basegfx::B2DPolygon& rUnitPolygon) { rOutDev.SetLineColor(); + rOutDev.SetFillColor(Color(rOutmostColor)); + rOutDev.DrawPolyPolygon(rTargetForm); + const sal_uInt32 nCount(rEntries.size()); - for(sal_uInt32 a(0L); a < rColors.size(); a++) + for(sal_uInt32 a(0); a < nCount; a++) { - // set correct color - const basegfx::BColor aFillColor(rColors[a]); - rOutDev.SetFillColor(Color(aFillColor)); + // create part polygon + basegfx::B2DPolygon aNewPoly(rUnitPolygon); - if(a) - { - if(a - 1L < static_cast< sal_uInt32 >(rMatrices.size())) - { - basegfx::B2DPolygon aNewPoly(rUnitPolygon); - aNewPoly.transform(rMatrices[a - 1L]); - rOutDev.DrawPolygon(aNewPoly); - } - } - else - { - rOutDev.DrawPolyPolygon(rTargetForm); - } + aNewPoly.transform(rEntries[a].maB2DHomMatrix); + + // create solid fill + rOutDev.SetFillColor(Color(rEntries[a].maBColor)); + rOutDev.DrawPolygon(aNewPoly); } } void impDrawGradientToOutDevComplex( OutputDevice& rOutDev, const basegfx::B2DPolyPolygon& rTargetForm, - const ::std::vector< basegfx::B2DHomMatrix >& rMatrices, - const ::std::vector< basegfx::BColor >& rColors, + const std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries, + const basegfx::BColor& rOutmostColor, const basegfx::B2DPolygon& rUnitPolygon) { PolyPolygon aVclTargetForm(rTargetForm); ::std::vector< Polygon > aVclPolygons; + const sal_uInt32 nCount(rEntries.size()); sal_uInt32 a; + // reserve when possible + aVclPolygons.reserve(nCount); + // remember and set to XOR rOutDev.SetLineColor(); rOutDev.Push(PUSH_RASTEROP); rOutDev.SetRasterOp(ROP_XOR); // draw gradient PolyPolygons - for(a = 0L; a < rMatrices.size(); a++) + for(a = 0; a < nCount; a++) { // create polygon and remember basegfx::B2DPolygon aNewPoly(rUnitPolygon); - aNewPoly.transform(rMatrices[a]); + aNewPoly.transform(rEntries[a].maB2DHomMatrix); aVclPolygons.push_back(Polygon(aNewPoly)); - // set correct color - if(rColors.size() > a) - { - const basegfx::BColor aFillColor(rColors[a]); - rOutDev.SetFillColor(Color(aFillColor)); - } - // create vcl PolyPolygon and draw it if(a) { - PolyPolygon aVclPolyPoly(aVclPolygons[a - 1L]); + rOutDev.SetFillColor(Color(rEntries[a - 1].maBColor)); + PolyPolygon aVclPolyPoly(aVclPolygons[a - 1]); aVclPolyPoly.Insert(aVclPolygons[a]); rOutDev.DrawPolyPolygon(aVclPolyPoly); } else { + rOutDev.SetFillColor(Color(rOutmostColor)); PolyPolygon aVclPolyPoly(aVclTargetForm); - aVclPolyPoly.Insert(aVclPolygons[0L]); + aVclPolyPoly.Insert(aVclPolygons[0]); rOutDev.DrawPolyPolygon(aVclPolyPoly); } } // draw last poly in last color - if(!rColors.empty()) + if(nCount) { - const basegfx::BColor aFillColor(rColors[rColors.size() - 1L]); - rOutDev.SetFillColor(Color(aFillColor)); - rOutDev.DrawPolygon(aVclPolygons[aVclPolygons.size() - 1L]); + rOutDev.SetFillColor(Color(rEntries[nCount - 1].maBColor)); + rOutDev.DrawPolygon(aVclPolygons[aVclPolygons.size() - 1]); } // draw object form in black and go back to XOR @@ -145,36 +137,30 @@ namespace drawinglayer rOutDev.SetRasterOp(ROP_XOR); // draw gradient PolyPolygons again - for(a = 0L; a < rMatrices.size(); a++) + for(a = 0; a < nCount; a++) { - // set correct color - if(rColors.size() > a) - { - const basegfx::BColor aFillColor(rColors[a]); - rOutDev.SetFillColor(Color(aFillColor)); - } - // create vcl PolyPolygon and draw it if(a) { - PolyPolygon aVclPolyPoly(aVclPolygons[a - 1L]); + rOutDev.SetFillColor(Color(rEntries[a - 1].maBColor)); + PolyPolygon aVclPolyPoly(aVclPolygons[a - 1]); aVclPolyPoly.Insert(aVclPolygons[a]); rOutDev.DrawPolyPolygon(aVclPolyPoly); } else { + rOutDev.SetFillColor(Color(rOutmostColor)); PolyPolygon aVclPolyPoly(aVclTargetForm); - aVclPolyPoly.Insert(aVclPolygons[0L]); + aVclPolyPoly.Insert(aVclPolygons[0]); rOutDev.DrawPolyPolygon(aVclPolyPoly); } } // draw last poly in last color - if(!rColors.empty()) + if(nCount) { - const basegfx::BColor aFillColor(rColors[rColors.size() - 1L]); - rOutDev.SetFillColor(Color(aFillColor)); - rOutDev.DrawPolygon(aVclPolygons[aVclPolygons.size() - 1L]); + rOutDev.SetFillColor(Color(rEntries[nCount - 1].maBColor)); + rOutDev.DrawPolygon(aVclPolygons[aVclPolygons.size() - 1]); } // reset drawmode @@ -195,8 +181,8 @@ namespace drawinglayer double fBorder, double fAngle, double fOffsetX, double fOffsetY, bool bSimple) { const basegfx::B2DRange aOutlineRange(basegfx::tools::getRange(rTargetForm)); - ::std::vector< basegfx::B2DHomMatrix > aMatrices; - ::std::vector< basegfx::BColor > aColors; + std::vector< drawinglayer::texture::B2DHomMatrixAndBColor > aEntries; + basegfx::BColor aOutmostColor; basegfx::B2DPolygon aUnitPolygon; // make sure steps is not too high/low @@ -208,63 +194,57 @@ namespace drawinglayer case attribute::GRADIENTSTYLE_LINEAR: { texture::GeoTexSvxGradientLinear aGradient(aOutlineRange, rStart, rEnd, nSteps, fBorder, fAngle); - aGradient.appendTransformations(aMatrices); - aGradient.appendColors(aColors); - aUnitPolygon = basegfx::tools::createUnitPolygon(); + aGradient.appendTransformationsAndColors(aEntries, aOutmostColor); + aUnitPolygon = basegfx::tools::createPolygonFromRect(basegfx::B2DRange(-1, -1, 1, 1)); break; } case attribute::GRADIENTSTYLE_AXIAL: { texture::GeoTexSvxGradientAxial aGradient(aOutlineRange, rStart, rEnd, nSteps, fBorder, fAngle); - aGradient.appendTransformations(aMatrices); - aGradient.appendColors(aColors); + aGradient.appendTransformationsAndColors(aEntries, aOutmostColor); aUnitPolygon = basegfx::tools::createPolygonFromRect(basegfx::B2DRange(-1, -1, 1, 1)); break; } case attribute::GRADIENTSTYLE_RADIAL: { texture::GeoTexSvxGradientRadial aGradient(aOutlineRange, rStart, rEnd, nSteps, fBorder, fOffsetX, fOffsetY); - aGradient.appendTransformations(aMatrices); - aGradient.appendColors(aColors); + aGradient.appendTransformationsAndColors(aEntries, aOutmostColor); aUnitPolygon = basegfx::tools::createPolygonFromCircle(basegfx::B2DPoint(0,0), 1); break; } case attribute::GRADIENTSTYLE_ELLIPTICAL: { texture::GeoTexSvxGradientElliptical aGradient(aOutlineRange, rStart, rEnd, nSteps, fBorder, fOffsetX, fOffsetX, fAngle); - aGradient.appendTransformations(aMatrices); - aGradient.appendColors(aColors); + aGradient.appendTransformationsAndColors(aEntries, aOutmostColor); aUnitPolygon = basegfx::tools::createPolygonFromCircle(basegfx::B2DPoint(0,0), 1); break; } case attribute::GRADIENTSTYLE_SQUARE: { texture::GeoTexSvxGradientSquare aGradient(aOutlineRange, rStart, rEnd, nSteps, fBorder, fOffsetX, fOffsetX, fAngle); - aGradient.appendTransformations(aMatrices); - aGradient.appendColors(aColors); + aGradient.appendTransformationsAndColors(aEntries, aOutmostColor); aUnitPolygon = basegfx::tools::createPolygonFromRect(basegfx::B2DRange(-1, -1, 1, 1)); break; } case attribute::GRADIENTSTYLE_RECT: { texture::GeoTexSvxGradientRect aGradient(aOutlineRange, rStart, rEnd, nSteps, fBorder, fOffsetX, fOffsetX, fAngle); - aGradient.appendTransformations(aMatrices); - aGradient.appendColors(aColors); + aGradient.appendTransformationsAndColors(aEntries, aOutmostColor); aUnitPolygon = basegfx::tools::createPolygonFromRect(basegfx::B2DRange(-1, -1, 1, 1)); break; } } // paint them with mask using the XOR method - if(!aMatrices.empty()) + if(aEntries.size()) { if(bSimple) { - impDrawGradientToOutDevSimple(rOutDev, rTargetForm, aMatrices, aColors, aUnitPolygon); + impDrawGradientToOutDevSimple(rOutDev, rTargetForm, aEntries, aOutmostColor, aUnitPolygon); } else { - impDrawGradientToOutDevComplex(rOutDev, rTargetForm, aMatrices, aColors, aUnitPolygon); + impDrawGradientToOutDevComplex(rOutDev, rTargetForm, aEntries, aOutmostColor, aUnitPolygon); } } } |