1464702f4SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3464702f4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4464702f4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5464702f4SAndrew Rist  * distributed with this work for additional information
6464702f4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7464702f4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8464702f4SAndrew Rist  * "License"); you may not use this file except in compliance
9464702f4SAndrew Rist  * with the License.  You may obtain a copy of the License at
10464702f4SAndrew Rist  *
11464702f4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12464702f4SAndrew Rist  *
13464702f4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14464702f4SAndrew Rist  * software distributed under the License is distributed on an
15464702f4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16464702f4SAndrew Rist  * KIND, either express or implied.  See the License for the
17464702f4SAndrew Rist  * specific language governing permissions and limitations
18464702f4SAndrew Rist  * under the License.
19464702f4SAndrew Rist  *
20464702f4SAndrew Rist  *************************************************************/
21464702f4SAndrew Rist 
22464702f4SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_drawinglayer.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <drawinglayer/primitive3d/textureprimitive3d.hxx>
28cdf0e10cSrcweir #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
29cdf0e10cSrcweir #include <basegfx/color/bcolor.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
32cdf0e10cSrcweir 
33cdf0e10cSrcweir using namespace com::sun::star;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace drawinglayer
38cdf0e10cSrcweir {
39cdf0e10cSrcweir 	namespace primitive3d
40cdf0e10cSrcweir 	{
TexturePrimitive3D(const Primitive3DSequence & rChildren,const basegfx::B2DVector & rTextureSize,bool bModulate,bool bFilter)41cdf0e10cSrcweir 		TexturePrimitive3D::TexturePrimitive3D(
42cdf0e10cSrcweir 			const Primitive3DSequence& rChildren,
43cdf0e10cSrcweir 			const basegfx::B2DVector& rTextureSize,
44cdf0e10cSrcweir 			bool bModulate, bool bFilter)
45cdf0e10cSrcweir 		:	GroupPrimitive3D(rChildren),
46cdf0e10cSrcweir 			maTextureSize(rTextureSize),
47cdf0e10cSrcweir 			mbModulate(bModulate),
48cdf0e10cSrcweir 			mbFilter(bFilter)
49cdf0e10cSrcweir 		{
50cdf0e10cSrcweir 		}
51cdf0e10cSrcweir 
operator ==(const BasePrimitive3D & rPrimitive) const52cdf0e10cSrcweir 		bool TexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
53cdf0e10cSrcweir 		{
54cdf0e10cSrcweir 			if(GroupPrimitive3D::operator==(rPrimitive))
55cdf0e10cSrcweir 			{
56cdf0e10cSrcweir 				const TexturePrimitive3D& rCompare = (TexturePrimitive3D&)rPrimitive;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 				return (getModulate() == rCompare.getModulate()
59cdf0e10cSrcweir 					&& getFilter() == rCompare.getFilter());
60cdf0e10cSrcweir 			}
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 			return false;
63cdf0e10cSrcweir 		}
64cdf0e10cSrcweir 	} // end of namespace primitive3d
65cdf0e10cSrcweir } // end of namespace drawinglayer
66cdf0e10cSrcweir 
67cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
68cdf0e10cSrcweir 
69cdf0e10cSrcweir namespace drawinglayer
70cdf0e10cSrcweir {
71cdf0e10cSrcweir 	namespace primitive3d
72cdf0e10cSrcweir 	{
UnifiedTransparenceTexturePrimitive3D(double fTransparence,const Primitive3DSequence & rChildren)73cdf0e10cSrcweir 		UnifiedTransparenceTexturePrimitive3D::UnifiedTransparenceTexturePrimitive3D(
74cdf0e10cSrcweir 			double fTransparence,
75cdf0e10cSrcweir 			const Primitive3DSequence& rChildren)
76cdf0e10cSrcweir 		:	TexturePrimitive3D(rChildren, basegfx::B2DVector(), false, false),
77cdf0e10cSrcweir 			mfTransparence(fTransparence)
78cdf0e10cSrcweir 		{
79cdf0e10cSrcweir 		}
80cdf0e10cSrcweir 
operator ==(const BasePrimitive3D & rPrimitive) const81cdf0e10cSrcweir 		bool UnifiedTransparenceTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
82cdf0e10cSrcweir 		{
83cdf0e10cSrcweir 			if(TexturePrimitive3D::operator==(rPrimitive))
84cdf0e10cSrcweir 			{
85cdf0e10cSrcweir 				const UnifiedTransparenceTexturePrimitive3D& rCompare = (UnifiedTransparenceTexturePrimitive3D&)rPrimitive;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 				return (getTransparence() == rCompare.getTransparence());
88cdf0e10cSrcweir 			}
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 			return false;
91cdf0e10cSrcweir 		}
92cdf0e10cSrcweir 
getB3DRange(const geometry::ViewInformation3D & rViewInformation) const93cdf0e10cSrcweir 		basegfx::B3DRange UnifiedTransparenceTexturePrimitive3D::getB3DRange(const geometry::ViewInformation3D& rViewInformation) const
94cdf0e10cSrcweir         {
95cdf0e10cSrcweir             // do not use the fallback to decomposition here since for a correct BoundRect we also
96cdf0e10cSrcweir             // need invisible (1.0 == getTransparence()) geometry; these would be deleted in the decomposition
97cdf0e10cSrcweir 			return getB3DRangeFromPrimitive3DSequence(getChildren(), rViewInformation);
98cdf0e10cSrcweir         }
99cdf0e10cSrcweir 
get3DDecomposition(const geometry::ViewInformation3D &) const100cdf0e10cSrcweir         Primitive3DSequence UnifiedTransparenceTexturePrimitive3D::get3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const
101cdf0e10cSrcweir 		{
102cdf0e10cSrcweir 			if(0.0 == getTransparence())
103cdf0e10cSrcweir 			{
104cdf0e10cSrcweir 				// no transparence used, so just use content
105cdf0e10cSrcweir 				return getChildren();
106cdf0e10cSrcweir 			}
107cdf0e10cSrcweir 			else if(getTransparence() > 0.0 && getTransparence() < 1.0)
108cdf0e10cSrcweir 			{
109cdf0e10cSrcweir 				// create TransparenceTexturePrimitive3D with fixed transparence as replacement
110cdf0e10cSrcweir 				const basegfx::BColor aGray(getTransparence(), getTransparence(), getTransparence());
111cdf0e10cSrcweir 				const attribute::FillGradientAttribute aFillGradient(attribute::GRADIENTSTYLE_LINEAR, 0.0, 0.0, 0.0, 0.0, aGray, aGray, 1);
112cdf0e10cSrcweir 				const Primitive3DReference xRef(new TransparenceTexturePrimitive3D(aFillGradient, getChildren(), getTextureSize()));
113cdf0e10cSrcweir 				return Primitive3DSequence(&xRef, 1L);
114cdf0e10cSrcweir 			}
115cdf0e10cSrcweir 			else
116cdf0e10cSrcweir 			{
117cdf0e10cSrcweir 				// completely transparent or invalid definition, add nothing
118cdf0e10cSrcweir 				return Primitive3DSequence();
119cdf0e10cSrcweir 			}
120cdf0e10cSrcweir 		}
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 		// provide unique ID
123cdf0e10cSrcweir 		ImplPrimitrive3DIDBlock(UnifiedTransparenceTexturePrimitive3D, PRIMITIVE3D_ID_UNIFIEDTRANSPARENCETEXTUREPRIMITIVE3D)
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 	} // end of namespace primitive3d
126cdf0e10cSrcweir } // end of namespace drawinglayer
127cdf0e10cSrcweir 
128cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
129cdf0e10cSrcweir 
130cdf0e10cSrcweir namespace drawinglayer
131cdf0e10cSrcweir {
132cdf0e10cSrcweir 	namespace primitive3d
133cdf0e10cSrcweir 	{
GradientTexturePrimitive3D(const attribute::FillGradientAttribute & rGradient,const Primitive3DSequence & rChildren,const basegfx::B2DVector & rTextureSize,bool bModulate,bool bFilter)134cdf0e10cSrcweir 		GradientTexturePrimitive3D::GradientTexturePrimitive3D(
135cdf0e10cSrcweir 			const attribute::FillGradientAttribute& rGradient,
136cdf0e10cSrcweir 			const Primitive3DSequence& rChildren,
137cdf0e10cSrcweir 			const basegfx::B2DVector& rTextureSize,
138cdf0e10cSrcweir 			bool bModulate,
139cdf0e10cSrcweir 			bool bFilter)
140cdf0e10cSrcweir 		:	TexturePrimitive3D(rChildren, rTextureSize, bModulate, bFilter),
141cdf0e10cSrcweir 			maGradient(rGradient)
142cdf0e10cSrcweir 		{
143cdf0e10cSrcweir 		}
144cdf0e10cSrcweir 
operator ==(const BasePrimitive3D & rPrimitive) const145cdf0e10cSrcweir 		bool GradientTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
146cdf0e10cSrcweir 		{
147cdf0e10cSrcweir 			if(TexturePrimitive3D::operator==(rPrimitive))
148cdf0e10cSrcweir 			{
149cdf0e10cSrcweir 				const GradientTexturePrimitive3D& rCompare = (GradientTexturePrimitive3D&)rPrimitive;
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 				return (getGradient() == rCompare.getGradient());
152cdf0e10cSrcweir 			}
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 			return false;
155cdf0e10cSrcweir 		}
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 		// provide unique ID
158cdf0e10cSrcweir 		ImplPrimitrive3DIDBlock(GradientTexturePrimitive3D, PRIMITIVE3D_ID_GRADIENTTEXTUREPRIMITIVE3D)
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 	} // end of namespace primitive3d
161cdf0e10cSrcweir } // end of namespace drawinglayer
162cdf0e10cSrcweir 
163cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
164cdf0e10cSrcweir 
165cdf0e10cSrcweir namespace drawinglayer
166cdf0e10cSrcweir {
167cdf0e10cSrcweir 	namespace primitive3d
168cdf0e10cSrcweir 	{
BitmapTexturePrimitive3D(const attribute::FillGraphicAttribute & rFillGraphicAttribute,const Primitive3DSequence & rChildren,const basegfx::B2DVector & rTextureSize,bool bModulate,bool bFilter)169cdf0e10cSrcweir 		BitmapTexturePrimitive3D::BitmapTexturePrimitive3D(
170*035a2f44SArmin Le Grand 			const attribute::FillGraphicAttribute& rFillGraphicAttribute,
171cdf0e10cSrcweir 			const Primitive3DSequence& rChildren,
172cdf0e10cSrcweir 			const basegfx::B2DVector& rTextureSize,
173cdf0e10cSrcweir 			bool bModulate, bool bFilter)
174cdf0e10cSrcweir 		:	TexturePrimitive3D(rChildren, rTextureSize, bModulate, bFilter),
175*035a2f44SArmin Le Grand 			maFillGraphicAttribute(rFillGraphicAttribute)
176cdf0e10cSrcweir 		{
177cdf0e10cSrcweir 		}
178cdf0e10cSrcweir 
operator ==(const BasePrimitive3D & rPrimitive) const179cdf0e10cSrcweir 		bool BitmapTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
180cdf0e10cSrcweir 		{
181cdf0e10cSrcweir 			if(TexturePrimitive3D::operator==(rPrimitive))
182cdf0e10cSrcweir 			{
183cdf0e10cSrcweir 				const BitmapTexturePrimitive3D& rCompare = (BitmapTexturePrimitive3D&)rPrimitive;
184cdf0e10cSrcweir 
185*035a2f44SArmin Le Grand 				return (getFillGraphicAttribute() == rCompare.getFillGraphicAttribute());
186cdf0e10cSrcweir 			}
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 			return false;
189cdf0e10cSrcweir 		}
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 		// provide unique ID
192cdf0e10cSrcweir 		ImplPrimitrive3DIDBlock(BitmapTexturePrimitive3D, PRIMITIVE3D_ID_BITMAPTEXTUREPRIMITIVE3D)
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 	} // end of namespace primitive3d
195cdf0e10cSrcweir } // end of namespace drawinglayer
196cdf0e10cSrcweir 
197cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
198cdf0e10cSrcweir 
199cdf0e10cSrcweir namespace drawinglayer
200cdf0e10cSrcweir {
201cdf0e10cSrcweir 	namespace primitive3d
202cdf0e10cSrcweir 	{
TransparenceTexturePrimitive3D(const attribute::FillGradientAttribute & rGradient,const Primitive3DSequence & rChildren,const basegfx::B2DVector & rTextureSize)203cdf0e10cSrcweir 		TransparenceTexturePrimitive3D::TransparenceTexturePrimitive3D(
204cdf0e10cSrcweir 			const attribute::FillGradientAttribute& rGradient,
205cdf0e10cSrcweir 			const Primitive3DSequence& rChildren,
206cdf0e10cSrcweir 			const basegfx::B2DVector& rTextureSize)
207cdf0e10cSrcweir 		:	GradientTexturePrimitive3D(rGradient, rChildren, rTextureSize, false, false)
208cdf0e10cSrcweir 		{
209cdf0e10cSrcweir 		}
210cdf0e10cSrcweir 
operator ==(const BasePrimitive3D & rPrimitive) const211cdf0e10cSrcweir 		bool TransparenceTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
212cdf0e10cSrcweir 		{
213cdf0e10cSrcweir 			return (GradientTexturePrimitive3D::operator==(rPrimitive));
214cdf0e10cSrcweir 		}
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 		// provide unique ID
217cdf0e10cSrcweir 		ImplPrimitrive3DIDBlock(TransparenceTexturePrimitive3D, PRIMITIVE3D_ID_TRANSPARENCETEXTUREPRIMITIVE3D)
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 	} // end of namespace primitive3d
220cdf0e10cSrcweir } // end of namespace drawinglayer
221cdf0e10cSrcweir 
222cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
223cdf0e10cSrcweir // eof
224