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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_drawinglayer.hxx"
26 
27 #include <drawinglayer/primitive3d/textureprimitive3d.hxx>
28 #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
29 #include <basegfx/color/bcolor.hxx>
30 
31 //////////////////////////////////////////////////////////////////////////////
32 
33 using namespace com::sun::star;
34 
35 //////////////////////////////////////////////////////////////////////////////
36 
37 namespace drawinglayer
38 {
39 	namespace primitive3d
40 	{
TexturePrimitive3D(const Primitive3DSequence & rChildren,const basegfx::B2DVector & rTextureSize,bool bModulate,bool bFilter)41 		TexturePrimitive3D::TexturePrimitive3D(
42 			const Primitive3DSequence& rChildren,
43 			const basegfx::B2DVector& rTextureSize,
44 			bool bModulate, bool bFilter)
45 		:	GroupPrimitive3D(rChildren),
46 			maTextureSize(rTextureSize),
47 			mbModulate(bModulate),
48 			mbFilter(bFilter)
49 		{
50 		}
51 
operator ==(const BasePrimitive3D & rPrimitive) const52 		bool TexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
53 		{
54 			if(GroupPrimitive3D::operator==(rPrimitive))
55 			{
56 				const TexturePrimitive3D& rCompare = (TexturePrimitive3D&)rPrimitive;
57 
58 				return (getModulate() == rCompare.getModulate()
59 					&& getFilter() == rCompare.getFilter());
60 			}
61 
62 			return false;
63 		}
64 	} // end of namespace primitive3d
65 } // end of namespace drawinglayer
66 
67 //////////////////////////////////////////////////////////////////////////////
68 
69 namespace drawinglayer
70 {
71 	namespace primitive3d
72 	{
UnifiedTransparenceTexturePrimitive3D(double fTransparence,const Primitive3DSequence & rChildren)73 		UnifiedTransparenceTexturePrimitive3D::UnifiedTransparenceTexturePrimitive3D(
74 			double fTransparence,
75 			const Primitive3DSequence& rChildren)
76 		:	TexturePrimitive3D(rChildren, basegfx::B2DVector(), false, false),
77 			mfTransparence(fTransparence)
78 		{
79 		}
80 
operator ==(const BasePrimitive3D & rPrimitive) const81 		bool UnifiedTransparenceTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
82 		{
83 			if(TexturePrimitive3D::operator==(rPrimitive))
84 			{
85 				const UnifiedTransparenceTexturePrimitive3D& rCompare = (UnifiedTransparenceTexturePrimitive3D&)rPrimitive;
86 
87 				return (getTransparence() == rCompare.getTransparence());
88 			}
89 
90 			return false;
91 		}
92 
getB3DRange(const geometry::ViewInformation3D & rViewInformation) const93 		basegfx::B3DRange UnifiedTransparenceTexturePrimitive3D::getB3DRange(const geometry::ViewInformation3D& rViewInformation) const
94         {
95             // do not use the fallback to decomposition here since for a correct BoundRect we also
96             // need invisible (1.0 == getTransparence()) geometry; these would be deleted in the decomposition
97 			return getB3DRangeFromPrimitive3DSequence(getChildren(), rViewInformation);
98         }
99 
get3DDecomposition(const geometry::ViewInformation3D &) const100         Primitive3DSequence UnifiedTransparenceTexturePrimitive3D::get3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const
101 		{
102 			if(0.0 == getTransparence())
103 			{
104 				// no transparence used, so just use content
105 				return getChildren();
106 			}
107 			else if(getTransparence() > 0.0 && getTransparence() < 1.0)
108 			{
109 				// create TransparenceTexturePrimitive3D with fixed transparence as replacement
110 				const basegfx::BColor aGray(getTransparence(), getTransparence(), getTransparence());
111 				const attribute::FillGradientAttribute aFillGradient(attribute::GRADIENTSTYLE_LINEAR, 0.0, 0.0, 0.0, 0.0, aGray, aGray, 1);
112 				const Primitive3DReference xRef(new TransparenceTexturePrimitive3D(aFillGradient, getChildren(), getTextureSize()));
113 				return Primitive3DSequence(&xRef, 1L);
114 			}
115 			else
116 			{
117 				// completely transparent or invalid definition, add nothing
118 				return Primitive3DSequence();
119 			}
120 		}
121 
122 		// provide unique ID
123 		ImplPrimitrive3DIDBlock(UnifiedTransparenceTexturePrimitive3D, PRIMITIVE3D_ID_UNIFIEDTRANSPARENCETEXTUREPRIMITIVE3D)
124 
125 	} // end of namespace primitive3d
126 } // end of namespace drawinglayer
127 
128 //////////////////////////////////////////////////////////////////////////////
129 
130 namespace drawinglayer
131 {
132 	namespace primitive3d
133 	{
GradientTexturePrimitive3D(const attribute::FillGradientAttribute & rGradient,const Primitive3DSequence & rChildren,const basegfx::B2DVector & rTextureSize,bool bModulate,bool bFilter)134 		GradientTexturePrimitive3D::GradientTexturePrimitive3D(
135 			const attribute::FillGradientAttribute& rGradient,
136 			const Primitive3DSequence& rChildren,
137 			const basegfx::B2DVector& rTextureSize,
138 			bool bModulate,
139 			bool bFilter)
140 		:	TexturePrimitive3D(rChildren, rTextureSize, bModulate, bFilter),
141 			maGradient(rGradient)
142 		{
143 		}
144 
operator ==(const BasePrimitive3D & rPrimitive) const145 		bool GradientTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
146 		{
147 			if(TexturePrimitive3D::operator==(rPrimitive))
148 			{
149 				const GradientTexturePrimitive3D& rCompare = (GradientTexturePrimitive3D&)rPrimitive;
150 
151 				return (getGradient() == rCompare.getGradient());
152 			}
153 
154 			return false;
155 		}
156 
157 		// provide unique ID
158 		ImplPrimitrive3DIDBlock(GradientTexturePrimitive3D, PRIMITIVE3D_ID_GRADIENTTEXTUREPRIMITIVE3D)
159 
160 	} // end of namespace primitive3d
161 } // end of namespace drawinglayer
162 
163 //////////////////////////////////////////////////////////////////////////////
164 
165 namespace drawinglayer
166 {
167 	namespace primitive3d
168 	{
BitmapTexturePrimitive3D(const attribute::FillGraphicAttribute & rFillGraphicAttribute,const Primitive3DSequence & rChildren,const basegfx::B2DVector & rTextureSize,bool bModulate,bool bFilter)169 		BitmapTexturePrimitive3D::BitmapTexturePrimitive3D(
170 			const attribute::FillGraphicAttribute& rFillGraphicAttribute,
171 			const Primitive3DSequence& rChildren,
172 			const basegfx::B2DVector& rTextureSize,
173 			bool bModulate, bool bFilter)
174 		:	TexturePrimitive3D(rChildren, rTextureSize, bModulate, bFilter),
175 			maFillGraphicAttribute(rFillGraphicAttribute)
176 		{
177 		}
178 
operator ==(const BasePrimitive3D & rPrimitive) const179 		bool BitmapTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
180 		{
181 			if(TexturePrimitive3D::operator==(rPrimitive))
182 			{
183 				const BitmapTexturePrimitive3D& rCompare = (BitmapTexturePrimitive3D&)rPrimitive;
184 
185 				return (getFillGraphicAttribute() == rCompare.getFillGraphicAttribute());
186 			}
187 
188 			return false;
189 		}
190 
191 		// provide unique ID
192 		ImplPrimitrive3DIDBlock(BitmapTexturePrimitive3D, PRIMITIVE3D_ID_BITMAPTEXTUREPRIMITIVE3D)
193 
194 	} // end of namespace primitive3d
195 } // end of namespace drawinglayer
196 
197 //////////////////////////////////////////////////////////////////////////////
198 
199 namespace drawinglayer
200 {
201 	namespace primitive3d
202 	{
TransparenceTexturePrimitive3D(const attribute::FillGradientAttribute & rGradient,const Primitive3DSequence & rChildren,const basegfx::B2DVector & rTextureSize)203 		TransparenceTexturePrimitive3D::TransparenceTexturePrimitive3D(
204 			const attribute::FillGradientAttribute& rGradient,
205 			const Primitive3DSequence& rChildren,
206 			const basegfx::B2DVector& rTextureSize)
207 		:	GradientTexturePrimitive3D(rGradient, rChildren, rTextureSize, false, false)
208 		{
209 		}
210 
operator ==(const BasePrimitive3D & rPrimitive) const211 		bool TransparenceTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
212 		{
213 			return (GradientTexturePrimitive3D::operator==(rPrimitive));
214 		}
215 
216 		// provide unique ID
217 		ImplPrimitrive3DIDBlock(TransparenceTexturePrimitive3D, PRIMITIVE3D_ID_TRANSPARENCETEXTUREPRIMITIVE3D)
218 
219 	} // end of namespace primitive3d
220 } // end of namespace drawinglayer
221 
222 //////////////////////////////////////////////////////////////////////////////
223 // eof
224