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>
3096fc4b33SArmin 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          */
58*64b14621SArmin Le Grand         class DRAWINGLAYER_DLLPUBLIC FillGradientPrimitive2D : public BufferedDecompositionPrimitive2D
59*64b14621SArmin Le Grand         {
60*64b14621SArmin Le Grand         private:
61*64b14621SArmin Le Grand             /// the geometrically visible area
62*64b14621SArmin Le Grand             basegfx::B2DRange                       maOutputRange;
63*64b14621SArmin Le Grand 
64*64b14621SArmin Le Grand             /// the area the gradient definition is based on
65*64b14621SArmin Le Grand             /// in the simplest case identical to OutputRange
66*64b14621SArmin Le Grand             basegfx::B2DRange                       maDefinitionRange;
67cdf0e10cSrcweir 
68cdf0e10cSrcweir             /// the gradient definition
69*64b14621SArmin Le Grand             attribute::FillGradientAttribute        maFillGradient;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir             /// local helpers
72cdf0e10cSrcweir             void generateMatricesAndColors(
7396fc4b33SArmin Le Grand                 std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries,
74*64b14621SArmin Le Grand                 basegfx::BColor& rOuterColor) const;
75cdf0e10cSrcweir             Primitive2DSequence createOverlappingFill(
7696fc4b33SArmin Le Grand                 const std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries,
77*64b14621SArmin Le Grand                 const basegfx::BColor& rOuterColor,
78cdf0e10cSrcweir                 const basegfx::B2DPolygon& rUnitPolygon) const;
79cdf0e10cSrcweir             Primitive2DSequence createNonOverlappingFill(
8096fc4b33SArmin Le Grand                 const std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries,
81*64b14621SArmin Le Grand                 const basegfx::BColor& rOuterColor,
82cdf0e10cSrcweir                 const basegfx::B2DPolygon& rUnitPolygon) const;
83cdf0e10cSrcweir 
84*64b14621SArmin Le Grand         protected:
85cdf0e10cSrcweir             /// local helper
86*64b14621SArmin Le Grand             Primitive2DSequence createFill(bool bOverlapping) const;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir             /// local decomposition.
89*64b14621SArmin Le Grand             virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
90*64b14621SArmin Le Grand 
91*64b14621SArmin Le Grand         public:
92*64b14621SArmin Le Grand             /// constructors. The one without definition range will use output range as definition range
93*64b14621SArmin Le Grand             FillGradientPrimitive2D(
94*64b14621SArmin Le Grand                 const basegfx::B2DRange& rOutputRange,
95*64b14621SArmin Le Grand                 const attribute::FillGradientAttribute& rFillGradient);
96*64b14621SArmin Le Grand             FillGradientPrimitive2D(
97*64b14621SArmin Le Grand                 const basegfx::B2DRange& rOutputRange,
98*64b14621SArmin Le Grand                 const basegfx::B2DRange& rDefinitionRange,
99*64b14621SArmin Le Grand                 const attribute::FillGradientAttribute& rFillGradient);
100*64b14621SArmin Le Grand 
101*64b14621SArmin Le Grand             /// data read access
getOutputRange() const102*64b14621SArmin Le Grand             const basegfx::B2DRange& getOutputRange() const { return maOutputRange; }
getDefinitionRange() const103*64b14621SArmin Le Grand             const basegfx::B2DRange& getDefinitionRange() const { return maDefinitionRange; }
getFillGradient() const104*64b14621SArmin Le Grand             const attribute::FillGradientAttribute& getFillGradient() const { return maFillGradient; }
105*64b14621SArmin Le Grand 
106*64b14621SArmin Le Grand             /// compare operator
107*64b14621SArmin Le Grand             virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
108*64b14621SArmin Le Grand 
109*64b14621SArmin Le Grand             /// get range
110*64b14621SArmin Le Grand             virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
111*64b14621SArmin Le Grand 
112*64b14621SArmin Le Grand             /// provide unique ID
113*64b14621SArmin Le Grand             DeclPrimitrive2DIDBlock()
114*64b14621SArmin Le Grand         };
115*64b14621SArmin Le Grand     } // end of namespace primitive2d
116cdf0e10cSrcweir } // end of namespace drawinglayer
117cdf0e10cSrcweir 
118cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
119cdf0e10cSrcweir 
120cdf0e10cSrcweir #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_FILLGRADIENTPRIMITIVE2D_HXX
121cdf0e10cSrcweir 
122cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
123cdf0e10cSrcweir // eof
124