/src/libreoffice/drawinglayer/source/primitive3d/textureprimitive3d.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include <primitive3d/textureprimitive3d.hxx> |
21 | | #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx> |
22 | | #include <basegfx/color/bcolor.hxx> |
23 | | #include <basegfx/range/b3drange.hxx> |
24 | | #include <basegfx/utils/bgradient.hxx> |
25 | | #include <utility> |
26 | | |
27 | | |
28 | | using namespace com::sun::star; |
29 | | |
30 | | |
31 | | namespace drawinglayer::primitive3d |
32 | | { |
33 | | TexturePrimitive3D::TexturePrimitive3D( |
34 | | const Primitive3DContainer& rChildren, |
35 | | const basegfx::B2DVector& rTextureSize, |
36 | | bool bModulate, bool bFilter) |
37 | 0 | : GroupPrimitive3D(rChildren), |
38 | 0 | maTextureSize(rTextureSize), |
39 | 0 | mbModulate(bModulate), |
40 | 0 | mbFilter(bFilter) |
41 | 0 | { |
42 | 0 | } Unexecuted instantiation: drawinglayer::primitive3d::TexturePrimitive3D::TexturePrimitive3D(drawinglayer::primitive3d::Primitive3DContainer const&, basegfx::B2DVector const&, bool, bool) Unexecuted instantiation: drawinglayer::primitive3d::TexturePrimitive3D::TexturePrimitive3D(drawinglayer::primitive3d::Primitive3DContainer const&, basegfx::B2DVector const&, bool, bool) |
43 | | |
44 | | bool TexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const |
45 | 0 | { |
46 | 0 | if(GroupPrimitive3D::operator==(rPrimitive)) |
47 | 0 | { |
48 | 0 | const TexturePrimitive3D& rCompare = static_cast<const TexturePrimitive3D&>(rPrimitive); |
49 | |
|
50 | 0 | return (getModulate() == rCompare.getModulate() |
51 | 0 | && getFilter() == rCompare.getFilter()); |
52 | 0 | } |
53 | | |
54 | 0 | return false; |
55 | 0 | } |
56 | | |
57 | | |
58 | | |
59 | | UnifiedTransparenceTexturePrimitive3D::UnifiedTransparenceTexturePrimitive3D( |
60 | | double fTransparence, |
61 | | const Primitive3DContainer& rChildren) |
62 | 0 | : TexturePrimitive3D(rChildren, basegfx::B2DVector(), false, false), |
63 | 0 | mfTransparence(fTransparence) |
64 | 0 | { |
65 | 0 | } Unexecuted instantiation: drawinglayer::primitive3d::UnifiedTransparenceTexturePrimitive3D::UnifiedTransparenceTexturePrimitive3D(double, drawinglayer::primitive3d::Primitive3DContainer const&) Unexecuted instantiation: drawinglayer::primitive3d::UnifiedTransparenceTexturePrimitive3D::UnifiedTransparenceTexturePrimitive3D(double, drawinglayer::primitive3d::Primitive3DContainer const&) |
66 | | |
67 | | bool UnifiedTransparenceTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const |
68 | 0 | { |
69 | 0 | if(TexturePrimitive3D::operator==(rPrimitive)) |
70 | 0 | { |
71 | 0 | const UnifiedTransparenceTexturePrimitive3D& rCompare = static_cast<const UnifiedTransparenceTexturePrimitive3D&>(rPrimitive); |
72 | |
|
73 | 0 | return (getTransparence() == rCompare.getTransparence()); |
74 | 0 | } |
75 | | |
76 | 0 | return false; |
77 | 0 | } |
78 | | |
79 | | basegfx::B3DRange UnifiedTransparenceTexturePrimitive3D::getB3DRange(const geometry::ViewInformation3D& rViewInformation) const |
80 | 0 | { |
81 | | // do not use the fallback to decomposition here since for a correct BoundRect we also |
82 | | // need invisible (1.0 == getTransparence()) geometry; these would be deleted in the decomposition |
83 | 0 | return getChildren().getB3DRange(rViewInformation); |
84 | 0 | } |
85 | | |
86 | | Primitive3DContainer UnifiedTransparenceTexturePrimitive3D::get3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const |
87 | 0 | { |
88 | 0 | if(0.0 == getTransparence()) |
89 | 0 | { |
90 | | // no transparence used, so just use content |
91 | 0 | return getChildren(); |
92 | 0 | } |
93 | 0 | else if(getTransparence() > 0.0 && getTransparence() < 1.0) |
94 | 0 | { |
95 | | // create TransparenceTexturePrimitive3D with fixed transparence as replacement |
96 | 0 | const basegfx::BColor aGray(getTransparence(), getTransparence(), getTransparence()); |
97 | | |
98 | | // create ColorStops with StartColor == EndColor == aGray |
99 | 0 | const basegfx::BColorStops aColorStops { |
100 | 0 | basegfx::BColorStop(0.0, aGray), |
101 | 0 | basegfx::BColorStop(1.0, aGray) }; |
102 | |
|
103 | 0 | const attribute::FillGradientAttribute aFillGradient(css::awt::GradientStyle_LINEAR, 0.0, 0.0, 0.0, 0.0, aColorStops); |
104 | 0 | const Primitive3DReference xRef(new TransparenceTexturePrimitive3D(aFillGradient, getChildren(), getTextureSize())); |
105 | 0 | return { xRef }; |
106 | 0 | } |
107 | 0 | else |
108 | 0 | { |
109 | | // completely transparent or invalid definition, add nothing |
110 | 0 | return Primitive3DContainer(); |
111 | 0 | } |
112 | 0 | } |
113 | | |
114 | | // provide unique ID |
115 | | ImplPrimitive3DIDBlock(UnifiedTransparenceTexturePrimitive3D, PRIMITIVE3D_ID_UNIFIEDTRANSPARENCETEXTUREPRIMITIVE3D) |
116 | | |
117 | | |
118 | | |
119 | | GradientTexturePrimitive3D::GradientTexturePrimitive3D( |
120 | | attribute::FillGradientAttribute aGradient, |
121 | | const Primitive3DContainer& rChildren, |
122 | | const basegfx::B2DVector& rTextureSize, |
123 | | bool bModulate, |
124 | | bool bFilter) |
125 | 0 | : TexturePrimitive3D(rChildren, rTextureSize, bModulate, bFilter), |
126 | 0 | maGradient(std::move(aGradient)) |
127 | 0 | { |
128 | 0 | } Unexecuted instantiation: drawinglayer::primitive3d::GradientTexturePrimitive3D::GradientTexturePrimitive3D(drawinglayer::attribute::FillGradientAttribute, drawinglayer::primitive3d::Primitive3DContainer const&, basegfx::B2DVector const&, bool, bool) Unexecuted instantiation: drawinglayer::primitive3d::GradientTexturePrimitive3D::GradientTexturePrimitive3D(drawinglayer::attribute::FillGradientAttribute, drawinglayer::primitive3d::Primitive3DContainer const&, basegfx::B2DVector const&, bool, bool) |
129 | | |
130 | | bool GradientTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const |
131 | 0 | { |
132 | 0 | if(TexturePrimitive3D::operator==(rPrimitive)) |
133 | 0 | { |
134 | 0 | const GradientTexturePrimitive3D& rCompare = static_cast<const GradientTexturePrimitive3D&>(rPrimitive); |
135 | |
|
136 | 0 | return (getGradient() == rCompare.getGradient()); |
137 | 0 | } |
138 | | |
139 | 0 | return false; |
140 | 0 | } |
141 | | |
142 | | // provide unique ID |
143 | | ImplPrimitive3DIDBlock(GradientTexturePrimitive3D, PRIMITIVE3D_ID_GRADIENTTEXTUREPRIMITIVE3D) |
144 | | |
145 | | |
146 | | |
147 | | BitmapTexturePrimitive3D::BitmapTexturePrimitive3D( |
148 | | const attribute::FillGraphicAttribute& rFillGraphicAttribute, |
149 | | const Primitive3DContainer& rChildren, |
150 | | const basegfx::B2DVector& rTextureSize, |
151 | | bool bModulate, bool bFilter) |
152 | 0 | : TexturePrimitive3D(rChildren, rTextureSize, bModulate, bFilter), |
153 | 0 | maFillGraphicAttribute(rFillGraphicAttribute) |
154 | 0 | { |
155 | 0 | } Unexecuted instantiation: drawinglayer::primitive3d::BitmapTexturePrimitive3D::BitmapTexturePrimitive3D(drawinglayer::attribute::FillGraphicAttribute const&, drawinglayer::primitive3d::Primitive3DContainer const&, basegfx::B2DVector const&, bool, bool) Unexecuted instantiation: drawinglayer::primitive3d::BitmapTexturePrimitive3D::BitmapTexturePrimitive3D(drawinglayer::attribute::FillGraphicAttribute const&, drawinglayer::primitive3d::Primitive3DContainer const&, basegfx::B2DVector const&, bool, bool) |
156 | | |
157 | | bool BitmapTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const |
158 | 0 | { |
159 | 0 | if(TexturePrimitive3D::operator==(rPrimitive)) |
160 | 0 | { |
161 | 0 | const BitmapTexturePrimitive3D& rCompare = static_cast<const BitmapTexturePrimitive3D&>(rPrimitive); |
162 | |
|
163 | 0 | return (getFillGraphicAttribute() == rCompare.getFillGraphicAttribute()); |
164 | 0 | } |
165 | | |
166 | 0 | return false; |
167 | 0 | } |
168 | | |
169 | | // provide unique ID |
170 | | ImplPrimitive3DIDBlock(BitmapTexturePrimitive3D, PRIMITIVE3D_ID_BITMAPTEXTUREPRIMITIVE3D) |
171 | | |
172 | | |
173 | | |
174 | | TransparenceTexturePrimitive3D::TransparenceTexturePrimitive3D( |
175 | | const attribute::FillGradientAttribute& rGradient, |
176 | | const Primitive3DContainer& rChildren, |
177 | | const basegfx::B2DVector& rTextureSize) |
178 | 0 | : GradientTexturePrimitive3D(rGradient, rChildren, rTextureSize, false, false) |
179 | 0 | { |
180 | 0 | } Unexecuted instantiation: drawinglayer::primitive3d::TransparenceTexturePrimitive3D::TransparenceTexturePrimitive3D(drawinglayer::attribute::FillGradientAttribute const&, drawinglayer::primitive3d::Primitive3DContainer const&, basegfx::B2DVector const&) Unexecuted instantiation: drawinglayer::primitive3d::TransparenceTexturePrimitive3D::TransparenceTexturePrimitive3D(drawinglayer::attribute::FillGradientAttribute const&, drawinglayer::primitive3d::Primitive3DContainer const&, basegfx::B2DVector const&) |
181 | | |
182 | | bool TransparenceTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const |
183 | 0 | { |
184 | 0 | return GradientTexturePrimitive3D::operator==(rPrimitive); |
185 | 0 | } |
186 | | |
187 | | // provide unique ID |
188 | | ImplPrimitive3DIDBlock(TransparenceTexturePrimitive3D, PRIMITIVE3D_ID_TRANSPARENCETEXTUREPRIMITIVE3D) |
189 | | |
190 | | } // end of namespace |
191 | | |
192 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |