inkscape-cairo.cpp revision 77eda576f455eeb23c7b92510f38bc60738473ab
/*
* Helper functions to use cairo with inkscape
*
* Copyright (C) 2007 bulia byak
* Copyright (C) 2008 Johan Engelen
*
* Released under GNU GPL
*
*/
#include <cairo.h>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <libnr/nr-pixblock.h>
#include <libnr/nr-convert2geom.h>
#include "../style.h"
#include "nr-arena.h"
#include "sp-canvas.h"
#include "helper/geom-curves.h"
/** Creates a cairo context to render to the given pixblock on the given area */
cairo_t *
nr_create_cairo_context_for_data (NRRectL *area, NRRectL *buf_area, unsigned char *px, unsigned int rowstride)
{
return NULL;
// even though cairo cannot draw in nonpremul mode, select ARGB32 for R8G8B8A8N as the closest; later eliminate R8G8B8A8N everywhere
(dpx,
return ct;
}
/** Creates a cairo context to render to the given SPCanvasBuf on the given area */
cairo_t *
{
}
/** Creates a cairo context to render to the given NRPixBlock on the given area */
cairo_t *
{
}
/*
* Can be called recursively.
* If optimize_stroke == false, the view Rect is not used.
*/
static void
feed_curve_to_cairo(cairo_t *cr, Geom::Curve const &c, Geom::Matrix const & trans, Geom::Rect view, bool optimize_stroke)
{
if( is_straight_curve(c) )
{
if (!optimize_stroke) {
} else {
} else {
}
}
}
else if(Geom::QuadraticBezier const *quadratic_bezier = dynamic_cast<Geom::QuadraticBezier const*>(&c)) {
if (!optimize_stroke) {
} else {
} else {
}
}
}
//points[0] *= trans; // don't do this one here for fun: it is only needed for optimized strokes
if (!optimize_stroke) {
cairo_curve_to(cr, points[1][0], points[1][1], points[2][0], points[2][1], points[3][0], points[3][1]);
} else {
cairo_curve_to(cr, points[1][0], points[1][1], points[2][0], points[2][1], points[3][0], points[3][1]);
} else {
}
}
}
// else if(Geom::SVGEllipticalArc const *svg_elliptical_arc = dynamic_cast<Geom::SVGEllipticalArc *>(c)) {
// //TODO: get at the innards and spit them out to cairo
// }
else {
//this case handles sbasis as well as all other curve types
//recurse to convert the new path resulting from the sbasis to svgd
}
}
}
/** Feeds path-creating calls to the cairo context translating them from the Path */
static void
{
return;
feed_curve_to_cairo(ct, *cit, Geom::identity(), Geom::Rect(), false); // optimize_stroke is false, so the view rect is not used
}
// cairo_close_path(ct);
/* I think we should use cairo_close_path(ct) here but it doesn't work. (the closing line is not rendered completely)
According to cairo documentation:
The behavior of cairo_close_path() is distinct from simply calling cairo_line_to() with the equivalent coordinate
in the case of stroking. When a closed sub-path is stroked, there are no caps on the ends of the sub-path. Instead,
there is a line join connecting the final and initial segments of the sub-path.
*/
}
}
/** Feeds path-creating calls to the cairo context translating them from the Path, with the given transform and shift */
static void
feed_path_to_cairo (cairo_t *ct, Geom::Path const &path, Geom::Matrix trans, NR::Maybe<NR::Rect> area, bool optimize_stroke, double stroke_width)
{
return;
return;
// Transform all coordinates to coords within "area"
// Pass transformation to feed_curve, so that we don't need to create a whole new path.
}
/* It seems we cannot use cairo_close_path(ct) here; maybe because some parts of the path have been clipped and not drawn (maybe the before last segment was outside view area)
However, according to cairo documentation:
The behavior of cairo_close_path() is distinct from simply calling cairo_line_to() with the equivalent coordinate
in the case of stroking. When a closed sub-path is stroked, there are no caps on the ends of the sub-path. Instead,
there is a line join connecting the final and initial segments of the sub-path.
*/
}
}
/** Feeds path-creating calls to the cairo context translating them from the PathVector, with the given transform and shift
* One must have done cairo_new_path(ct); before calling this function. */
void
feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv, Geom::Matrix trans, NR::Maybe<NR::Rect> area, bool optimize_stroke, double stroke_width)
{
return;
return;
}
}
/** Feeds path-creating calls to the cairo context translating them from the PathVector
* One must have done cairo_new_path(ct); before calling this function. */
void
{
return;
}
}
/*
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:encoding=utf-8:textwidth=99 :