inkscape-cairo.cpp revision ae9bb17bcf65f0e053c0b292a0b53f4a1435eb5c
/*
* Helper functions to use cairo with inkscape
*
* Copyright (C) 2007 bulia byak
* Copyright (C) 2008 Johan Engelen
*
* Released under GNU GPL
*
*/
#include <cairo.h>
#include <typeinfo>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <libnr/n-art-bpath.h>
#include <libnr/nr-matrix-ops.h>
#include <libnr/nr-matrix-fns.h>
#include <libnr/nr-pixblock.h>
#include <libnr/nr-convert2geom.h>
#include "../style.h"
#include "nr-arena.h"
#include "sp-canvas.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 *
{
}
/** Feeds path-creating calls to the cairo context translating them from the SPCurve, with the given transform and shift */
void
feed_curve_to_cairo (cairo_t *ct, NArtBpath const *bpath, NR::Matrix trans, NR::Maybe<NR::Rect> area, bool optimize_stroke, double stroke_width)
{
return;
bool closed = false;
case NR_MOVETO_OPEN:
case NR_MOVETO:
if (closed) {
}
// remember the start point of the subpath, for closing it later
closed = true;
} else {
closed = false;
}
break;
case NR_LINETO:
if (optimize_stroke) {
//std::cout << "swept: " << swept;
//std::cout << "view: " << view;
//std::cout << "intersects? " << (swept.intersects(view)? "YES" : "NO") << "\n";
}
else
break;
case NR_CURVETO: {
if (optimize_stroke) {
}
else
break;
}
default:
break;
}
}
}
static void
feed_curve_to_cairo(cairo_t *cr, Geom::Curve const &c, Geom::Matrix & trans, Geom::Rect view, bool optimize_stroke)
{
if( typeid(c) == typeid(Geom::LineSegment) ||
typeid(c) == typeid(Geom::HLineSegment) ||
typeid(c) == typeid(Geom::VLineSegment) )
{
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::EllipticalArc const *svg_elliptical_arc = dynamic_cast<Geom::EllipticalArc *>(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 SPCurve, with the given transform and shift */
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.
}
// 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 SPCurve, with the given transform and shift */
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;
}
}
/*
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 :