nr-arena-item.cpp revision 724821145d62dee9f97465c706952582da6e432d
#define __NR_ARENA_ITEM_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
*/
#define noNR_ARENA_ITEM_VERBOSE
#define noNR_ARENA_ITEM_DEBUG_CASCADE
#include <libnr/nr-pixops.h>
#include "nr-arena.h"
#include "nr-arena-item.h"
#include "gc-core.h"
#include "nr-filter.h"
#include "nr-arena-group.h"
#include "prefs-utils.h"
static NRObjectClass *parent_class;
nr_arena_item_get_type (void)
{
if (!type) {
"NRArenaItem",
sizeof (NRArenaItemClass),
sizeof (NRArenaItem),
(void (*)(NRObjectClass *))
(void (*)(NRObject *))
}
return type;
}
static void
{
}
static void
{
item->background_new = false;
}
static void
{
}
{
return NULL;
}
{
} else {
if (ref)
return ref;
}
}
void
{
}
void
{
}
void
{
}
{
return item;
}
{
return NULL;
}
unsigned int
{
#ifdef NR_ARENA_ITEM_DEBUG_CASCADE
printf ("Update %s:%p %x %x %x\n",
#endif
/* return if in error */
/* Set reset flags according to propagation status */
}
/* Reset our state */
/* Return if NOP */
/* Test whether to return immediately */
}
/* Reset image cache, if not to be kept */
}
/* Set up local gc */
}
/* Remember the transformation matrix */
/* Invoke the real method */
reset);
/* Enlarge the bounding box to contain filter effects */
}
// fixme: to fix the display glitches, in outline mode bbox must be a combination of
// full item bbox and its clip and mask (after we have the API to get these)
/* Clipping */
// FIXME: since here we only need bbox, consider passing
// ((state & !(NR_ARENA_ITEM_STATE_RENDER)) | NR_ARENA_ITEM_STATE_BBOX)
// instead of state, so it does not have to create rendering structures in nr_arena_shape_update
if (newstate & NR_ARENA_ITEM_STATE_INVALID) {
}
}
/* Masking */
if (newstate & NR_ARENA_ITEM_STATE_INVALID) {
}
}
}
/**
* Render item to pixblock.
*
* \return Has NR_ARENA_ITEM_STATE_RENDER set on success.
*/
unsigned int
{
#ifdef NR_ARENA_ITEM_VERBOSE
#endif
/* If we are outside bbox just return successfully */
if (nr_rect_l_test_empty (&carea))
}
if (outline) {
// No caching in outline mode for now; investigate if it really gives any advantage with cairo.
// Also no attempts to clip anything; just render everything: item, clip, mask
// First, render the object itself
if (state & NR_ARENA_ITEM_STATE_INVALID) {
/* Clean up and return error */
}
// render clip and mask, if any
// render clippath as an object, using a different color
item->arena->outlinecolor = prefs_get_int_attribute("options.wireframecolors", "clips", 0x00ff00ff); // green clips
}
// render mask as an object, using a different color
item->arena->outlinecolor = prefs_get_int_attribute("options.wireframecolors", "masks", 0x0000ffff); // blue masks
}
}
/* Has cache pixblock, render this and return */
/* fixme: This probably cannot overflow, because we render only if visible */
/* fixme: and pixel cache is there only for small items */
/* fixme: But this still needs extra check (Lauris) */
FALSE);
}
/* Setup cache if we can */
if ((!(flags & NR_ARENA_ITEM_RENDER_NO_CACHE)) &&
// Item bbox is fully in renderable area and size is acceptable
// Set nocache flag for downstream rendering
}
/* Determine, whether we need temporary buffer */
/* Setup and render item buffer */
TRUE);
// if memory allocation failed, abort render
}
/* If background access is used, save the pixblock address.
* This address is set to NULL at the end of this block */
if (item->background_new
}
if (state & NR_ARENA_ITEM_STATE_INVALID) {
/* Clean up and return error */
}
/* Run filtering, if a filter is set for this object */
}
/* Setup mask pixblock */
/* Do clip if needed */
if (state & NR_ARENA_ITEM_STATE_INVALID) {
/* Clean up and return error */
}
}
/* Do mask if needed */
/* Set up yet another temporary pixblock */
unsigned int state = NR_ARENA_ITEM_VIRTUAL (item->mask, render) (ct, item->mask, &carea, &tpb, flags);
if (state & NR_ARENA_ITEM_STATE_INVALID) {
/* Clean up and return error */
}
/* Composite with clip */
int x, y;
unsigned char *s, *d;
s = NR_PIXBLOCK_PX (&tpb) + (y -
d = NR_PIXBLOCK_PX (&mpb) + (y -
unsigned int m;
d[0] =
(NR_PREMUL_123 (d[0], m));
s += 4;
d += 1;
}
}
} else {
int x, y;
unsigned char *s, *d;
s = NR_PIXBLOCK_PX (&tpb) + (y -
d = NR_PIXBLOCK_PX (&mpb) + (y -
unsigned int m;
s += 4;
d += 1;
}
}
}
}
}
/* Multiply with opacity if needed */
) {
int x, y;
unsigned int a;
unsigned char *d;
d[0] = NR_PREMUL_111 (d[0], a);
d += 1;
}
}
}
/* Compose rendering pixblock int destination */
}
/* This pointer wouldn't be valid outside this block, so clear it */
} else {
} else { // copy while multiplying by opacity
}
}
} else {
/* Just render */
if (state & NR_ARENA_ITEM_STATE_INVALID) {
/* Clean up and return error */
}
}
/* Have to blit from cache */
}
}
unsigned int
{
/* we originally short-circuited if the object state included
* NR_ARENA_ITEM_STATE_CLIP (and showed a warning on the console);
* anyone know why we stopped doing so?
*/
#ifdef NR_ARENA_ITEM_VERBOSE
printf ("Invoke clip by %p: %d %d - %d %d, item bbox %d %d - %d %d\n",
#endif
/* Need render that item */
}
}
}
unsigned int sticky)
{
// Sometimes there's no BBOX in item->state, reason unknown (bug 992817); I made this not an assert to remove the warning
return NULL;
return NULL;
// TODO: rewrite using NR::Rect
const double x = p[NR::X];
const double y = p[NR::Y];
}
return NULL;
}
void
unsigned int propagate)
{
} else {
}
}
}
void
{
}
/* Public */
{
}
return NULL;
}
void
{
}
void
{
nr_arena_item_set_transform (item, &t);
}
void
{
return;
/* Set to identity affine */
} else {
}
}
}
void
{
}
void
{
}
void
{
}
void
{
if (clip)
}
}
void
{
if (mask)
}
}
void
{
return;
int pos = 0;
break;
pos += 1;
}
}
}
/** Returns a background image for use with filter effects. */
{
NRPixBlock *pb;
if (!item->background_pb)
return NULL;
if (item->background_new) {
pb = new NRPixBlock ();
return NULL;
} else
return NULL;
if (depth > 0)
return pb;
}
/* Helpers */
{
if (prev)
if (next)
return child;
}
{
if (prev)
if (next)
return next;
}
/*
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 :