Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Inkscape::DrawingSurface Class Reference

Drawing surface that remembers its origin. More...

#include <drawing-surface.h>

Inheritance diagram for Inkscape::DrawingSurface:
Inkscape::DrawingCache

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_traw ()
 
cairo_tcreateRawContext ()
 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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ DrawingSurface() [1/3]

Inkscape::DrawingSurface::DrawingSurface ( Geom::IntRect const &  area,
int  device_scale = 1 
)
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.

◆ DrawingSurface() [2/3]

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.

Parameters
logboxLogical extents of the surface
pixdimsPixel dimensions of the surface.

Definition at line 59 of file drawing-surface.cpp.

References _device_scale.

◆ DrawingSurface() [3/3]

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.

◆ ~DrawingSurface()

Inkscape::DrawingSurface::~DrawingSurface ( )
virtual

Definition at line 93 of file drawing-surface.cpp.

References _surface.

Member Function Documentation

◆ area()

◆ createRawContext()

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().

◆ device_scale()

int Inkscape::DrawingSurface::device_scale ( ) const
inline

Definition at line 43 of file drawing-surface.h.

References _device_scale.

Referenced by Inkscape::DrawingItem::render().

◆ dimensions()

Geom::Point Inkscape::DrawingSurface::dimensions ( ) const
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().

◆ drawingTransform()

Geom::Affine Inkscape::DrawingSurface::drawingTransform ( ) const
inline

Get the transformation applied to the drawing context on construction.

Definition at line 44 of file drawing-surface.h.

References _origin, and _scale.

◆ dropContents()

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.

◆ origin()

Geom::Point Inkscape::DrawingSurface::origin ( ) const
inline

Definition at line 41 of file drawing-surface.h.

References _origin.

Referenced by Inkscape::DrawingContext::setSource().

◆ pixelArea()

Geom::IntRect Inkscape::DrawingSurface::pixelArea ( ) const
protected

◆ pixels()

Geom::IntPoint Inkscape::DrawingSurface::pixels ( ) const
inline

Get the pixel dimensions of the surface.

Definition at line 39 of file drawing-surface.h.

References _pixels.

◆ raw()

cairo_surface_t * Inkscape::DrawingSurface::raw ( )
inline

Definition at line 47 of file drawing-surface.h.

References _surface.

Referenced by Inkscape::DrawingContext::setSource().

◆ scale()

Geom::Scale Inkscape::DrawingSurface::scale ( ) const
inline

Definition at line 42 of file drawing-surface.h.

References _scale.

Friends And Related Symbol Documentation

◆ DrawingContext

friend class DrawingContext
friend

Definition at line 60 of file drawing-surface.h.

Member Data Documentation

◆ _device_scale

int Inkscape::DrawingSurface::_device_scale
protected

◆ _has_context

bool Inkscape::DrawingSurface::_has_context
protected

◆ _origin

Geom::Point Inkscape::DrawingSurface::_origin
protected

◆ _pixels

Geom::IntPoint Inkscape::DrawingSurface::_pixels
protected

◆ _scale

Geom::Scale Inkscape::DrawingSurface::_scale
protected

Definition at line 55 of file drawing-surface.h.

Referenced by createRawContext(), dimensions(), drawingTransform(), and scale().

◆ _surface

cairo_surface_t* Inkscape::DrawingSurface::_surface
protected

The documentation for this class was generated from the following files: