cairo-renderer.cpp revision d444ed610362dab3c3e727d1b110312318b84cb8
#define __SP_CAIRO_RENDERER_C__
/** \file
* Rendering with Cairo.
*/
/*
* Author:
* Miklos Erdelyi <erdelyim@gmail.com>
*
* Copyright (C) 2006 Miklos Erdelyi
*
* Licensed under GNU GPL
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_CAIRO_PDF
#ifndef PANGO_ENABLE_BACKEND
#define PANGO_ENABLE_BACKEND
#endif
#ifndef PANGO_ENABLE_ENGINE
#define PANGO_ENABLE_ENGINE
#endif
#include <signal.h>
#include <errno.h>
#include <libnr/n-art-bpath.h>
#include <libnr/nr-matrix-ops.h>
#include <libnr/nr-matrix-fns.h>
#include <libnr/nr-matrix-translate-ops.h>
#include <libnr/nr-scale-matrix-ops.h>
#include "display/nr-arena.h"
#include "display/nr-arena-item.h"
#include "display/nr-arena-group.h"
#include "display/canvas-bpath.h"
#include "sp-item.h"
#include "sp-item-group.h"
#include "marker-status.h"
#include "style.h"
#include "sp-marker.h"
#include "sp-linear-gradient.h"
#include "sp-radial-gradient.h"
#include "sp-root.h"
#include "sp-shape.h"
#include "sp-use.h"
#include "sp-text.h"
#include "sp-flowtext.h"
#include "sp-image.h"
#include "sp-symbol.h"
#include "sp-pattern.h"
#include "sp-mask.h"
#include "sp-clippath.h"
#include <unit-constants.h>
#include "cairo-renderer.h"
#include "cairo-render-context.h"
#include <cairo.h>
// include support for only the compiled-in surface types
#ifdef CAIRO_HAS_PDF_SURFACE
#include <cairo-pdf.h>
#endif
#ifdef CAIRO_HAS_PS_SURFACE
#include <cairo-ps.h>
#endif
//#define TRACE(_args) g_printf _args
// FIXME: expose these from sp-clippath/mask.cpp
struct SPClipPathView {
unsigned int key;
};
struct SPMaskView {
unsigned int key;
};
namespace Inkscape {
namespace Extension {
namespace Internal {
CairoRenderer::CairoRenderer(void)
{}
CairoRenderer::~CairoRenderer(void)
{
/* restore default signal handling for SIGPIPE */
#endif
return;
}
CairoRenderer::createContext(void)
{
// create initial render state
return new_context;
}
void
{
delete ctx;
}
/*
Here comes the rendering part which could be put into the 'render' methods of SPItems'
*/
/* The below functions are copy&pasted plus slightly modified from *_invoke_print functions. */
{
/* fixme: Think (Lauris) */
for (int m = SP_MARKER_LOC_START; m < SP_MARKER_LOC_QTY; m++) {
}
}
}
}
}
{
while (l) {
if (SP_IS_ITEM(o)) {
}
l = g_slist_remove (l, o);
}
}
{
bool translated = false;
translated = true;
}
}
if (translated) {
}
}
{
}
{
}
{
int w, h, rs;
}
ctx->addClippingRect(image->x.computed, image->y.computed, image->width.computed, image->height.computed);
}
nr_matrix_set_translate (&tp, x, y);
nr_matrix_multiply (&t, &s, &tp);
}
{
if (!SP_OBJECT_IS_CLONED (symbol))
return;
/* Cloned <symbol> is actually renderable */
// apply viewbox if set
if (0 /*symbol->viewBox_set*/) {
double view_width, view_height;
x = 0.0;
y = 0.0;
width = 1.0;
height = 1.0;
}
}
{
ctx->addClippingRect(root->x.computed, root->y.computed, root->width.computed, root->height.computed);
}
{
if (SP_IS_ROOT(item)) {
TRACE(("root\n"));
} else if (SP_IS_GROUP(item)) {
TRACE(("group\n"));
} else if (SP_IS_SHAPE(item)) {
TRACE(("shape\n"));
TRACE(("use begin---\n"));
TRACE(("---use end\n"));
} else if (SP_IS_SYMBOL(item)) {
TRACE(("symbol\n"));
} else if (SP_IS_TEXT(item)) {
TRACE(("text\n"));
} else if (SP_IS_FLOWTEXT(item)) {
TRACE(("flowtext\n"));
} else if (SP_IS_IMAGE(item)) {
TRACE(("image\n"));
}
}
void
{
// If parent_has_userspace is true the parent state's transform
// This is so because we use the image's/(flow)text's transform for positioning
// instead of explicitly specifying it and letting the renderer do the
// transformation before rendering the item.
}
void
{
if (state->need_layer) {
}
if (state->need_layer)
}
bool
{
if (ctx->_vector_based_target) {
// width and height in pt
} else {
}
NRRect d;
bool pageBoundingBox = true;
if (pageBoundingBox) {
} else {
if (ctx->_vector_based_target) {
// convert from px to pt
}
}
}
#include "macros.h" // SP_PRINT_*
void
{
return;
NRMatrix t;
//SP_PRINT_DRECT("clipd", cp->display->bbox);
ctx->setTransform(&t);
}
TRACE(("BEGIN clip\n"));
if (SP_IS_ITEM(child)) {
}
}
TRACE(("END clip\n"));
// do clipping only if this was the first call to applyClipPath
}
void
{
return;
//SP_PRINT_DRECT("maskd", &mask->display->bbox);
// TODO: should the bbox be transformed if maskUnits != userSpaceOnUse ?
NRMatrix t;
ctx->setTransform(&t);
}
// clip mask contents
ctx->addClippingRect(mask_bbox.x0, mask_bbox.y0, mask_bbox.x1 - mask_bbox.x0, mask_bbox.y1 - mask_bbox.y0);
TRACE(("BEGIN mask\n"));
if (SP_IS_ITEM(child)) {
}
}
TRACE(("END mask\n"));
}
void
calculatePreserveAspectRatio(unsigned int aspect_align, unsigned int aspect_clip, double vp_width, double vp_height,
{
if (aspect_align == SP_ASPECT_NONE)
return;
double new_width, new_height;
/* Now place viewbox to requested position */
switch (aspect_align) {
case SP_ASPECT_XMIN_YMIN:
break;
case SP_ASPECT_XMID_YMIN:
break;
case SP_ASPECT_XMAX_YMIN:
break;
case SP_ASPECT_XMIN_YMID:
break;
case SP_ASPECT_XMID_YMID:
break;
case SP_ASPECT_XMAX_YMID:
break;
case SP_ASPECT_XMIN_YMAX:
break;
case SP_ASPECT_XMID_YMAX:
break;
case SP_ASPECT_XMAX_YMAX:
break;
default:
break;
}
*height = new_height;
}
#include "clear-n_.h"
} /* namespace Internal */
} /* namespace Extension */
} /* namespace Inkscape */
/* End of GNU GPL code */
#endif /* HAVE_CAIRO_PDF */
/*
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 :