summaryrefslogtreecommitdiff
path: root/drawinglayer/source/tools/converters.cxx
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2017-09-22 10:21:50 +0300
committerTor Lillqvist <tml@collabora.com>2017-09-22 11:04:46 +0200
commit632edfabe8065cd59a237d975ee03468ce4d868b (patch)
tree3d82710b94c062c8f60e7f87364d792edad27a99 /drawinglayer/source/tools/converters.cxx
parent442df6cf8345f8029d5a3b470bc4981a5aa2bf20 (diff)
<drawinglayer/tools/converters.hxx> can be internal to drawinglayer
And while moving it, get rid of the 'drawinglyer::tools' subnamespace. Less potential confusion with the global 'tools' namespace. Change-Id: Iab3c25be0cec7f3d182228d122837e9f2ac9a529 Reviewed-on: https://gerrit.libreoffice.org/42619 Reviewed-by: Tor Lillqvist <tml@collabora.com> Tested-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'drawinglayer/source/tools/converters.cxx')
-rw-r--r--drawinglayer/source/tools/converters.cxx194
1 files changed, 96 insertions, 98 deletions
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: */