Update ooo320-m1
[ooovba.git] / drawinglayer / source / primitive3d / textureprimitive3d.cxx
blob4063ee299f1fb8c10113b85adbf0d9f24746fd05
1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: textureprimitive3d.cxx,v $
7 * $Revision: 1.9 $
9 * last change: $Author: aw $ $Date: 2008-06-10 09:29:33 $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 * MA 02111-1307 USA
34 ************************************************************************/
36 // MARKER(update_precomp.py): autogen include statement, do not remove
37 #include "precompiled_drawinglayer.hxx"
39 #include <drawinglayer/primitive3d/textureprimitive3d.hxx>
40 #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
42 //////////////////////////////////////////////////////////////////////////////
44 using namespace com::sun::star;
46 //////////////////////////////////////////////////////////////////////////////
48 namespace drawinglayer
50 namespace primitive3d
52 TexturePrimitive3D::TexturePrimitive3D(
53 const Primitive3DSequence& rChildren,
54 const basegfx::B2DVector& rTextureSize,
55 bool bModulate, bool bFilter)
56 : GroupPrimitive3D(rChildren),
57 maTextureSize(rTextureSize),
58 mbModulate(bModulate),
59 mbFilter(bFilter)
63 bool TexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
65 if(GroupPrimitive3D::operator==(rPrimitive))
67 const TexturePrimitive3D& rCompare = (TexturePrimitive3D&)rPrimitive;
69 return (getModulate() == rCompare.getModulate()
70 && getFilter() == rCompare.getFilter());
73 return false;
75 } // end of namespace primitive3d
76 } // end of namespace drawinglayer
78 //////////////////////////////////////////////////////////////////////////////
80 namespace drawinglayer
82 namespace primitive3d
84 Primitive3DSequence UnifiedAlphaTexturePrimitive3D::createLocalDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const
86 if(0.0 == getTransparence())
88 // no transparence used, so just use content
89 return getChildren();
91 else if(getTransparence() > 0.0 && getTransparence() < 1.0)
93 // create AlphaTexturePrimitive3D with fixed transparence as replacement
94 const basegfx::BColor aGray(getTransparence(), getTransparence(), getTransparence());
95 const attribute::FillGradientAttribute aFillGradient(attribute::GRADIENTSTYLE_LINEAR, 0.0, 0.0, 0.0, 0.0, aGray, aGray, 1);
96 const Primitive3DReference xRef(new AlphaTexturePrimitive3D(aFillGradient, getChildren(), getTextureSize()));
97 return Primitive3DSequence(&xRef, 1L);
99 else
101 // completely transparent or invalid definition, add nothing
102 return Primitive3DSequence();
106 UnifiedAlphaTexturePrimitive3D::UnifiedAlphaTexturePrimitive3D(
107 double fTransparence,
108 const Primitive3DSequence& rChildren)
109 : TexturePrimitive3D(rChildren, basegfx::B2DVector(), false, false),
110 mfTransparence(fTransparence)
114 bool UnifiedAlphaTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
116 if(TexturePrimitive3D::operator==(rPrimitive))
118 const UnifiedAlphaTexturePrimitive3D& rCompare = (UnifiedAlphaTexturePrimitive3D&)rPrimitive;
120 return (getTransparence() == rCompare.getTransparence());
123 return false;
126 // provide unique ID
127 ImplPrimitrive3DIDBlock(UnifiedAlphaTexturePrimitive3D, PRIMITIVE3D_ID_UNIFIEDALPHATEXTUREPRIMITIVE3D)
129 } // end of namespace primitive3d
130 } // end of namespace drawinglayer
132 //////////////////////////////////////////////////////////////////////////////
134 namespace drawinglayer
136 namespace primitive3d
138 Primitive3DSequence GradientTexturePrimitive3D::createLocalDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const
140 return getChildren();
143 GradientTexturePrimitive3D::GradientTexturePrimitive3D(
144 const attribute::FillGradientAttribute& rGradient,
145 const Primitive3DSequence& rChildren,
146 const basegfx::B2DVector& rTextureSize,
147 bool bModulate,
148 bool bFilter)
149 : TexturePrimitive3D(rChildren, rTextureSize, bModulate, bFilter),
150 maGradient(rGradient)
154 bool GradientTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
156 if(TexturePrimitive3D::operator==(rPrimitive))
158 const GradientTexturePrimitive3D& rCompare = (GradientTexturePrimitive3D&)rPrimitive;
160 return (getGradient() == rCompare.getGradient());
163 return false;
166 // provide unique ID
167 ImplPrimitrive3DIDBlock(GradientTexturePrimitive3D, PRIMITIVE3D_ID_GRADIENTTEXTUREPRIMITIVE3D)
169 } // end of namespace primitive3d
170 } // end of namespace drawinglayer
172 //////////////////////////////////////////////////////////////////////////////
174 namespace drawinglayer
176 namespace primitive3d
178 Primitive3DSequence BitmapTexturePrimitive3D::createLocalDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const
180 return getChildren();
183 BitmapTexturePrimitive3D::BitmapTexturePrimitive3D(
184 const attribute::FillBitmapAttribute& rBitmap,
185 const Primitive3DSequence& rChildren,
186 const basegfx::B2DVector& rTextureSize,
187 bool bModulate, bool bFilter)
188 : TexturePrimitive3D(rChildren, rTextureSize, bModulate, bFilter),
189 maBitmap(rBitmap)
193 bool BitmapTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
195 if(TexturePrimitive3D::operator==(rPrimitive))
197 const BitmapTexturePrimitive3D& rCompare = (BitmapTexturePrimitive3D&)rPrimitive;
199 return (getBitmap() == rCompare.getBitmap());
202 return false;
205 // provide unique ID
206 ImplPrimitrive3DIDBlock(BitmapTexturePrimitive3D, PRIMITIVE3D_ID_BITMAPTEXTUREPRIMITIVE3D)
208 } // end of namespace primitive3d
209 } // end of namespace drawinglayer
211 //////////////////////////////////////////////////////////////////////////////
213 namespace drawinglayer
215 namespace primitive3d
217 AlphaTexturePrimitive3D::AlphaTexturePrimitive3D(
218 const attribute::FillGradientAttribute& rGradient,
219 const Primitive3DSequence& rChildren,
220 const basegfx::B2DVector& rTextureSize)
221 : GradientTexturePrimitive3D(rGradient, rChildren, rTextureSize, false, false)
225 bool AlphaTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
227 return (GradientTexturePrimitive3D::operator==(rPrimitive));
230 // provide unique ID
231 ImplPrimitrive3DIDBlock(AlphaTexturePrimitive3D, PRIMITIVE3D_ID_ALPHATEXTUREPRIMITIVE3D)
233 } // end of namespace primitive3d
234 } // end of namespace drawinglayer
236 //////////////////////////////////////////////////////////////////////////////
237 // eof