Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
drawing-paintserver.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2#ifndef INKSCAPE_DISPLAY_DRAWING_PAINT_SERVER_H
3#define INKSCAPE_DISPLAY_DRAWING_PAINT_SERVER_H
8/*
9 * Author: PBS <pbs3141@gmail.com>
10 * Copyright (C) 2022 Authors
11 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
12 */
13
14#include <array>
15#include <vector>
16#include <cairo.h>
17#include <2geom/rect.h>
18#include <2geom/affine.h>
22
23class SPGradient;
24
25namespace Inkscape {
26namespace Colors {
27class Color;
28}
29
39{
40public:
41 virtual ~DrawingPaintServer() = 0;
42
44 virtual cairo_pattern_t *create_pattern(cairo_t *ct, Geom::OptRect const &bbox, double opacity) const = 0;
45
47 virtual bool ditherable() const { return false; }
48
51 virtual bool uses_cairo_ctx() const { return false; }
52};
53
54// Todo: Remove, merging with existing implementation for solid colours.
59 : public DrawingPaintServer
60{
61public:
63 cairo_pattern_t *create_pattern(cairo_t *, Geom::OptRect const &, double opacity) const override;
64
65private:
67};
68
73 : public DrawingPaintServer
74{
75protected:
80
81 bool ditherable() const override { return true; }
82
84 void common_setup(cairo_pattern_t *pat, Geom::OptRect const &bbox, double opacity) const;
85
89};
90
95 : public DrawingGradient
96{
97public:
99 float x1, float y1, float x2, float y2, std::vector<SPGradientStop> stops)
101 , x1(x1)
102 , y1(y1)
103 , x2(x2)
104 , y2(y2)
105 , stops(std::move(stops)) {}
106
107 cairo_pattern_t *create_pattern(cairo_t*, Geom::OptRect const &bbox, double opacity) const override;
108
109private:
110 float x1, y1, x2, y2;
111 std::vector<SPGradientStop> stops;
112};
113
118 : public DrawingGradient
119{
120public:
122 float fx, float fy, float cx, float cy, float r, float fr, std::vector<SPGradientStop> stops)
124 , fx(fx)
125 , fy(fy)
126 , cx(cx)
127 , cy(cy)
128 , r(r)
129 , fr(fr)
130 , stops(std::move(stops)) {}
131
132 cairo_pattern_t *create_pattern(cairo_t *ct, Geom::OptRect const &bbox, double opacity) const override;
133
134 bool uses_cairo_ctx() const override { return true; }
135
136private:
137 float fx, fy, cx, cy, r, fr;
138 std::vector<SPGradientStop> stops;
139};
140
145 : public DrawingGradient
146{
147public:
149 {
151 char pathtype[4];
152 bool tensorIsSet[4];
154 std::array<float, 3> color[4];
155 double opacity[4];
156 };
157
159 int rows, int cols, std::vector<std::vector<PatchData>> patchdata)
161 , rows(rows)
162 , cols(cols)
163 , patchdata(std::move(patchdata)) {}
164
165 cairo_pattern_t *create_pattern(cairo_t*, Geom::OptRect const &bbox, double opacity) const override;
166
167private:
168 int rows;
169 int cols;
170 std::vector<std::vector<PatchData>> patchdata;
171};
172
173} // namespace Inkscape
174
175#endif // INKSCAPE_DISPLAY_DRAWING_PAINT_SERVER_H
176/*
177 Local Variables:
178 mode:c++
179 c-file-style:"stroustrup"
180 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
181 indent-tabs-mode:nil
182 fill-column:99
183 End:
184*/
185// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
3x3 affine transformation matrix.
uint32_t Color
3x3 matrix representing an affine transformation.
Definition affine.h:70
Axis-aligned rectangle that can be empty.
Definition rect.h:203
Two-dimensional point that doubles as a vector.
Definition point.h:66
The base class for all gradients.
void common_setup(cairo_pattern_t *pat, Geom::OptRect const &bbox, double opacity) const
Perform some common initialization steps on the given Cairo pattern.
DrawingGradient(SPGradientSpread spread, SPGradientUnits units, Geom::Affine const &transform)
bool ditherable() const override
Return whether this paint server could benefit from dithering.
std::vector< SPGradientStop > stops
DrawingLinearGradient(SPGradientSpread spread, SPGradientUnits units, Geom::Affine const &transform, float x1, float y1, float x2, float y2, std::vector< SPGradientStop > stops)
cairo_pattern_t * create_pattern(cairo_t *, Geom::OptRect const &bbox, double opacity) const override
Produce a pattern that can be used for painting with Cairo.
DrawingMeshGradient(SPGradientSpread spread, SPGradientUnits units, Geom::Affine const &transform, int rows, int cols, std::vector< std::vector< PatchData > > patchdata)
cairo_pattern_t * create_pattern(cairo_t *, Geom::OptRect const &bbox, double opacity) const override
Produce a pattern that can be used for painting with Cairo.
std::vector< std::vector< PatchData > > patchdata
A DrawingPaintServer is a lightweight copy of the resources needed to paint using a paint server.
virtual bool uses_cairo_ctx() const
Return whether create_pattern() uses its cairo_t argument.
virtual bool ditherable() const
Return whether this paint server could benefit from dithering.
virtual cairo_pattern_t * create_pattern(cairo_t *ct, Geom::OptRect const &bbox, double opacity) const =0
Produce a pattern that can be used for painting with Cairo.
cairo_pattern_t * create_pattern(cairo_t *ct, Geom::OptRect const &bbox, double opacity) const override
Produce a pattern that can be used for painting with Cairo.
std::vector< SPGradientStop > stops
DrawingRadialGradient(SPGradientSpread spread, SPGradientUnits units, Geom::Affine const &transform, float fx, float fy, float cx, float cy, float r, float fr, std::vector< SPGradientStop > stops)
bool uses_cairo_ctx() const override
Return whether create_pattern() uses its cairo_t argument.
A simple solid color, storing an RGB color and an opacity.
cairo_pattern_t * create_pattern(cairo_t *, Geom::OptRect const &, double opacity) const override
Produce a pattern that can be used for painting with Cairo.
Gradient.
Definition sp-gradient.h:86
_cairo_pattern cairo_pattern_t
Helper class to stream background task notifications as a series of messages.
STL namespace.
struct _cairo cairo_t
Definition path-cairo.h:16
Axis-aligned rectangle.
TODO: insert short description here.
SPGradientSpread
TODO: insert short description here.
SPGradientUnits
TODO: insert short description here.