summaryrefslogtreecommitdiff
path: root/drawinglayer
diff options
context:
space:
mode:
authorArmin Le Grand <armin.le.grand@me.com>2020-04-10 18:07:41 +0200
committerArmin Le Grand <Armin.Le.Grand@me.com>2020-04-10 20:37:52 +0200
commitae743c6fae4543282f8930dc78175cc510fabbb3 (patch)
treeeb44065aece45c9fd86b50df495c3746192fb0be /drawinglayer
parent25468bba15a149edc1e53a7518070c64d4c967e9 (diff)
Make BitmapPrimitive2D vcl-independent
as preparation to have drawinglayer module independent from vcl in the future Change-Id: Iaa01370f27b51cba5114a54f37d1ec73d0719918 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92048 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/source/primitive2d/bitmapprimitive2d.cxx25
-rw-r--r--drawinglayer/source/primitive2d/controlprimitive2d.cxx5
-rw-r--r--drawinglayer/source/primitive2d/discretebitmapprimitive2d.cxx6
-rw-r--r--drawinglayer/source/primitive2d/discreteshadowprimitive2d.cxx17
-rw-r--r--drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx5
-rw-r--r--drawinglayer/source/primitive2d/markerarrayprimitive2d.cxx6
-rw-r--r--drawinglayer/source/primitive2d/patternfillprimitive2d.cxx3
-rw-r--r--drawinglayer/source/primitive2d/sceneprimitive2d.cxx6
-rw-r--r--drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx5
-rw-r--r--drawinglayer/source/processor2d/hittestprocessor2d.cxx7
-rw-r--r--drawinglayer/source/processor2d/vclprocessor2d.cxx4
-rw-r--r--drawinglayer/source/tools/emfphelperdata.cxx5
-rw-r--r--drawinglayer/source/tools/wmfemfhelper.cxx3
13 files changed, 69 insertions, 28 deletions
diff --git a/drawinglayer/source/primitive2d/bitmapprimitive2d.cxx b/drawinglayer/source/primitive2d/bitmapprimitive2d.cxx
index 1953a36a71ac..f495d531d8ff 100644
--- a/drawinglayer/source/primitive2d/bitmapprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/bitmapprimitive2d.cxx
@@ -19,15 +19,16 @@
#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
+#include <com/sun/star/awt/XBitmap.hpp>
using namespace com::sun::star;
namespace drawinglayer::primitive2d
{
-BitmapPrimitive2D::BitmapPrimitive2D(const BitmapEx& rBitmapEx,
+BitmapPrimitive2D::BitmapPrimitive2D(const css::uno::Reference<css::awt::XBitmap>& rXBitmap,
const basegfx::B2DHomMatrix& rTransform)
: BasePrimitive2D()
- , maBitmapEx(rBitmapEx)
+ , maXBitmap(rXBitmap)
, maTransform(rTransform)
{
}
@@ -38,8 +39,7 @@ bool BitmapPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
{
const BitmapPrimitive2D& rCompare = static_cast<const BitmapPrimitive2D&>(rPrimitive);
- return (getBitmapEx() == rCompare.getBitmapEx()
- && getTransform() == rCompare.getTransform());
+ return (getXBitmap() == rCompare.getXBitmap() && getTransform() == rCompare.getTransform());
}
return false;
@@ -53,7 +53,22 @@ BitmapPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInforma
return aRetval;
}
-sal_Int64 SAL_CALL BitmapPrimitive2D::estimateUsage() { return getBitmapEx().GetSizeBytes(); }
+sal_Int64 SAL_CALL BitmapPrimitive2D::estimateUsage()
+{
+ if (!getXBitmap().is())
+ {
+ return 0;
+ }
+
+ uno::Reference<util::XAccounting> const xAcc(getXBitmap(), uno::UNO_QUERY);
+
+ if (!xAcc.is())
+ {
+ return 0;
+ }
+
+ return xAcc->estimateUsage();
+}
// provide unique ID
ImplPrimitive2DIDBlock(BitmapPrimitive2D, PRIMITIVE2D_ID_BITMAPPRIMITIVE2D)
diff --git a/drawinglayer/source/primitive2d/controlprimitive2d.cxx b/drawinglayer/source/primitive2d/controlprimitive2d.cxx
index a10f8810da73..600bb4be8a3f 100644
--- a/drawinglayer/source/primitive2d/controlprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/controlprimitive2d.cxx
@@ -37,6 +37,7 @@
#include <toolkit/awt/vclxwindow.hxx>
#include <vcl/window.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
using namespace com::sun::star;
@@ -205,7 +206,9 @@ namespace drawinglayer::primitive2d
aBitmapSizeLogic.getX(), aBitmapSizeLogic.getY(), aTranslate.getX(), aTranslate.getY()));
// create primitive
- xRetval = new BitmapPrimitive2D(aContent, aBitmapTransform);
+ xRetval = new BitmapPrimitive2D(
+ VCLUnoHelper::CreateVCLXBitmap(aContent),
+ aBitmapTransform);
}
catch( const uno::Exception& )
{
diff --git a/drawinglayer/source/primitive2d/discretebitmapprimitive2d.cxx b/drawinglayer/source/primitive2d/discretebitmapprimitive2d.cxx
index a61c4a39f7e8..bb73067a7d36 100644
--- a/drawinglayer/source/primitive2d/discretebitmapprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/discretebitmapprimitive2d.cxx
@@ -20,6 +20,7 @@
#include <drawinglayer/primitive2d/discretebitmapprimitive2d.hxx>
#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
namespace drawinglayer::primitive2d
@@ -62,7 +63,10 @@ namespace drawinglayer::primitive2d
aObjectTransform = aInverseObjectTransformation * aObjectTransform;
// create BitmapPrimitive2D with now object-local coordinate data
- rContainer.push_back(new BitmapPrimitive2D(getBitmapEx(), aObjectTransform));
+ rContainer.push_back(
+ new BitmapPrimitive2D(
+ VCLUnoHelper::CreateVCLXBitmap(getBitmapEx()),
+ aObjectTransform));
}
}
diff --git a/drawinglayer/source/primitive2d/discreteshadowprimitive2d.cxx b/drawinglayer/source/primitive2d/discreteshadowprimitive2d.cxx
index c3dd299148cf..116389383b4c 100644
--- a/drawinglayer/source/primitive2d/discreteshadowprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/discreteshadowprimitive2d.cxx
@@ -23,6 +23,7 @@
#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
#include <drawinglayer/geometry/viewinformation2d.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
namespace drawinglayer::primitive2d
@@ -176,7 +177,7 @@ namespace drawinglayer::primitive2d
// TopLeft
xRetval[0] = Primitive2DReference(
new BitmapPrimitive2D(
- getDiscreteShadow().getTopLeft(),
+ VCLUnoHelper::CreateVCLXBitmap(getDiscreteShadow().getTopLeft()),
basegfx::utils::createScaleTranslateB2DHomMatrix(
fBigLenX,
fBigLenY,
@@ -186,7 +187,7 @@ namespace drawinglayer::primitive2d
// Top
xRetval[1] = Primitive2DReference(
new BitmapPrimitive2D(
- getDiscreteShadow().getTop(),
+ VCLUnoHelper::CreateVCLXBitmap(getDiscreteShadow().getTop()),
basegfx::utils::createScaleTranslateB2DHomMatrix(
1.0 - (2.0 * (fBorderX + fSingleX)) + fSingleX,
fBorderY,
@@ -196,7 +197,7 @@ namespace drawinglayer::primitive2d
// TopRight
xRetval[2] = Primitive2DReference(
new BitmapPrimitive2D(
- getDiscreteShadow().getTopRight(),
+ VCLUnoHelper::CreateVCLXBitmap(getDiscreteShadow().getTopRight()),
basegfx::utils::createScaleTranslateB2DHomMatrix(
fBigLenX,
fBigLenY,
@@ -206,7 +207,7 @@ namespace drawinglayer::primitive2d
// Right
xRetval[3] = Primitive2DReference(
new BitmapPrimitive2D(
- getDiscreteShadow().getRight(),
+ VCLUnoHelper::CreateVCLXBitmap(getDiscreteShadow().getRight()),
basegfx::utils::createScaleTranslateB2DHomMatrix(
fBorderX,
1.0 - (2.0 * (fBorderY + fSingleY)) + fSingleY,
@@ -216,7 +217,7 @@ namespace drawinglayer::primitive2d
// BottomRight
xRetval[4] = Primitive2DReference(
new BitmapPrimitive2D(
- getDiscreteShadow().getBottomRight(),
+ VCLUnoHelper::CreateVCLXBitmap(getDiscreteShadow().getBottomRight()),
basegfx::utils::createScaleTranslateB2DHomMatrix(
fBigLenX,
fBigLenY,
@@ -226,7 +227,7 @@ namespace drawinglayer::primitive2d
// Bottom
xRetval[5] = Primitive2DReference(
new BitmapPrimitive2D(
- getDiscreteShadow().getBottom(),
+ VCLUnoHelper::CreateVCLXBitmap(getDiscreteShadow().getBottom()),
basegfx::utils::createScaleTranslateB2DHomMatrix(
1.0 - (2.0 * (fBorderX + fSingleX)) + fSingleX,
fBorderY,
@@ -236,7 +237,7 @@ namespace drawinglayer::primitive2d
// BottomLeft
xRetval[6] = Primitive2DReference(
new BitmapPrimitive2D(
- getDiscreteShadow().getBottomLeft(),
+ VCLUnoHelper::CreateVCLXBitmap(getDiscreteShadow().getBottomLeft()),
basegfx::utils::createScaleTranslateB2DHomMatrix(
fBigLenX,
fBigLenY,
@@ -246,7 +247,7 @@ namespace drawinglayer::primitive2d
// Left
xRetval[7] = Primitive2DReference(
new BitmapPrimitive2D(
- getDiscreteShadow().getLeft(),
+ VCLUnoHelper::CreateVCLXBitmap(getDiscreteShadow().getLeft()),
basegfx::utils::createScaleTranslateB2DHomMatrix(
fBorderX,
1.0 - (2.0 * (fBorderY + fSingleY)) + fSingleY,
diff --git a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
index 7c8597a14498..d301adc16a9c 100644
--- a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
+++ b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
@@ -40,6 +40,7 @@
#include <vcl/graph.hxx>
#include <vcl/virdev.hxx>
#include <vcl/svapp.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
namespace drawinglayer::primitive2d
{
@@ -170,7 +171,7 @@ namespace drawinglayer::primitive2d
return Primitive2DReference(
new BitmapPrimitive2D(
- BitmapEx(aMainBitmap, aMaskBitmap),
+ VCLUnoHelper::CreateVCLXBitmap(BitmapEx(aMainBitmap, aMaskBitmap)),
getTransform()));
}
@@ -511,7 +512,7 @@ namespace drawinglayer::primitive2d
{
aRetval.resize(1);
aRetval[0] = new BitmapPrimitive2D(
- rGraphic.GetBitmapEx(),
+ VCLUnoHelper::CreateVCLXBitmap(rGraphic.GetBitmapEx()),
rTransform);
}
diff --git a/drawinglayer/source/primitive2d/markerarrayprimitive2d.cxx b/drawinglayer/source/primitive2d/markerarrayprimitive2d.cxx
index 60e504bb63e0..d038353db9be 100644
--- a/drawinglayer/source/primitive2d/markerarrayprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/markerarrayprimitive2d.cxx
@@ -22,6 +22,7 @@
#include <drawinglayer/geometry/viewinformation2d.hxx>
#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
using namespace com::sun::star;
@@ -59,7 +60,10 @@ namespace drawinglayer::primitive2d
aTransform.set(0, 2, aRange.getMinX());
aTransform.set(1, 2, aRange.getMinY());
- rContainer.push_back(new BitmapPrimitive2D(getMarker(), aTransform));
+ rContainer.push_back(
+ new BitmapPrimitive2D(
+ VCLUnoHelper::CreateVCLXBitmap(getMarker()),
+ aTransform));
}
}
}
diff --git a/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx b/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx
index e754a7f97e59..5ed50cf95ebd 100644
--- a/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx
@@ -26,6 +26,7 @@
#include <texture/texture.hxx>
#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
#include <drawinglayer/geometry/viewinformation2d.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
#include <converters.hxx>
@@ -122,7 +123,7 @@ namespace drawinglayer::primitive2d
{
const primitive2d::Primitive2DReference xEmbedRefBitmap(
new primitive2d::BitmapPrimitive2D(
- aBitmapEx,
+ VCLUnoHelper::CreateVCLXBitmap(aBitmapEx),
basegfx::B2DHomMatrix()));
aContent = primitive2d::Primitive2DContainer { xEmbedRefBitmap };
}
diff --git a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx
index 66264ae9a039..c0c0fec7d41a 100644
--- a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx
@@ -33,6 +33,7 @@
#include <basegfx/raster/bzpixelraster.hxx>
#include <vcl/BitmapTools.hxx>
#include <comphelper/threadpool.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
using namespace com::sun::star;
@@ -468,7 +469,10 @@ namespace drawinglayer::primitive2d
aNew2DTransform *= aInverseOToV;
// create bitmap primitive and add
- rContainer.push_back(new BitmapPrimitive2D(maOldRenderedBitmap, aNew2DTransform));
+ rContainer.push_back(
+ new BitmapPrimitive2D(
+ VCLUnoHelper::CreateVCLXBitmap(maOldRenderedBitmap),
+ aNew2DTransform));
// test: Allow to add an outline in the debugger when tests are needed
static bool bAddOutlineToCreated3DSceneRepresentation(false); // loplugin:constvars:ignore
diff --git a/drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx b/drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx
index 921483861b60..d8926824f65a 100644
--- a/drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx
@@ -26,6 +26,7 @@
#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <vcl/graph.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
namespace drawinglayer::primitive2d
@@ -53,7 +54,7 @@ namespace drawinglayer::primitive2d
Primitive2DReference xReference(
new BitmapPrimitive2D(
- getBitmapEx(),
+ VCLUnoHelper::CreateVCLXBitmap(getBitmapEx()),
aObjectTransform));
aRetval = xReference;
@@ -152,7 +153,7 @@ namespace drawinglayer::primitive2d
Primitive2DReference xReference(
new BitmapPrimitive2D(
- getBitmapEx(),
+ VCLUnoHelper::CreateVCLXBitmap(getBitmapEx()),
aObjectTransform));
aRetval = xReference;
diff --git a/drawinglayer/source/processor2d/hittestprocessor2d.cxx b/drawinglayer/source/processor2d/hittestprocessor2d.cxx
index 525dceaef429..eb57052de924 100644
--- a/drawinglayer/source/processor2d/hittestprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/hittestprocessor2d.cxx
@@ -33,6 +33,7 @@
#include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx>
#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
#include <comphelper/lok.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
namespace drawinglayer::processor2d
{
@@ -432,8 +433,8 @@ namespace drawinglayer::processor2d
if(!aRange.isEmpty())
{
const primitive2d::BitmapPrimitive2D& rBitmapCandidate(static_cast< const primitive2d::BitmapPrimitive2D& >(rCandidate));
- const BitmapEx& rBitmapEx = rBitmapCandidate.getBitmapEx();
- const Size& rSizePixel(rBitmapEx.GetSizePixel());
+ const BitmapEx aBitmapEx(VCLUnoHelper::GetBitmap(rBitmapCandidate.getXBitmap()));
+ const Size& rSizePixel(aBitmapEx.GetSizePixel());
// When tiled rendering, don't bother with the pixel size of the candidate.
if(rSizePixel.Width() && rSizePixel.Height() && !comphelper::LibreOfficeKit::isActive())
@@ -451,7 +452,7 @@ namespace drawinglayer::processor2d
const sal_Int32 nX(basegfx::fround(aRelativePoint.getX() * rSizePixel.Width()));
const sal_Int32 nY(basegfx::fround(aRelativePoint.getY() * rSizePixel.Height()));
- mbHit = (0xff != rBitmapEx.GetTransparency(nX, nY));
+ mbHit = (0xff != aBitmapEx.GetTransparency(nX, nY));
}
}
else
diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx
index ced2cc96998c..34ff2992934f 100644
--- a/drawinglayer/source/processor2d/vclprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx
@@ -66,6 +66,8 @@
// for support of Title/Description in all apps when embedding pictures
#include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
using namespace com::sun::star;
namespace
@@ -346,7 +348,7 @@ namespace drawinglayer::processor2d
// direct draw of transformed BitmapEx primitive
void VclProcessor2D::RenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate)
{
- BitmapEx aBitmapEx(rBitmapCandidate.getBitmapEx());
+ BitmapEx aBitmapEx(VCLUnoHelper::GetBitmap(rBitmapCandidate.getXBitmap()));
const basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rBitmapCandidate.getTransform());
if(maBColorModifierStack.count())
diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx
index 2758509f9856..bc04cd3e8df3 100644
--- a/drawinglayer/source/tools/emfphelperdata.cxx
+++ b/drawinglayer/source/tools/emfphelperdata.cxx
@@ -55,6 +55,7 @@
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <i18nlangtag/languagetag.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
#include <algorithm>
@@ -1510,7 +1511,9 @@ namespace emfplushelper
if (aSize.Width() > 0 && aSize.Height() > 0)
{
mrTargetHolders.Current().append(
- std::make_unique<drawinglayer::primitive2d::BitmapPrimitive2D>(aBmp, aTransformMatrix));
+ std::make_unique<drawinglayer::primitive2d::BitmapPrimitive2D>(
+ VCLUnoHelper::CreateVCLXBitmap(aBmp),
+ aTransformMatrix));
}
else
{
diff --git a/drawinglayer/source/tools/wmfemfhelper.cxx b/drawinglayer/source/tools/wmfemfhelper.cxx
index bb4146ca9444..bef598449ce9 100644
--- a/drawinglayer/source/tools/wmfemfhelper.cxx
+++ b/drawinglayer/source/tools/wmfemfhelper.cxx
@@ -59,6 +59,7 @@
#include <i18nlangtag/languagetag.hxx>
#include <emfplushelper.hxx>
#include <numeric>
+#include <toolkit/helper/vclunohelper.hxx>
namespace drawinglayer::primitive2d
{
@@ -661,7 +662,7 @@ namespace wmfemfhelper
rTarget.append(
std::make_unique<drawinglayer::primitive2d::BitmapPrimitive2D>(
- rBitmapEx,
+ VCLUnoHelper::CreateVCLXBitmap(rBitmapEx),
aObjectTransform));
}
}