nss: upgrade to release 3.73
[LibreOffice.git] / include / drawinglayer / primitive2d / fillgradientprimitive2d.hxx
blob6b6547327930490837f40c2d651880928f74ffce
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 <drawinglayer/drawinglayerdllapi.h>
24 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
25 #include <drawinglayer/attribute/fillgradientattribute.hxx>
28 // predefines
30 namespace basegfx { class B2DPolygon; }
31 namespace drawinglayer::texture { struct B2DHomMatrixAndBColor; }
34 // FillGradientPrimitive2D class
36 namespace drawinglayer::primitive2d
38 /** FillGradientPrimitive2D class
40 This class defines a gradient filling for a rectangular area. The
41 Range is defined by the Transformation, the gradient by the FillGradientAttribute.
43 The decomposition will deliver the decomposed gradient, e.g. for an ellipse
44 gradient the various ellipses in various color steps will be created.
46 I have added functionality to create both versions of filled decompositions:
47 Those who overlap and non-overlapping ones. The overlapping version is the
48 default one since it works with and without AntiAliasing. The non-overlapping
49 version is used in the MetafilePrimitive2D decomposition when the old XOR
50 paint was recorded.
52 class DRAWINGLAYER_DLLPUBLIC FillGradientPrimitive2D : public BufferedDecompositionPrimitive2D
54 private:
55 /// the geometrically visible area
56 basegfx::B2DRange maOutputRange;
58 /// the area the gradient definition is based on
59 /// in the simplest case identical to OutputRange
60 basegfx::B2DRange maDefinitionRange;
62 /// the gradient definition
63 attribute::FillGradientAttribute maFillGradient;
65 /// local helpers
66 void generateMatricesAndColors(
67 std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries,
68 basegfx::BColor& rOuterColor) const;
69 void createOverlappingFill(
70 Primitive2DContainer& rContainer,
71 const std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries,
72 const basegfx::BColor& rOuterColor,
73 const basegfx::B2DPolygon& rUnitPolygon) const;
74 void createNonOverlappingFill(
75 Primitive2DContainer& rContainer,
76 const std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries,
77 const basegfx::BColor& rOuterColor,
78 const basegfx::B2DPolygon& rUnitPolygon) const;
80 protected:
81 /// local helper
82 void createFill(Primitive2DContainer& rContainer, bool bOverlapping) const;
84 /// local decomposition.
85 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override;
87 public:
88 /// constructors. The one without definition range will use output range as definition range
89 FillGradientPrimitive2D(
90 const basegfx::B2DRange& rOutputRange,
91 const attribute::FillGradientAttribute& rFillGradient);
92 FillGradientPrimitive2D(
93 const basegfx::B2DRange& rOutputRange,
94 const basegfx::B2DRange& rDefinitionRange,
95 const attribute::FillGradientAttribute& rFillGradient);
97 /// data read access
98 const basegfx::B2DRange& getOutputRange() const { return maOutputRange; }
99 const basegfx::B2DRange& getDefinitionRange() const { return maDefinitionRange; }
100 const attribute::FillGradientAttribute& getFillGradient() const { return maFillGradient; }
102 /// compare operator
103 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
105 /// get range
106 virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override;
108 /// provide unique ID
109 virtual sal_uInt32 getPrimitive2DID() const override;
111 } // end of namespace drawinglayer::primitive2d
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */