diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-09-21 10:01:03 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-09-21 15:34:21 +0200 |
commit | 19d638eaedf84cefadf55d561c3c36df33fed6fe (patch) | |
tree | 3f2b157d60c8db2d06eac5f86140da582f1da13f /include | |
parent | 4ba0460e3cf3ce33794090968fd4c906422bbd25 (diff) |
reduce cost of BasePrimitive2D (tdf#125892)
the default WeakComponentImplHelper wants to allocate two child objects
(osl::Mutex and BroadcastHelper).
So use a custom re-implemenation that does not need to allocate any
child objects.
Change-Id: I288e58558398e39daa0d4b11e0b60a924445240d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122381
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include')
-rw-r--r-- | include/drawinglayer/primitive2d/baseprimitive2d.hxx | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/include/drawinglayer/primitive2d/baseprimitive2d.hxx b/include/drawinglayer/primitive2d/baseprimitive2d.hxx index 7d648d9b6845..f76c3e5a1520 100644 --- a/include/drawinglayer/primitive2d/baseprimitive2d.hxx +++ b/include/drawinglayer/primitive2d/baseprimitive2d.hxx @@ -29,17 +29,49 @@ #include <cppuhelper/basemutex.hxx> #include <basegfx/range/b2drange.hxx> #include <com/sun/star/graphic/XPrimitive2D.hpp> +#include <mutex> namespace drawinglayer::geometry { class ViewInformation2D; } -namespace drawinglayer::primitive2d +/** This is a custom re-implementation of cppu::WeakComponentImplHelper which uses + std::recursive_mutex and skips parts of the XComponent stuff. +*/ +class DRAWINGLAYER_DLLPUBLIC BasePrimitive2DImplBase : public cppu::OWeakObject, + public css::lang::XComponent, + public css::lang::XTypeProvider, + public css::graphic::XPrimitive2D, + public css::util::XAccounting { -typedef cppu::WeakComponentImplHelper<css::graphic::XPrimitive2D, css::util::XAccounting> - BasePrimitive2DImplBase; +public: + virtual ~BasePrimitive2DImplBase() override; + + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; + virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const& aType) override; + + // css::lang::XComponent + virtual void SAL_CALL dispose() override; + virtual void SAL_CALL + addEventListener(css::uno::Reference<css::lang::XEventListener> const& xListener) override; + virtual void SAL_CALL + removeEventListener(css::uno::Reference<css::lang::XEventListener> const& xListener) override; + + // css::lang::XTypeProvider + virtual css::uno::Sequence<css::uno::Type> SAL_CALL getTypes() override; + virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId() override + { + return css::uno::Sequence<sal_Int8>(); + } + +protected: + mutable std::recursive_mutex m_aMutex; +}; +namespace drawinglayer::primitive2d +{ /** BasePrimitive2D class Baseclass for all C++ implementations of css::graphic::XPrimitive2D @@ -113,8 +145,7 @@ typedef cppu::WeakComponentImplHelper<css::graphic::XPrimitive2D, css::util::XAc for view-independent primitives which are defined by not using ViewInformation2D in their get2DDecomposition/getB2DRange implementations. */ -class DRAWINGLAYER_DLLPUBLIC BasePrimitive2D : protected cppu::BaseMutex, - public BasePrimitive2DImplBase +class DRAWINGLAYER_DLLPUBLIC BasePrimitive2D : public BasePrimitive2DImplBase { BasePrimitive2D(const BasePrimitive2D&) = delete; BasePrimitive2D& operator=(const BasePrimitive2D&) = delete; |