diff options
author | Armin Le Grand (Allotropia) <Armin.Le.Grand@me.com> | 2023-01-06 12:16:10 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2023-01-06 15:24:39 +0000 |
commit | 7e07225a1b48f3f987a818213256d3cbb9266d87 (patch) | |
tree | c75cd5bec0216d0a4149c97d9f2f700d89ddabc4 /include | |
parent | 6cabd7d9bfed37799a344f872d5f8fcf3214116a (diff) |
SDPR: Overhauled D2DRenderer to use sal::systools::COMReference
All stuff used from MS with names starting with ID2D1* is COM
API stuff, so referenced and interface-based. I thought about
making this more safe since a while (shared/unique_ptr, ...)
but found no good way to do it.
Also did not want to use CComPtr from MS and expand the devenv
we need on win, so was short before doing an own small smartptr
class. Luckily I asked sberg and he pointed me to the already
existing sal::systools::COMReference which exactly does what
I need here - thanks!
Unluckily I now had to change a lot of code - sigh. I wish
I had known earlier :-/
This change contains the renderer completely adapted to using
that much safer and better ressource control.
Plus I added (even more) comments to try to make more clear
in many plasces what's going on, what is done and why.
Change-Id: Ia2aa3223d0e5f7ec6569cde176cec1fadcd921dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145142
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/drawinglayer/processor2d/d2dpixelprocessor2d.hxx | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/include/drawinglayer/processor2d/d2dpixelprocessor2d.hxx b/include/drawinglayer/processor2d/d2dpixelprocessor2d.hxx index a08fef7b7ae2..10f9a11cb296 100644 --- a/include/drawinglayer/processor2d/d2dpixelprocessor2d.hxx +++ b/include/drawinglayer/processor2d/d2dpixelprocessor2d.hxx @@ -21,6 +21,7 @@ #include <drawinglayer/processor2d/baseprocessor2d.hxx> #include <basegfx/color/bcolormodifier.hxx> +#include <systools/win32/comtools.hxx> #include <sal/config.h> // win-specific @@ -56,7 +57,7 @@ class DRAWINGLAYER_DLLPUBLIC D2DPixelProcessor2D : public BaseProcessor2D basegfx::BColorModifierStack maBColorModifierStack; // win and render specific data - ID2D1RenderTarget* mpRT; + sal::systools::COMReference<ID2D1RenderTarget> mpRT; sal_uInt32 mnRecursionCounter; sal_uInt32 mnErrorCounter; @@ -90,9 +91,10 @@ class DRAWINGLAYER_DLLPUBLIC D2DPixelProcessor2D : public BaseProcessor2D processSingleLinePrimitive2D(const primitive2d::SingleLinePrimitive2D& rSingleLinePrimitive2D); // common helpers - ID2D1Bitmap* implCreateAlpha_Direct(const primitive2d::TransparencePrimitive2D& rTransCandidate, - const basegfx::B2DRange& rVisibleRange); - ID2D1Bitmap* + sal::systools::COMReference<ID2D1Bitmap> + implCreateAlpha_Direct(const primitive2d::TransparencePrimitive2D& rTransCandidate, + const basegfx::B2DRange& rVisibleRange); + sal::systools::COMReference<ID2D1Bitmap> implCreateAlpha_B2DBitmap(const primitive2d::TransparencePrimitive2D& rTransCandidate, const basegfx::B2DRange& rVisibleRange, D2D1_MATRIX_3X2_F& rMaskScale); @@ -109,14 +111,17 @@ protected: // local protected minimal accessors for usage in derivates, e.g. helpers void increaseError() { mnErrorCounter++; } bool hasError() const { return 0 != mnErrorCounter; } - void setRenderTarget(ID2D1RenderTarget* mpNewRT) { mpRT = mpNewRT; } - bool hasRenderTarget() const { return nullptr != mpRT; } - ID2D1RenderTarget& getRenderTarget() { return *mpRT; } + bool hasRenderTarget() const { return mpRT.is(); } + + void setRenderTarget(const sal::systools::COMReference<ID2D1RenderTarget>& rNewRT) + { + mpRT = rNewRT; + } + sal::systools::COMReference<ID2D1RenderTarget>& getRenderTarget() { return mpRT; } public: bool valid() const { return hasRenderTarget() && !hasError(); } D2DPixelProcessor2D(const geometry::ViewInformation2D& rViewInformation, HDC aHdc); - virtual ~D2DPixelProcessor2D() override; }; } |