tdf#164793: fix misplaced rounding
[LibreOffice.git] / drawinglayer / inc / texture / texture3d.hxx
blob1ec4df70734c016692f65e63d0afdb5bd4b2f28a
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 #pragma once
22 #include <texture/texture.hxx>
23 #include <vcl/bitmapex.hxx>
24 #include <vcl/BitmapReadAccess.hxx>
26 namespace drawinglayer::primitive3d {
27 class HatchTexturePrimitive3D;
30 namespace drawinglayer::texture
32 class GeoTexSvxMono final : public GeoTexSvx
34 basegfx::BColor maSingleColor;
35 double mfOpacity;
37 public:
38 GeoTexSvxMono(
39 const basegfx::BColor& rSingleColor,
40 double fOpacity);
42 // compare operator
43 virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const override;
44 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override;
45 virtual void modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const override;
48 } // end of namespace drawinglayer::texture
50 namespace drawinglayer::texture
52 class GeoTexSvxBitmapEx : public GeoTexSvx
54 protected:
55 BitmapEx maBitmapEx;
56 Bitmap maBitmap; // Bitmap held within maBitmapEx, to exist during mpReadBitmap scope
57 BitmapScopedReadAccess mpReadBitmap;
58 Bitmap maTransparence;
59 BitmapScopedReadAccess mpReadTransparence;
60 basegfx::B2DPoint maTopLeft;
61 basegfx::B2DVector maSize;
62 double mfMulX;
63 double mfMulY;
65 bool mbIsAlpha : 1;
67 // helpers
68 bool impIsValid(const basegfx::B2DPoint& rUV, sal_Int32& rX, sal_Int32& rY) const;
69 sal_uInt8 impGetAlpha(sal_Int32 rX, sal_Int32 rY) const;
71 public:
72 GeoTexSvxBitmapEx(
73 const BitmapEx& rBitmapEx,
74 const basegfx::B2DRange& rRange);
75 virtual ~GeoTexSvxBitmapEx() override;
77 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override;
78 virtual void modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const override;
81 } // end of namespace drawinglayer::texture
83 namespace drawinglayer::texture
85 class GeoTexSvxBitmapExTiled final : public GeoTexSvxBitmapEx
87 double mfOffsetX;
88 double mfOffsetY;
90 bool mbUseOffsetX : 1;
91 bool mbUseOffsetY : 1;
93 // helpers
94 basegfx::B2DPoint impGetCorrected(const basegfx::B2DPoint& rUV) const;
96 public:
97 GeoTexSvxBitmapExTiled(
98 const BitmapEx& rBitmapEx,
99 const basegfx::B2DRange& rRange,
100 double fOffsetX,
101 double fOffsetY);
103 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override;
104 virtual void modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const override;
107 } // end of namespace drawinglayer::texture
109 namespace drawinglayer::texture
111 class GeoTexSvxMultiHatch final : public GeoTexSvx
113 basegfx::BColor maColor;
114 double mfLogicPixelSize;
115 std::unique_ptr<GeoTexSvxHatch> mp0;
116 std::unique_ptr<GeoTexSvxHatch> mp1;
117 std::unique_ptr<GeoTexSvxHatch> mp2;
119 bool mbFillBackground : 1;
121 // helpers
122 bool impIsOnHatch(const basegfx::B2DPoint& rUV) const;
124 public:
125 GeoTexSvxMultiHatch(const primitive3d::HatchTexturePrimitive3D& rPrimitive, double fLogicPixelSize);
126 virtual ~GeoTexSvxMultiHatch() override;
127 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override;
128 virtual void modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const override;
131 } // end of namespace drawinglayer::texture
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */