32 scale_factor *= device_scale;
33 pixsize.
x() *= device_scale;
34 pixsize.
y() *= device_scale;
40 if (ibox.
width() > pixsize.
x() || ibox.
height() > pixsize.
y()) {
41 auto sx =
static_cast<double>(ibox.
width()) / pixsize.
x();
42 auto sy =
static_cast<double>(ibox.
height()) / pixsize.
y();
44 scale_factor /= std::max(sx, sy);
45 ibox = (dbox *
Geom::Scale(scale_factor)).roundOutwards();
64 cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, pixsize.
x(), pixsize.
y());
67 if (checkerboard_color) {
68 guint rgba = *checkerboard_color;
76 cairo_pattern_destroy(pattern);
80 cairo_surface_flush(s);
102 g_object_unref(i.second);
109 key += (uri!=
nullptr) ? uri :
"";
118 std::map<Glib::ustring, GdkPixbuf *>::iterator found =
_pixmap_cache.find(
key);
120 return found->second;
131 double ,
unsigned int psize) {
146 std::map<Glib::ustring, GdkPixbuf *>::iterator found =
_pixmap_cache.find(
key);
148 g_object_unref(found->second);
149 found->second = NULL;
cairo_pattern_t * ink_cairo_pattern_create_checkerboard(guint32 rgba, bool use_alpha)
GdkPixbuf * ink_pixbuf_create_from_cairo_surface(cairo_surface_t *s)
Converts the Cairo surface to a GdkPixbuf pixel format, without allocating extra memory.
Cairo integration helpers.
struct _GdkPixbuf GdkPixbuf
Axis aligned, non-empty, generic rectangle.
static CRect from_xywh(C x, C y, C w, C h)
Create rectangle from origin and dimensions.
C height() const
Get the vertical extent of the rectangle.
C width() const
Get the horizontal extent of the rectangle.
CPoint min() const
Get the corner of the rectangle with smallest coordinate values.
Two-dimensional point with integer coordinates.
constexpr IntCoord x() const noexcept
constexpr IntCoord y() const noexcept
Axis aligned, non-empty rectangle.
Minimal wrapper over Cairo.
void setSource(cairo_pattern_t *source)
void transform(Geom::Affine const &trans)
void paint(double alpha=1.0)
void setOperator(cairo_operator_t op)
SVG drawing item for display.
void setTransform(Geom::Affine const &trans)
void update(Geom::IntRect const &area=Geom::IntRect::infinite(), Geom::Affine const &affine=Geom::identity(), unsigned flags=DrawingItem::STATE_ALL, unsigned reset=0)
void render(DrawingContext &dc, Geom::IntRect const &area, unsigned flags=0) const
std::map< Glib::ustring, GdkPixbuf * > _pixmap_cache
Glib::ustring cache_key(gchar const *uri, gchar const *name, unsigned psize) const
void remove_preview_from_cache(const Glib::ustring &key)
GdkPixbuf * get_preview_from_cache(const Glib::ustring &key)
GdkPixbuf * get_preview(const gchar *uri, const gchar *id, Inkscape::DrawingItem *root, double scale_factor, unsigned int psize)
void set_preview_in_cache(const Glib::ustring &key, GdkPixbuf *px)
Cairo drawing context with Inkscape extensions.
Canvas item belonging to an SVG drawing element.
struct _cairo_surface cairo_surface_t
Helper class to stream background task notifications as a series of messages.
static cairo_user_data_key_t key
GdkPixbuf * render_pixbuf(Inkscape::Drawing &drawing, double scale_factor, Geom::Rect const &dbox, unsigned psize)
cairo_surface_t * render_surface(Inkscape::Drawing &drawing, double scale_factor, Geom::Rect const &dbox, Geom::IntPoint pixsize, double device_scale, const guint32 *checkerboard_color, bool no_clip)