nr-arena-shape.cpp revision 9afebee14c02f00152d69ac83b6e537d34e1357f
#define __NR_ARENA_SHAPE_C__
/*
* RGBA display list system for inkscape
*
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
*
* Copyright (C) 2001-2002 Lauris Kaplinski
* Copyright (C) 2001 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <display/canvas-arena.h>
#include <display/nr-arena.h>
#include <display/nr-arena-shape.h>
#include <libnr/nr-pixops.h>
#include <libnr/nr-convert2geom.h>
#include <livarot/float-line.h>
#include <livarot/int-line.h>
#include <style.h>
#include "inkscape-cairo.h"
#include "helper/geom-curves.h"
#include "sp-filter.h"
#include "sp-filter-reference.h"
#include "display/nr-filter.h"
#include <typeinfo>
#include <cairo.h>
#include "preferences.h"
#include <glib.h>
#include <fenv.h>
//int showRuns=0;
static void nr_arena_shape_set_child_position(NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref);
static guint nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, guint reset);
static unsigned int nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags);
static NRArenaItem *nr_arena_shape_pick(NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky);
static NRArenaItemClass *shape_parent_class;
nr_arena_shape_get_type(void)
{
if (!type) {
"NRArenaShape",
sizeof(NRArenaShapeClass),
sizeof(NRArenaShape),
(void (*)(NRObjectClass *)) nr_arena_shape_class_init,
(void (*)(NRObject *)) nr_arena_shape_init);
}
return type;
}
static void
{
}
/**
* Initializes the arena shape, setting all parameters to null, 0, false,
* or other defaults
*/
static void
{
shape->delayed_shp = false;
shape->repick_after = 0;
}
static void
{
}
/**
* Retrieves the markers from the item
*/
static NRArenaItem *
{
}
/**
* Attaches child to item, and if ref is not NULL, sets it and ref->next as
* the prev and next items. If ref is NULL, then it sets the item's markers
* as the next items.
*/
static void
{
if (!ref) {
} else {
}
}
/**
* Removes child from the shape. If there are no prev items in
* the child, it sets items' markers to the next item in the child.
*/
static void
{
} else {
}
}
/**
* Detaches child from item, and if there are no previous items in child, it
* sets item's markers to the child. It then attaches the child back onto the item.
* If ref is null, it sets the markers to be the next item, otherwise it uses
*/
static void
{
} else {
}
if (!ref) {
} else {
}
}
/**
* Updates the arena shape 'item' and all of its children, including the markers.
*/
static guint
{
unsigned int beststate = NR_ARENA_ITEM_STATE_ALL;
// update markers
unsigned int newstate;
}
if (!(state & NR_ARENA_ITEM_STATE_RENDER)) {
/* We do not have to create rendering structures */
if (state & NR_ARENA_ITEM_STATE_BBOX) {
if (boundingbox) {
item->bbox.x0 = static_cast<NR::ICoord>(floor((*boundingbox)[0][0])); // Floor gives the coordinate in which the point resides
item->bbox.x1 = static_cast<NR::ICoord>(ceil ((*boundingbox)[0][1])); // Ceil gives the first coordinate beyond the point
} else {
}
}
if (beststate & NR_ARENA_ITEM_STATE_BBOX) {
}
}
}
}
shape->delayed_shp=true;
// clear Cairo data to force update
}
}
// those pesky miters, now
if ( miterMax > 0.01 ) {
// grunt mode. we should compute the various miters instead
// (one for each point on the curve)
}
}
}
/// \todo just write item->bbox = boundingbox
if (boundingbox) {
} else {
}
// TODO: compute a better bounding box that respects miters
{
//item->bbox = shape->approx_bbox;
return NR_ARENA_ITEM_STATE_ALL;
}
if (beststate & NR_ARENA_ITEM_STATE_BBOX) {
}
}
return NR_ARENA_ITEM_STATE_ALL;
}
// cairo outline rendering:
static unsigned int
{
if (!ct)
// FIXME: we use RGBA buffers but cairo writes BGRA (on i386), so we must cheat
// by setting color channels in the "wrong" order
cairo_set_source_rgba(ct, SP_RGBA32_B_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_R_F(rgba), SP_RGBA32_A_F(rgba));
}
/**
* Renders the item. Markers are just composed into the parent buffer.
*/
static unsigned int
nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags)
{
// skip if not within bounding box
}
//bool print_colors_preview = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_PRINT_COLORS_PREVIEW);
if (outline) { // cairo outline rendering
} else {
bool has_stroke, has_fill;
// we assume the context has no path
cairo_save(ct);
// update fill and stroke paints.
// this cannot be done during nr_arena_shape_update, because we need a Cairo context
// to render svg:pattern
if (has_fill || has_stroke) {
if (needs_opacity) {
}
// TODO: remove segments outside of bbox when no dashes present
if (has_fill) {
}
if (has_stroke) {
}
if (needs_opacity) {
}
} // has fill or stroke pattern
}
/* Render markers into parent buffer */
}
}
static guint
{
// NOTE: for now this is incorrect, because it doesn't honor clip-rule,
// and will be incorrect for nested clipping paths.
cairo_save(ct);
}
static NRArenaItem *
{
if (shape->repick_after > 0)
shape->repick_after--;
if (shape->repick_after > 0) // we are a slow, huge path. skip this pick, returning what was returned last time
// fully transparent, no pick unless outline mode
return NULL;
double width;
if (outline) {
width = 0.5;
} else if (shape->nrstyle.stroke.type != NRStyle::PAINT_NONE && shape->nrstyle.stroke.opacity > 1e-3) {
} else {
width = 0;
}
int wind = 0;
pathv_matrix_point_bbox_wind_distance(shape->curve->get_pathvector(), shape->ctm, p, NULL, needfill? &wind : NULL, &dist, 0.5, &viewbox);
} else {
pathv_matrix_point_bbox_wind_distance(shape->curve->get_pathvector(), shape->ctm, p, NULL, needfill? &wind : NULL, &dist, 0.5, NULL);
}
//g_print ("pick time %lu\n", this_pick);
}
// covered by fill?
if (needfill) {
if (wind != 0) {
return item;
}
} else {
if (wind & 0x1) {
return item;
}
}
}
// close to the edge, as defined by strokewidth and delta?
// this ignores dashing (as if the stroke is solid) and always works as if caps are round
return item;
}
}
// if not picked on the shape itself, try its markers
if (ret) {
return item;
}
}
return NULL;
}
/**
*
* Requests a render of the shape, then if the shape is already a curve it
* unrefs the old curve; if the new curve is valid it creates a copy of the
* curve and adds it to the shape. Finally, it requests an update of the
* arena for the shape.
*/
{
}
if (curve) {
}
}
/** nr_arena_shape_set_style
*
* Unrefs any existing style and ref's to the given one, then requests an update of the arena
*/
void
{
//if shape has a filter
}
} else {
//no filter set for this shape
}
}
void
{
} else {
/* fixme: We kill warning, although not sure what to do here (Lauris) */
}
}
{
}
static void
{
if ( vst > 0.999 ) {
/* Simple copy */
while (len > 0) {
d[0] = 255;
d += 1;
len -= 1;
}
} else {
sv*=256;
c0_24&=0xFF;
while (len > 0) {
/* Draw */
d[0] = NR_COMPOSEA_111(c0_24,d[0]);
d += 1;
len -= 1;
}
}
} else {
sv*=256;
c0_24&=0xFF;
/* Draw */
d[0] = NR_COMPOSEA_111(c0_24,d[0]);
} else {
sv*=16777216;
dv*=16777216;
while (len > 0) {
unsigned int ca;
/* Draw */
d[0] = NR_COMPOSEA_111(ca,d[0]);
d += 1;
len -= 1;
}
}
}
}
{
/* This is the FloatLigne version. See svn (prior to Apr 2006) for versions using BitLigne or direct BitLigne. */
int curPt;
float curY;
}
theS->EndQuickRaster();
delete theI;
delete theIL;
}
/*
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 :