summaryrefslogtreecommitdiffstats
path: root/include/drawinglayer/processor2d
diff options
context:
space:
mode:
Diffstat (limited to 'include/drawinglayer/processor2d')
-rw-r--r--include/drawinglayer/processor2d/SDPRProcessor2dTools.hxx129
-rw-r--r--include/drawinglayer/processor2d/baseprocessor2d.hxx200
-rw-r--r--include/drawinglayer/processor2d/cairopixelprocessor2d.hxx98
-rw-r--r--include/drawinglayer/processor2d/contourextractor2d.hxx62
-rw-r--r--include/drawinglayer/processor2d/d2dpixelprocessor2d.hxx145
-rw-r--r--include/drawinglayer/processor2d/hittestprocessor2d.hxx96
-rw-r--r--include/drawinglayer/processor2d/linegeometryextractor2d.hxx61
-rw-r--r--include/drawinglayer/processor2d/objectinfoextractor2d.hxx54
-rw-r--r--include/drawinglayer/processor2d/processor2dtools.hxx71
-rw-r--r--include/drawinglayer/processor2d/textaspolygonextractor2d.hxx95
10 files changed, 1011 insertions, 0 deletions
diff --git a/include/drawinglayer/processor2d/SDPRProcessor2dTools.hxx b/include/drawinglayer/processor2d/SDPRProcessor2dTools.hxx
new file mode 100644
index 0000000000..0dd81f594f
--- /dev/null
+++ b/include/drawinglayer/processor2d/SDPRProcessor2dTools.hxx
@@ -0,0 +1,129 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <sal/config.h>
+
+namespace drawinglayer::primitive2d
+{
+class FillGraphicPrimitive2D;
+}
+
+namespace drawinglayer::geometry
+{
+class ViewInformation2D;
+}
+
+namespace basegfx
+{
+class B2DRange;
+}
+
+class BitmapEx;
+
+namespace drawinglayer::processor2d
+{
+/** helper to process FillGraphicPrimitive2D:
+
+ In places that want to implement direct rendering of this primitive
+ e.g. in SDPRs all impls would need to handle the FillGraphicAttribute
+ settings and the type of Graphic. Unify this by this helper in one place
+ since this may get complicated (many cases to cover).
+ It will create and return a BitmapEx when direct tiled rendering is
+ preferable and suggested.
+ Of course every impl may still do what it wants, this is just to make
+ implementations easier.
+
+ @param rFillGraphicPrimitive2D
+ The primitive to work on
+
+ @param rViewInformation2D
+ The ViewInformation to work with (from the processor)
+
+ @param rTarget
+ The prepared PixelData to use for tiled rendering. If this
+ is empty on return this means to evtl. use the decompose.
+ Please hand in an empty one to make this work.
+
+ @param rFillUnitRange
+ This is a modifiable copy of FillGraphicAttribute.getGraphicRange(). We
+ need a modifiable one since params since OffsetX/OffsetY in
+ FillGraphicAttribute may require to change/adapt this if used
+
+ @param fBigDiscreteArea
+ Defines starting with which number of square pixels a target is seen
+ to be painted 'big'
+
+ @return
+ false: rendering is not needed (invalid, outside, ...), done
+ true: rendering is needed
+ -> if rTarget is filled, use for tiled rendering
+ -> if not, use fallback (primitive decomposition)
+
+ For the various reasons/things that get checked/tested/done, please
+ see the implementation
+ */
+bool prepareBitmapForDirectRender(
+ const drawinglayer::primitive2d::FillGraphicPrimitive2D& rFillGraphicPrimitive2D,
+ const drawinglayer::geometry::ViewInformation2D& rViewInformation2D, BitmapEx& rTarget,
+ basegfx::B2DRange& rFillUnitRange, double fBigDiscreteArea = 300.0 * 300.0);
+
+/** helper to react/process if OffsetX/OffsetY of the FillGraphicAttribute is used.
+
+ This is old but hard to remove stuff that allows hor/ver offset when
+ tiled fill is used. To solve that, create pixel data that doubles
+ resp. in width/height and copies the off-setted version of the bitmap
+ information to the extra space, so rendering does not need to do that.
+
+ Since this doubles the geometry, an adaption of the used fill range
+ (here rFillUnitRange in unit coordinates) also needs to be adapted,
+ refer to usage.
+ */
+void takeCareOfOffsetXY(
+ const drawinglayer::primitive2d::FillGraphicPrimitive2D& rFillGraphicPrimitive2D,
+ BitmapEx& rTarget, basegfx::B2DRange& rFillUnitRange);
+
+/** helper to calculate a discrete visible range based on a given logic range
+ and a current ViewInformation2D. This is used for pixel renderers.
+ It is handy to check for visibility of a primitive, but also to continue
+ working with just the visible discrete part.
+
+ The result rDiscreteVisibleRange will be reset if rContentRange is empty.
+ Else it will be calculated. If ViewInformation2D does have a valid
+ Viewport (getDiscreteViewport is not empty), it will also be clipped
+ against that to calculate the visible part.
+
+ @param rDiscreteVisibleRange
+ The logic range in view-coordinates (will be transformed by
+ getObjectToViewTransformation)
+
+ @param rContentRange
+ The logic input range in view-coordinates (will be transformed by
+ getObjectToViewTransformation)
+
+ @param rViewInformation2D
+ The ViewInformation to work with (from the processor)
+ */
+void calculateDiscreteVisibleRange(
+ basegfx::B2DRange& rDiscreteVisibleRange, const basegfx::B2DRange& rContentRange,
+ const drawinglayer::geometry::ViewInformation2D& rViewInformation2D);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/drawinglayer/processor2d/baseprocessor2d.hxx b/include/drawinglayer/processor2d/baseprocessor2d.hxx
new file mode 100644
index 0000000000..9d1bb6b8a7
--- /dev/null
+++ b/include/drawinglayer/processor2d/baseprocessor2d.hxx
@@ -0,0 +1,200 @@
+/* -*- 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_PROCESSOR2D_BASEPROCESSOR2D_HXX
+#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_BASEPROCESSOR2D_HXX
+
+#include <drawinglayer/drawinglayerdllapi.h>
+
+#include <drawinglayer/primitive2d/Primitive2DVisitor.hxx>
+#include <drawinglayer/primitive2d/baseprimitive2d.hxx>
+#include <drawinglayer/geometry/viewinformation2d.hxx>
+
+
+namespace drawinglayer::processor2d
+ {
+ /** BaseProcessor2D class
+
+ Base class for all C++ implementations of instances which process
+ primitives.
+
+ Instances which process primitives can be renderers, but also stuff
+ for HitTests, BoundRect calculations and/or animation processing. The
+ main usage are renderers, but they are supposed to handle any primitive
+ processing.
+
+ The base implementation is constructed with a ViewInformation2D which
+ is accessible throughout the processor implementations. The idea is
+ to construct any processor with a given ViewInformation2D. To be able
+ to handle primitives which need to change the current transformation
+ (as e.g. TransformPrimitive2D) it is allowed for the processor implementation
+ to change its local value using updateViewInformation.
+
+ The basic processing method is process(..) which gets handed over the
+ sequence of primitives to process. For convenience of the C++ implementations,
+ the default implementation of process(..) maps all accesses to primitives to
+ single calls to processBasePrimitive2D(..) where the primitive in question is
+ already casted to the C++ implementation class.
+
+ The process(..) implementation makes a complete iteration over the given
+ sequence of primitives. If the Primitive is not derived from BasePrimitive2D
+ and thus not part of the C++ implementations, it converts ViewInformation2D
+ to the corresponding API implementation (a uno::Sequence< beans::PropertyValue >)
+ and recursively calls the method process(..) at the primitive with the decomposition
+ derived from that primitive. This is the preparation to handle unknown implementations
+ of the css::graphic::XPrimitive2D interface in the future.
+
+ So, to implement a basic processor, it is necessary to override and implement the
+ processBasePrimitive2D(..) method. A minimal renderer has to support the
+ Basic Primitives (see baseprimitive2d.hxx) and the Grouping Primitives (see
+ groupprimitive2d.hxx). These are (currently):
+
+ Basic Primitives:
+
+ - BitmapPrimitive2D (bitmap data, possibly with transparency)
+ - PointArrayPrimitive2D (single points)
+ - PolygonHairlinePrimitive2D (hairline curves/polygons)
+ - PolyPolygonColorPrimitive2D (colored polygons)
+
+ Grouping Primitives:
+
+ - TransparencePrimitive2D (objects with freely defined transparence)
+ - InvertPrimitive2D (for XOR)
+ - MaskPrimitive2D (for masking)
+ - ModifiedColorPrimitive2D (for a stack of color modifications)
+ - TransformPrimitive2D (for a transformation stack)
+
+ A processor doing so is a minimal processor. Of course a processor may
+ handle any higher-level primitive (that has a decomposition implementation)
+ for more direct data access or performance reasons, too.
+
+ The main part of a processBasePrimitive2D implementation is a switch..case
+ construct, looking like the following:
+
+ void foo::processBasePrimitive2D(const BasePrimitive2D& rCandidate)
+ {
+ switch(rCandidate.getPrimitive2DID())
+ {
+ case PRIMITIVE2D_ID_??? :
+ {
+ // process PRIMITIVE2D_ID_??? here...
+
+ ...
+
+ break;
+ }
+
+ ...
+
+ default :
+ {
+ // process recursively
+ process(rCandidate.get2DDecomposition(getViewInformation2D()));
+ break;
+ }
+ }
+ }
+
+ The default case makes the processor work with all complex primitives
+ by recursively using their decomposition.
+
+ You can also add a case for ignoring primitives by using:
+
+ case PRIMITIVE2D_ID_...IGNORE.A.. :
+ case PRIMITIVE2D_ID_...IGNORE.B.. :
+ case PRIMITIVE2D_ID_...IGNORE.C.. :
+ {
+ // ignore these primitives by neither processing nor
+ // recursively processing their decomposition
+ break;
+ }
+
+ Another useful case is embedding the processing of a complex primitive by
+ bracketing it with some actions:
+
+ case PRIMITIVE2D_ID_SOME_TEXT :
+ {
+ // encapsulate e.g. with changing local variables, e.g.
+ // sometimes it's good to know if a basic primitive is
+ // part of a text, especially when not handling the text
+ // self but by purpose want to handle the decomposed
+ // geometries in the processor
+ startText();
+ process(rCandidate.get2DDecomposition(getViewInformation2D()));
+ endText();
+ break;
+ }
+
+ As an example a processor collecting the outlines of a sequence of primitives
+ only needs to handle some Basic Primitives and create outline and collect
+ outline polygons e.g. for primitives with area like BitmapPrimitive2D (a
+ rectangle) and PolyPolygonColorPrimitive2D. When also handling the Grouping
+ Primitives MaskPrimitive2D (e.g. ignoring its content, using the mask polyPolygon)
+ and TransformPrimitive2D (to have the correct local transformation), a processor
+ creating the outline can be written using just four (4) primitives. As a tipp, it can
+ be helpful to add many for the purpose not interesting higher level primitives
+ to not force their decomposition to be created and/or parsed.
+ */
+ class DRAWINGLAYER_DLLPUBLIC BaseProcessor2D : public drawinglayer::primitive2d::Primitive2DDecompositionVisitor
+ {
+ private:
+ /// The ViewInformation2D itself. It's private to isolate accesses to it
+ geometry::ViewInformation2D maViewInformation2D;
+
+ protected:
+ /* access method to allow the implementations to change the current
+ ViewInformation2D if needed. This allows isolating these accesses
+ later if needed
+ */
+ void updateViewInformation(const geometry::ViewInformation2D& rViewInformation2D)
+ {
+ maViewInformation2D = rViewInformation2D;
+ }
+
+ /* as tooling, the process() implementation takes over API handling and calls this
+ virtual render method when the primitive implementation is BasePrimitive2D-based.
+ Default implementation does nothing
+ */
+ virtual void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate);
+
+ void process(const primitive2d::BasePrimitive2D& rCandidate);
+
+ // Primitive2DDecompositionVisitor
+ virtual void visit(const primitive2d::Primitive2DReference&) override final;
+ virtual void visit(const primitive2d::Primitive2DContainer&) override final;
+ virtual void visit(primitive2d::Primitive2DContainer&&) override final;
+
+ public:
+ /// constructor/destructor
+ explicit BaseProcessor2D(geometry::ViewInformation2D aViewInformation);
+ virtual ~BaseProcessor2D();
+
+ /// the central processing method
+ void process(const primitive2d::Primitive2DContainer& rSource);
+
+ /// data read access
+ const geometry::ViewInformation2D& getViewInformation2D() const { return maViewInformation2D; }
+ };
+
+} // end of namespace drawinglayer::processor2d
+
+
+#endif //INCLUDED_DRAWINGLAYER_PROCESSOR2D_BASEPROCESSOR2D_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/drawinglayer/processor2d/cairopixelprocessor2d.hxx b/include/drawinglayer/processor2d/cairopixelprocessor2d.hxx
new file mode 100644
index 0000000000..2324b9f619
--- /dev/null
+++ b/include/drawinglayer/processor2d/cairopixelprocessor2d.hxx
@@ -0,0 +1,98 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+
+#pragma once
+
+#include <drawinglayer/processor2d/baseprocessor2d.hxx>
+#include <basegfx/color/bcolormodifier.hxx>
+#include <sal/config.h>
+
+// cairo-specific
+#include <cairo.h>
+
+namespace drawinglayer::primitive2d
+{
+class PolyPolygonColorPrimitive2D;
+class PolygonHairlinePrimitive2D;
+class BitmapPrimitive2D;
+class UnifiedTransparencePrimitive2D;
+class BackgroundColorPrimitive2D;
+class TransparencePrimitive2D;
+class MaskPrimitive2D;
+class ModifiedColorPrimitive2D;
+class TransformPrimitive2D;
+class PointArrayPrimitive2D;
+class MarkerArrayPrimitive2D;
+class PolygonStrokePrimitive2D;
+class LineRectanglePrimitive2D;
+class FilledRectanglePrimitive2D;
+class SingleLinePrimitive2D;
+}
+
+namespace drawinglayer::processor2d
+{
+class DRAWINGLAYER_DLLPUBLIC CairoPixelProcessor2D final : public BaseProcessor2D
+{
+ // the modifiedColorPrimitive stack
+ basegfx::BColorModifierStack maBColorModifierStack;
+
+ // cairo specific data
+ cairo_t* mpRT;
+
+ // helpers for direct paints
+ void processPolygonHairlinePrimitive2D(
+ const primitive2d::PolygonHairlinePrimitive2D& rPolygonHairlinePrimitive2D);
+ void processPolyPolygonColorPrimitive2D(
+ const primitive2d::PolyPolygonColorPrimitive2D& rPolyPolygonColorPrimitive2D);
+ void processBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate);
+ void
+ processTransparencePrimitive2D(const primitive2d::TransparencePrimitive2D& rTransCandidate);
+ void processUnifiedTransparencePrimitive2D(
+ const primitive2d::UnifiedTransparencePrimitive2D& rTransCandidate);
+ void processMaskPrimitive2DPixel(const primitive2d::MaskPrimitive2D& rMaskCandidate);
+ void processModifiedColorPrimitive2D(
+ const primitive2d::ModifiedColorPrimitive2D& rModifiedCandidate);
+ void processTransformPrimitive2D(const primitive2d::TransformPrimitive2D& rTransformCandidate);
+ void
+ processPointArrayPrimitive2D(const primitive2d::PointArrayPrimitive2D& rPointArrayCandidate);
+ void
+ processMarkerArrayPrimitive2D(const primitive2d::MarkerArrayPrimitive2D& rMarkerArrayCandidate);
+ void processBackgroundColorPrimitive2D(
+ const primitive2d::BackgroundColorPrimitive2D& rBackgroundColorCandidate);
+ void processPolygonStrokePrimitive2D(
+ const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokeCandidate);
+ void processLineRectanglePrimitive2D(
+ const primitive2d::LineRectanglePrimitive2D& rLineRectanglePrimitive2D);
+ void processFilledRectanglePrimitive2D(
+ const primitive2d::FilledRectanglePrimitive2D& rFilledRectanglePrimitive2D);
+ void
+ processSingleLinePrimitive2D(const primitive2d::SingleLinePrimitive2D& rSingleLinePrimitive2D);
+
+ /* the local processor for BasePrimitive2D-Implementation based primitives,
+ called from the common process()-implementation
+ */
+ virtual void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) override;
+
+protected:
+ // local protected minimal constructor for usage in derivates, e.g. helpers
+ CairoPixelProcessor2D(const geometry::ViewInformation2D& rViewInformation);
+
+ bool hasError() const { return cairo_status(mpRT) != CAIRO_STATUS_SUCCESS; }
+ void setRenderTarget(cairo_t* mpNewRT) { mpRT = mpNewRT; }
+ bool hasRenderTarget() const { return nullptr != mpRT; }
+
+public:
+ bool valid() const { return hasRenderTarget() && !hasError(); }
+ CairoPixelProcessor2D(const geometry::ViewInformation2D& rViewInformation,
+ cairo_surface_t* pTarget);
+ virtual ~CairoPixelProcessor2D() override;
+};
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/include/drawinglayer/processor2d/contourextractor2d.hxx b/include/drawinglayer/processor2d/contourextractor2d.hxx
new file mode 100644
index 0000000000..53158cc212
--- /dev/null
+++ b/include/drawinglayer/processor2d/contourextractor2d.hxx
@@ -0,0 +1,62 @@
+/* -*- 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_PROCESSOR2D_CONTOUREXTRACTOR2D_HXX
+#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_CONTOUREXTRACTOR2D_HXX
+
+#include <drawinglayer/drawinglayerdllapi.h>
+
+#include <drawinglayer/processor2d/baseprocessor2d.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+
+
+namespace drawinglayer::processor2d
+ {
+ /** ContourExtractor2D class
+
+ A processor who extracts the contour of the primitives fed to it
+ in the single local PolyPolygon
+ */
+ class DRAWINGLAYER_DLLPUBLIC ContourExtractor2D final : public BaseProcessor2D
+ {
+ private:
+ /// the extracted contour
+ basegfx::B2DPolyPolygonVector maExtractedContour;
+
+ bool mbExtractFillOnly : 1;
+
+ /// tooling methods
+ void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) override;
+
+ public:
+ explicit ContourExtractor2D(
+ const geometry::ViewInformation2D& rViewInformation,
+ bool bExtractFillOnly);
+
+ virtual ~ContourExtractor2D() override;
+
+ const basegfx::B2DPolyPolygonVector& getExtractedContour() const { return maExtractedContour; }
+ };
+
+} // end of namespace drawinglayer::processor2d
+
+
+#endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_CONTOUREXTRACTOR2D_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/drawinglayer/processor2d/d2dpixelprocessor2d.hxx b/include/drawinglayer/processor2d/d2dpixelprocessor2d.hxx
new file mode 100644
index 0000000000..b627bf2b16
--- /dev/null
+++ b/include/drawinglayer/processor2d/d2dpixelprocessor2d.hxx
@@ -0,0 +1,145 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <drawinglayer/processor2d/baseprocessor2d.hxx>
+#include <basegfx/color/bcolormodifier.hxx>
+#include <systools/win32/comtools.hxx>
+#include <sal/config.h>
+
+// win-specific
+#include <d2d1.h>
+
+namespace drawinglayer::primitive2d
+{
+class PolyPolygonColorPrimitive2D;
+class PolygonHairlinePrimitive2D;
+class BitmapPrimitive2D;
+class UnifiedTransparencePrimitive2D;
+class BackgroundColorPrimitive2D;
+class TransparencePrimitive2D;
+class MaskPrimitive2D;
+class ModifiedColorPrimitive2D;
+class TransformPrimitive2D;
+class PointArrayPrimitive2D;
+class MarkerArrayPrimitive2D;
+class PolygonStrokePrimitive2D;
+class LineRectanglePrimitive2D;
+class FilledRectanglePrimitive2D;
+class SingleLinePrimitive2D;
+class FillGraphicPrimitive2D;
+class InvertPrimitive2D;
+class FillGradientPrimitive2D;
+}
+
+namespace basegfx
+{
+class B2DHomMatrix;
+class B2DPolyPolygon;
+class BColor;
+}
+
+struct ID2D1RenderTarget;
+struct ID2D1Factory;
+
+namespace drawinglayer::processor2d
+{
+class DRAWINGLAYER_DLLPUBLIC D2DPixelProcessor2D : public BaseProcessor2D
+{
+ // the modifiedColorPrimitive stack
+ basegfx::BColorModifierStack maBColorModifierStack;
+
+ // win and render specific data
+ sal::systools::COMReference<ID2D1RenderTarget> mpRT;
+ sal_uInt32 mnRecursionCounter;
+ sal_uInt32 mnErrorCounter;
+
+ // helpers for direct paints
+ void processPolygonHairlinePrimitive2D(
+ const primitive2d::PolygonHairlinePrimitive2D& rPolygonHairlinePrimitive2D);
+ void processPolyPolygonColorPrimitive2D(
+ const primitive2d::PolyPolygonColorPrimitive2D& rPolyPolygonColorPrimitive2D);
+ void processBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate);
+ void
+ processTransparencePrimitive2D(const primitive2d::TransparencePrimitive2D& rTransCandidate);
+ void processUnifiedTransparencePrimitive2D(
+ const primitive2d::UnifiedTransparencePrimitive2D& rTransCandidate);
+ void processMaskPrimitive2DPixel(const primitive2d::MaskPrimitive2D& rMaskCandidate);
+ void processModifiedColorPrimitive2D(
+ const primitive2d::ModifiedColorPrimitive2D& rModifiedCandidate);
+ void processTransformPrimitive2D(const primitive2d::TransformPrimitive2D& rTransformCandidate);
+ void
+ processPointArrayPrimitive2D(const primitive2d::PointArrayPrimitive2D& rPointArrayCandidate);
+ void
+ processMarkerArrayPrimitive2D(const primitive2d::MarkerArrayPrimitive2D& rMarkerArrayCandidate);
+ void processBackgroundColorPrimitive2D(
+ const primitive2d::BackgroundColorPrimitive2D& rBackgroundColorCandidate);
+ void processPolygonStrokePrimitive2D(
+ const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokeCandidate);
+ void processLineRectanglePrimitive2D(
+ const primitive2d::LineRectanglePrimitive2D& rLineRectanglePrimitive2D);
+ void processFilledRectanglePrimitive2D(
+ const primitive2d::FilledRectanglePrimitive2D& rFilledRectanglePrimitive2D);
+ void
+ processSingleLinePrimitive2D(const primitive2d::SingleLinePrimitive2D& rSingleLinePrimitive2D);
+ void processFillGraphicPrimitive2D(
+ const primitive2d::FillGraphicPrimitive2D& rFillGraphicPrimitive2D);
+ void processInvertPrimitive2D(const primitive2d::InvertPrimitive2D& rInvertPrimitive2D);
+ void processFillGradientPrimitive2D(
+ const primitive2d::FillGradientPrimitive2D& rFillGradientPrimitive2D);
+
+ // common helpers
+ sal::systools::COMReference<ID2D1Bitmap>
+ implCreateAlpha_Direct(const primitive2d::TransparencePrimitive2D& rTransCandidate);
+ sal::systools::COMReference<ID2D1Bitmap>
+ implCreateAlpha_B2DBitmap(const primitive2d::TransparencePrimitive2D& rTransCandidate,
+ const basegfx::B2DRange& rVisibleRange,
+ D2D1_MATRIX_3X2_F& rMaskScale);
+ bool drawPolyPolygonColorTransformed(const basegfx::B2DHomMatrix& rTansformation,
+ const basegfx::B2DPolyPolygon& rPolyPolygon,
+ const basegfx::BColor& rColor);
+
+ /* the local processor for BasePrimitive2D-Implementation based primitives,
+ called from the common process()-implementation
+ */
+ virtual void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) override;
+
+protected:
+ // local protected minimal constructor for usage in derivates, e.g. helpers
+ D2DPixelProcessor2D(const geometry::ViewInformation2D& rViewInformation);
+
+ // local protected minimal accessors for usage in derivates, e.g. helpers
+ void increaseError() { mnErrorCounter++; }
+ bool hasError() const { return 0 != mnErrorCounter; }
+ 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);
+};
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/drawinglayer/processor2d/hittestprocessor2d.hxx b/include/drawinglayer/processor2d/hittestprocessor2d.hxx
new file mode 100644
index 0000000000..6d092efe98
--- /dev/null
+++ b/include/drawinglayer/processor2d/hittestprocessor2d.hxx
@@ -0,0 +1,96 @@
+/* -*- 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_PROCESSOR2D_HITTESTPROCESSOR2D_HXX
+#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX
+
+#include <drawinglayer/drawinglayerdllapi.h>
+#include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
+#include <drawinglayer/processor2d/baseprocessor2d.hxx>
+
+namespace basegfx { class B2DPolygon; }
+namespace basegfx { class B2DPolyPolygon; }
+namespace drawinglayer::primitive2d { class ScenePrimitive2D; }
+
+namespace drawinglayer::processor2d
+ {
+ /** HitTestProcessor2D class
+
+ This processor implements a HitTest with the fed primitives,
+ given tolerance and extras
+ */
+ class DRAWINGLAYER_DLLPUBLIC HitTestProcessor2D final : public BaseProcessor2D
+ {
+ private:
+ /// discrete HitTest position
+ basegfx::B2DPoint maDiscreteHitPosition;
+
+ /// discrete HitTolerance
+ basegfx::B2DVector maDiscreteHitTolerancePerAxis;
+
+ /// stack of HitPrimitives, taken care of during HitTest run
+ primitive2d::Primitive2DContainer maHitStack;
+
+ /// flag if HitStack shall be collected as part of the result, default is false
+ bool mbCollectHitStack : 1;
+
+ /// Boolean to flag if a hit was found. If yes, fast exit is taken
+ bool mbHit : 1;
+
+ /// flag to concentrate on text hits only
+ bool mbHitTextOnly : 1;
+
+ /// tooling methods
+ void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) override;
+ bool checkHairlineHitWithTolerance(
+ const basegfx::B2DPolygon& rPolygon,
+ const basegfx::B2DVector& rDiscreteHitTolerancePerAxis) const;
+ bool checkFillHitWithTolerance(
+ const basegfx::B2DPolyPolygon& rPolyPolygon,
+ const basegfx::B2DVector& rDiscreteHitTolerancePerAxis) const;
+ void check3DHit(const primitive2d::ScenePrimitive2D& rCandidate);
+
+ public:
+ HitTestProcessor2D(
+ const geometry::ViewInformation2D& rViewInformation,
+ const basegfx::B2DPoint& rLogicHitPosition,
+ const basegfx::B2DVector& rLogicHitTolerancePerAxis,
+ bool bHitTextOnly);
+ virtual ~HitTestProcessor2D() override;
+
+ /// switch on collecting primitives for a found hit on maHitStack, default is off
+ void collectHitStack(bool bCollect) { mbCollectHitStack = bCollect; }
+
+ /// get HitStack of primitives, first is the one that created the hit, last is the
+ /// top-most
+ const primitive2d::Primitive2DContainer& getHitStack() const { return maHitStack; }
+
+ /// data read access
+ const basegfx::B2DPoint& getDiscreteHitPosition() const { return maDiscreteHitPosition; }
+ const basegfx::B2DVector& getDiscreteHitTolerance() const { return maDiscreteHitTolerancePerAxis; }
+ bool getCollectHitStack() const { return mbCollectHitStack; }
+ bool getHit() const { return mbHit; }
+ bool getHitTextOnly() const { return mbHitTextOnly; }
+ };
+
+} // end of namespace drawinglayer::processor2d
+
+#endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/drawinglayer/processor2d/linegeometryextractor2d.hxx b/include/drawinglayer/processor2d/linegeometryextractor2d.hxx
new file mode 100644
index 0000000000..a2a388dd12
--- /dev/null
+++ b/include/drawinglayer/processor2d/linegeometryextractor2d.hxx
@@ -0,0 +1,61 @@
+/* -*- 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_PROCESSOR2D_LINEGEOMETRYEXTRACTOR2D_HXX
+#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_LINEGEOMETRYEXTRACTOR2D_HXX
+
+#include <drawinglayer/drawinglayerdllapi.h>
+
+#include <drawinglayer/processor2d/baseprocessor2d.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+
+namespace drawinglayer::processor2d
+ {
+ /** LineGeometryExtractor2D class
+
+ This processor can extract the line geometry from fed primitives. The
+ hairlines and the fill geometry from fat lines are separated.
+ */
+ class DRAWINGLAYER_DLLPUBLIC LineGeometryExtractor2D final : public BaseProcessor2D
+ {
+ private:
+ basegfx::B2DPolygonVector maExtractedHairlines;
+ basegfx::B2DPolyPolygonVector maExtractedLineFills;
+
+ bool mbInLineGeometry : 1;
+
+ /// tooling methods
+ void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) override;
+
+ public:
+ LineGeometryExtractor2D(const geometry::ViewInformation2D& rViewInformation);
+ virtual ~LineGeometryExtractor2D() override;
+
+ const basegfx::B2DPolygonVector& getExtractedHairlines() const { return maExtractedHairlines; }
+ const basegfx::B2DPolyPolygonVector& getExtractedLineFills() const { return maExtractedLineFills; }
+ };
+
+} // end of namespace drawinglayer::processor2d
+
+
+#endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_LINEGEOMETRYEXTRACTOR2D_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/drawinglayer/processor2d/objectinfoextractor2d.hxx b/include/drawinglayer/processor2d/objectinfoextractor2d.hxx
new file mode 100644
index 0000000000..f7dc1d1468
--- /dev/null
+++ b/include/drawinglayer/processor2d/objectinfoextractor2d.hxx
@@ -0,0 +1,54 @@
+/* -*- 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_PROCESSOR2D_OBJECTINFOEXTRACTOR2D_HXX
+#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_OBJECTINFOEXTRACTOR2D_HXX
+
+#include <drawinglayer/drawinglayerdllapi.h>
+#include <drawinglayer/processor2d/baseprocessor2d.hxx>
+
+namespace drawinglayer::primitive2d { class ObjectInfoPrimitive2D; }
+
+namespace drawinglayer::processor2d
+ {
+ /** ObjectInfoPrimitiveExtractor2D class
+
+ A processor to find the first incarnation of ObjectInfoPrimitive2D
+ in a given hierarchy
+ */
+ class DRAWINGLAYER_DLLPUBLIC ObjectInfoPrimitiveExtractor2D final : public BaseProcessor2D
+ {
+ private:
+ /// the target
+ const primitive2d::ObjectInfoPrimitive2D* mpFound;
+
+ /// tooling methods
+ void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) override;
+
+ public:
+ ObjectInfoPrimitiveExtractor2D(const geometry::ViewInformation2D& rViewInformation);
+ virtual ~ObjectInfoPrimitiveExtractor2D() override;
+
+ const primitive2d::ObjectInfoPrimitive2D* getResult() const { return mpFound; }
+ };
+
+} // end of namespace drawinglayer::processor2d
+
+#endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_OBJECTINFOEXTRACTOR2D_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/drawinglayer/processor2d/processor2dtools.hxx b/include/drawinglayer/processor2d/processor2dtools.hxx
new file mode 100644
index 0000000000..86ad2562e7
--- /dev/null
+++ b/include/drawinglayer/processor2d/processor2dtools.hxx
@@ -0,0 +1,71 @@
+/* -*- 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_PROCESSOR2D_PROCESSOR2DTOOLS_HXX
+#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_PROCESSOR2DTOOLS_HXX
+
+#include <drawinglayer/drawinglayerdllapi.h>
+#include <memory>
+
+namespace drawinglayer::geometry { class ViewInformation2D; }
+namespace drawinglayer::processor2d { class BaseProcessor2D; }
+
+class OutputDevice;
+
+namespace drawinglayer::processor2d
+ {
+ /** create the best available pixel based BaseProcessor2D
+ (which may be system-dependent)
+
+ @param rTargetOutDev
+ The target OutputDevice
+
+ @param rViewInformation2D
+ The ViewInformation to use
+
+ @return
+ the created BaseProcessor2D (ownership change)
+ */
+ DRAWINGLAYER_DLLPUBLIC std::unique_ptr<BaseProcessor2D> createPixelProcessor2DFromOutputDevice(
+ OutputDevice& rTargetOutDev,
+ const drawinglayer::geometry::ViewInformation2D& rViewInformation2D);
+
+ /** create a BaseProcessor2D dependent on some states of the
+ given OutputDevice. If metafile is recorded, the needed
+ VclMetafileProcessor2D will be created. If a pixel renderer
+ is requested, the best one is incarnated
+
+ @param rTargetOutDev
+ The target OutputDevice
+
+ @param rViewInformation2D
+ The ViewInformation to use
+
+ @return
+ the created BaseProcessor2D (ownership change)
+ */
+ DRAWINGLAYER_DLLPUBLIC std::unique_ptr<BaseProcessor2D> createProcessor2DFromOutputDevice(
+ OutputDevice& rTargetOutDev,
+ const drawinglayer::geometry::ViewInformation2D& rViewInformation2D);
+
+
+} // end of namespace drawinglayer::processor2d
+
+#endif //INCLUDED_DRAWINGLAYER_PROCESSOR2D_PROCESSOR2DTOOLS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/drawinglayer/processor2d/textaspolygonextractor2d.hxx b/include/drawinglayer/processor2d/textaspolygonextractor2d.hxx
new file mode 100644
index 0000000000..feaea118e1
--- /dev/null
+++ b/include/drawinglayer/processor2d/textaspolygonextractor2d.hxx
@@ -0,0 +1,95 @@
+/* -*- 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_PROCESSOR2D_TEXTASPOLYGONEXTRACTOR2D_HXX
+#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_TEXTASPOLYGONEXTRACTOR2D_HXX
+
+#include <drawinglayer/drawinglayerdllapi.h>
+
+#include <drawinglayer/processor2d/baseprocessor2d.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/color/bcolor.hxx>
+#include <basegfx/color/bcolormodifier.hxx>
+#include <utility>
+#include <vector>
+
+
+namespace drawinglayer::processor2d
+ {
+ /// helper data structure for returning the result
+ struct DRAWINGLAYER_DLLPUBLIC TextAsPolygonDataNode
+ {
+ private:
+ basegfx::B2DPolyPolygon maB2DPolyPolygon;
+ basegfx::BColor maBColor;
+ bool mbIsFilled;
+
+ public:
+ TextAsPolygonDataNode(
+ basegfx::B2DPolyPolygon aB2DPolyPolygon,
+ const basegfx::BColor& rBColor,
+ bool bIsFilled)
+ : maB2DPolyPolygon(std::move(aB2DPolyPolygon)),
+ maBColor(rBColor),
+ mbIsFilled(bIsFilled)
+ {
+ }
+
+ // data read access
+ const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maB2DPolyPolygon; }
+ const basegfx::BColor& getBColor() const { return maBColor; }
+ bool getIsFilled() const { return mbIsFilled; }
+ };
+
+ /// typedef for a vector of that helper data
+ typedef ::std::vector< TextAsPolygonDataNode > TextAsPolygonDataNodeVector;
+
+ /** TextAsPolygonExtractor2D class
+
+ This processor extracts text in the fed primitives to filled polygons
+ */
+ class DRAWINGLAYER_DLLPUBLIC TextAsPolygonExtractor2D final : public BaseProcessor2D
+ {
+ private:
+ // extraction target
+ TextAsPolygonDataNodeVector maTarget;
+
+ // the modifiedColorPrimitive stack
+ basegfx::BColorModifierStack maBColorModifierStack;
+
+ // flag if we are in a decomposed text
+ sal_uInt32 mnInText;
+
+ // tooling methods
+ void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) override;
+
+ public:
+ explicit TextAsPolygonExtractor2D(const geometry::ViewInformation2D& rViewInformation);
+ virtual ~TextAsPolygonExtractor2D() override;
+
+ // data read access
+ const TextAsPolygonDataNodeVector& getTarget() const { return maTarget; }
+ };
+
+} // end of namespace drawinglayer::processor2d
+
+
+#endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_TEXTASPOLYGONEXTRACTOR2D_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */