summaryrefslogtreecommitdiff
path: root/drawinglayer
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
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')
-rw-r--r--drawinglayer/inc/converters.hxx43
-rw-r--r--drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx5
-rw-r--r--drawinglayer/source/primitive2d/patternfillprimitive2d.cxx5
-rw-r--r--drawinglayer/source/primitive2d/polygonprimitive2d.cxx9
-rw-r--r--drawinglayer/source/texture/texture.cxx9
-rw-r--r--drawinglayer/source/tools/converters.cxx194
6 files changed, 153 insertions, 112 deletions
diff --git a/drawinglayer/inc/converters.hxx b/drawinglayer/inc/converters.hxx
new file mode 100644
index 000000000000..6f520509bb2f
--- /dev/null
+++ b/drawinglayer/inc/converters.hxx
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#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
+{
+
+ 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_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: */