cairo-utils.h revision c4b7d06a7a266052b966b47e25d5e3a0dfbfbd70
/**
* @file
* Cairo integration helpers.
*//*
* Authors:
* Krzysztof KosiĆski <tweenk.pl@gmail.com>
*
* Copyright (C) 2010 Authors
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <boost/noncopyable.hpp>
#include <glib.h>
#include "style.h"
struct SPColor;
void ink_cairo_pixbuf_cleanup(guchar *, void *);
/**
* RAII idiom for Cairo groups.
* Groups are temporary surfaces used when rendering e.g. masks and opacity.
* Use this class to ensure that each group push is matched with a pop.
*/
~CairoGroup();
void push();
cairo_pattern_t *pop();
void pop_to_source();
bool pushed;
};
/** RAII idiom for Cairo state saving. */
{
if (save) {
cairo_save(ct);
}
}
void save() {
if (!saved) {
cairo_save(ct);
saved = true;
}
}
~CairoSave() {
if (saved)
}
bool saved;
};
/** Cairo context with Inkscape-specific operations. */
};
/** Class to hold image data for raster images.
* Allows easy interoperation with GdkPixbuf and Cairo. */
enum PixelFormat {
PF_CAIRO = 1,
PF_GDK = 2,
};
~Pixbuf();
//Glib::RefPtr<Gdk::Pixbuf> getPixbuf(bool convert_format = true);
int width() const;
int height() const;
int rowstride() const;
void markDirty();
bool hasMimeData() const;
void _ensurePixelsARGB32();
void _ensurePixelsPixbuf();
void _forceAlpha();
bool _cairo_store;
};
} // namespace Inkscape
// TODO: these declarations may not be needed in the header
extern cairo_user_data_key_t ink_pixbuf_key;
void ink_cairo_surface_average_color(cairo_surface_t *surface, double &r, double &g, double &b, double &a);
void ink_cairo_surface_average_color_premul(cairo_surface_t *surface, double &r, double &g, double &b, double &a);
double srgb_to_linear( const double c );
/** Convert a pixel in 0xRRGGBBAA format to Cairo ARGB32 format. */
G_GNUC_CONST inline guint32
{
}
G_GNUC_CONST inline guint32
{
// NOTE: you must check for alpha != 0 yourself.
}
// TODO: move those to 2Geom
void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv, Geom::Affine trans, Geom::OptRect area, bool optimize_stroke, double stroke_width);
#define EXTRACT_ARGB32(px,a,r,g,b) \
guint32 a, r, g, b; \
b = ((px) & 0x000000ff);
#define ASSEMBLE_ARGB32(px,a,r,g,b) \
inline double srgb_to_linear( const double c ) {
if( c < 0.04045 ) {
return c / 12.92;
} else {
}
}
{
{
b = ((px) & 0x000000ff);
}
{
b = ((px) & 0x000000ff);
}
{
return (a << 24) | (r << 16) | (g << 8) | b;
}
} // namespace Display
} // namespace Inkscape
#endif // SEEN_INKSCAPE_DISPLAY_CAIRO_UTILS_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 :