Coverage Report

Created: 2026-11-06 11:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/drawinglayer/primitive2d/PolyPolygonAlphaGradientPrimitive2D.hxx
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
#pragma once
21
22
#include <drawinglayer/drawinglayerdllapi.h>
23
24
#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx>
25
#include <basegfx/polygon/b2dpolypolygon.hxx>
26
#include <basegfx/color/bcolor.hxx>
27
#include <drawinglayer/attribute/fillgradientattribute.hxx>
28
// #include <basegfx/numeric/ftools.hxx>
29
30
namespace drawinglayer::primitive2d
31
{
32
/** PolyPolygonAlphaGradientPrimitive2D class
33
34
    This is a simple extension to PolyPolygonColorPrimitive2D
35
    that allows to directly define an alpha gradient for the PolyPolygon
36
    to be represented, additionally to the color.
37
38
    It will be decomposed simply to PolyPolygonColorPrimitive2D,
39
    maybe embedded to a FillGradientPrimitive2D if
40
    needed, so no changes have to be done to any primitive processor.
41
42
    OTOH e.g. SDPR implementations *may* use this directly if they
43
    are capable to draw a filled PolyPolygon with transparency gradient
44
    directly (e.g. CairoPixelProcessor2D)
45
 */
46
class DRAWINGLAYER_DLLPUBLIC PolyPolygonAlphaGradientPrimitive2D final
47
    : public BufferedDecompositionPrimitive2D
48
{
49
private:
50
    /// the tools::PolyPolygon geometry
51
    basegfx::B2DPolyPolygon maPolyPolygon;
52
53
    /// the polygon fill color
54
    basegfx::BColor maBColor;
55
56
    /// alphaGradient definition
57
    attribute::FillGradientAttribute maAlphaGradient;
58
59
    /// create local decomposition
60
    virtual Primitive2DReference
61
    create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const override;
62
63
public:
64
    /// constructor
65
    PolyPolygonAlphaGradientPrimitive2D(const basegfx::B2DPolyPolygon& rPolyPolygon,
66
                                        const basegfx::BColor& rBColor,
67
                                        const attribute::FillGradientAttribute& rAlphaGradient);
68
69
    /// data read access
70
0
    const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; }
71
0
    const basegfx::BColor& getBColor() const { return maBColor; }
72
0
    const attribute::FillGradientAttribute& getAlphaGradient() const { return maAlphaGradient; }
73
74
    /// compare operator
75
    virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
76
77
    /// get B2Drange
78
    virtual basegfx::B2DRange
79
    getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override;
80
81
    /// provide unique ID
82
    virtual sal_uInt32 getPrimitive2DID() const override;
83
};
84
85
} // end of namespace drawinglayer::primitive2d
86
87
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */