1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <drawinglayer/primitive3d/textureprimitive3d.hxx>
30 #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
31 #include <basegfx/color/bcolor.hxx>
33 //////////////////////////////////////////////////////////////////////////////
35 using namespace com::sun::star
;
37 //////////////////////////////////////////////////////////////////////////////
39 namespace drawinglayer
43 TexturePrimitive3D::TexturePrimitive3D(
44 const Primitive3DSequence
& rChildren
,
45 const basegfx::B2DVector
& rTextureSize
,
46 bool bModulate
, bool bFilter
)
47 : GroupPrimitive3D(rChildren
),
48 maTextureSize(rTextureSize
),
49 mbModulate(bModulate
),
54 bool TexturePrimitive3D::operator==(const BasePrimitive3D
& rPrimitive
) const
56 if(GroupPrimitive3D::operator==(rPrimitive
))
58 const TexturePrimitive3D
& rCompare
= (TexturePrimitive3D
&)rPrimitive
;
60 return (getModulate() == rCompare
.getModulate()
61 && getFilter() == rCompare
.getFilter());
66 } // end of namespace primitive3d
67 } // end of namespace drawinglayer
69 //////////////////////////////////////////////////////////////////////////////
71 namespace drawinglayer
75 UnifiedTransparenceTexturePrimitive3D::UnifiedTransparenceTexturePrimitive3D(
77 const Primitive3DSequence
& rChildren
)
78 : TexturePrimitive3D(rChildren
, basegfx::B2DVector(), false, false),
79 mfTransparence(fTransparence
)
83 bool UnifiedTransparenceTexturePrimitive3D::operator==(const BasePrimitive3D
& rPrimitive
) const
85 if(TexturePrimitive3D::operator==(rPrimitive
))
87 const UnifiedTransparenceTexturePrimitive3D
& rCompare
= (UnifiedTransparenceTexturePrimitive3D
&)rPrimitive
;
89 return (getTransparence() == rCompare
.getTransparence());
95 basegfx::B3DRange
UnifiedTransparenceTexturePrimitive3D::getB3DRange(const geometry::ViewInformation3D
& rViewInformation
) const
97 // do not use the fallback to decomposition here since for a correct BoundRect we also
98 // need invisible (1.0 == getTransparence()) geometry; these would be deleted in the decomposition
99 return getB3DRangeFromPrimitive3DSequence(getChildren(), rViewInformation
);
102 Primitive3DSequence
UnifiedTransparenceTexturePrimitive3D::get3DDecomposition(const geometry::ViewInformation3D
& /*rViewInformation*/) const
104 if(0.0 == getTransparence())
106 // no transparence used, so just use content
107 return getChildren();
109 else if(getTransparence() > 0.0 && getTransparence() < 1.0)
111 // create TransparenceTexturePrimitive3D with fixed transparence as replacement
112 const basegfx::BColor
aGray(getTransparence(), getTransparence(), getTransparence());
113 const attribute::FillGradientAttribute
aFillGradient(attribute::GRADIENTSTYLE_LINEAR
, 0.0, 0.0, 0.0, 0.0, aGray
, aGray
, 1);
114 const Primitive3DReference
xRef(new TransparenceTexturePrimitive3D(aFillGradient
, getChildren(), getTextureSize()));
115 return Primitive3DSequence(&xRef
, 1L);
119 // completely transparent or invalid definition, add nothing
120 return Primitive3DSequence();
125 ImplPrimitrive3DIDBlock(UnifiedTransparenceTexturePrimitive3D
, PRIMITIVE3D_ID_UNIFIEDTRANSPARENCETEXTUREPRIMITIVE3D
)
127 } // end of namespace primitive3d
128 } // end of namespace drawinglayer
130 //////////////////////////////////////////////////////////////////////////////
132 namespace drawinglayer
134 namespace primitive3d
136 GradientTexturePrimitive3D::GradientTexturePrimitive3D(
137 const attribute::FillGradientAttribute
& rGradient
,
138 const Primitive3DSequence
& rChildren
,
139 const basegfx::B2DVector
& rTextureSize
,
142 : TexturePrimitive3D(rChildren
, rTextureSize
, bModulate
, bFilter
),
143 maGradient(rGradient
)
147 bool GradientTexturePrimitive3D::operator==(const BasePrimitive3D
& rPrimitive
) const
149 if(TexturePrimitive3D::operator==(rPrimitive
))
151 const GradientTexturePrimitive3D
& rCompare
= (GradientTexturePrimitive3D
&)rPrimitive
;
153 return (getGradient() == rCompare
.getGradient());
160 ImplPrimitrive3DIDBlock(GradientTexturePrimitive3D
, PRIMITIVE3D_ID_GRADIENTTEXTUREPRIMITIVE3D
)
162 } // end of namespace primitive3d
163 } // end of namespace drawinglayer
165 //////////////////////////////////////////////////////////////////////////////
167 namespace drawinglayer
169 namespace primitive3d
171 BitmapTexturePrimitive3D::BitmapTexturePrimitive3D(
172 const attribute::FillBitmapAttribute
& rFillBitmapAttribute
,
173 const Primitive3DSequence
& rChildren
,
174 const basegfx::B2DVector
& rTextureSize
,
175 bool bModulate
, bool bFilter
)
176 : TexturePrimitive3D(rChildren
, rTextureSize
, bModulate
, bFilter
),
177 maFillBitmapAttribute(rFillBitmapAttribute
)
181 bool BitmapTexturePrimitive3D::operator==(const BasePrimitive3D
& rPrimitive
) const
183 if(TexturePrimitive3D::operator==(rPrimitive
))
185 const BitmapTexturePrimitive3D
& rCompare
= (BitmapTexturePrimitive3D
&)rPrimitive
;
187 return (getFillBitmapAttribute() == rCompare
.getFillBitmapAttribute());
194 ImplPrimitrive3DIDBlock(BitmapTexturePrimitive3D
, PRIMITIVE3D_ID_BITMAPTEXTUREPRIMITIVE3D
)
196 } // end of namespace primitive3d
197 } // end of namespace drawinglayer
199 //////////////////////////////////////////////////////////////////////////////
201 namespace drawinglayer
203 namespace primitive3d
205 TransparenceTexturePrimitive3D::TransparenceTexturePrimitive3D(
206 const attribute::FillGradientAttribute
& rGradient
,
207 const Primitive3DSequence
& rChildren
,
208 const basegfx::B2DVector
& rTextureSize
)
209 : GradientTexturePrimitive3D(rGradient
, rChildren
, rTextureSize
, false, false)
213 bool TransparenceTexturePrimitive3D::operator==(const BasePrimitive3D
& rPrimitive
) const
215 return (GradientTexturePrimitive3D::operator==(rPrimitive
));
219 ImplPrimitrive3DIDBlock(TransparenceTexturePrimitive3D
, PRIMITIVE3D_ID_TRANSPARENCETEXTUREPRIMITIVE3D
)
221 } // end of namespace primitive3d
222 } // end of namespace drawinglayer
224 //////////////////////////////////////////////////////////////////////////////
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */