calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / drawinglayer / source / primitive3d / textureprimitive3d.cxx
blobceeca048948798262b7f7119dec81eccaa44423c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <primitive3d/textureprimitive3d.hxx>
21 #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
22 #include <basegfx/color/bcolor.hxx>
23 #include <basegfx/utils/gradienttools.hxx>
24 #include <utility>
27 using namespace com::sun::star;
30 namespace drawinglayer::primitive3d
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),
39 mbFilter(bFilter)
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());
53 return false;
58 UnifiedTransparenceTexturePrimitive3D::UnifiedTransparenceTexturePrimitive3D(
59 double fTransparence,
60 const Primitive3DContainer& rChildren)
61 : TexturePrimitive3D(rChildren, basegfx::B2DVector(), false, false),
62 mfTransparence(fTransparence)
66 bool UnifiedTransparenceTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
68 if(TexturePrimitive3D::operator==(rPrimitive))
70 const UnifiedTransparenceTexturePrimitive3D& rCompare = static_cast<const UnifiedTransparenceTexturePrimitive3D&>(rPrimitive);
72 return (getTransparence() == rCompare.getTransparence());
75 return false;
78 basegfx::B3DRange UnifiedTransparenceTexturePrimitive3D::getB3DRange(const geometry::ViewInformation3D& rViewInformation) const
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 return getChildren().getB3DRange(rViewInformation);
85 Primitive3DContainer UnifiedTransparenceTexturePrimitive3D::get3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const
87 if(0.0 == getTransparence())
89 // no transparence used, so just use content
90 return getChildren();
92 else if(getTransparence() > 0.0 && getTransparence() < 1.0)
94 // create TransparenceTexturePrimitive3D with fixed transparence as replacement
95 const basegfx::BColor aGray(getTransparence(), getTransparence(), getTransparence());
97 // create ColorStops with StartColor == EndColor == aGray
98 const basegfx::BColorStops aColorStops {
99 basegfx::BColorStop(0.0, aGray),
100 basegfx::BColorStop(1.0, aGray) };
102 const attribute::FillGradientAttribute aFillGradient(css::awt::GradientStyle_LINEAR, 0.0, 0.0, 0.0, 0.0, aColorStops);
103 const Primitive3DReference xRef(new TransparenceTexturePrimitive3D(aFillGradient, getChildren(), getTextureSize()));
104 return { xRef };
106 else
108 // completely transparent or invalid definition, add nothing
109 return Primitive3DContainer();
113 // provide unique ID
114 ImplPrimitive3DIDBlock(UnifiedTransparenceTexturePrimitive3D, PRIMITIVE3D_ID_UNIFIEDTRANSPARENCETEXTUREPRIMITIVE3D)
118 GradientTexturePrimitive3D::GradientTexturePrimitive3D(
119 attribute::FillGradientAttribute aGradient,
120 const Primitive3DContainer& rChildren,
121 const basegfx::B2DVector& rTextureSize,
122 bool bModulate,
123 bool bFilter)
124 : TexturePrimitive3D(rChildren, rTextureSize, bModulate, bFilter),
125 maGradient(std::move(aGradient))
129 bool GradientTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
131 if(TexturePrimitive3D::operator==(rPrimitive))
133 const GradientTexturePrimitive3D& rCompare = static_cast<const GradientTexturePrimitive3D&>(rPrimitive);
135 return (getGradient() == rCompare.getGradient());
138 return false;
141 // provide unique ID
142 ImplPrimitive3DIDBlock(GradientTexturePrimitive3D, PRIMITIVE3D_ID_GRADIENTTEXTUREPRIMITIVE3D)
146 BitmapTexturePrimitive3D::BitmapTexturePrimitive3D(
147 const attribute::FillGraphicAttribute& rFillGraphicAttribute,
148 const Primitive3DContainer& rChildren,
149 const basegfx::B2DVector& rTextureSize,
150 bool bModulate, bool bFilter)
151 : TexturePrimitive3D(rChildren, rTextureSize, bModulate, bFilter),
152 maFillGraphicAttribute(rFillGraphicAttribute)
156 bool BitmapTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
158 if(TexturePrimitive3D::operator==(rPrimitive))
160 const BitmapTexturePrimitive3D& rCompare = static_cast<const BitmapTexturePrimitive3D&>(rPrimitive);
162 return (getFillGraphicAttribute() == rCompare.getFillGraphicAttribute());
165 return false;
168 // provide unique ID
169 ImplPrimitive3DIDBlock(BitmapTexturePrimitive3D, PRIMITIVE3D_ID_BITMAPTEXTUREPRIMITIVE3D)
173 TransparenceTexturePrimitive3D::TransparenceTexturePrimitive3D(
174 const attribute::FillGradientAttribute& rGradient,
175 const Primitive3DContainer& rChildren,
176 const basegfx::B2DVector& rTextureSize)
177 : GradientTexturePrimitive3D(rGradient, rChildren, rTextureSize, false, false)
181 bool TransparenceTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
183 return GradientTexturePrimitive3D::operator==(rPrimitive);
186 // provide unique ID
187 ImplPrimitive3DIDBlock(TransparenceTexturePrimitive3D, PRIMITIVE3D_ID_TRANSPARENCETEXTUREPRIMITIVE3D)
189 } // end of namespace
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */