diff options
author | Armin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de> | 2022-08-31 12:49:50 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2022-09-01 12:39:27 +0200 |
commit | 08e62dfbc156ef79cd9fa98e54bfba043247af8f (patch) | |
tree | b8b02da93d93ff5e69452c03f88fdbcf452f5088 /drawinglayer | |
parent | 256086fc9b3a00181c7022294712226cd920b2e1 (diff) |
Added BufferedDecompositionGroupPrimitive2D
...and adapted GlowPrimitive2D to it as a preparation to
use similar to BufferedDecompositionPrimitive2D, but for
primitives based on GroupPrimitive2D.
Change-Id: Ia1f9a09d4db09238ebbf6ad1303a4cdbdb8baedf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139099
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/Library_drawinglayer.mk | 1 | ||||
-rw-r--r-- | drawinglayer/source/primitive2d/BufferedDecompositionGroupPrimitive2D.cxx | 50 | ||||
-rw-r--r-- | drawinglayer/source/primitive2d/glowprimitive2d.cxx | 29 |
3 files changed, 59 insertions, 21 deletions
diff --git a/drawinglayer/Library_drawinglayer.mk b/drawinglayer/Library_drawinglayer.mk index 2b618f73136d..28e073f983c8 100644 --- a/drawinglayer/Library_drawinglayer.mk +++ b/drawinglayer/Library_drawinglayer.mk @@ -78,6 +78,7 @@ $(eval $(call gb_Library_add_exception_objects,drawinglayer,\ drawinglayer/source/primitive2d/backgroundcolorprimitive2d \ drawinglayer/source/primitive2d/bitmapprimitive2d \ drawinglayer/source/primitive2d/borderlineprimitive2d \ + drawinglayer/source/primitive2d/BufferedDecompositionGroupPrimitive2D \ drawinglayer/source/primitive2d/controlprimitive2d \ drawinglayer/source/primitive2d/cropprimitive2d \ drawinglayer/source/primitive2d/discretebitmapprimitive2d \ diff --git a/drawinglayer/source/primitive2d/BufferedDecompositionGroupPrimitive2D.cxx b/drawinglayer/source/primitive2d/BufferedDecompositionGroupPrimitive2D.cxx new file mode 100644 index 000000000000..67f41627718e --- /dev/null +++ b/drawinglayer/source/primitive2d/BufferedDecompositionGroupPrimitive2D.cxx @@ -0,0 +1,50 @@ +/* -*- 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 . + */ + +#include <sal/config.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionGroupPrimitive2D.hxx> +#include <drawinglayer/geometry/viewinformation2d.hxx> + +namespace drawinglayer::primitive2d +{ +BufferedDecompositionGroupPrimitive2D::BufferedDecompositionGroupPrimitive2D( + Primitive2DContainer&& aChildren) + : GroupPrimitive2D(std::move(aChildren)) +{ +} + +void BufferedDecompositionGroupPrimitive2D::get2DDecomposition( + Primitive2DDecompositionVisitor& rVisitor, + const geometry::ViewInformation2D& rViewInformation) const +{ + if (getBuffered2DDecomposition().empty()) + { + Primitive2DContainer aNewSequence; + create2DDecomposition(aNewSequence, rViewInformation); + const_cast<BufferedDecompositionGroupPrimitive2D*>(this)->setBuffered2DDecomposition( + std::move(aNewSequence)); + } + + rVisitor.visit(getBuffered2DDecomposition()); +} + +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/source/primitive2d/glowprimitive2d.cxx b/drawinglayer/source/primitive2d/glowprimitive2d.cxx index 0bce06d90a1d..d3c8539eddf8 100644 --- a/drawinglayer/source/primitive2d/glowprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/glowprimitive2d.cxx @@ -37,8 +37,7 @@ namespace drawinglayer::primitive2d { GlowPrimitive2D::GlowPrimitive2D(const Color& rGlowColor, double fRadius, Primitive2DContainer&& rChildren) - : GroupPrimitive2D(std::move(rChildren)) - , maBuffered2DDecomposition() + : BufferedDecompositionGroupPrimitive2D(std::move(rChildren)) , maGlowColor(rGlowColor) , mfGlowRadius(fRadius) , mfLastDiscreteGlowRadius(0.0) @@ -48,7 +47,7 @@ GlowPrimitive2D::GlowPrimitive2D(const Color& rGlowColor, double fRadius, bool GlowPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if (BasePrimitive2D::operator==(rPrimitive)) + if (BufferedDecompositionGroupPrimitive2D::operator==(rPrimitive)) { const GlowPrimitive2D& rCompare = static_cast<const GlowPrimitive2D&>(rPrimitive); @@ -239,10 +238,9 @@ void GlowPrimitive2D::create2DDecomposition( } } -// Same as in BufferedDecompositionPrimitive2D, maybe we need a tooling class -// like BufferedDecompositionGropupPrimitive2D if this is used more often -// (AFAIR it's similar for ScenePrimitive2D which also does quite some re-use/ -// buffering checks to avoid too much re-creation) +// Using tooling class BufferedDecompositionGroupPrimitive2D now, so +// no more need to locally do the buffered get2DDecomposition here, +// see BufferedDecompositionGroupPrimitive2D::get2DDecomposition void GlowPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const { @@ -319,20 +317,9 @@ void GlowPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisit } } - if (getBuffered2DDecomposition().empty()) - { - // refresh last used DiscreteGlowRadius and ClippedRange to new remembered values - const_cast<GlowPrimitive2D*>(this)->mfLastDiscreteGlowRadius = fDiscreteGlowRadius; - const_cast<GlowPrimitive2D*>(this)->maLastClippedRange = aClippedRange; - - // create decomposition - Primitive2DContainer aNewSequence; - - create2DDecomposition(aNewSequence, rViewInformation); - const_cast<GlowPrimitive2D*>(this)->setBuffered2DDecomposition(std::move(aNewSequence)); - } - - rVisitor.visit(getBuffered2DDecomposition()); + // call parent, that will check for empty, call create2DDecomposition and + // set as decomposition + BufferedDecompositionGroupPrimitive2D::get2DDecomposition(rVisitor, rViewInformation); } basegfx::B2DRange |