diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2011-07-28 05:04:08 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2011-07-28 05:04:08 +0000 |
| commit | 905b8a96963f78358abfd109c0c49758c6fe4e9d (patch) | |
| tree | f36eff88e8cc148264f9ea46df7b525c6a9ea80e /src/display/drawing-context.cpp | |
| parent | Add deferred allocation functionality to DrawingSurface (diff) | |
| download | inkscape-905b8a96963f78358abfd109c0c49758c6fe4e9d.tar.gz inkscape-905b8a96963f78358abfd109c0c49758c6fe4e9d.zip | |
Per-item render cache.
Cache some offscreen data to facilitate smoother navigation.
(bzr r10347.1.20)
Diffstat (limited to 'src/display/drawing-context.cpp')
| -rw-r--r-- | src/display/drawing-context.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/display/drawing-context.cpp b/src/display/drawing-context.cpp index 8f37bb693..3c0c2163b 100644 --- a/src/display/drawing-context.cpp +++ b/src/display/drawing-context.cpp @@ -55,10 +55,23 @@ void DrawingContext::Save::save(DrawingContext &ct) * for drawing entire SPObjects when exporting. */ +DrawingContext::DrawingContext(cairo_t *ct, Geom::Point const &origin) + : _ct(ct) + , _surface(new DrawingSurface(cairo_get_group_target(ct), origin)) + , _delete_surface(true) + , _restore_context(true) +{ + _surface->_has_context = true; + cairo_reference(_ct); + cairo_save(_ct); + cairo_translate(_ct, -origin[Geom::X], -origin[Geom::Y]); +} + DrawingContext::DrawingContext(cairo_surface_t *surface, Geom::Point const &origin) : _ct(NULL) , _surface(new DrawingSurface(surface, origin)) , _delete_surface(true) + , _restore_context(false) { _surface->_has_context = true; _ct = _surface->createRawContext(); @@ -68,10 +81,14 @@ DrawingContext::DrawingContext(DrawingSurface &s) : _ct(s.createRawContext()) , _surface(&s) , _delete_surface(false) + , _restore_context(false) {} DrawingContext::~DrawingContext() { + if (_restore_context) { + cairo_restore(_ct); + } cairo_destroy(_ct); _surface->_has_context = false; if (_delete_surface) { |
