summaryrefslogtreecommitdiffstats
path: root/src/display/drawing.h
blob: b33c8976c439544bf0dd1d35c193c2fbaff20e4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// SPDX-License-Identifier: GPL-2.0-or-later
/**
 * @file
 * SVG drawing for display.
 *//*
 * Authors:
 *   Krzysztof Kosiński <tweenk.pl@gmail.com>
 *
 * Copyright (C) 2011 Authors
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 */

#ifndef SEEN_INKSCAPE_DISPLAY_DRAWING_H
#define SEEN_INKSCAPE_DISPLAY_DRAWING_H

#include <2geom/rect.h>
#include <boost/operators.hpp>
#include <boost/utility.hpp>
#include <set>
#include <sigc++/sigc++.h>

#include "display/drawing-item.h"
#include "display/rendermode.h"
#include "nr-filter-colormatrix.h"

typedef struct _SPCanvasArena SPCanvasArena;
typedef unsigned int guint32;

namespace Inkscape {

class DrawingItem;

class Drawing
    : boost::noncopyable
{
public:
    struct OutlineColors {
        guint32 paths;
        guint32 clippaths;
        guint32 masks;
        guint32 images;
    };

    Drawing(SPCanvasArena *arena = nullptr);
    ~Drawing();

    DrawingItem *root() { return _root; }
    SPCanvasArena *arena() { return _canvasarena; }
    void setRoot(DrawingItem *item);

    RenderMode renderMode() const;
    ColorMode colorMode() const;
    bool outline() const;
    bool visibleHairlines() const;
    bool renderFilters() const;
    int blurQuality() const;
    int filterQuality() const;
    void setRenderMode(RenderMode mode);
    void setColorMode(ColorMode mode);
    void setBlurQuality(int q);
    void setFilterQuality(int q);
    void setExact(bool e);
    bool getExact() const { return _exact; };
    void setOutlineSensitive(bool e);
    bool getOutlineSensitive() const { return _outline_sensitive; };

    Geom::OptIntRect const &cacheLimit() const;
    void setCacheLimit(Geom::OptIntRect const &r, bool update_cache = true);
    void setCacheBudget(size_t bytes);

    OutlineColors const &colors() const { return _colors; }

    void setGrayscaleMatrix(double value_matrix[20]);

    void update(Geom::IntRect const &area = Geom::IntRect::infinite(), unsigned flags = DrawingItem::STATE_ALL, unsigned reset = 0);
    void render(DrawingContext &dc, Geom::IntRect const &area, unsigned flags = 0, int antialiasing = -1);
    DrawingItem *pick(Geom::Point const &p, double delta, unsigned flags);

    sigc::signal<void, DrawingItem *> signal_request_update;
    sigc::signal<void, Geom::IntRect const &> signal_request_render;
    sigc::signal<void, DrawingItem *> signal_item_deleted;

private:
    void _pickItemsForCaching();

    typedef std::list<CacheRecord> CandidateList;
    bool _outline_sensitive;
    DrawingItem *_root;
    std::set<DrawingItem *> _cached_items; // modified by DrawingItem::setCached()
    CacheList _candidate_items;
public:
    // TODO: remove these temporarily public members
    guint32 outlinecolor;
    double delta;
private:
    bool _exact;  // if true then rendering must be exact
    RenderMode _rendermode;
    ColorMode _colormode;
    int _blur_quality;
    int _filter_quality;
    Geom::OptIntRect _cache_limit;

    double _cache_score_threshold; ///< do not consider objects for caching below this score
    size_t _cache_budget; ///< maximum allowed size of cache

    OutlineColors _colors;
    Filters::FilterColorMatrix::ColorMatrixMatrix _grayscale_colormatrix;
    SPCanvasArena *_canvasarena; // may be NULL if this arena is not the screen
                                 // but used for export etc.

    friend class DrawingItem;
};

} // end namespace Inkscape

#endif // !SEEN_INKSCAPE_DRAWING_H

/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :