summaryrefslogtreecommitdiffstats
path: root/src/ui/cache/svg_preview_cache.h
blob: 9006eb42626933162f09b265f3ab251d105ed887 (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
// SPDX-License-Identifier: GPL-2.0-or-later
/** @file
 * @brief Preview cache
 */
/*
 * Copyright (C) 2007 Bryce W. Harrington <bryce@bryceharrington.org>
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 */

#ifndef SEEN_INKSCAPE_UI_SVG_PREVIEW_CACHE_H
#define SEEN_INKSCAPE_UI_SVG_PREVIEW_CACHE_H

#include <map>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <glibmm/ustring.h>
#include <2geom/rect.h>
#include <2geom/int-point.h>

namespace Inkscape {

class Drawing;
class DrawingItem;

} // namespace Inkscape


cairo_surface_t* render_surface(Inkscape::Drawing &drawing, double scale_factor, const Geom::Rect& dbox,
    Geom::IntPoint pixsize, double device_scale, const guint32* checkerboard_color, bool no_clip);

GdkPixbuf* render_pixbuf(Inkscape::Drawing &drawing, double scale_factor, const Geom::Rect& dbox, unsigned psize);

namespace Inkscape {
namespace UI {
namespace Cache {

class SvgPreview {
 protected:
    std::map<Glib::ustring, GdkPixbuf*>   _pixmap_cache;

 public:
    SvgPreview();
    ~SvgPreview();

    Glib::ustring cache_key(gchar const *uri, gchar const *name, unsigned psize) const;
    GdkPixbuf*    get_preview_from_cache(const Glib::ustring& key);
    void          set_preview_in_cache(const Glib::ustring& key, GdkPixbuf* px);
    GdkPixbuf*    get_preview(const gchar* uri, const gchar* id, Inkscape::DrawingItem *root, double scale_factor, unsigned int psize);
    void          remove_preview_from_cache(const Glib::ustring& key);
};

}; // namespace Cache
}; // namespace UI
}; // namespace Inkscape



#endif // SEEN_INKSCAPE_UI_SVG_PREVIEW_CACHE_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 :