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