1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <drawinglayer/primitive3d/textureprimitive3d.hxx>
21 #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
22 #include <basegfx/color/bcolor.hxx>
25 using namespace com::sun::star
;
28 namespace drawinglayer
32 TexturePrimitive3D::TexturePrimitive3D(
33 const Primitive3DContainer
& rChildren
,
34 const basegfx::B2DVector
& rTextureSize
,
35 bool bModulate
, bool bFilter
)
36 : GroupPrimitive3D(rChildren
),
37 maTextureSize(rTextureSize
),
38 mbModulate(bModulate
),
43 bool TexturePrimitive3D::operator==(const BasePrimitive3D
& rPrimitive
) const
45 if(GroupPrimitive3D::operator==(rPrimitive
))
47 const TexturePrimitive3D
& rCompare
= static_cast<const TexturePrimitive3D
&>(rPrimitive
);
49 return (getModulate() == rCompare
.getModulate()
50 && getFilter() == rCompare
.getFilter());
55 } // end of namespace primitive3d
56 } // end of namespace drawinglayer
59 namespace drawinglayer
63 UnifiedTransparenceTexturePrimitive3D::UnifiedTransparenceTexturePrimitive3D(
65 const Primitive3DContainer
& rChildren
)
66 : TexturePrimitive3D(rChildren
, basegfx::B2DVector(), false, false),
67 mfTransparence(fTransparence
)
71 bool UnifiedTransparenceTexturePrimitive3D::operator==(const BasePrimitive3D
& rPrimitive
) const
73 if(TexturePrimitive3D::operator==(rPrimitive
))
75 const UnifiedTransparenceTexturePrimitive3D
& rCompare
= static_cast<const UnifiedTransparenceTexturePrimitive3D
&>(rPrimitive
);
77 return (getTransparence() == rCompare
.getTransparence());
83 basegfx::B3DRange
UnifiedTransparenceTexturePrimitive3D::getB3DRange(const geometry::ViewInformation3D
& rViewInformation
) const
85 // do not use the fallback to decomposition here since for a correct BoundRect we also
86 // need invisible (1.0 == getTransparence()) geometry; these would be deleted in the decomposition
87 return getChildren().getB3DRange(rViewInformation
);
90 Primitive3DContainer
UnifiedTransparenceTexturePrimitive3D::get3DDecomposition(const geometry::ViewInformation3D
& /*rViewInformation*/) const
92 if(0.0 == getTransparence())
94 // no transparence used, so just use content
97 else if(getTransparence() > 0.0 && getTransparence() < 1.0)
99 // create TransparenceTexturePrimitive3D with fixed transparence as replacement
100 const basegfx::BColor
aGray(getTransparence(), getTransparence(), getTransparence());
101 const attribute::FillGradientAttribute
aFillGradient(attribute::GradientStyle::Linear
, 0.0, 0.0, 0.0, 0.0, aGray
, aGray
, 1);
102 const Primitive3DReference
xRef(new TransparenceTexturePrimitive3D(aFillGradient
, getChildren(), getTextureSize()));
107 // completely transparent or invalid definition, add nothing
108 return Primitive3DContainer();
113 ImplPrimitive3DIDBlock(UnifiedTransparenceTexturePrimitive3D
, PRIMITIVE3D_ID_UNIFIEDTRANSPARENCETEXTUREPRIMITIVE3D
)
115 } // end of namespace primitive3d
116 } // end of namespace drawinglayer
119 namespace drawinglayer
121 namespace primitive3d
123 GradientTexturePrimitive3D::GradientTexturePrimitive3D(
124 const attribute::FillGradientAttribute
& rGradient
,
125 const Primitive3DContainer
& rChildren
,
126 const basegfx::B2DVector
& rTextureSize
,
129 : TexturePrimitive3D(rChildren
, rTextureSize
, bModulate
, bFilter
),
130 maGradient(rGradient
)
134 bool GradientTexturePrimitive3D::operator==(const BasePrimitive3D
& rPrimitive
) const
136 if(TexturePrimitive3D::operator==(rPrimitive
))
138 const GradientTexturePrimitive3D
& rCompare
= static_cast<const GradientTexturePrimitive3D
&>(rPrimitive
);
140 return (getGradient() == rCompare
.getGradient());
147 ImplPrimitive3DIDBlock(GradientTexturePrimitive3D
, PRIMITIVE3D_ID_GRADIENTTEXTUREPRIMITIVE3D
)
149 } // end of namespace primitive3d
150 } // end of namespace drawinglayer
153 namespace drawinglayer
155 namespace primitive3d
157 BitmapTexturePrimitive3D::BitmapTexturePrimitive3D(
158 const attribute::FillGraphicAttribute
& rFillGraphicAttribute
,
159 const Primitive3DContainer
& rChildren
,
160 const basegfx::B2DVector
& rTextureSize
,
161 bool bModulate
, bool bFilter
)
162 : TexturePrimitive3D(rChildren
, rTextureSize
, bModulate
, bFilter
),
163 maFillGraphicAttribute(rFillGraphicAttribute
)
167 bool BitmapTexturePrimitive3D::operator==(const BasePrimitive3D
& rPrimitive
) const
169 if(TexturePrimitive3D::operator==(rPrimitive
))
171 const BitmapTexturePrimitive3D
& rCompare
= static_cast<const BitmapTexturePrimitive3D
&>(rPrimitive
);
173 return (getFillGraphicAttribute() == rCompare
.getFillGraphicAttribute());
180 ImplPrimitive3DIDBlock(BitmapTexturePrimitive3D
, PRIMITIVE3D_ID_BITMAPTEXTUREPRIMITIVE3D
)
182 } // end of namespace primitive3d
183 } // end of namespace drawinglayer
186 namespace drawinglayer
188 namespace primitive3d
190 TransparenceTexturePrimitive3D::TransparenceTexturePrimitive3D(
191 const attribute::FillGradientAttribute
& rGradient
,
192 const Primitive3DContainer
& rChildren
,
193 const basegfx::B2DVector
& rTextureSize
)
194 : GradientTexturePrimitive3D(rGradient
, rChildren
, rTextureSize
, false, false)
198 bool TransparenceTexturePrimitive3D::operator==(const BasePrimitive3D
& rPrimitive
) const
200 return GradientTexturePrimitive3D::operator==(rPrimitive
);
204 ImplPrimitive3DIDBlock(TransparenceTexturePrimitive3D
, PRIMITIVE3D_ID_TRANSPARENCETEXTUREPRIMITIVE3D
)
206 } // end of namespace primitive3d
207 } // end of namespace drawinglayer
209 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */