Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
drawing-pattern.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
/*
6 * Authors:
7 * Tomasz Boczkowski <penginsbacon@gmail.com>
8 *
9 * Copyright (C) 2014 Authors
10 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
11 */
12
13#ifndef INKSCAPE_DISPLAY_DRAWING_PATTERN_H
14#define INKSCAPE_DISPLAY_DRAWING_PATTERN_H
15
16#include <mutex>
17#include <cairomm/surface.h>
18#include "drawing-group.h"
19
20using cairo_pattern_t = struct _cairo_pattern;
21
22namespace Inkscape {
23
33 : public DrawingGroup
34{
35public:
37 int tag() const override { return tag_of<decltype(*this)>; }
38
44
48 void setTileRect(Geom::Rect const &);
49
56 void setOverflow(Geom::Affine const &initial_transform, int steps, Geom::Affine const &step_transform);
57
63 cairo_pattern_t *renderPattern(RenderContext &rc, Geom::IntRect const &area, float opacity, int device_scale) const;
64
65protected:
66 ~DrawingPattern() override = default;
67
68 unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) override;
69
70 void _dropPatternCache() override;
71
72 std::unique_ptr<Geom::Affine> _pattern_to_user;
73
74 // Set by overflow.
78
80
81 // Set on update.
83
84 struct Surface
85 {
86 Surface(Geom::IntRect const &rect, int device_scale);
88 Cairo::RefPtr<Cairo::ImageSurface> surface;
89 };
90
91 mutable std::mutex mutables;
92
93 // Parts of the pattern tile that have been rendered. Read/written on render, cleared on update.
94 mutable std::vector<Surface> surfaces;
95};
96
97} // namespace Inkscape
98
99#endif // INKSCAPE_DISPLAY_DRAWING_PATTERN_H
100
101/*
102 Local Variables:
103 mode:c++
104 c-file-style:"stroustrup"
105 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
106 indent-tabs-mode:nil
107 fill-column:99
108 End:
109*/
110// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
constexpr int tag_of
Convenience function to retrieve the tag (class id) of a given type.
Definition cast.h:26
3x3 matrix representing an affine transformation.
Definition affine.h:70
Axis aligned, non-empty, generic rectangle.
Two-dimensional point with integer coordinates.
Definition int-point.h:57
Axis-aligned rectangle that can be empty.
Definition rect.h:203
Axis aligned, non-empty rectangle.
Definition rect.h:92
Drawing & drawing() const
Drawing tree node used for rendering paints.
void _dropPatternCache() override
void setTileRect(Geom::Rect const &)
Set the tile rect position and dimensions in content coordinate system.
void setPatternToUserTransform(Geom::Affine const &)
Set the transformation from pattern to user coordinate systems.
std::unique_ptr< Geom::Affine > _pattern_to_user
std::vector< Surface > surfaces
void setOverflow(Geom::Affine const &initial_transform, int steps, Geom::Affine const &step_transform)
Turn on overflow rendering.
~DrawingPattern() override=default
unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) override
Geom::Affine _overflow_step_transform
Geom::Affine _overflow_initial_transform
cairo_pattern_t * renderPattern(RenderContext &rc, Geom::IntRect const &area, float opacity, int device_scale) const
Render the pattern.
Geom::IntPoint _pattern_resolution
int tag() const override
Unlink this node and its subtree from the rendering tree and destroy.
RectangularCluster rc
Group belonging to an SVG drawing element.
_cairo_pattern cairo_pattern_t
Helper class to stream background task notifications as a series of messages.
Cairo::RefPtr< Cairo::ImageSurface > surface