Inkscape
Vector Graphics Editor
|
Drawing surface that remembers its origin. More...
#include <drawing-surface.h>
Public Member Functions | |
DrawingSurface (Geom::IntRect const &area, int device_scale=1) | |
Creates a surface with the given physical extents. | |
DrawingSurface (Geom::Rect const &logbox, Geom::IntPoint const &pixdims, int device_scale=1) | |
Creates a surface with the given logical and physical extents. | |
DrawingSurface (cairo_surface_t *surface, Geom::Point const &origin) | |
Wrap a cairo_surface_t. | |
virtual | ~DrawingSurface () |
Geom::Rect | area () const |
Get the logical extents of the surface. | |
Geom::IntPoint | pixels () const |
Get the pixel dimensions of the surface. | |
Geom::Point | dimensions () const |
Get the logical width and weight of the surface as a point. | |
Geom::Point | origin () const |
Geom::Scale | scale () const |
int | device_scale () const |
Geom::Affine | drawingTransform () const |
Get the transformation applied to the drawing context on construction. | |
void | dropContents () |
Drop contents of the surface and release the underlying Cairo object. | |
cairo_surface_t * | raw () |
cairo_t * | createRawContext () |
Create a drawing context for this surface. | |
Protected Member Functions | |
Geom::IntRect | pixelArea () const |
Protected Attributes | |
cairo_surface_t * | _surface |
Geom::Point | _origin |
Geom::Scale | _scale |
Geom::IntPoint | _pixels |
int | _device_scale |
bool | _has_context |
Friends | |
class | DrawingContext |
Drawing surface that remembers its origin.
This is a very minimalistic wrapper over cairo_surface_t. The main extra functionality provided by this class is that it automates the mapping from "logical space" (coordinates in the rendering) and the "physical space" (surface pixels). For example, patterns have to be rendered on tiles which have possibly non-integer widths and heights.
This class has delayed allocation functionality - it creates the Cairo surface it wraps on the first call to createRawContext() of when a DrawingContext is constructed.
Definition at line 30 of file drawing-surface.h.
|
explicit |
Creates a surface with the given physical extents.
When a drawing context is created for this surface, its pixels will cover the area under the given rectangle.
Definition at line 41 of file drawing-surface.cpp.
References _device_scale.
Inkscape::DrawingSurface::DrawingSurface | ( | Geom::Rect const & | logbox, |
Geom::IntPoint const & | pixdims, | ||
int | device_scale = 1 |
||
) |
Creates a surface with the given logical and physical extents.
When a drawing context is created for this surface, its pixels will cover the area under the given rectangle. IT will contain the number of pixels specified by the second argument.
logbox | Logical extents of the surface |
pixdims | Pixel dimensions of the surface. |
Definition at line 59 of file drawing-surface.cpp.
References _device_scale.
Inkscape::DrawingSurface::DrawingSurface | ( | cairo_surface_t * | surface, |
Geom::Point const & | origin | ||
) |
Wrap a cairo_surface_t.
This constructor will take an extra reference on surface, which will be released on destruction.
Definition at line 74 of file drawing-surface.cpp.
References _device_scale, _pixels, and surface.
|
virtual |
Definition at line 93 of file drawing-surface.cpp.
References _surface.
|
inline |
Get the logical extents of the surface.
Definition at line 38 of file drawing-surface.h.
References _origin, dimensions(), and Geom::GenericRect< Coord >::from_xywh().
Referenced by Inkscape::DrawingCache::_dumpCache(), Inkscape::DrawingCache::markClean(), Inkscape::DrawingCache::markDirty(), Inkscape::DrawingCache::paintFromCache(), and Inkscape::DrawingContext::targetLogicalBounds().
cairo_t * Inkscape::DrawingSurface::createRawContext | ( | ) |
Create a drawing context for this surface.
It's better to use the surface constructor of DrawingContext.
Definition at line 113 of file drawing-surface.cpp.
References _device_scale, _origin, _pixels, _scale, _surface, Geom::Scale::identity(), Geom::Scale::vector(), Geom::IntPoint::x(), Geom::Point::x(), Geom::IntPoint::y(), and Geom::Point::y().
Referenced by Inkscape::DrawingContext::DrawingContext(), and Inkscape::DrawingCache::prepare().
|
inline |
Definition at line 43 of file drawing-surface.h.
References _device_scale.
Referenced by Inkscape::DrawingItem::render().
|
inline |
Get the logical width and weight of the surface as a point.
Definition at line 40 of file drawing-surface.h.
References _pixels, _scale, and Geom::Scale::vector().
Referenced by area().
|
inline |
Get the transformation applied to the drawing context on construction.
Definition at line 44 of file drawing-surface.h.
void Inkscape::DrawingSurface::dropContents | ( | ) |
Drop contents of the surface and release the underlying Cairo object.
Definition at line 101 of file drawing-surface.cpp.
References _surface.
|
inline |
Definition at line 41 of file drawing-surface.h.
References _origin.
Referenced by Inkscape::DrawingContext::setSource().
|
protected |
Definition at line 130 of file drawing-surface.cpp.
References _origin, _pixels, Geom::GenericRect< C >::from_xywh(), and Geom::Point::round().
Referenced by Inkscape::DrawingCache::markClean(), and Inkscape::DrawingCache::prepare().
|
inline |
Get the pixel dimensions of the surface.
Definition at line 39 of file drawing-surface.h.
References _pixels.
|
inline |
Definition at line 47 of file drawing-surface.h.
References _surface.
Referenced by Inkscape::DrawingContext::setSource().
|
inline |
Definition at line 42 of file drawing-surface.h.
References _scale.
|
friend |
Definition at line 60 of file drawing-surface.h.
|
protected |
Definition at line 57 of file drawing-surface.h.
Referenced by createRawContext(), device_scale(), DrawingSurface(), DrawingSurface(), and DrawingSurface().
|
protected |
Definition at line 58 of file drawing-surface.h.
Referenced by Inkscape::DrawingContext::DrawingContext(), Inkscape::DrawingContext::DrawingContext(), and Inkscape::DrawingContext::~DrawingContext().
|
protected |
Definition at line 54 of file drawing-surface.h.
Referenced by Inkscape::DrawingCache::_dumpCache(), area(), createRawContext(), drawingTransform(), origin(), pixelArea(), and Inkscape::DrawingCache::prepare().
|
protected |
Definition at line 56 of file drawing-surface.h.
Referenced by createRawContext(), dimensions(), DrawingSurface(), pixelArea(), pixels(), and Inkscape::DrawingCache::prepare().
|
protected |
Definition at line 55 of file drawing-surface.h.
Referenced by createRawContext(), dimensions(), drawingTransform(), and scale().
|
protected |
Definition at line 53 of file drawing-surface.h.
Referenced by Inkscape::DrawingCache::_dumpCache(), createRawContext(), dropContents(), Inkscape::DrawingCache::prepare(), raw(), and ~DrawingSurface().