1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_drawinglayer.hxx"
30 
31 #include <drawinglayer/primitive3d/textureprimitive3d.hxx>
32 #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
33 #include <basegfx/color/bcolor.hxx>
34 
35 //////////////////////////////////////////////////////////////////////////////
36 
37 using namespace com::sun::star;
38 
39 //////////////////////////////////////////////////////////////////////////////
40 
41 namespace drawinglayer
42 {
43 	namespace primitive3d
44 	{
45 		TexturePrimitive3D::TexturePrimitive3D(
46 			const Primitive3DSequence& rChildren,
47 			const basegfx::B2DVector& rTextureSize,
48 			bool bModulate, bool bFilter)
49 		:	GroupPrimitive3D(rChildren),
50 			maTextureSize(rTextureSize),
51 			mbModulate(bModulate),
52 			mbFilter(bFilter)
53 		{
54 		}
55 
56 		bool TexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
57 		{
58 			if(GroupPrimitive3D::operator==(rPrimitive))
59 			{
60 				const TexturePrimitive3D& rCompare = (TexturePrimitive3D&)rPrimitive;
61 
62 				return (getModulate() == rCompare.getModulate()
63 					&& getFilter() == rCompare.getFilter());
64 			}
65 
66 			return false;
67 		}
68 	} // end of namespace primitive3d
69 } // end of namespace drawinglayer
70 
71 //////////////////////////////////////////////////////////////////////////////
72 
73 namespace drawinglayer
74 {
75 	namespace primitive3d
76 	{
77 		UnifiedTransparenceTexturePrimitive3D::UnifiedTransparenceTexturePrimitive3D(
78 			double fTransparence,
79 			const Primitive3DSequence& rChildren)
80 		:	TexturePrimitive3D(rChildren, basegfx::B2DVector(), false, false),
81 			mfTransparence(fTransparence)
82 		{
83 		}
84 
85 		bool UnifiedTransparenceTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
86 		{
87 			if(TexturePrimitive3D::operator==(rPrimitive))
88 			{
89 				const UnifiedTransparenceTexturePrimitive3D& rCompare = (UnifiedTransparenceTexturePrimitive3D&)rPrimitive;
90 
91 				return (getTransparence() == rCompare.getTransparence());
92 			}
93 
94 			return false;
95 		}
96 
97 		basegfx::B3DRange UnifiedTransparenceTexturePrimitive3D::getB3DRange(const geometry::ViewInformation3D& rViewInformation) const
98         {
99             // do not use the fallback to decomposition here since for a correct BoundRect we also
100             // need invisible (1.0 == getTransparence()) geometry; these would be deleted in the decomposition
101 			return getB3DRangeFromPrimitive3DSequence(getChildren(), rViewInformation);
102         }
103 
104         Primitive3DSequence UnifiedTransparenceTexturePrimitive3D::get3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const
105 		{
106 			if(0.0 == getTransparence())
107 			{
108 				// no transparence used, so just use content
109 				return getChildren();
110 			}
111 			else if(getTransparence() > 0.0 && getTransparence() < 1.0)
112 			{
113 				// create TransparenceTexturePrimitive3D with fixed transparence as replacement
114 				const basegfx::BColor aGray(getTransparence(), getTransparence(), getTransparence());
115 				const attribute::FillGradientAttribute aFillGradient(attribute::GRADIENTSTYLE_LINEAR, 0.0, 0.0, 0.0, 0.0, aGray, aGray, 1);
116 				const Primitive3DReference xRef(new TransparenceTexturePrimitive3D(aFillGradient, getChildren(), getTextureSize()));
117 				return Primitive3DSequence(&xRef, 1L);
118 			}
119 			else
120 			{
121 				// completely transparent or invalid definition, add nothing
122 				return Primitive3DSequence();
123 			}
124 		}
125 
126 		// provide unique ID
127 		ImplPrimitrive3DIDBlock(UnifiedTransparenceTexturePrimitive3D, PRIMITIVE3D_ID_UNIFIEDTRANSPARENCETEXTUREPRIMITIVE3D)
128 
129 	} // end of namespace primitive3d
130 } // end of namespace drawinglayer
131 
132 //////////////////////////////////////////////////////////////////////////////
133 
134 namespace drawinglayer
135 {
136 	namespace primitive3d
137 	{
138 		GradientTexturePrimitive3D::GradientTexturePrimitive3D(
139 			const attribute::FillGradientAttribute& rGradient,
140 			const Primitive3DSequence& rChildren,
141 			const basegfx::B2DVector& rTextureSize,
142 			bool bModulate,
143 			bool bFilter)
144 		:	TexturePrimitive3D(rChildren, rTextureSize, bModulate, bFilter),
145 			maGradient(rGradient)
146 		{
147 		}
148 
149 		bool GradientTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
150 		{
151 			if(TexturePrimitive3D::operator==(rPrimitive))
152 			{
153 				const GradientTexturePrimitive3D& rCompare = (GradientTexturePrimitive3D&)rPrimitive;
154 
155 				return (getGradient() == rCompare.getGradient());
156 			}
157 
158 			return false;
159 		}
160 
161 		// provide unique ID
162 		ImplPrimitrive3DIDBlock(GradientTexturePrimitive3D, PRIMITIVE3D_ID_GRADIENTTEXTUREPRIMITIVE3D)
163 
164 	} // end of namespace primitive3d
165 } // end of namespace drawinglayer
166 
167 //////////////////////////////////////////////////////////////////////////////
168 
169 namespace drawinglayer
170 {
171 	namespace primitive3d
172 	{
173 		BitmapTexturePrimitive3D::BitmapTexturePrimitive3D(
174 			const attribute::FillBitmapAttribute& rFillBitmapAttribute,
175 			const Primitive3DSequence& rChildren,
176 			const basegfx::B2DVector& rTextureSize,
177 			bool bModulate, bool bFilter)
178 		:	TexturePrimitive3D(rChildren, rTextureSize, bModulate, bFilter),
179 			maFillBitmapAttribute(rFillBitmapAttribute)
180 		{
181 		}
182 
183 		bool BitmapTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
184 		{
185 			if(TexturePrimitive3D::operator==(rPrimitive))
186 			{
187 				const BitmapTexturePrimitive3D& rCompare = (BitmapTexturePrimitive3D&)rPrimitive;
188 
189 				return (getFillBitmapAttribute() == rCompare.getFillBitmapAttribute());
190 			}
191 
192 			return false;
193 		}
194 
195 		// provide unique ID
196 		ImplPrimitrive3DIDBlock(BitmapTexturePrimitive3D, PRIMITIVE3D_ID_BITMAPTEXTUREPRIMITIVE3D)
197 
198 	} // end of namespace primitive3d
199 } // end of namespace drawinglayer
200 
201 //////////////////////////////////////////////////////////////////////////////
202 
203 namespace drawinglayer
204 {
205 	namespace primitive3d
206 	{
207 		TransparenceTexturePrimitive3D::TransparenceTexturePrimitive3D(
208 			const attribute::FillGradientAttribute& rGradient,
209 			const Primitive3DSequence& rChildren,
210 			const basegfx::B2DVector& rTextureSize)
211 		:	GradientTexturePrimitive3D(rGradient, rChildren, rTextureSize, false, false)
212 		{
213 		}
214 
215 		bool TransparenceTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
216 		{
217 			return (GradientTexturePrimitive3D::operator==(rPrimitive));
218 		}
219 
220 		// provide unique ID
221 		ImplPrimitrive3DIDBlock(TransparenceTexturePrimitive3D, PRIMITIVE3D_ID_TRANSPARENCETEXTUREPRIMITIVE3D)
222 
223 	} // end of namespace primitive3d
224 } // end of namespace drawinglayer
225 
226 //////////////////////////////////////////////////////////////////////////////
227 // eof
228