Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
drawing-surface.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
/*
6 * Authors:
7 * Krzysztof KosiƄski <tweenk.pl@gmail.com>
8 *
9 * Copyright (C) 2011 Authors
10 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
11 */
12
13#ifndef INKSCAPE_DISPLAY_DRAWING_SURFACE_H
14#define INKSCAPE_DISPLAY_DRAWING_SURFACE_H
15
16#include <cairo.h>
17#include <2geom/affine.h>
18#include <2geom/rect.h>
19#include <2geom/transforms.h>
20
21extern "C" {
22typedef struct _cairo cairo_t;
23typedef struct _cairo_surface cairo_surface_t;
24typedef struct _cairo_region cairo_region_t;
25}
26
27namespace Inkscape {
28class DrawingContext;
29
31{
32public:
33 explicit DrawingSurface(Geom::IntRect const &area, int device_scale = 1);
34 DrawingSurface(Geom::Rect const &logbox, Geom::IntPoint const &pixdims, int device_scale = 1);
36 virtual ~DrawingSurface();
37
39 Geom::IntPoint pixels() const { return _pixels; }
40 Geom::Point dimensions() const { return _pixels / _scale.vector(); }
41 Geom::Point origin() const { return _origin; }
42 Geom::Scale scale() const { return _scale; }
43 int device_scale() const { return _device_scale; }
45 void dropContents();
46
49
50protected:
52
59
60 friend class DrawingContext;
61};
62
64 : public DrawingSurface
65{
66public:
67 explicit DrawingCache(Geom::IntRect const &area, int device_scale = 1);
68 ~DrawingCache() override;
69
72 void scheduleTransform(Geom::IntRect const &new_area, Geom::Affine const &trans);
73 void prepare();
74 void paintFromCache(DrawingContext &dc, Geom::OptIntRect &area, bool is_filter);
75
76protected:
80
81private:
82 void _dumpCache(Geom::OptIntRect const &area);
83};
84
85} // namespace Inkscape
86
87#endif // INKSCAPE_DISPLAY_DRAWING_SURFACE_H
88
89/*
90 Local Variables:
91 mode:c++
92 c-file-style:"stroustrup"
93 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
94 indent-tabs-mode:nil
95 fill-column:99
96 End:
97*/
98// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
3x3 affine transformation matrix.
Cairo::RefPtr< Cairo::ImageSurface > surface
Definition canvas.cpp:137
3x3 matrix representing an affine transformation.
Definition affine.h:70
Axis-aligned generic rectangle that can be empty.
Axis aligned, non-empty, generic rectangle.
static CRect from_xywh(Coord x, Coord y, Coord w, Coord h)
Create rectangle from origin and dimensions.
static CRect infinite()
Create infinite rectangle.
Two-dimensional point with integer coordinates.
Definition int-point.h:57
Two-dimensional point that doubles as a vector.
Definition point.h:66
Axis aligned, non-empty rectangle.
Definition rect.h:92
Scaling from the origin.
Definition transforms.h:150
Point vector() const
Definition transforms.h:171
Translation by a vector.
Definition transforms.h:115
void markDirty(Geom::IntRect const &area=Geom::IntRect::infinite())
void prepare()
Transforms the cache according to the transform specified during the update phase.
void paintFromCache(DrawingContext &dc, Geom::OptIntRect &area, bool is_filter)
Paints the clean area from cache and modifies the area parameter to the bounds of the region that mus...
void scheduleTransform(Geom::IntRect const &new_area, Geom::Affine const &trans)
Call this during the update phase to schedule a transformation of the cache.
Geom::Affine _pending_transform
void _dumpCache(Geom::OptIntRect const &area)
void markClean(Geom::IntRect const &area=Geom::IntRect::infinite())
cairo_region_t * _clean_region
Geom::IntRect _pending_area
Minimal wrapper over Cairo.
Drawing surface that remembers its origin.
void dropContents()
Drop contents of the surface and release the underlying Cairo object.
Geom::IntRect pixelArea() const
cairo_t * createRawContext()
Create a drawing context for this surface.
Geom::Affine drawingTransform() const
Get the transformation applied to the drawing context on construction.
Geom::Point origin() const
Geom::Rect area() const
Get the logical extents of the surface.
cairo_surface_t * raw()
Geom::Point dimensions() const
Get the logical width and weight of the surface as a point.
Geom::IntPoint pixels() const
Get the pixel dimensions of the surface.
Geom::Scale scale() const
cairo_surface_t * _surface
struct _cairo_surface cairo_surface_t
struct _cairo_region cairo_region_t
Helper class to stream background task notifications as a series of messages.
struct _cairo cairo_t
Definition path-cairo.h:16
Axis-aligned rectangle.
Affine transformation classes.