1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLGRADIENTPRIMITIVE2D_HXX
25 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLGRADIENTPRIMITIVE2D_HXX
26 
27 #include <drawinglayer/drawinglayerdllapi.h>
28 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
29 #include <drawinglayer/attribute/fillgradientattribute.hxx>
30 #include <drawinglayer/texture/texture.hxx>
31 
32 //////////////////////////////////////////////////////////////////////////////
33 // predefines
34 
35 namespace basegfx { class B2DPolygon; }
36 
37 //////////////////////////////////////////////////////////////////////////////
38 // FillGradientPrimitive2D class
39 
40 namespace drawinglayer
41 {
42 	namespace primitive2d
43 	{
44         /** FillGradientPrimitive2D class
45 
46             This class defines a gradient filling for a rectangular area. The
47             Range is defined by the Transformation, the gradient by the FillGradientAttribute.
48 
49             The decomposition will deliver the decomposed gradient, e.g. for an ellipse
50             gradient the various ellipses in various color steps will be created.
51 
52             I have added functionality to create both versions of filled decompositions:
53             Those who overlap and non-overlapping ones. The overlapping version is the
54             default one since it works with and without AntiAliasing. The non-overlapping
55             version is used in the MetafilePrimitive2D decomposition when the old XOR
56             paint was recorded.
57          */
58 		class DRAWINGLAYER_DLLPUBLIC FillGradientPrimitive2D : public BufferedDecompositionPrimitive2D
59 		{
60 		private:
61             /// the geometric definition
62 			basegfx::B2DRange						maObjectRange;
63 
64             /// the gradient definition
65 			attribute::FillGradientAttribute		maFillGradient;
66 
67             /// local helpers
68             void generateMatricesAndColors(
69                 std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries,
70                 basegfx::BColor& rOutmostColor) const;
71             Primitive2DSequence createOverlappingFill(
72                 const std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries,
73                 const basegfx::BColor& rOutmostColor,
74                 const basegfx::B2DPolygon& rUnitPolygon) const;
75             Primitive2DSequence createNonOverlappingFill(
76                 const std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries,
77                 const basegfx::BColor& rOutmostColor,
78                 const basegfx::B2DPolygon& rUnitPolygon) const;
79 
80 		protected:
81             /// local helper
82     		Primitive2DSequence createFill(bool bOverlapping) const;
83 
84             /// local decomposition.
85 			virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
86 
87 		public:
88             /// constructor
89 			FillGradientPrimitive2D(
90 				const basegfx::B2DRange& rObjectRange,
91 				const attribute::FillGradientAttribute& rFillGradient);
92 
93 			/// data read access
getObjectRange() const94 			const basegfx::B2DRange& getObjectRange() const { return maObjectRange; }
getFillGradient() const95 			const attribute::FillGradientAttribute& getFillGradient() const { return maFillGradient; }
96 
97 			/// compare operator
98 			virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
99 
100 			/// get range
101 			virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
102 
103 			/// provide unique ID
104 			DeclPrimitrive2DIDBlock()
105 		};
106 	} // end of namespace primitive2d
107 } // end of namespace drawinglayer
108 
109 //////////////////////////////////////////////////////////////////////////////
110 
111 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLGRADIENTPRIMITIVE2D_HXX
112 
113 //////////////////////////////////////////////////////////////////////////////
114 // eof
115