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