1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLGRADIENTPRIMITIVE2D_HXX
21 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLGRADIENTPRIMITIVE2D_HXX
23 #include <drawinglayer/drawinglayerdllapi.h>
25 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
26 #include <drawinglayer/attribute/fillgradientattribute.hxx>
31 namespace basegfx
{ class B2DPolygon
; }
32 namespace drawinglayer
{ namespace texture
{ struct B2DHomMatrixAndBColor
; } }
35 // FillGradientPrimitive2D class
37 namespace drawinglayer
41 /** FillGradientPrimitive2D class
43 This class defines a gradient filling for a rectangular area. The
44 Range is defined by the Transformation, the gradient by the FillGradientAttribute.
46 The decomposition will deliver the decomposed gradient, e.g. for an ellipse
47 gradient the various ellipses in various color steps will be created.
49 I have added functionality to create both versions of filled decompositions:
50 Those who overlap and non-overlapping ones. The overlapping version is the
51 default one since it works with and without AntiAliasing. The non-overlapping
52 version is used in the MetafilePrimitive2D decomposition when the old XOR
55 class DRAWINGLAYER_DLLPUBLIC FillGradientPrimitive2D
: public BufferedDecompositionPrimitive2D
58 /// the geometrically visible area
59 basegfx::B2DRange maOutputRange
;
61 /// the area the gradient definition is based on
62 /// in the simplest case identical to OutputRange
63 basegfx::B2DRange maDefinitionRange
;
65 /// the gradient definition
66 attribute::FillGradientAttribute maFillGradient
;
69 void generateMatricesAndColors(
70 std::vector
< drawinglayer::texture::B2DHomMatrixAndBColor
>& rEntries
,
71 basegfx::BColor
& rOuterColor
) const;
72 void createOverlappingFill(
73 Primitive2DContainer
& rContainer
,
74 const std::vector
< drawinglayer::texture::B2DHomMatrixAndBColor
>& rEntries
,
75 const basegfx::BColor
& rOuterColor
,
76 const basegfx::B2DPolygon
& rUnitPolygon
) const;
77 void createNonOverlappingFill(
78 Primitive2DContainer
& rContainer
,
79 const std::vector
< drawinglayer::texture::B2DHomMatrixAndBColor
>& rEntries
,
80 const basegfx::BColor
& rOuterColor
,
81 const basegfx::B2DPolygon
& rUnitPolygon
) const;
85 void createFill(Primitive2DContainer
& rContainer
, bool bOverlapping
) const;
87 /// local decomposition.
88 virtual void create2DDecomposition(Primitive2DContainer
& rContainer
, const geometry::ViewInformation2D
& rViewInformation
) const override
;
91 /// constructors. The one without definition range will use output range as definition range
92 FillGradientPrimitive2D(
93 const basegfx::B2DRange
& rOutputRange
,
94 const attribute::FillGradientAttribute
& rFillGradient
);
95 FillGradientPrimitive2D(
96 const basegfx::B2DRange
& rOutputRange
,
97 const basegfx::B2DRange
& rDefinitionRange
,
98 const attribute::FillGradientAttribute
& rFillGradient
);
101 const basegfx::B2DRange
& getOutputRange() const { return maOutputRange
; }
102 const basegfx::B2DRange
& getDefinitionRange() const { return maDefinitionRange
; }
103 const attribute::FillGradientAttribute
& getFillGradient() const { return maFillGradient
; }
106 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const override
;
109 virtual basegfx::B2DRange
getB2DRange(const geometry::ViewInformation2D
& rViewInformation
) const override
;
111 /// provide unique ID
112 DeclPrimitive2DIDBlock()
114 } // end of namespace primitive2d
115 } // end of namespace drawinglayer
118 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLGRADIENTPRIMITIVE2D_HXX
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */