~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to src/display/drawing-surface.h

  • Committer: JazzyNico
  • Date: 2011-08-29 20:25:30 UTC
  • Revision ID: nicoduf@yahoo.fr-20110829202530-6deuoz11q90usldv
Code refactoring and merging with trunk (revision 10599).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * @file
 
3
 * @brief Cairo surface that remembers its origin
 
4
 *//*
 
5
 * Authors:
 
6
 *   Krzysztof Kosiński <tweenk.pl@gmail.com>
 
7
 *
 
8
 * Copyright (C) 2011 Authors
 
9
 * Released under GNU GPL, read the file 'COPYING' for more information
 
10
 */
 
11
 
 
12
#ifndef SEEN_INKSCAPE_DISPLAY_DRAWING_SURFACE_H
 
13
#define SEEN_INKSCAPE_DISPLAY_DRAWING_SURFACE_H
 
14
 
 
15
#include <boost/shared_ptr.hpp>
 
16
#include <cairo.h>
 
17
#include <gdk-pixbuf/gdk-pixbuf.h>
 
18
#include <2geom/affine.h>
 
19
#include <2geom/rect.h>
 
20
#include <2geom/transforms.h>
 
21
 
 
22
namespace Inkscape {
 
23
class DrawingContext;
 
24
 
 
25
class DrawingSurface
 
26
{
 
27
public:
 
28
    explicit DrawingSurface(Geom::IntRect const &area);
 
29
    DrawingSurface(Geom::Rect const &logbox, Geom::IntPoint const &pixdims);
 
30
    DrawingSurface(cairo_surface_t *surface, Geom::Point const &origin);
 
31
    virtual ~DrawingSurface();
 
32
 
 
33
    Geom::Rect area() const;
 
34
    Geom::IntPoint pixels() const;
 
35
    Geom::Point dimensions() const;
 
36
    Geom::Point origin() const;
 
37
    Geom::Scale scale() const;
 
38
    Geom::Affine drawingTransform() const;
 
39
    cairo_surface_type_t type() const;
 
40
    void dropContents();
 
41
 
 
42
    cairo_surface_t *raw() { return _surface; }
 
43
    cairo_t *createRawContext();
 
44
 
 
45
protected:
 
46
    Geom::IntRect pixelArea() const;
 
47
 
 
48
    cairo_surface_t *_surface;
 
49
    Geom::Point _origin;
 
50
    Geom::Scale _scale;
 
51
    Geom::IntPoint _pixels;
 
52
    bool _has_context;
 
53
 
 
54
    friend class DrawingContext;
 
55
};
 
56
 
 
57
class DrawingCache
 
58
    : public DrawingSurface
 
59
{
 
60
public:
 
61
    explicit DrawingCache(Geom::IntRect const &area);
 
62
    ~DrawingCache();
 
63
 
 
64
    void markDirty(Geom::IntRect const &area = Geom::IntRect::infinite());
 
65
    void markClean(Geom::IntRect const &area = Geom::IntRect::infinite());
 
66
    void scheduleTransform(Geom::IntRect const &new_area, Geom::Affine const &trans);
 
67
    void prepare();
 
68
    void paintFromCache(DrawingContext &ct, Geom::OptIntRect &area);
 
69
 
 
70
protected:
 
71
    cairo_region_t *_clean_region;
 
72
    Geom::IntRect _pending_area;
 
73
    Geom::Affine _pending_transform;
 
74
private:
 
75
    void _dumpCache(Geom::OptIntRect const &area);
 
76
    static cairo_rectangle_int_t _convertRect(Geom::IntRect const &r);
 
77
    static Geom::IntRect _convertRect(cairo_rectangle_int_t const &r);
 
78
};
 
79
 
 
80
} // end namespace Inkscape
 
81
 
 
82
#endif // !SEEN_INKSCAPE_DISPLAY_DRAWING_ITEM_H
 
83
 
 
84
/*
 
85
  Local Variables:
 
86
  mode:c++
 
87
  c-file-style:"stroustrup"
 
88
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
89
  indent-tabs-mode:nil
 
90
  fill-column:99
 
91
  End:
 
92
*/
 
93
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :