use insert function instead of for loop
[LibreOffice.git] / include / drawinglayer / processor2d / d2dpixelprocessor2d.hxx
blobf3a564c8b2a56e3df86c182a0d47690d0f5f23d7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <drawinglayer/processor2d/baseprocessor2d.hxx>
23 #include <basegfx/color/bcolormodifier.hxx>
24 #include <systools/win32/comtools.hxx>
25 #include <sal/config.h>
27 // win-specific
28 #include <d2d1.h>
30 namespace drawinglayer::primitive2d
32 class PolyPolygonColorPrimitive2D;
33 class PolygonHairlinePrimitive2D;
34 class BitmapPrimitive2D;
35 class UnifiedTransparencePrimitive2D;
36 class BackgroundColorPrimitive2D;
37 class TransparencePrimitive2D;
38 class MaskPrimitive2D;
39 class ModifiedColorPrimitive2D;
40 class TransformPrimitive2D;
41 class PointArrayPrimitive2D;
42 class MarkerArrayPrimitive2D;
43 class PolygonStrokePrimitive2D;
44 class LineRectanglePrimitive2D;
45 class FilledRectanglePrimitive2D;
46 class SingleLinePrimitive2D;
47 class FillGraphicPrimitive2D;
48 class InvertPrimitive2D;
49 class FillGradientPrimitive2D;
52 namespace basegfx
54 class B2DHomMatrix;
55 class B2DPolyPolygon;
56 class BColor;
59 struct ID2D1RenderTarget;
60 struct ID2D1Factory;
62 namespace drawinglayer::processor2d
64 class DRAWINGLAYER_DLLPUBLIC D2DPixelProcessor2D : public BaseProcessor2D
66 // the modifiedColorPrimitive stack
67 basegfx::BColorModifierStack maBColorModifierStack;
69 // win and render specific data
70 sal::systools::COMReference<ID2D1RenderTarget> mpRT;
71 sal_uInt32 mnRecursionCounter;
72 sal_uInt32 mnErrorCounter;
74 // helpers for direct paints
75 void processPolygonHairlinePrimitive2D(
76 const primitive2d::PolygonHairlinePrimitive2D& rPolygonHairlinePrimitive2D);
77 void processPolyPolygonColorPrimitive2D(
78 const primitive2d::PolyPolygonColorPrimitive2D& rPolyPolygonColorPrimitive2D);
79 void processBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate);
80 void
81 processTransparencePrimitive2D(const primitive2d::TransparencePrimitive2D& rTransCandidate);
82 void processUnifiedTransparencePrimitive2D(
83 const primitive2d::UnifiedTransparencePrimitive2D& rTransCandidate);
84 void processMaskPrimitive2D(const primitive2d::MaskPrimitive2D& rMaskCandidate);
85 void processModifiedColorPrimitive2D(
86 const primitive2d::ModifiedColorPrimitive2D& rModifiedCandidate);
87 void processTransformPrimitive2D(const primitive2d::TransformPrimitive2D& rTransformCandidate);
88 void
89 processPointArrayPrimitive2D(const primitive2d::PointArrayPrimitive2D& rPointArrayCandidate);
90 void
91 processMarkerArrayPrimitive2D(const primitive2d::MarkerArrayPrimitive2D& rMarkerArrayCandidate);
92 void processBackgroundColorPrimitive2D(
93 const primitive2d::BackgroundColorPrimitive2D& rBackgroundColorCandidate);
94 void processPolygonStrokePrimitive2D(
95 const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokeCandidate);
96 void processLineRectanglePrimitive2D(
97 const primitive2d::LineRectanglePrimitive2D& rLineRectanglePrimitive2D);
98 void processFilledRectanglePrimitive2D(
99 const primitive2d::FilledRectanglePrimitive2D& rFilledRectanglePrimitive2D);
100 void
101 processSingleLinePrimitive2D(const primitive2d::SingleLinePrimitive2D& rSingleLinePrimitive2D);
102 void processFillGraphicPrimitive2D(
103 const primitive2d::FillGraphicPrimitive2D& rFillGraphicPrimitive2D);
104 void processInvertPrimitive2D(const primitive2d::InvertPrimitive2D& rInvertPrimitive2D);
105 void processFillGradientPrimitive2D(
106 const primitive2d::FillGradientPrimitive2D& rFillGradientPrimitive2D);
108 // common helpers
109 sal::systools::COMReference<ID2D1Bitmap>
110 implCreateAlpha_Direct(const primitive2d::TransparencePrimitive2D& rTransCandidate);
111 sal::systools::COMReference<ID2D1Bitmap>
112 implCreateAlpha_B2DBitmap(const primitive2d::TransparencePrimitive2D& rTransCandidate,
113 const basegfx::B2DRange& rVisibleRange,
114 D2D1_MATRIX_3X2_F& rMaskScale);
115 bool drawPolyPolygonColorTransformed(const basegfx::B2DHomMatrix& rTansformation,
116 const basegfx::B2DPolyPolygon& rPolyPolygon,
117 const basegfx::BColor& rColor);
119 /* the local processor for BasePrimitive2D-Implementation based primitives,
120 called from the common process()-implementation
122 virtual void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) override;
124 protected:
125 // local protected minimal constructor for usage in derivates, e.g. helpers
126 D2DPixelProcessor2D(const geometry::ViewInformation2D& rViewInformation);
128 // local protected minimal accessors for usage in derivates, e.g. helpers
129 void increaseError() { mnErrorCounter++; }
130 bool hasError() const { return 0 != mnErrorCounter; }
131 bool hasRenderTarget() const { return mpRT.is(); }
133 void setRenderTarget(const sal::systools::COMReference<ID2D1RenderTarget>& rNewRT)
135 mpRT = rNewRT;
137 sal::systools::COMReference<ID2D1RenderTarget>& getRenderTarget() { return mpRT; }
139 public:
140 bool valid() const { return hasRenderTarget() && !hasError(); }
141 D2DPixelProcessor2D(const geometry::ViewInformation2D& rViewInformation, HDC aHdc);
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */