Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/basegfx/DrawCommands.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
10
#pragma once
11
12
#include <memory>
13
#include <utility>
14
#include <vector>
15
16
#include <basegfx/color/bcolor.hxx>
17
#include <basegfx/polygon/b2dpolypolygon.hxx>
18
#include <basegfx/range/b2drange.hxx>
19
#include <basegfx/matrix/b2dhommatrix.hxx>
20
21
namespace gfx
22
{
23
class DrawBase;
24
25
class DrawCommand
26
{
27
public:
28
    std::vector<std::shared_ptr<DrawBase>> maChildren;
29
};
30
31
enum class DrawCommandType
32
{
33
    Root,
34
    Rectangle,
35
    Path
36
};
37
38
enum class GradientType
39
{
40
    Linear
41
};
42
43
class GradientStop
44
{
45
public:
46
    basegfx::BColor maColor;
47
    float mfOffset;
48
    float mfOpacity;
49
};
50
51
class GradientInfo
52
{
53
public:
54
    GradientType meType;
55
56
    std::vector<GradientStop> maGradientStops;
57
58
    GradientInfo(GradientType eType)
59
        : meType(eType)
60
0
    {
61
0
    }
62
};
63
64
class LinearGradientInfo : public GradientInfo
65
{
66
public:
67
    LinearGradientInfo()
68
        : GradientInfo(GradientType::Linear)
69
        , x1(0.0)
70
        , y1(0.0)
71
        , x2(0.0)
72
        , y2(0.0)
73
0
    {
74
0
    }
75
76
    double x1;
77
    double y1;
78
    double x2;
79
    double y2;
80
81
    basegfx::B2DHomMatrix maMatrix;
82
};
83
84
class DrawBase : public DrawCommand
85
{
86
private:
87
    DrawCommandType meType;
88
89
public:
90
    DrawBase(DrawCommandType eType)
91
        : meType(eType)
92
0
    {
93
0
    }
94
95
0
    DrawCommandType getType() const { return meType; }
96
};
97
98
class DrawRoot : public DrawBase
99
{
100
public:
101
    basegfx::B2DRange maRectangle;
102
103
    DrawRoot()
104
        : DrawBase(DrawCommandType::Root)
105
0
    {
106
0
    }
107
};
108
109
class DrawRectangle : public DrawBase
110
{
111
public:
112
    basegfx::B2DRange maRectangle;
113
    double mnRx;
114
    double mnRy;
115
116
    double mnStrokeWidth;
117
    double mnOpacity;
118
    std::shared_ptr<basegfx::BColor> mpFillColor;
119
    std::shared_ptr<basegfx::BColor> mpStrokeColor;
120
    std::shared_ptr<GradientInfo> mpFillGradient;
121
122
    DrawRectangle(basegfx::B2DRange const& rRectangle)
123
        : DrawBase(DrawCommandType::Rectangle)
124
        , maRectangle(rRectangle)
125
        , mnRx(1.0)
126
        , mnRy(1.0)
127
        , mnStrokeWidth(1.0)
128
        , mnOpacity(1.0)
129
0
    {
130
0
    }
131
};
132
133
class DrawPath : public DrawBase
134
{
135
public:
136
    basegfx::B2DPolyPolygon maPolyPolygon;
137
138
    double mnStrokeWidth;
139
    double mnOpacity;
140
    std::shared_ptr<basegfx::BColor> mpFillColor;
141
    std::shared_ptr<basegfx::BColor> mpStrokeColor;
142
    std::shared_ptr<GradientInfo> mpFillGradient;
143
144
    DrawPath(basegfx::B2DPolyPolygon aPolyPolygon)
145
        : DrawBase(DrawCommandType::Path)
146
        , maPolyPolygon(std::move(aPolyPolygon))
147
        , mnStrokeWidth(1.0)
148
        , mnOpacity(1.0)
149
0
    {
150
0
    }
151
};
152
153
} // end namespace gfx
154
155
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */