Coverage Report

Created: 2026-04-09 11:41

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