diff options
-rw-r--r-- | drawinglayer/inc/converters.hxx (renamed from include/drawinglayer/tools/converters.hxx) | 30 | ||||
-rw-r--r-- | drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx | 5 | ||||
-rw-r--r-- | drawinglayer/source/primitive2d/patternfillprimitive2d.cxx | 5 | ||||
-rw-r--r-- | drawinglayer/source/primitive2d/polygonprimitive2d.cxx | 9 | ||||
-rw-r--r-- | drawinglayer/source/texture/texture.cxx | 9 | ||||
-rw-r--r-- | drawinglayer/source/tools/converters.cxx | 194 |
6 files changed, 123 insertions, 129 deletions
diff --git a/include/drawinglayer/tools/converters.hxx b/drawinglayer/inc/converters.hxx index c5f6bcd38c49..6f520509bb2f 100644 --- a/include/drawinglayer/tools/converters.hxx +++ b/drawinglayer/inc/converters.hxx @@ -17,31 +17,27 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_DRAWINGLAYER_TOOLS_CONVERTERS_HXX -#define INCLUDED_DRAWINGLAYER_TOOLS_CONVERTERS_HXX +#ifndef INCLUDED_DRAWINGLAYER_INC_CONVERTERS_HXX +#define INCLUDED_DRAWINGLAYER_INC_CONVERTERS_HXX #include <drawinglayer/drawinglayerdllapi.h> #include <vcl/bitmapex.hxx> #include <drawinglayer/primitive2d/baseprimitive2d.hxx> - namespace drawinglayer { - namespace tools - { - BitmapEx DRAWINGLAYER_DLLPUBLIC convertToBitmapEx( - const drawinglayer::primitive2d::Primitive2DContainer& rSeq, - const geometry::ViewInformation2D& rViewInformation2D, - sal_uInt32 nDiscreteWidth, - sal_uInt32 nDiscreteHeight, - sal_uInt32 nMaxQuadratPixels); - - double DRAWINGLAYER_DLLPUBLIC getRandomColorRange(); - - } // end of namespace tools -} // end of namespace drawinglayer + BitmapEx convertToBitmapEx( + const drawinglayer::primitive2d::Primitive2DContainer& rSeq, + const geometry::ViewInformation2D& rViewInformation2D, + sal_uInt32 nDiscreteWidth, + sal_uInt32 nDiscreteHeight, + sal_uInt32 nMaxQuadratPixels); + + double getRandomColorRange(); + +} // end of namespace drawinglayer -#endif // INCLUDED_DRAWINGLAYER_TOOLS_CONVERTERS_HXX +#endif // INCLUDED_DRAWINGLAYER_INC_CONVERTERS_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx b/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx index 8a515b117e4d..02dd689b7048 100644 --- a/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx +++ b/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx @@ -31,12 +31,13 @@ #include <drawinglayer/geometry/viewinformation2d.hxx> #include <basegfx/numeric/ftools.hxx> #include <vcl/bitmapex.hxx> -#include <drawinglayer/tools/converters.hxx> #include <vcl/canvastools.hxx> #include <com/sun/star/geometry/RealRectangle2D.hpp> #include <basegfx/matrix/b2dhommatrixtools.hxx> #include <drawinglayer/primitive2d/transformprimitive2d.hxx> +#include "converters.hxx" + #include <xprimitive2drenderer.hxx> using namespace ::com::sun::star; @@ -160,7 +161,7 @@ namespace drawinglayer const primitive2d::Primitive2DContainer xEmbedSeq { xEmbedRef }; BitmapEx aBitmapEx( - tools::convertToBitmapEx( + convertToBitmapEx( xEmbedSeq, aViewInformation2D, nDiscreteWidth, diff --git a/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx b/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx index 6d6ef225d022..ed26d32470b9 100644 --- a/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx @@ -26,9 +26,10 @@ #include <basegfx/matrix/b2dhommatrixtools.hxx> #include <drawinglayer/texture/texture.hxx> #include <drawinglayer/primitive2d/maskprimitive2d.hxx> -#include <drawinglayer/tools/converters.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> +#include "converters.hxx" + using namespace com::sun::star; #define MAXIMUM_SQUARE_LENGTH (186.0) @@ -109,7 +110,7 @@ namespace drawinglayer const primitive2d::Primitive2DContainer xEmbedSeq { xEmbedRef }; const BitmapEx aBitmapEx( - tools::convertToBitmapEx( + convertToBitmapEx( xEmbedSeq, aViewInformation2D, mnDiscreteWidth, diff --git a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx index 2f6deba32bfe..0511d3602fd4 100644 --- a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx @@ -206,12 +206,9 @@ namespace drawinglayer namespace drawinglayer { - namespace tools + double getRandomColorRange() { - double getRandomColorRange() - { - return comphelper::rng::uniform_real_distribution(0.0, nextafter(1.0, DBL_MAX)); - } + return comphelper::rng::uniform_real_distribution(0.0, nextafter(1.0, DBL_MAX)); } namespace primitive2d @@ -270,7 +267,7 @@ namespace drawinglayer const basegfx::B2DPolyPolygon aNewPolyPolygon(aAreaPolyPolygon.getB2DPolygon(b)); static bool bTestByUsingRandomColor(false); const basegfx::BColor aColor(bTestByUsingRandomColor - ? basegfx::BColor(tools::getRandomColorRange(), tools::getRandomColorRange(), tools::getRandomColorRange()) + ? basegfx::BColor(getRandomColorRange(), getRandomColorRange(), getRandomColorRange()) : getLineAttribute().getColor()); rContainer.push_back(new PolyPolygonColorPrimitive2D(aNewPolyPolygon, aColor)); } diff --git a/drawinglayer/source/texture/texture.cxx b/drawinglayer/source/texture/texture.cxx index d5bcfd8553e9..3ec49e8440a5 100644 --- a/drawinglayer/source/texture/texture.cxx +++ b/drawinglayer/source/texture/texture.cxx @@ -18,11 +18,12 @@ */ #include <drawinglayer/texture/texture.hxx> -#include <drawinglayer/tools/converters.hxx> #include <basegfx/numeric/ftools.hxx> #include <basegfx/tools/gradienttools.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx> +#include "converters.hxx" + namespace drawinglayer { namespace texture @@ -44,9 +45,9 @@ namespace drawinglayer void GeoTexSvx::modifyBColor(const basegfx::B2DPoint& /*rUV*/, basegfx::BColor& rBColor, double& /*rfOpacity*/) const { // base implementation creates random color (for testing only, may also be pure virtual) - rBColor.setRed(tools::getRandomColorRange()); - rBColor.setGreen(tools::getRandomColorRange()); - rBColor.setBlue(tools::getRandomColorRange()); + rBColor.setRed(getRandomColorRange()); + rBColor.setGreen(getRandomColorRange()); + rBColor.setBlue(getRandomColorRange()); } void GeoTexSvx::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const diff --git a/drawinglayer/source/tools/converters.cxx b/drawinglayer/source/tools/converters.cxx index 5ca6377bec34..0f9e0cec26c0 100644 --- a/drawinglayer/source/tools/converters.cxx +++ b/drawinglayer/source/tools/converters.cxx @@ -17,7 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <drawinglayer/tools/converters.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx> @@ -25,134 +24,133 @@ #include <drawinglayer/processor2d/processor2dtools.hxx> #include <vcl/virdev.hxx> +#include "converters.hxx" + #ifdef DBG_UTIL #include <tools/stream.hxx> #include <vcl/pngwrite.hxx> #endif - namespace drawinglayer { - namespace tools + + BitmapEx convertToBitmapEx( + const drawinglayer::primitive2d::Primitive2DContainer& rSeq, + const geometry::ViewInformation2D& rViewInformation2D, + sal_uInt32 nDiscreteWidth, + sal_uInt32 nDiscreteHeight, + sal_uInt32 nMaxQuadratPixels) { - BitmapEx convertToBitmapEx( - const drawinglayer::primitive2d::Primitive2DContainer& rSeq, - const geometry::ViewInformation2D& rViewInformation2D, - sal_uInt32 nDiscreteWidth, - sal_uInt32 nDiscreteHeight, - sal_uInt32 nMaxQuadratPixels) - { - BitmapEx aRetval; + BitmapEx aRetval; #ifdef DBG_UTIL - static bool bDoSaveForVisualControl(false); + static bool bDoSaveForVisualControl(false); #endif - if(!rSeq.empty() && nDiscreteWidth && nDiscreteHeight) - { - // get destination size in pixels - const MapMode aMapModePixel(MapUnit::MapPixel); - const sal_uInt32 nViewVisibleArea(nDiscreteWidth * nDiscreteHeight); - drawinglayer::primitive2d::Primitive2DContainer aSequence(rSeq); + if(!rSeq.empty() && nDiscreteWidth && nDiscreteHeight) + { + // get destination size in pixels + const MapMode aMapModePixel(MapUnit::MapPixel); + const sal_uInt32 nViewVisibleArea(nDiscreteWidth * nDiscreteHeight); + drawinglayer::primitive2d::Primitive2DContainer aSequence(rSeq); - if(nViewVisibleArea > nMaxQuadratPixels) - { - // reduce render size - double fReduceFactor = sqrt((double)nMaxQuadratPixels / (double)nViewVisibleArea); - nDiscreteWidth = basegfx::fround((double)nDiscreteWidth * fReduceFactor); - nDiscreteHeight = basegfx::fround((double)nDiscreteHeight * fReduceFactor); + if(nViewVisibleArea > nMaxQuadratPixels) + { + // reduce render size + double fReduceFactor = sqrt((double)nMaxQuadratPixels / (double)nViewVisibleArea); + nDiscreteWidth = basegfx::fround((double)nDiscreteWidth * fReduceFactor); + nDiscreteHeight = basegfx::fround((double)nDiscreteHeight * fReduceFactor); - const drawinglayer::primitive2d::Primitive2DReference aEmbed( - new drawinglayer::primitive2d::TransformPrimitive2D( - basegfx::tools::createScaleB2DHomMatrix(fReduceFactor, fReduceFactor), - rSeq)); + const drawinglayer::primitive2d::Primitive2DReference aEmbed( + new drawinglayer::primitive2d::TransformPrimitive2D( + basegfx::tools::createScaleB2DHomMatrix(fReduceFactor, fReduceFactor), + rSeq)); - aSequence = drawinglayer::primitive2d::Primitive2DContainer { aEmbed }; - } + aSequence = drawinglayer::primitive2d::Primitive2DContainer { aEmbed }; + } - const Point aEmptyPoint; - const Size aSizePixel(nDiscreteWidth, nDiscreteHeight); - ScopedVclPtrInstance< VirtualDevice > pContent; + const Point aEmptyPoint; + const Size aSizePixel(nDiscreteWidth, nDiscreteHeight); + ScopedVclPtrInstance< VirtualDevice > pContent; - // prepare vdev - pContent->SetOutputSizePixel(aSizePixel, false); - pContent->SetMapMode(aMapModePixel); + // prepare vdev + pContent->SetOutputSizePixel(aSizePixel, false); + pContent->SetMapMode(aMapModePixel); - // set to all white - pContent->SetBackground(Wallpaper(Color(COL_WHITE))); - pContent->Erase(); + // set to all white + pContent->SetBackground(Wallpaper(Color(COL_WHITE))); + pContent->Erase(); - // create pixel processor, also already takes care of AAing and - // checking the getOptionsDrawinglayer().IsAntiAliasing() switch. If - // not wanted, change after this call as needed - processor2d::BaseProcessor2D* pContentProcessor = processor2d::createPixelProcessor2DFromOutputDevice( - *pContent.get(), - rViewInformation2D); + // create pixel processor, also already takes care of AAing and + // checking the getOptionsDrawinglayer().IsAntiAliasing() switch. If + // not wanted, change after this call as needed + processor2d::BaseProcessor2D* pContentProcessor = processor2d::createPixelProcessor2DFromOutputDevice( + *pContent.get(), + rViewInformation2D); - if(pContentProcessor) - { - // render content - pContentProcessor->process(aSequence); + if(pContentProcessor) + { + // render content + pContentProcessor->process(aSequence); - // get content - pContent->EnableMapMode(false); - const Bitmap aContent(pContent->GetBitmap(aEmptyPoint, aSizePixel)); + // get content + pContent->EnableMapMode(false); + const Bitmap aContent(pContent->GetBitmap(aEmptyPoint, aSizePixel)); #ifdef DBG_UTIL - if(bDoSaveForVisualControl) - { - SvFileStream aNew("c:\\test_content.png", StreamMode::WRITE|StreamMode::TRUNC); - vcl::PNGWriter aPNGWriter(aContent); - aPNGWriter.Write(aNew); - } + if(bDoSaveForVisualControl) + { + SvFileStream aNew("c:\\test_content.png", StreamMode::WRITE|StreamMode::TRUNC); + vcl::PNGWriter aPNGWriter(aContent); + aPNGWriter.Write(aNew); + } #endif - // prepare for mask creation - pContent->SetMapMode(aMapModePixel); - - // set alpha to all white (fully transparent) - pContent->Erase(); - - // embed primitives to paint them black - const primitive2d::Primitive2DReference xRef( - new primitive2d::ModifiedColorPrimitive2D( - aSequence, - basegfx::BColorModifierSharedPtr( - new basegfx::BColorModifier_replace( - basegfx::BColor(0.0, 0.0, 0.0))))); - const primitive2d::Primitive2DContainer xSeq { xRef }; - - // render - pContentProcessor->process(xSeq); - delete pContentProcessor; - - // get alpha channel from vdev - pContent->EnableMapMode(false); - const Bitmap aAlpha(pContent->GetBitmap(aEmptyPoint, aSizePixel)); + // prepare for mask creation + pContent->SetMapMode(aMapModePixel); + + // set alpha to all white (fully transparent) + pContent->Erase(); + + // embed primitives to paint them black + const primitive2d::Primitive2DReference xRef( + new primitive2d::ModifiedColorPrimitive2D( + aSequence, + basegfx::BColorModifierSharedPtr( + new basegfx::BColorModifier_replace( + basegfx::BColor(0.0, 0.0, 0.0))))); + const primitive2d::Primitive2DContainer xSeq { xRef }; + + // render + pContentProcessor->process(xSeq); + delete pContentProcessor; + + // get alpha channel from vdev + pContent->EnableMapMode(false); + const Bitmap aAlpha(pContent->GetBitmap(aEmptyPoint, aSizePixel)); #ifdef DBG_UTIL - if(bDoSaveForVisualControl) - { - SvFileStream aNew("c:\\test_alpha.png", StreamMode::WRITE|StreamMode::TRUNC); - vcl::PNGWriter aPNGWriter(aAlpha); - aPNGWriter.Write(aNew); - } + if(bDoSaveForVisualControl) + { + SvFileStream aNew("c:\\test_alpha.png", StreamMode::WRITE|StreamMode::TRUNC); + vcl::PNGWriter aPNGWriter(aAlpha); + aPNGWriter.Write(aNew); + } #endif - // create BitmapEx result - aRetval = BitmapEx(aContent, AlphaMask(aAlpha)); + // create BitmapEx result + aRetval = BitmapEx(aContent, AlphaMask(aAlpha)); #ifdef DBG_UTIL - if(bDoSaveForVisualControl) - { - SvFileStream aNew("c:\\test_combined.png", StreamMode::WRITE|StreamMode::TRUNC); - vcl::PNGWriter aPNGWriter(aRetval); - aPNGWriter.Write(aNew); - } -#endif + if(bDoSaveForVisualControl) + { + SvFileStream aNew("c:\\test_combined.png", StreamMode::WRITE|StreamMode::TRUNC); + vcl::PNGWriter aPNGWriter(aRetval); + aPNGWriter.Write(aNew); } +#endif } - - return aRetval; } - } // end of namespace tools + return aRetval; + } + } // end of namespace drawinglayer /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |