summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e750fb8)
raw | patch | inline | side by side (parent: e750fb8)
author | pjrm <pjrm@users.sourceforge.net> | |
Sat, 29 Sep 2007 12:54:44 +0000 (12:54 +0000) | ||
committer | pjrm <pjrm@users.sourceforge.net> | |
Sat, 29 Sep 2007 12:54:44 +0000 (12:54 +0000) |
21 files changed:
index 8604c1207c24a0544ebd4692ea1013568cf78bdc..75ec5be86f93e7252ab0f99c22cf9d9ae08246cc 100644 (file)
Solve for dH/db[2].z==0:
--sum_i B2(u[i]) B2(u[i]) * b[2].z = sum_i B2(u[i]) * (B0(u[i]) * b[0] +
- B1(u[i]) * b[1] +
- B3(u[i]) * b[3]
+-sum_i B2(u[i]) B2(u[i]) * b[2].z = sum_i B2(u[i]) * (B0(u[i]) * b[0] +
+ B1(u[i]) * b[1] +
+ B3(u[i]) * b[3]
- d[i] ).z
-b[2].z = ((sum_i B2(u[i]) * (B0(u[i]) * b[0] +
- B1(u[i]) * b[1] +
- B3(u[i]) * b[3]
+b[2].z = ((sum_i B2(u[i]) * (B0(u[i]) * b[0] +
+ B1(u[i]) * b[1] +
+ B3(u[i]) * b[3]
- d[i] ).z)
/ -sum_i (B2(u[i]))^2)
index bb60cdc938cd32ba481bb923a73d90562add9415..bb636a91aa58d95da66c0f20f7fa36afde6c6f6b 100644 (file)
#include <display/inkscape-cairo.h>
enum {
- ARENA_EVENT,
- LAST_SIGNAL
+ ARENA_EVENT,
+ LAST_SIGNAL
};
static void sp_canvas_arena_class_init(SPCanvasArenaClass *klass);
static void sp_canvas_arena_request_render (NRArena *arena, NRRectL *area, void *data);
NRArenaEventVector carenaev = {
- {NULL},
- sp_canvas_arena_request_update,
- sp_canvas_arena_request_render
+ {NULL},
+ sp_canvas_arena_request_update,
+ sp_canvas_arena_request_render
};
static SPCanvasItemClass *parent_class;
GtkType
sp_canvas_arena_get_type (void)
{
- static GtkType type = 0;
- if (!type) {
- GtkTypeInfo info = {
- "SPCanvasArena",
- sizeof (SPCanvasArena),
- sizeof (SPCanvasArenaClass),
- (GtkClassInitFunc) sp_canvas_arena_class_init,
- (GtkObjectInitFunc) sp_canvas_arena_init,
- NULL, NULL, NULL
- };
- type = gtk_type_unique (SP_TYPE_CANVAS_ITEM, &info);
- }
- return type;
+ static GtkType type = 0;
+ if (!type) {
+ GtkTypeInfo info = {
+ "SPCanvasArena",
+ sizeof (SPCanvasArena),
+ sizeof (SPCanvasArenaClass),
+ (GtkClassInitFunc) sp_canvas_arena_class_init,
+ (GtkObjectInitFunc) sp_canvas_arena_init,
+ NULL, NULL, NULL
+ };
+ type = gtk_type_unique (SP_TYPE_CANVAS_ITEM, &info);
+ }
+ return type;
}
static void
sp_canvas_arena_class_init (SPCanvasArenaClass *klass)
{
- GtkObjectClass *object_class;
- SPCanvasItemClass *item_class;
+ GtkObjectClass *object_class;
+ SPCanvasItemClass *item_class;
- object_class = (GtkObjectClass *) klass;
- item_class = (SPCanvasItemClass *) klass;
+ object_class = (GtkObjectClass *) klass;
+ item_class = (SPCanvasItemClass *) klass;
- parent_class = (SPCanvasItemClass*)gtk_type_class (SP_TYPE_CANVAS_ITEM);
+ parent_class = (SPCanvasItemClass*)gtk_type_class (SP_TYPE_CANVAS_ITEM);
- signals[ARENA_EVENT] = gtk_signal_new ("arena_event",
- GTK_RUN_LAST,
- GTK_CLASS_TYPE(object_class),
- GTK_SIGNAL_OFFSET (SPCanvasArenaClass, arena_event),
- sp_marshal_INT__POINTER_POINTER,
- GTK_TYPE_INT, 2, GTK_TYPE_POINTER, GTK_TYPE_POINTER);
+ signals[ARENA_EVENT] = gtk_signal_new ("arena_event",
+ GTK_RUN_LAST,
+ GTK_CLASS_TYPE(object_class),
+ GTK_SIGNAL_OFFSET (SPCanvasArenaClass, arena_event),
+ sp_marshal_INT__POINTER_POINTER,
+ GTK_TYPE_INT, 2, GTK_TYPE_POINTER, GTK_TYPE_POINTER);
- object_class->destroy = sp_canvas_arena_destroy;
+ object_class->destroy = sp_canvas_arena_destroy;
- item_class->update = sp_canvas_arena_update;
- item_class->render = sp_canvas_arena_render;
- item_class->point = sp_canvas_arena_point;
- item_class->event = sp_canvas_arena_event;
+ item_class->update = sp_canvas_arena_update;
+ item_class->render = sp_canvas_arena_render;
+ item_class->point = sp_canvas_arena_point;
+ item_class->event = sp_canvas_arena_event;
}
static void
sp_canvas_arena_init (SPCanvasArena *arena)
{
- arena->sticky = FALSE;
+ arena->sticky = FALSE;
- arena->arena = NRArena::create();
- arena->arena->canvasarena = arena;
- arena->root = NRArenaGroup::create(arena->arena);
- nr_arena_group_set_transparent (NR_ARENA_GROUP (arena->root), TRUE);
+ arena->arena = NRArena::create();
+ arena->arena->canvasarena = arena;
+ arena->root = NRArenaGroup::create(arena->arena);
+ nr_arena_group_set_transparent (NR_ARENA_GROUP (arena->root), TRUE);
- arena->active = NULL;
+ arena->active = NULL;
- nr_active_object_add_listener ((NRActiveObject *) arena->arena, (NRObjectEventVector *) &carenaev, sizeof (carenaev), arena);
+ nr_active_object_add_listener ((NRActiveObject *) arena->arena, (NRObjectEventVector *) &carenaev, sizeof (carenaev), arena);
}
static void
sp_canvas_arena_destroy (GtkObject *object)
{
- SPCanvasArena *arena = SP_CANVAS_ARENA (object);
+ SPCanvasArena *arena = SP_CANVAS_ARENA (object);
- if (arena->active) {
- nr_object_unref ((NRObject *) arena->active);
- arena->active = NULL;
- }
+ if (arena->active) {
+ nr_object_unref ((NRObject *) arena->active);
+ arena->active = NULL;
+ }
- if (arena->root) {
- nr_arena_item_unref (arena->root);
- arena->root = NULL;
- }
+ if (arena->root) {
+ nr_arena_item_unref (arena->root);
+ arena->root = NULL;
+ }
- if (arena->arena) {
- nr_active_object_remove_listener_by_data ((NRActiveObject *) arena->arena, arena);
+ if (arena->arena) {
+ nr_active_object_remove_listener_by_data ((NRActiveObject *) arena->arena, arena);
- nr_object_unref ((NRObject *) arena->arena);
- arena->arena = NULL;
- }
+ nr_object_unref ((NRObject *) arena->arena);
+ arena->arena = NULL;
+ }
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+ if (GTK_OBJECT_CLASS (parent_class)->destroy)
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
sp_canvas_arena_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags)
{
- SPCanvasArena *arena = SP_CANVAS_ARENA (item);
-
- if (((SPCanvasItemClass *) parent_class)->update)
- (* ((SPCanvasItemClass *) parent_class)->update) (item, affine, flags);
-
- arena->gc.transform = affine;
-
- guint reset;
- reset = (flags & SP_CANVAS_UPDATE_AFFINE)? NR_ARENA_ITEM_STATE_ALL : NR_ARENA_ITEM_STATE_NONE;
-
- nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, NR_ARENA_ITEM_STATE_ALL, reset);
-
- item->x1 = arena->root->bbox.x0 - 1;
- item->y1 = arena->root->bbox.y0 - 1;
- item->x2 = arena->root->bbox.x1 + 1;
- item->y2 = arena->root->bbox.y1 + 1;
-
- if (arena->cursor) {
- /* Mess with enter/leave notifiers */
- NRArenaItem *new_arena = nr_arena_item_invoke_pick (arena->root, arena->c, arena->arena->delta, arena->sticky);
- if (new_arena != arena->active) {
- GdkEventCrossing ec;
- ec.window = GTK_WIDGET (item->canvas)->window;
- ec.send_event = TRUE;
- ec.subwindow = ec.window;
- ec.time = GDK_CURRENT_TIME;
- ec.x = arena->c[NR::X];
- ec.y = arena->c[NR::Y];
- /* fixme: */
- if (arena->active) {
- ec.type = GDK_LEAVE_NOTIFY;
- sp_canvas_arena_send_event (arena, (GdkEvent *) &ec);
- }
- /* fixme: This is not optimal - better track ::destroy (Lauris) */
- if (arena->active) nr_object_unref ((NRObject *) arena->active);
- arena->active = new_arena;
- if (arena->active) nr_object_ref ((NRObject *) arena->active);
- if (arena->active) {
- ec.type = GDK_ENTER_NOTIFY;
- sp_canvas_arena_send_event (arena, (GdkEvent *) &ec);
- }
- }
- }
+ SPCanvasArena *arena = SP_CANVAS_ARENA (item);
+
+ if (((SPCanvasItemClass *) parent_class)->update)
+ (* ((SPCanvasItemClass *) parent_class)->update) (item, affine, flags);
+
+ arena->gc.transform = affine;
+
+ guint reset;
+ reset = (flags & SP_CANVAS_UPDATE_AFFINE)? NR_ARENA_ITEM_STATE_ALL : NR_ARENA_ITEM_STATE_NONE;
+
+ nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, NR_ARENA_ITEM_STATE_ALL, reset);
+
+ item->x1 = arena->root->bbox.x0 - 1;
+ item->y1 = arena->root->bbox.y0 - 1;
+ item->x2 = arena->root->bbox.x1 + 1;
+ item->y2 = arena->root->bbox.y1 + 1;
+
+ if (arena->cursor) {
+ /* Mess with enter/leave notifiers */
+ NRArenaItem *new_arena = nr_arena_item_invoke_pick (arena->root, arena->c, arena->arena->delta, arena->sticky);
+ if (new_arena != arena->active) {
+ GdkEventCrossing ec;
+ ec.window = GTK_WIDGET (item->canvas)->window;
+ ec.send_event = TRUE;
+ ec.subwindow = ec.window;
+ ec.time = GDK_CURRENT_TIME;
+ ec.x = arena->c[NR::X];
+ ec.y = arena->c[NR::Y];
+ /* fixme: */
+ if (arena->active) {
+ ec.type = GDK_LEAVE_NOTIFY;
+ sp_canvas_arena_send_event (arena, (GdkEvent *) &ec);
+ }
+ /* fixme: This is not optimal - better track ::destroy (Lauris) */
+ if (arena->active) nr_object_unref ((NRObject *) arena->active);
+ arena->active = new_arena;
+ if (arena->active) nr_object_ref ((NRObject *) arena->active);
+ if (arena->active) {
+ ec.type = GDK_ENTER_NOTIFY;
+ sp_canvas_arena_send_event (arena, (GdkEvent *) &ec);
+ }
+ }
+ }
}
static void
sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf)
{
- gint bw, bh, sw, sh;
- gint x, y;
-
- SPCanvasArena *arena = SP_CANVAS_ARENA (item);
-
- nr_arena_item_invoke_update (arena->root, NULL, &arena->gc,
- NR_ARENA_ITEM_STATE_BBOX | NR_ARENA_ITEM_STATE_RENDER,
- NR_ARENA_ITEM_STATE_NONE);
-
- sp_canvas_prepare_buffer(buf);
-
- bw = buf->rect.x1 - buf->rect.x0;
- bh = buf->rect.y1 - buf->rect.y0;
- if ((bw < 1) || (bh < 1)) return;
-
- // FIXME: currently this function is a huge waste. It receives a buffer but creates a new one and loops
- // within the large one, doing arena painting in several blocks. This just makes no sense because the
- // buf that we are given is already only a strip of the screen, created by one iteration of a loop in
- // sp_canvas_paint_rect_internal. With the current numbers, this function's buffer is always 1/4
- // smaller than the one we get, because they both are the same number of bytes but
- // buf uses 3 bytes per pixel (24bpp, packed) while the pixblock created here uses 4 bytes (32bpp).
- // Eventually I want to switch buf to using 4 bytes (see comment in canvas.cpp) and then remove
- // from here the sw/sh calculation, the loop, and creating the intermediate buffer, allowing arena
- // just render into buf in one go.
-
- if (arena->arena->rendermode != RENDERMODE_OUTLINE) { // use 256K as a compromise to not slow down gradients
- /* 256K is the cached buffer and we need 4 channels */
- if (bw * bh < 65536) { // 256K/4
- /* We can go with single buffer */
- sw = bw;
- sh = bh;
- } else if (bw <= 4096) {
- /* Go with row buffer */
- sw = bw;
- sh = 65536 / bw;
- } else if (bh <= 4096) {
- /* Go with column buffer */
- sw = 65536 / bh;
- sh = bh;
- } else {
- sw = 256;
- sh = 256;
- }
- } else { // paths only, so 1M works faster
- /* 1M is the cached buffer and we need 4 channels */
- if (bw * bh < 262144) { // 1M/4
- /* We can go with single buffer */
- sw = bw;
- sh = bh;
- } else if (bw <= 8192) {
- /* Go with row buffer */
- sw = bw;
- sh = 262144 / bw;
- } else if (bh <= 8192) {
- /* Go with column buffer */
- sw = 262144 / bh;
- sh = bh;
- } else {
- sw = 512;
- sh = 512;
- }
- }
+ gint bw, bh, sw, sh;
+ gint x, y;
+
+ SPCanvasArena *arena = SP_CANVAS_ARENA (item);
+
+ nr_arena_item_invoke_update (arena->root, NULL, &arena->gc,
+ NR_ARENA_ITEM_STATE_BBOX | NR_ARENA_ITEM_STATE_RENDER,
+ NR_ARENA_ITEM_STATE_NONE);
+
+ sp_canvas_prepare_buffer(buf);
+
+ bw = buf->rect.x1 - buf->rect.x0;
+ bh = buf->rect.y1 - buf->rect.y0;
+ if ((bw < 1) || (bh < 1)) return;
+
+ // FIXME: currently this function is a huge waste. It receives a buffer but creates a new one and loops
+ // within the large one, doing arena painting in several blocks. This just makes no sense because the
+ // buf that we are given is already only a strip of the screen, created by one iteration of a loop in
+ // sp_canvas_paint_rect_internal. With the current numbers, this function's buffer is always 1/4
+ // smaller than the one we get, because they both are the same number of bytes but
+ // buf uses 3 bytes per pixel (24bpp, packed) while the pixblock created here uses 4 bytes (32bpp).
+ // Eventually I want to switch buf to using 4 bytes (see comment in canvas.cpp) and then remove
+ // from here the sw/sh calculation, the loop, and creating the intermediate buffer, allowing arena
+ // just render into buf in one go.
+
+ if (arena->arena->rendermode != RENDERMODE_OUTLINE) { // use 256K as a compromise to not slow down gradients
+ /* 256K is the cached buffer and we need 4 channels */
+ if (bw * bh < 65536) { // 256K/4
+ /* We can go with single buffer */
+ sw = bw;
+ sh = bh;
+ } else if (bw <= 4096) {
+ /* Go with row buffer */
+ sw = bw;
+ sh = 65536 / bw;
+ } else if (bh <= 4096) {
+ /* Go with column buffer */
+ sw = 65536 / bh;
+ sh = bh;
+ } else {
+ sw = 256;
+ sh = 256;
+ }
+ } else { // paths only, so 1M works faster
+ /* 1M is the cached buffer and we need 4 channels */
+ if (bw * bh < 262144) { // 1M/4
+ /* We can go with single buffer */
+ sw = bw;
+ sh = bh;
+ } else if (bw <= 8192) {
+ /* Go with row buffer */
+ sw = bw;
+ sh = 262144 / bw;
+ } else if (bh <= 8192) {
+ /* Go with column buffer */
+ sw = 262144 / bh;
+ sh = bh;
+ } else {
+ sw = 512;
+ sh = 512;
+ }
+ }
/*
-This define chooses between two modes: When on, arena renders into a temporary
-32bpp buffer, and the result is then squished into the SPCanvasBuf. When off, arena
-renders directly to SPCanvasBuf. However currently this gives no speed advantage,
-perhaps because the lack of squishing is offset by the need for arena items to render
-to the inconvenient (and probably slower) 24bpp buffer. When SPCanvasBuf is
-switched to 32bpp and cairo drawing, however, this define should be removed to
-streamline rendering.
+This define chooses between two modes: When on, arena renders into a temporary
+32bpp buffer, and the result is then squished into the SPCanvasBuf. When off, arena
+renders directly to SPCanvasBuf. However currently this gives no speed advantage,
+perhaps because the lack of squishing is offset by the need for arena items to render
+to the inconvenient (and probably slower) 24bpp buffer. When SPCanvasBuf is
+switched to 32bpp and cairo drawing, however, this define should be removed to
+streamline rendering.
*/
#define STRICT_RGBA
- for (y = buf->rect.y0; y < buf->rect.y1; y += sh) {
- for (x = buf->rect.x0; x < buf->rect.x1; x += sw) {
- NRRectL area;
+ for (y = buf->rect.y0; y < buf->rect.y1; y += sh) {
+ for (x = buf->rect.x0; x < buf->rect.x1; x += sw) {
+ NRRectL area;
#ifdef STRICT_RGBA
- NRPixBlock pb;
+ NRPixBlock pb;
#endif
- NRPixBlock cb;
+ NRPixBlock cb;
- area.x0 = x;
- area.y0 = y;
- area.x1 = MIN (x + sw, buf->rect.x1);
- area.y1 = MIN (y + sh, buf->rect.y1);
+ area.x0 = x;
+ area.y0 = y;
+ area.x1 = MIN (x + sw, buf->rect.x1);
+ area.y1 = MIN (y + sh, buf->rect.y1);
#ifdef STRICT_RGBA
- nr_pixblock_setup_fast (&pb, NR_PIXBLOCK_MODE_R8G8B8A8P, area.x0, area.y0, area.x1, area.y1, TRUE);
+ nr_pixblock_setup_fast (&pb, NR_PIXBLOCK_MODE_R8G8B8A8P, area.x0, area.y0, area.x1, area.y1, TRUE);
#endif
// CAIRO FIXME: switch this to R8G8B8A8P and 4 * ...
- nr_pixblock_setup_extern (&cb, NR_PIXBLOCK_MODE_R8G8B8, area.x0, area.y0, area.x1, area.y1,
- buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + 3 * (x - buf->rect.x0),
- buf->buf_rowstride,
- FALSE, FALSE);
+ nr_pixblock_setup_extern (&cb, NR_PIXBLOCK_MODE_R8G8B8, area.x0, area.y0, area.x1, area.y1,
+ buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + 3 * (x - buf->rect.x0),
+ buf->buf_rowstride,
+ FALSE, FALSE);
#ifdef STRICT_RGBA
- pb.visible_area = buf->visible_rect;
-
- if (pb.data.px != NULL) {
- cairo_t *ct = nr_create_cairo_context (&area, &pb);
-
- nr_arena_item_invoke_render (ct, arena->root, &area, &pb, 0);
-
- if (pb.empty == FALSE) {
-
- if (arena->arena->rendermode == RENDERMODE_OUTLINE) {
- // currently we only use cairo in outline mode
-
- // ENDIANNESS FIX
- // Inkscape and GTK use fixed byte order in their buffers: r, g, b, a.
- // Cairo reads/writes buffer values as in32s and therefore depends on the hardware byte order
- // (little-endian vs big-endian).
- // Until we move ALL of inkscape rendering and screen display to cairo,
- // we must reverse the order for big-endian architectures (e.g. PowerPC).
- if (G_BYTE_ORDER == G_BIG_ENDIAN) {
- unsigned char *start = NR_PIXBLOCK_PX(&pb);
- unsigned char *end = start + pb.rs * (pb.area.y1 - pb.area.y0);
- for (unsigned char *i = start; i < end; i += 4) {
- unsigned char tmp0 = i[0];
- unsigned char tmp1 = i[1];
- i[0] = i[3];
- i[1] = i[2];
- i[2] = tmp1;
- i[3] = tmp0;
- }
- }
- }
-
- // this does the 32->24 squishing, using an assembler routine:
- nr_blit_pixblock_pixblock (&cb, &pb);
- }
-
- cairo_surface_t *cst = cairo_get_target(ct);
- cairo_destroy (ct);
- cairo_surface_finish (cst);
- cairo_surface_destroy (cst);
- }
-
- nr_pixblock_release (&pb);
+ pb.visible_area = buf->visible_rect;
+
+ if (pb.data.px != NULL) {
+ cairo_t *ct = nr_create_cairo_context (&area, &pb);
+
+ nr_arena_item_invoke_render (ct, arena->root, &area, &pb, 0);
+
+ if (pb.empty == FALSE) {
+
+ if (arena->arena->rendermode == RENDERMODE_OUTLINE) {
+ // currently we only use cairo in outline mode
+
+ // ENDIANNESS FIX
+ // Inkscape and GTK use fixed byte order in their buffers: r, g, b, a.
+ // Cairo reads/writes buffer values as in32s and therefore depends on the hardware byte order
+ // (little-endian vs big-endian).
+ // Until we move ALL of inkscape rendering and screen display to cairo,
+ // we must reverse the order for big-endian architectures (e.g. PowerPC).
+ if (G_BYTE_ORDER == G_BIG_ENDIAN) {
+ unsigned char *start = NR_PIXBLOCK_PX(&pb);
+ unsigned char *end = start + pb.rs * (pb.area.y1 - pb.area.y0);
+ for (unsigned char *i = start; i < end; i += 4) {
+ unsigned char tmp0 = i[0];
+ unsigned char tmp1 = i[1];
+ i[0] = i[3];
+ i[1] = i[2];
+ i[2] = tmp1;
+ i[3] = tmp0;
+ }
+ }
+ }
+
+ // this does the 32->24 squishing, using an assembler routine:
+ nr_blit_pixblock_pixblock (&cb, &pb);
+ }
+
+ cairo_surface_t *cst = cairo_get_target(ct);
+ cairo_destroy (ct);
+ cairo_surface_finish (cst);
+ cairo_surface_destroy (cst);
+ }
+
+ nr_pixblock_release (&pb);
#else
- cb.visible_area = buf->visible_rect;
- nr_arena_item_invoke_render (NULL, arena->root, &area, &cb, 0);
+ cb.visible_area = buf->visible_rect;
+ nr_arena_item_invoke_render (NULL, arena->root, &area, &cb, 0);
#endif
- nr_pixblock_release (&cb);
- }
- }
+ nr_pixblock_release (&cb);
+ }
+ }
}
static double
sp_canvas_arena_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item)
{
- SPCanvasArena *arena = SP_CANVAS_ARENA (item);
+ SPCanvasArena *arena = SP_CANVAS_ARENA (item);
- nr_arena_item_invoke_update (arena->root, NULL, &arena->gc,
- NR_ARENA_ITEM_STATE_BBOX | NR_ARENA_ITEM_STATE_PICK,
- NR_ARENA_ITEM_STATE_NONE);
+ nr_arena_item_invoke_update (arena->root, NULL, &arena->gc,
+ NR_ARENA_ITEM_STATE_BBOX | NR_ARENA_ITEM_STATE_PICK,
+ NR_ARENA_ITEM_STATE_NONE);
- NRArenaItem *picked = nr_arena_item_invoke_pick (arena->root, p, arena->arena->delta, arena->sticky);
+ NRArenaItem *picked = nr_arena_item_invoke_pick (arena->root, p, arena->arena->delta, arena->sticky);
- arena->picked = picked;
+ arena->picked = picked;
- if (picked) {
- *actual_item = item;
- return 0.0;
- }
+ if (picked) {
+ *actual_item = item;
+ return 0.0;
+ }
- return 1e18;
+ return 1e18;
}
static gint
sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event)
{
- NRArenaItem *new_arena;
- /* fixme: This sucks, we have to handle enter/leave notifiers */
-
- SPCanvasArena *arena = SP_CANVAS_ARENA (item);
-
- gint ret = FALSE;
-
- switch (event->type) {
- case GDK_ENTER_NOTIFY:
- if (!arena->cursor) {
- if (arena->active) {
- //g_warning ("Cursor entered to arena with already active item");
- nr_object_unref ((NRObject *) arena->active);
- }
- arena->cursor = TRUE;
-
- /* TODO ... event -> arena transform? */
- arena->c = NR::Point(event->crossing.x, event->crossing.y);
-
- /* fixme: Not sure abut this, but seems the right thing (Lauris) */
- nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, NR_ARENA_ITEM_STATE_PICK, NR_ARENA_ITEM_STATE_NONE);
- arena->active = nr_arena_item_invoke_pick (arena->root, arena->c, arena->arena->delta, arena->sticky);
- if (arena->active) nr_object_ref ((NRObject *) arena->active);
- ret = sp_canvas_arena_send_event (arena, event);
- }
- break;
- case GDK_LEAVE_NOTIFY:
- if (arena->cursor) {
- ret = sp_canvas_arena_send_event (arena, event);
- if (arena->active) nr_object_unref ((NRObject *) arena->active);
- arena->active = NULL;
- arena->cursor = FALSE;
- }
- break;
- case GDK_MOTION_NOTIFY:
- /* TODO ... event -> arena transform? */
- arena->c = NR::Point(event->motion.x, event->motion.y);
-
- /* fixme: Not sure abut this, but seems the right thing (Lauris) */
- nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, NR_ARENA_ITEM_STATE_PICK, NR_ARENA_ITEM_STATE_NONE);
- new_arena = nr_arena_item_invoke_pick (arena->root, arena->c, arena->arena->delta, arena->sticky);
- if (new_arena != arena->active) {
- GdkEventCrossing ec;
- ec.window = event->motion.window;
- ec.send_event = event->motion.send_event;
- ec.subwindow = event->motion.window;
- ec.time = event->motion.time;
- ec.x = event->motion.x;
- ec.y = event->motion.y;
- /* fixme: */
- if (arena->active) {
- ec.type = GDK_LEAVE_NOTIFY;
- ret = sp_canvas_arena_send_event (arena, (GdkEvent *) &ec);
- }
- if (arena->active) nr_object_unref ((NRObject *) arena->active);
- arena->active = new_arena;
- if (arena->active) nr_object_ref ((NRObject *) arena->active);
- if (arena->active) {
- ec.type = GDK_ENTER_NOTIFY;
- ret = sp_canvas_arena_send_event (arena, (GdkEvent *) &ec);
- }
- }
- ret = sp_canvas_arena_send_event (arena, event);
- break;
- default:
- /* Just send event */
- ret = sp_canvas_arena_send_event (arena, event);
- break;
- }
-
- return ret;
+ NRArenaItem *new_arena;
+ /* fixme: This sucks, we have to handle enter/leave notifiers */
+
+ SPCanvasArena *arena = SP_CANVAS_ARENA (item);
+
+ gint ret = FALSE;
+
+ switch (event->type) {
+ case GDK_ENTER_NOTIFY:
+ if (!arena->cursor) {
+ if (arena->active) {
+ //g_warning ("Cursor entered to arena with already active item");
+ nr_object_unref ((NRObject *) arena->active);
+ }
+ arena->cursor = TRUE;
+
+ /* TODO ... event -> arena transform? */
+ arena->c = NR::Point(event->crossing.x, event->crossing.y);
+
+ /* fixme: Not sure abut this, but seems the right thing (Lauris) */
+ nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, NR_ARENA_ITEM_STATE_PICK, NR_ARENA_ITEM_STATE_NONE);
+ arena->active = nr_arena_item_invoke_pick (arena->root, arena->c, arena->arena->delta, arena->sticky);
+ if (arena->active) nr_object_ref ((NRObject *) arena->active);
+ ret = sp_canvas_arena_send_event (arena, event);
+ }
+ break;
+
+ case GDK_LEAVE_NOTIFY:
+ if (arena->cursor) {
+ ret = sp_canvas_arena_send_event (arena, event);
+ if (arena->active) nr_object_unref ((NRObject *) arena->active);
+ arena->active = NULL;
+ arena->cursor = FALSE;
+ }
+ break;
+
+ case GDK_MOTION_NOTIFY:
+ /* TODO ... event -> arena transform? */
+ arena->c = NR::Point(event->motion.x, event->motion.y);
+
+ /* fixme: Not sure abut this, but seems the right thing (Lauris) */
+ nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, NR_ARENA_ITEM_STATE_PICK, NR_ARENA_ITEM_STATE_NONE);
+ new_arena = nr_arena_item_invoke_pick (arena->root, arena->c, arena->arena->delta, arena->sticky);
+ if (new_arena != arena->active) {
+ GdkEventCrossing ec;
+ ec.window = event->motion.window;
+ ec.send_event = event->motion.send_event;
+ ec.subwindow = event->motion.window;
+ ec.time = event->motion.time;
+ ec.x = event->motion.x;
+ ec.y = event->motion.y;
+ /* fixme: */
+ if (arena->active) {
+ ec.type = GDK_LEAVE_NOTIFY;
+ ret = sp_canvas_arena_send_event (arena, (GdkEvent *) &ec);
+ }
+ if (arena->active) nr_object_unref ((NRObject *) arena->active);
+ arena->active = new_arena;
+ if (arena->active) nr_object_ref ((NRObject *) arena->active);
+ if (arena->active) {
+ ec.type = GDK_ENTER_NOTIFY;
+ ret = sp_canvas_arena_send_event (arena, (GdkEvent *) &ec);
+ }
+ }
+ ret = sp_canvas_arena_send_event (arena, event);
+ break;
+
+ default:
+ /* Just send event */
+ ret = sp_canvas_arena_send_event (arena, event);
+ break;
+ }
+
+ return ret;
}
static gint
sp_canvas_arena_send_event (SPCanvasArena *arena, GdkEvent *event)
{
- gint ret = FALSE;
+ gint ret = FALSE;
- /* Send event to arena */
- gtk_signal_emit (GTK_OBJECT (arena), signals[ARENA_EVENT], arena->active, event, &ret);
+ /* Send event to arena */
+ gtk_signal_emit (GTK_OBJECT (arena), signals[ARENA_EVENT], arena->active, event, &ret);
- return ret;
+ return ret;
}
static void
sp_canvas_arena_request_update (NRArena *arena, NRArenaItem *item, void *data)
{
- sp_canvas_item_request_update (SP_CANVAS_ITEM (data));
+ sp_canvas_item_request_update (SP_CANVAS_ITEM (data));
}
static void
sp_canvas_arena_request_render (NRArena *arena, NRRectL *area, void *data)
{
- sp_canvas_request_redraw (SP_CANVAS_ITEM (data)->canvas, area->x0, area->y0, area->x1, area->y1);
+ sp_canvas_request_redraw (SP_CANVAS_ITEM (data)->canvas, area->x0, area->y0, area->x1, area->y1);
}
void
sp_canvas_arena_set_pick_delta (SPCanvasArena *ca, gdouble delta)
{
- g_return_if_fail (ca != NULL);
- g_return_if_fail (SP_IS_CANVAS_ARENA (ca));
+ g_return_if_fail (ca != NULL);
+ g_return_if_fail (SP_IS_CANVAS_ARENA (ca));
- /* fixme: repick? */
- ca->delta = delta;
+ /* fixme: repick? */
+ ca->delta = delta;
}
void
sp_canvas_arena_set_sticky (SPCanvasArena *ca, gboolean sticky)
{
- g_return_if_fail (ca != NULL);
- g_return_if_fail (SP_IS_CANVAS_ARENA (ca));
+ g_return_if_fail (ca != NULL);
+ g_return_if_fail (SP_IS_CANVAS_ARENA (ca));
- /* fixme: repick? */
- ca->sticky = sticky;
+ /* fixme: repick? */
+ ca->sticky = sticky;
}
void
sp_canvas_arena_render_pixblock (SPCanvasArena *ca, NRPixBlock *pb)
{
- NRRectL area;
+ NRRectL area;
- g_return_if_fail (ca != NULL);
- g_return_if_fail (SP_IS_CANVAS_ARENA (ca));
+ g_return_if_fail (ca != NULL);
+ g_return_if_fail (SP_IS_CANVAS_ARENA (ca));
- /* fixme: */
- pb->empty = FALSE;
+ /* fixme: */
+ pb->empty = FALSE;
- area.x0 = pb->area.x0;
- area.y0 = pb->area.y0;
- area.x1 = pb->area.x1;
- area.y1 = pb->area.y1;
+ area.x0 = pb->area.x0;
+ area.y0 = pb->area.y0;
+ area.x1 = pb->area.x1;
+ area.y1 = pb->area.y1;
- nr_arena_item_invoke_render (NULL, ca->root, &area, pb, 0);
+ nr_arena_item_invoke_render (NULL, ca->root, &area, pb, 0);
}
+
+/*
+ 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 :
index d7e60596f0f395dbc21ce442287ec3cf11036e58..beb5c088a570e3222961b690c17a8a7e3e3cc39e 100644 (file)
*/
/*
- * TODO: LOTS LOTS LOTS. Clean up code. dirty as hell
+ * TODO: LOTS LOTS LOTS. Clean up code. dirty as hell
* THIS FILE AND THE HEADER FILE NEED HUGE CLEANING UP. PLEASE DO NOT HESISTATE TO DO SO.
-* For example: the line drawing code should not be here. There _must_ be a function somewhere else that can provide this functionality...
+ * For example: the line drawing code should not be here. There _must_ be a function somewhere else that can provide this functionality...
*/
#include "sp-canvas-util.h"
#include "inkscape.h"
#include "desktop.h"
-#include "../document.h"
+#include "document.h"
#define SAFE_SETPIXEL //undefine this when it is certain that setpixel is never called with invalid params
enum Dim3 { X=0, Y, Z };
#ifndef M_PI
-#define M_PI 3.14159265358979323846
+# define M_PI 3.14159265358979323846
#endif
static double deg_to_rad(double deg) { return deg*M_PI/180.0;}
( rect.x1 - rect.x0 , rect.y1 - rect.y0 ) in setpixel coordinates
*/
static void
-sp_caxonomgrid_setpixel (SPCanvasBuf *buf, gint x, gint y, guint32 rgba) {
+sp_caxonomgrid_setpixel (SPCanvasBuf *buf, gint x, gint y, guint32 rgba)
+{
#ifdef SAFE_SETPIXEL
if ( (x >= buf->rect.x0) && (x < buf->rect.x1) && (y >= buf->rect.y0) && (y < buf->rect.y1) ) {
#endif
Coordinates are interpreted as SCREENcoordinates
*/
static void
-sp_caxonomgrid_drawline (SPCanvasBuf *buf, gint x0, gint y0, gint x1, gint y1, guint32 rgba) {
+sp_caxonomgrid_drawline (SPCanvasBuf *buf, gint x0, gint y0, gint x1, gint y1, guint32 rgba)
+{
int dy = y1 - y0;
int dx = x1 - x0;
int stepx, stepy;
static inline void
attach_all(Gtk::Table &table, Gtk::Widget const *const arr[], unsigned size, int start = 0)
{
- for (unsigned i=0, r=start; i<size/sizeof(Gtk::Widget*); i+=2)
- {
- if (arr[i] && arr[i+1])
- {
+ for (unsigned i=0, r=start; i<size/sizeof(Gtk::Widget*); i+=2) {
+ if (arr[i] && arr[i+1]) {
table.attach (const_cast<Gtk::Widget&>(*arr[i]), 1, 2, r, r+1,
- Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
+ Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 2, 3, r, r+1,
- Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
- }
- else
- {
- if (arr[i+1])
+ Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
+ } else {
+ if (arr[i+1]) {
table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 1, 3, r, r+1,
- Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
- else if (arr[i])
- {
+ Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
+ } else if (arr[i]) {
Gtk::Label& label = reinterpret_cast<Gtk::Label&> (const_cast<Gtk::Widget&>(*arr[i]));
label.set_alignment (0.0);
table.attach (label, 0, 3, r, r+1,
- Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
- }
- else
- {
+ Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
+ } else {
Gtk::HBox *space = manage (new Gtk::HBox);
space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
table.attach (*space, 0, 1, r, r+1,
- (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0);
+ (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0);
}
}
++r;
@@ -198,11 +193,7 @@ attach_all(Gtk::Table &table, Gtk::Widget const *const arr[], unsigned size, int
CanvasAxonomGrid::CanvasAxonomGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc)
: CanvasGrid(nv, in_repr, in_doc), table(1, 1)
{
-
origin[NR::X] = origin[NR::Y] = 0.0;
-// nv->gridcolor = (nv->gridcolor & 0xff) | (DEFAULTGRIDCOLOR & 0xffffff00);
-// case SP_ATTR_GRIDOPACITY:
-// nv->gridcolor = (nv->gridcolor & 0xffffff00) | (DEFAULTGRIDCOLOR & 0xff);
color = 0xff3f3f20;
empcolor = 0xFF3F3F40;
empspacing = 5;
@@ -265,7 +256,7 @@ CanvasAxonomGrid::CanvasAxonomGrid (SPNamedView * nv, Inkscape::XML::Node * in_r
CanvasAxonomGrid::~CanvasAxonomGrid ()
{
- if (snapper) delete snapper;
+ if (snapper) delete snapper;
}
_wr.setUpdating (true);
-// _rrb_gridtype.setValue (nv->gridtype);
+ //_rrb_gridtype.setValue (nv->gridtype);
_rumg.setUnit (gridunit);
gdouble val;
{
ow = origin * affine;
sw = NR::Point(fabs(affine[0]),fabs(affine[3]));
-
+
for(int dim = 0; dim < 2; dim++) {
gint scaling_factor = empspacing;
void
CanvasAxonomGrid::Render (SPCanvasBuf *buf)
{
- // gc = gridcoordinates (the coordinates calculated from the grids origin 'grid->ow'.
- // sc = screencoordinates ( for example "buf->rect.x0" is in screencoordinates )
- // bc = buffer patch coordinates
+ // gc = gridcoordinates (the coordinates calculated from the grids origin 'grid->ow'.
+ // sc = screencoordinates ( for example "buf->rect.x0" is in screencoordinates )
+ // bc = buffer patch coordinates
- // tl = topleft ; br = bottomright
+ // tl = topleft ; br = bottomright
NR::Point buf_tl_gc;
NR::Point buf_br_gc;
buf_tl_gc[NR::X] = buf->rect.x0 - ow[NR::X];
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
index 909ea84ec1db61f65ce75b05ce7cb12530e4582a..8fecb4e3d756a5d922d3982f9ccb86e15f2b6a6e 100644 (file)
{
static GtkType type = 0;
if (!type) {
- GtkTypeInfo info = {
- "SPCanvasBPath",
- sizeof (SPCanvasBPath),
- sizeof (SPCanvasBPathClass),
- (GtkClassInitFunc) sp_canvas_bpath_class_init,
- (GtkObjectInitFunc) sp_canvas_bpath_init,
- NULL, NULL, NULL
- };
- type = gtk_type_unique (SP_TYPE_CANVAS_ITEM, &info);
+ GtkTypeInfo info = {
+ "SPCanvasBPath",
+ sizeof (SPCanvasBPath),
+ sizeof (SPCanvasBPathClass),
+ (GtkClassInitFunc) sp_canvas_bpath_class_init,
+ (GtkObjectInitFunc) sp_canvas_bpath_init,
+ NULL, NULL, NULL
+ };
+ type = gtk_type_unique (SP_TYPE_CANVAS_ITEM, &info);
}
return type;
}
{
SPCanvasBPath *cbp = SP_CANVAS_BPATH (object);
if (cbp->fill_shp) {
- delete cbp->fill_shp;
- cbp->fill_shp = NULL;
+ delete cbp->fill_shp;
+ cbp->fill_shp = NULL;
}
if (cbp->stroke_shp) {
- delete cbp->stroke_shp;
- cbp->stroke_shp = NULL;
+ delete cbp->stroke_shp;
+ cbp->stroke_shp = NULL;
}
if (cbp->curve) {
- cbp->curve = sp_curve_unref (cbp->curve);
+ cbp->curve = sp_curve_unref (cbp->curve);
}
if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
@@ -118,18 +118,18 @@ sp_canvas_bpath_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned i
sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
if (((SPCanvasItemClass *) parent_class)->update)
- ((SPCanvasItemClass *) parent_class)->update (item, affine, flags);
+ ((SPCanvasItemClass *) parent_class)->update (item, affine, flags);
sp_canvas_item_reset_bounds (item);
if (cbp->fill_shp) {
- delete cbp->fill_shp;
- cbp->fill_shp = NULL;
+ delete cbp->fill_shp;
+ cbp->fill_shp = NULL;
}
if (cbp->stroke_shp) {
- delete cbp->stroke_shp;
- cbp->stroke_shp = NULL;
+ delete cbp->stroke_shp;
+ cbp->stroke_shp = NULL;
}
if (!cbp->curve) return;
@@ -139,62 +139,62 @@ sp_canvas_bpath_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned i
dbox.x1 = dbox.y1 = -1.0;
if ((cbp->fill_rgba & 0xff) || (cbp->stroke_rgba & 0xff)) {
- Path* thePath=new Path;
- thePath->LoadArtBPath(SP_CURVE_BPATH(cbp->curve), affine, true);
- thePath->Convert(0.25);
- if ((cbp->fill_rgba & 0xff) && (cbp->curve->end > 2)) {
- Shape* theShape=new Shape;
- thePath->Fill(theShape,0);
- if ( cbp->fill_shp == NULL ) cbp->fill_shp=new Shape;
- if ( cbp->fill_rule == SP_WIND_RULE_EVENODD ) {
- cbp->fill_shp->ConvertToShape(theShape,fill_oddEven);
- } else {
- cbp->fill_shp->ConvertToShape(theShape,fill_nonZero);
- }
- delete theShape;
- cbp->fill_shp->CalcBBox();
- if ( cbp->fill_shp->leftX < cbp->fill_shp->rightX ) {
- if ( dbox.x0 >= dbox.x1 ) {
- dbox.x0 = cbp->fill_shp->leftX; dbox.x1 = cbp->fill_shp->rightX;
- dbox.y0 = cbp->fill_shp->topY; dbox.y1 = cbp->fill_shp->bottomY;
- } else {
- if ( cbp->fill_shp->leftX < dbox.x0 ) dbox.x0=cbp->fill_shp->leftX;
- if ( cbp->fill_shp->rightX > dbox.x1 ) dbox.x1=cbp->fill_shp->rightX;
- if ( cbp->fill_shp->topY < dbox.y0 ) dbox.y0=cbp->fill_shp->topY;
- if ( cbp->fill_shp->bottomY > dbox.y1 ) dbox.y1=cbp->fill_shp->bottomY;
- }
- }
- }
- if ((cbp->stroke_rgba & 0xff) && (cbp->curve->end > 1)) {
- JoinType join=join_straight;
+ Path* thePath=new Path;
+ thePath->LoadArtBPath(SP_CURVE_BPATH(cbp->curve), affine, true);
+ thePath->Convert(0.25);
+ if ((cbp->fill_rgba & 0xff) && (cbp->curve->end > 2)) {
+ Shape* theShape=new Shape;
+ thePath->Fill(theShape,0);
+ if ( cbp->fill_shp == NULL ) cbp->fill_shp=new Shape;
+ if ( cbp->fill_rule == SP_WIND_RULE_EVENODD ) {
+ cbp->fill_shp->ConvertToShape(theShape,fill_oddEven);
+ } else {
+ cbp->fill_shp->ConvertToShape(theShape,fill_nonZero);
+ }
+ delete theShape;
+ cbp->fill_shp->CalcBBox();
+ if ( cbp->fill_shp->leftX < cbp->fill_shp->rightX ) {
+ if ( dbox.x0 >= dbox.x1 ) {
+ dbox.x0 = cbp->fill_shp->leftX; dbox.x1 = cbp->fill_shp->rightX;
+ dbox.y0 = cbp->fill_shp->topY; dbox.y1 = cbp->fill_shp->bottomY;
+ } else {
+ if ( cbp->fill_shp->leftX < dbox.x0 ) dbox.x0=cbp->fill_shp->leftX;
+ if ( cbp->fill_shp->rightX > dbox.x1 ) dbox.x1=cbp->fill_shp->rightX;
+ if ( cbp->fill_shp->topY < dbox.y0 ) dbox.y0=cbp->fill_shp->topY;
+ if ( cbp->fill_shp->bottomY > dbox.y1 ) dbox.y1=cbp->fill_shp->bottomY;
+ }
+ }
+ }
+ if ((cbp->stroke_rgba & 0xff) && (cbp->curve->end > 1)) {
+ JoinType join=join_straight;
// Shape* theShape=new Shape;
- ButtType butt=butt_straight;
- if ( cbp->stroke_shp == NULL ) cbp->stroke_shp=new Shape;
- if ( cbp->stroke_linecap == SP_STROKE_LINECAP_BUTT ) butt=butt_straight;
- if ( cbp->stroke_linecap == SP_STROKE_LINECAP_ROUND ) butt=butt_round;
- if ( cbp->stroke_linecap == SP_STROKE_LINECAP_SQUARE ) butt=butt_square;
- if ( cbp->stroke_linejoin == SP_STROKE_LINEJOIN_MITER ) join=join_pointy;
- if ( cbp->stroke_linejoin == SP_STROKE_LINEJOIN_ROUND ) join=join_round;
- if ( cbp->stroke_linejoin == SP_STROKE_LINEJOIN_BEVEL ) join=join_straight;
- thePath->Stroke(cbp->stroke_shp,false,0.5*cbp->stroke_width, join,butt,cbp->stroke_width*cbp->stroke_miterlimit );
- // thePath->Stroke(theShape,false,0.5*cbp->stroke_width, join,butt,cbp->stroke_width*cbp->stroke_miterlimit );
- // cbp->stroke_shp->ConvertToShape(theShape,fill_nonZero);
-
- cbp->stroke_shp->CalcBBox();
- if ( cbp->stroke_shp->leftX < cbp->stroke_shp->rightX ) {
- if ( dbox.x0 >= dbox.x1 ) {
- dbox.x0 = cbp->stroke_shp->leftX;dbox.x1 = cbp->stroke_shp->rightX;
- dbox.y0 = cbp->stroke_shp->topY;dbox.y1 = cbp->stroke_shp->bottomY;
- } else {
- if ( cbp->stroke_shp->leftX < dbox.x0 ) dbox.x0 = cbp->stroke_shp->leftX;
- if ( cbp->stroke_shp->rightX > dbox.x1 ) dbox.x1 = cbp->stroke_shp->rightX;
- if ( cbp->stroke_shp->topY < dbox.y0 ) dbox.y0 = cbp->stroke_shp->topY;
- if ( cbp->stroke_shp->bottomY > dbox.y1 ) dbox.y1 = cbp->stroke_shp->bottomY;
- }
- }
+ ButtType butt=butt_straight;
+ if ( cbp->stroke_shp == NULL ) cbp->stroke_shp=new Shape;
+ if ( cbp->stroke_linecap == SP_STROKE_LINECAP_BUTT ) butt=butt_straight;
+ if ( cbp->stroke_linecap == SP_STROKE_LINECAP_ROUND ) butt=butt_round;
+ if ( cbp->stroke_linecap == SP_STROKE_LINECAP_SQUARE ) butt=butt_square;
+ if ( cbp->stroke_linejoin == SP_STROKE_LINEJOIN_MITER ) join=join_pointy;
+ if ( cbp->stroke_linejoin == SP_STROKE_LINEJOIN_ROUND ) join=join_round;
+ if ( cbp->stroke_linejoin == SP_STROKE_LINEJOIN_BEVEL ) join=join_straight;
+ thePath->Stroke(cbp->stroke_shp,false,0.5*cbp->stroke_width, join,butt,cbp->stroke_width*cbp->stroke_miterlimit );
+ // thePath->Stroke(theShape,false,0.5*cbp->stroke_width, join,butt,cbp->stroke_width*cbp->stroke_miterlimit );
+ // cbp->stroke_shp->ConvertToShape(theShape,fill_nonZero);
+
+ cbp->stroke_shp->CalcBBox();
+ if ( cbp->stroke_shp->leftX < cbp->stroke_shp->rightX ) {
+ if ( dbox.x0 >= dbox.x1 ) {
+ dbox.x0 = cbp->stroke_shp->leftX;dbox.x1 = cbp->stroke_shp->rightX;
+ dbox.y0 = cbp->stroke_shp->topY;dbox.y1 = cbp->stroke_shp->bottomY;
+ } else {
+ if ( cbp->stroke_shp->leftX < dbox.x0 ) dbox.x0 = cbp->stroke_shp->leftX;
+ if ( cbp->stroke_shp->rightX > dbox.x1 ) dbox.x1 = cbp->stroke_shp->rightX;
+ if ( cbp->stroke_shp->topY < dbox.y0 ) dbox.y0 = cbp->stroke_shp->topY;
+ if ( cbp->stroke_shp->bottomY > dbox.y1 ) dbox.y1 = cbp->stroke_shp->bottomY;
+ }
+ }
// delete theShape;
- }
- delete thePath;
+ }
+ delete thePath;
}
area.y0=buf->rect.y0;
area.y1=buf->rect.y1;
if ( cbp->fill_shp ) {
- nr_pixblock_render_bpath_rgba (cbp->fill_shp,cbp->fill_rgba,area,(char*)buf->buf, buf->buf_rowstride);
+ nr_pixblock_render_bpath_rgba (cbp->fill_shp,cbp->fill_rgba,area,(char*)buf->buf, buf->buf_rowstride);
}
if ( cbp->stroke_shp ) {
- nr_pixblock_render_bpath_rgba (cbp->stroke_shp,cbp->stroke_rgba,area,(char*)buf->buf, buf->buf_rowstride);
+ nr_pixblock_render_bpath_rgba (cbp->stroke_shp,cbp->stroke_rgba,area,(char*)buf->buf, buf->buf_rowstride);
}
}
@@ -235,15 +235,15 @@ sp_canvas_bpath_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_it
SPCanvasBPath *cbp = SP_CANVAS_BPATH (item);
if (cbp->fill_shp && (cbp->fill_shp->PtWinding(p) > 0 )) {
- *actual_item = item;
- return 0.0;
+ *actual_item = item;
+ return 0.0;
}
if (cbp->stroke_shp ) {
- if (cbp->stroke_shp->PtWinding(p) > 0 ) {
- *actual_item = item;
- return 0.0;
- }
- return distance(cbp->stroke_shp, p);
+ if (cbp->stroke_shp->PtWinding(p) > 0 ) {
+ *actual_item = item;
+ return 0.0;
+ }
+ return distance(cbp->stroke_shp, p);
}
if (cbp->fill_shp) {
return distance(cbp->fill_shp, p);
g_return_if_fail (SP_IS_CANVAS_BPATH (cbp));
if (cbp->curve) {
- cbp->curve = sp_curve_unref (cbp->curve);
+ cbp->curve = sp_curve_unref (cbp->curve);
}
if (curve) {
- cbp->curve = sp_curve_ref (curve);
+ cbp->curve = sp_curve_ref (curve);
}
sp_canvas_item_request_update (SP_CANVAS_ITEM (cbp));
bpath_run_A8_OR (raster_info &dest,void *data,int st,float vst,int en,float ven)
{
union {
- uint8_t comp[4];
- uint32_t col;
+ uint8_t comp[4];
+ uint32_t col;
} tempCol;
if ( st >= en ) return;
tempCol.col=*(uint32_t*)data;
@@ -341,55 +341,55 @@ bpath_run_A8_OR (raster_info &dest,void *data,int st,float vst,int en,float ven)
d+=3*(st-dest.startPix);
if ( fabs(dv) < 0.001 ) {
- if ( sv > 249.999 ) {
- /* Simple copy */
- while (len > 0) {
- d[0] = NR_COMPOSEN11_1111 (r, 255, d[0]);
- d[1] = NR_COMPOSEN11_1111 (g, 255, d[1]);
- d[2] = NR_COMPOSEN11_1111 (b, 255, d[2]);
- d += 3;
- len -= 1;
- }
- } else {
- unsigned int c0_24=(int)sv;
- c0_24&=0xFF;
- while (len > 0) {
- d[0] = NR_COMPOSEN11_1111 (r, c0_24, d[0]);
- d[1] = NR_COMPOSEN11_1111 (g, c0_24, d[1]);
- d[2] = NR_COMPOSEN11_1111 (b, c0_24, d[2]);
- d += 3;
- len -= 1;
- }
- }
+ if ( sv > 249.999 ) {
+ /* Simple copy */
+ while (len > 0) {
+ d[0] = NR_COMPOSEN11_1111 (r, 255, d[0]);
+ d[1] = NR_COMPOSEN11_1111 (g, 255, d[1]);
+ d[2] = NR_COMPOSEN11_1111 (b, 255, d[2]);
+ d += 3;
+ len -= 1;
+ }
+ } else {
+ unsigned int c0_24=(int)sv;
+ c0_24&=0xFF;
+ while (len > 0) {
+ d[0] = NR_COMPOSEN11_1111 (r, c0_24, d[0]);
+ d[1] = NR_COMPOSEN11_1111 (g, c0_24, d[1]);
+ d[2] = NR_COMPOSEN11_1111 (b, c0_24, d[2]);
+ d += 3;
+ len -= 1;
+ }
+ }
} else {
- if ( en <= st+1 ) {
- sv=0.5*(vst+ven);
- unsigned int c0_24=(int)sv;
- c0_24&=0xFF;
- d[0] = NR_COMPOSEN11_1111 (r, c0_24, d[0]);
- d[1] = NR_COMPOSEN11_1111 (g, c0_24, d[1]);
- d[2] = NR_COMPOSEN11_1111 (b, c0_24, d[2]);
- } else {
- dv/=len;
- sv+=0.5*dv; // correction trapezoidale
- sv*=65536;
- dv*=65536;
- int c0_24 = static_cast<int>(CLAMP(sv, 0, 16777216));
- int s0_24 = static_cast<int>(dv);
- while (len > 0) {
- unsigned int ca;
- /* Draw */
- ca = c0_24 >> 16;
- if ( ca > 255 ) ca=255;
- d[0] = NR_COMPOSEN11_1111 (r, ca, d[0]);
- d[1] = NR_COMPOSEN11_1111 (g, ca, d[1]);
- d[2] = NR_COMPOSEN11_1111 (b, ca, d[2]);
- d += 3;
- c0_24 += s0_24;
- c0_24 = CLAMP (c0_24, 0, 16777216);
- len -= 1;
- }
- }
+ if ( en <= st+1 ) {
+ sv=0.5*(vst+ven);
+ unsigned int c0_24=(int)sv;
+ c0_24&=0xFF;
+ d[0] = NR_COMPOSEN11_1111 (r, c0_24, d[0]);
+ d[1] = NR_COMPOSEN11_1111 (g, c0_24, d[1]);
+ d[2] = NR_COMPOSEN11_1111 (b, c0_24, d[2]);
+ } else {
+ dv/=len;
+ sv+=0.5*dv; // correction trapezoidale
+ sv*=65536;
+ dv*=65536;
+ int c0_24 = static_cast<int>(CLAMP(sv, 0, 16777216));
+ int s0_24 = static_cast<int>(dv);
+ while (len > 0) {
+ unsigned int ca;
+ /* Draw */
+ ca = c0_24 >> 16;
+ if ( ca > 255 ) ca=255;
+ d[0] = NR_COMPOSEN11_1111 (r, ca, d[0]);
+ d[1] = NR_COMPOSEN11_1111 (g, ca, d[1]);
+ d[2] = NR_COMPOSEN11_1111 (b, ca, d[2]);
+ d += 3;
+ c0_24 += s0_24;
+ c0_24 = CLAMP (c0_24, 0, 16777216);
+ len -= 1;
+ }
+ }
}
}
@@ -459,27 +459,39 @@ void nr_pixblock_render_bpath_rgba (Shape* theS,uint32_t color,NRRectL &area,cha
char* mdata=(char*)destBuf;
uint32_t* ligStart=((uint32_t*)(mdata+(3*(il-area.x0)+stride*(it-area.y0))));
for (int y=it;y<ib;y++) {
- for (int i = 0; i < 4; i++)
- theI[i]->Reset();
-
- for (int i = 0; i < 4; i++)
- theS->QuickScan(curY, curPt, ((float)(y+0.25*(i+1))),
- fill_oddEven, theI[i], 0.25);
-
- theIL->Copy(4,theI);
- // theI[0]->Affiche();
- // theIL->Affiche();
-
- raster_info dest;
- dest.startPix=il;
- dest.endPix=ir;
- dest.sth=il;
- dest.stv=y;
- dest.buffer=ligStart;
- theIL->Raster(dest,&color,bpath_run_A8_OR);
- ligStart=((uint32_t*)(((char*)ligStart)+stride));
+ for (int i = 0; i < 4; i++)
+ theI[i]->Reset();
+
+ for (int i = 0; i < 4; i++)
+ theS->QuickScan(curY, curPt, ((float)(y+0.25*(i+1))),
+ fill_oddEven, theI[i], 0.25);
+
+ theIL->Copy(4,theI);
+ // theI[0]->Affiche();
+ // theIL->Affiche();
+
+ raster_info dest;
+ dest.startPix=il;
+ dest.endPix=ir;
+ dest.sth=il;
+ dest.stv=y;
+ dest.buffer=ligStart;
+ theIL->Raster(dest,&color,bpath_run_A8_OR);
+ ligStart=((uint32_t*)(((char*)ligStart)+stride));
}
theS->EndQuickRaster();
for (int i=0;i<4;i++) delete theI[i];
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 :
index 7c391803e94f46dd5dda4e8930d5ea410390418a..b6086db270f64bee8d93b2ce19b50f4ece48573e 100644 (file)
-char const *
+char const *
CanvasGrid::getName(GridType type)
{
return _(grid_name[type]);
}
-char const *
+char const *
CanvasGrid::getSVGName(GridType type)
{
return grid_svgname[type];
@@ -314,33 +314,26 @@ CanvasGrid::on_repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gc
static inline void
attach_all(Gtk::Table &table, Gtk::Widget const *const arr[], unsigned size, int start = 0)
{
- for (unsigned i=0, r=start; i<size/sizeof(Gtk::Widget*); i+=2)
- {
- if (arr[i] && arr[i+1])
- {
+ for (unsigned i=0, r=start; i<size/sizeof(Gtk::Widget*); i+=2) {
+ if (arr[i] && arr[i+1]) {
table.attach (const_cast<Gtk::Widget&>(*arr[i]), 1, 2, r, r+1,
- Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
+ Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 2, 3, r, r+1,
- Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
- }
- else
- {
- if (arr[i+1])
+ Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
+ } else {
+ if (arr[i+1]) {
table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 1, 3, r, r+1,
- Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
- else if (arr[i])
- {
+ Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
+ } else if (arr[i]) {
Gtk::Label& label = reinterpret_cast<Gtk::Label&> (const_cast<Gtk::Widget&>(*arr[i]));
label.set_alignment (0.0);
table.attach (label, 0, 3, r, r+1,
- Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
- }
- else
- {
+ Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
+ } else {
Gtk::HBox *space = manage (new Gtk::HBox);
space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
table.attach (*space, 0, 1, r, r+1,
- (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0);
+ (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0);
}
}
++r;
@@ -380,7 +373,7 @@ CanvasXYGrid::CanvasXYGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr, SPD
_("Color of the major (highlighted) grid lines"),
"empcolor", "empopacity", _wr, repr, doc);
_rsi.init (_("_Major grid line every:"), _("lines"), "empspacing", _wr, repr, doc);
- _rcb_dotted.init ( _("_Show dots instead of lines"),
+ _rcb_dotted.init ( _("_Show dots instead of lines"),
_("If set, displays dots at gridpoints instead of gridlines"),
"dotted", _wr, false, repr, doc);
/** If the passed scalar is invalid (<=0), then set the widget and the scalar
to use the given old value.
- @param oldVal old value to use if the new one is invalid
- @param pTarget the scalar to validate
- @param widget widget associated with the scalar
+
+ @param oldVal Old value to use if the new one is invalid.
+ @param pTarget The scalar to validate.
+ @param widget Widget associated with the scalar.
*/
static void validateScalar(double oldVal,
- double* pTarget,
- Inkscape::UI::Widget::RegisteredScalarUnit& widget)
+ double* pTarget,
+ Inkscape::UI::Widget::RegisteredScalarUnit& widget)
{
- // Avoid nullness.
- if ( pTarget == NULL )
- return;
+ // Avoid nullness.
+ if ( pTarget == NULL )
+ return;
- // Invalid new value?
- if ( *pTarget <= 0 )
- {
- // If the old value is somehow invalid as well, then default to 1.
- if ( oldVal <= 0 )
- oldVal = 1;
+ // Invalid new value?
+ if ( *pTarget <= 0 ) {
+ // If the old value is somehow invalid as well, then default to 1.
+ if ( oldVal <= 0 )
+ oldVal = 1;
- // Reset the scalar and associated widget to the old value.
- *pTarget = oldVal;
- widget.setValue( *pTarget);
- } //if
+ // Reset the scalar and associated widget to the old value.
+ *pTarget = oldVal;
+ widget.setValue( *pTarget);
+ } //if
} //validateScalar
/** If the passed int is invalid (<=0), then set the widget and the int
to use the given old value.
- @param oldVal old value to use if the new one is invalid
- @param pTarget the int to validate
- @param widget widget associated with the int
+
+ @param oldVal Old value to use if the new one is invalid.
+ @param pTarget The int to validate.
+ @param widget Widget associated with the int.
*/
static void validateInt(gint oldVal,
- gint* pTarget,
- Inkscape::UI::Widget::RegisteredSuffixedInteger& widget)
+ gint* pTarget,
+ Inkscape::UI::Widget::RegisteredSuffixedInteger& widget)
{
- // Avoid nullness.
- if ( pTarget == NULL )
- return;
+ // Avoid nullness.
+ if ( pTarget == NULL )
+ return;
- // Invalid new value?
- if ( *pTarget <= 0 )
- {
- // If the old value is somehow invalid as well, then default to 1.
- if ( oldVal <= 0 )
- oldVal = 1;
+ // Invalid new value?
+ if ( *pTarget <= 0 ) {
+ // If the old value is somehow invalid as well, then default to 1.
+ if ( oldVal <= 0 )
+ oldVal = 1;
- // Reset the int and associated widget to the old value.
- *pTarget = oldVal;
- widget.setValue( *pTarget);
- } //if
+ // Reset the int and associated widget to the old value.
+ *pTarget = oldVal;
+ widget.setValue( *pTarget);
+ } //if
} //validateInt
void
CanvasXYGrid::readRepr()
{
- char buff[100];
+ char buff[100];
gchar const *value;
if ( (value = repr->attribute("originx")) ) {
sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[NR::X], &gridunit);
}
if ( (value = repr->attribute("spacingx")) ) {
- double oldVal = spacing[NR::X];
+ double oldVal = spacing[NR::X];
sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &spacing[NR::X], &gridunit);
validateScalar( oldVal, &spacing[NR::X], _rsu_sx );
spacing[NR::X] = sp_units_get_pixels(spacing[NR::X], *(gridunit));
}
if ( (value = repr->attribute("spacingy")) ) {
- double oldVal = spacing[NR::Y];
+ double oldVal = spacing[NR::Y];
sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &spacing[NR::Y], &gridunit);
- validateScalar( oldVal, &spacing[NR::Y], _rsu_sy );
+ validateScalar( oldVal, &spacing[NR::Y], _rsu_sy );
spacing[NR::Y] = sp_units_get_pixels(spacing[NR::Y], *(gridunit));
}
}
if ( (value = repr->attribute("empspacing")) ) {
- gint oldVal = empspacing;
+ gint oldVal = empspacing;
empspacing = atoi(value);
validateInt( oldVal, &empspacing, _rsi );
}
static void
grid_dot (SPCanvasBuf *buf, gint x, gint y, guint32 rgba)
{
- if ( (y >= buf->rect.y0) && (y < buf->rect.y1)
+ if ( (y >= buf->rect.y0) && (y < buf->rect.y1)
&& (x >= buf->rect.x0) && (x < buf->rect.x1) ) {
guint r, g, b, a;
guchar *p;
p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 3;
p[0] = NR_COMPOSEN11_1111 (r, a, p[0]);
p[1] = NR_COMPOSEN11_1111 (g, a, p[1]);
- p[2] = NR_COMPOSEN11_1111 (b, a, p[2]);
+ p[2] = NR_COMPOSEN11_1111 (b, a, p[2]);
}
}
gdouble y;
for (y = syg, ylinenum = ylinestart; y < buf->rect.y1; y += sw[NR::Y], ylinenum++) {
gint const y0 = (gint) Inkscape::round(y);
-
+
if (!scaled[NR::Y] && (ylinenum % empspacing) == 0) {
grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, empcolor);
} else {
grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, color);
}
}
-
+
gint xlinenum;
gdouble x;
for (x = sxg, xlinenum = xlinestart; x < buf->rect.x1; x += sw[NR::X], xlinenum++) {
gdouble x;
for (x = sxg, xlinenum = xlinestart; x < buf->rect.x1; x += sw[NR::X], xlinenum++) {
gint const ix = (gint) Inkscape::round(x);
- if ( (!scaled[NR::X] && (xlinenum % empspacing) == 0)
- || (!scaled[NR::Y] && (ylinenum % empspacing) == 0) )
+ if ( (!scaled[NR::X] && (xlinenum % empspacing) == 0)
+ || (!scaled[NR::Y] && (ylinenum % empspacing) == 0) )
{
grid_dot (buf, ix, iy, empcolor | (guint32)0x000000FF); // put alpha to max value
- }
- else
- {
+ } else {
grid_dot (buf, ix, iy, color | (guint32)0x000000FF); // put alpha to max value
}
}
}; /* namespace Inkscape */
+
/*
Local Variables:
mode:c++
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/display/curve.cpp b/src/display/curve.cpp
index 04af56990269176edf27ee68e54bc80ac3b2a2f5..bcf5e92a01ac2004dcfd7d5d275623390a86625d 100644 (file)
--- a/src/display/curve.cpp
+++ b/src/display/curve.cpp
return curve;
}
-SPCurve *sp_curve_new_from_rect(NR::Maybe<NR::Rect> const &rect)
+SPCurve *sp_curve_new_from_rect(NR::Maybe<NR::Rect> const &rect)
{
- g_return_val_if_fail(rect, NULL);
-
- SPCurve *c = sp_curve_new();
+ g_return_val_if_fail(rect, NULL);
- NR::Point p = rect->corner(0);
+ SPCurve *c = sp_curve_new();
+
+ NR::Point p = rect->corner(0);
sp_curve_moveto(c, p);
-
+
for (int i=3; i>=0; i--) {
- sp_curve_lineto(c, rect->corner(i));
+ sp_curve_lineto(c, rect->corner(i));
}
sp_curve_closepath_current(c);
-
- return c;
+
+ return c;
}
/**
/**
* Decrease refcount of curve, with possible destruction.
- *
+ *
* \todo should this be shared with other refcounting code?
*/
SPCurve *
return new_curve;
}
-/**
+/**
* Returns a list of new curves corresponding to the subpaths in \a curve.
*/
GSList *
curve->closed = true;
for (NArtBpath const *bp = curve->_bpath; bp->code != NR_END; bp++) {
- /** \todo
- * effic: Maintain a count of NR_MOVETO_OPEN's (e.g. instead of
+ /** \todo
+ * effic: Maintain a count of NR_MOVETO_OPEN's (e.g. instead of
* the closed boolean).
*/
if (bp->code == NR_MOVETO_OPEN) {
curve->closed = true;
for (NArtBpath const *bp = curve->_bpath; bp->code != NR_END; bp++) {
- /** \todo
- * effic: Maintain a count of NR_MOVETO_OPEN's (e.g. instead of
+ /** \todo
+ * effic: Maintain a count of NR_MOVETO_OPEN's (e.g. instead of
* the closed boolean).
*/
if (bp->code == NR_MOVETO_OPEN) {
return c == NR_MOVETO || c == NR_MOVETO_OPEN;
}
-/**
- * Returns \a curve but drawn in the opposite direction.
+/**
+ * Returns \a curve but drawn in the opposite direction.
* Should result in the same shape, but
* with all its markers drawn facing the other direction.
**/
&& ( fabs( bs->y3 - be->y3 ) <= tolerance ) )
{
/** \todo
- * fixme: Strictly we mess in case of multisegment mixed
- * open/close curves
+ * fixme: Strictly we mess in case of multisegment mixed
+ * open/close curves
*/
bool closed = false;
for (bs = bs + 1; bs->code != NR_END; bs++) {
* \brief
*
* \todo
- * fixme: this is bogus -- it doesn't check for nr_moveto, which will indicate
- * a closing of the subpath it's nonsense to talk about a path as a whole
- * being closed, although maybe someone would want that for some other reason?
- * Oh, also, if the bpath just ends, then it's *open*. I hope nobody is using
+ * fixme: this is bogus -- it doesn't check for nr_moveto, which will indicate
+ * a closing of the subpath it's nonsense to talk about a path as a whole
+ * being closed, although maybe someone would want that for some other reason?
+ * Oh, also, if the bpath just ends, then it's *open*. I hope nobody is using
* this code for anything.
*/
static bool sp_bpath_closed(NArtBpath const bpath[])
double const threshold)
{
/** \todo
- * The SVG spec claims that a closed form exists, but for the moment I'll
+ * The SVG spec claims that a closed form exists, but for the moment I'll
* use a stupid algorithm.
*/
double const lbound = L2( c3 - c0 );
@@ -1149,8 +1149,8 @@ sp_curve_distance_including_space(SPCurve const *const curve, double seg2len[])
return ret;
}
-/**
- * Like sp_curve_distance_including_space(), but ensures that the
+/**
+ * Like sp_curve_distance_including_space(), but ensures that the
* result >= 1e-18: uses 1 per segment if necessary.
*/
static double
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
index 41429b408d27a7b74176250f9d9fc29f50b4a559..36f51d3c613b636e76e2f1091fd892fc2a27632a 100644 (file)
static GType guideline_type = 0;
if (!guideline_type) {
- static const GTypeInfo guideline_info =
- {
- sizeof (SPGuideLineClass),
- NULL, NULL,
- (GClassInitFunc) sp_guideline_class_init,
- NULL, NULL,
- sizeof (SPGuideLine),
- 16,
- (GInstanceInitFunc) sp_guideline_init,
- NULL,
- };
-
+ static GTypeInfo const guideline_info = {
+ sizeof (SPGuideLineClass),
+ NULL, NULL,
+ (GClassInitFunc) sp_guideline_class_init,
+ NULL, NULL,
+ sizeof (SPGuideLine),
+ 16,
+ (GInstanceInitFunc) sp_guideline_init,
+ NULL,
+ };
+
guideline_type = g_type_register_static(SP_TYPE_CANVAS_ITEM, "SPGuideLine", &guideline_info, (GTypeFlags) 0);
}
-
+
return guideline_type;
}
static void sp_guideline_class_init(SPGuideLineClass *c)
{
- parent_class = (SPCanvasItemClass*) g_type_class_peek_parent(c);
+ parent_class = (SPCanvasItemClass*) g_type_class_peek_parent(c);
- GtkObjectClass *object_class = (GtkObjectClass *) c;
- object_class->destroy = sp_guideline_destroy;
+ GtkObjectClass *object_class = (GtkObjectClass *) c;
+ object_class->destroy = sp_guideline_destroy;
- SPCanvasItemClass *item_class = (SPCanvasItemClass *) c;
- item_class->update = sp_guideline_update;
- item_class->render = sp_guideline_render;
- item_class->point = sp_guideline_point;
+ SPCanvasItemClass *item_class = (SPCanvasItemClass *) c;
+ item_class->update = sp_guideline_update;
+ item_class->render = sp_guideline_render;
+ item_class->point = sp_guideline_point;
}
static void sp_guideline_init(SPGuideLine *gl)
{
gl->rgba = 0x0000ff7f;
-
+
gl->vertical = 0;
gl->sensitive = 0;
}
static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf)
{
SPGuideLine const *gl = SP_GUIDELINE (item);
-
+
sp_canvas_prepare_buffer(buf);
-
+
unsigned int const r = NR_RGBA32_R (gl->rgba);
unsigned int const g = NR_RGBA32_G (gl->rgba);
unsigned int const b = NR_RGBA32_B (gl->rgba);
unsigned int const a = NR_RGBA32_A (gl->rgba);
-
+
int p0, p1, step;
unsigned char *d;
p1 = buf->rect.y1;
step = buf->buf_rowstride;
d = buf->buf + 3 * (gl->position - buf->rect.x0);
-
+
} else {
- if (gl->position < buf->rect.y0 || gl->position >= buf->rect.y1) {
+ if (gl->position < buf->rect.y0 || gl->position >= buf->rect.y1) {
return;
}
-
+
p0 = buf->rect.x0;
p1 = buf->rect.x1;
step = 3;
void sp_guideline_set_position(SPGuideLine *gl, double position)
{
- sp_canvas_item_affine_absolute(SP_CANVAS_ITEM (gl),
+ sp_canvas_item_affine_absolute(SP_CANVAS_ITEM (gl),
NR::Matrix(NR::translate(position, position)));
}
gl->sensitive = sensitive;
}
+
/*
Local Variables:
mode:c++
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
index 243cf66187cf9deee5a2e582eb35d39e596a57c4..bba6f00c833e7d3967142446890810b2e9c7b89b 100644 (file)
@@ -239,7 +239,7 @@ nr_arena_glyphs_pick(NRArenaItem *item, NR::Point p, gdouble delta, unsigned int
if (!glyphs->font ) return NULL;
if (!glyphs->style) return NULL;
-
+
double const x = p[NR::X];
double const y = p[NR::Y];
/* With text we take a simple approach: pick if the point is in a characher bbox */
@@ -255,13 +255,13 @@ nr_arena_glyphs_set_path(NRArenaGlyphs *glyphs, SPCurve *curve, unsigned int lie
nr_return_if_fail(NR_IS_ARENA_GLYPHS(glyphs));
nr_arena_item_request_render(NR_ARENA_ITEM(glyphs));
-
+
if (transform) {
glyphs->g_transform = *transform;
} else {
nr_matrix_set_identity(&glyphs->g_transform);
}
-
+
if (font) font->Ref();
if (glyphs->font) glyphs->font->Unref();
glyphs->font=font;
@@ -444,11 +444,11 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi
if (item->arena->rendermode == RENDERMODE_OUTLINE) {
- if (!ct)
+ if (!ct)
return item->state;
guint32 rgba = item->arena->outlinecolor;
- // FIXME: we use RGBA buffers but cairo writes BGRA (on i386), so we must cheat
+ // 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));
cairo_set_tolerance(ct, 1.25); // low quality, but good enough for outline mode
@@ -475,13 +475,13 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi
NRPixBlock m;
nr_pixblock_setup_fast(&m, NR_PIXBLOCK_MODE_A8, area->x0, area->y0, area->x1, area->y1, TRUE);
- // if memory allocation failed, abort
+ // if memory allocation failed, abort
if (m.size != NR_PIXBLOCK_SIZE_TINY && m.data.px == NULL) {
nr_pixblock_release (&m);
return (item->state);
}
- m.visible_area = pb->visible_area;
+ m.visible_area = pb->visible_area;
/* Render children fill mask */
for (child = group->children; child != NULL; child = child->next) {
@@ -521,7 +521,7 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi
guint32 rgba;
nr_pixblock_setup_fast(&m, NR_PIXBLOCK_MODE_A8, area->x0, area->y0, area->x1, area->y1, TRUE);
- // if memory allocation failed, abort
+ // if memory allocation failed, abort
if (m.size != NR_PIXBLOCK_SIZE_TINY && m.data.px == NULL) {
nr_pixblock_release (&m);
return (item->state);
index 912992a6e38bc88633a32e13d13d5f4b9138b7d0..fcce681a87f5643dcd0bef856c9c1023d1087b97 100644 (file)
NRType
nr_arena_group_get_type (void)
{
- static NRType type = 0;
- if (!type) {
- type = nr_object_register_type (NR_TYPE_ARENA_ITEM,
- "NRArenaGroup",
- sizeof (NRArenaGroupClass),
- sizeof (NRArenaGroup),
- (void (*) (NRObjectClass *)) nr_arena_group_class_init,
- (void (*) (NRObject *)) nr_arena_group_init);
- }
- return type;
+ static NRType type = 0;
+ if (!type) {
+ type = nr_object_register_type (NR_TYPE_ARENA_ITEM,
+ "NRArenaGroup",
+ sizeof (NRArenaGroupClass),
+ sizeof (NRArenaGroup),
+ (void (*) (NRObjectClass *)) nr_arena_group_class_init,
+ (void (*) (NRObject *)) nr_arena_group_init);
+ }
+ return type;
}
static void
nr_arena_group_class_init (NRArenaGroupClass *klass)
{
- NRObjectClass *object_class;
- NRArenaItemClass *item_class;
+ NRObjectClass *object_class;
+ NRArenaItemClass *item_class;
- object_class = (NRObjectClass *) klass;
- item_class = (NRArenaItemClass *) klass;
+ object_class = (NRObjectClass *) klass;
+ item_class = (NRArenaItemClass *) klass;
- parent_class = (NRArenaItemClass *) ((NRObjectClass *) klass)->parent;
+ parent_class = (NRArenaItemClass *) ((NRObjectClass *) klass)->parent;
- object_class->cpp_ctor = NRObject::invoke_ctor<NRArenaGroup>;
+ object_class->cpp_ctor = NRObject::invoke_ctor<NRArenaGroup>;
- item_class->children = nr_arena_group_children;
- item_class->last_child = nr_arena_group_last_child;
- item_class->add_child = nr_arena_group_add_child;
- item_class->set_child_position = nr_arena_group_set_child_position;
- item_class->remove_child = nr_arena_group_remove_child;
- item_class->update = nr_arena_group_update;
- item_class->render = nr_arena_group_render;
- item_class->clip = nr_arena_group_clip;
- item_class->pick = nr_arena_group_pick;
+ item_class->children = nr_arena_group_children;
+ item_class->last_child = nr_arena_group_last_child;
+ item_class->add_child = nr_arena_group_add_child;
+ item_class->set_child_position = nr_arena_group_set_child_position;
+ item_class->remove_child = nr_arena_group_remove_child;
+ item_class->update = nr_arena_group_update;
+ item_class->render = nr_arena_group_render;
+ item_class->clip = nr_arena_group_clip;
+ item_class->pick = nr_arena_group_pick;
}
static void
nr_arena_group_init (NRArenaGroup *group)
{
- group->transparent = FALSE;
- group->children = NULL;
- group->last = NULL;
- group->style = NULL;
- nr_matrix_set_identity (&group->child_transform);
+ group->transparent = FALSE;
+ group->children = NULL;
+ group->last = NULL;
+ group->style = NULL;
+ nr_matrix_set_identity (&group->child_transform);
}
static NRArenaItem *
nr_arena_group_children (NRArenaItem *item)
{
- NRArenaGroup *group = NR_ARENA_GROUP (item);
+ NRArenaGroup *group = NR_ARENA_GROUP (item);
- return group->children;
+ return group->children;
}
static NRArenaItem *
nr_arena_group_last_child (NRArenaItem *item)
{
- NRArenaGroup *group = NR_ARENA_GROUP (item);
+ NRArenaGroup *group = NR_ARENA_GROUP (item);
- return group->last;
+ return group->last;
}
static void
nr_arena_group_add_child (NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref)
{
- NRArenaGroup *group = NR_ARENA_GROUP (item);
+ NRArenaGroup *group = NR_ARENA_GROUP (item);
- if (!ref) {
- group->children = nr_arena_item_attach (item, child, NULL, group->children);
- } else {
- ref->next = nr_arena_item_attach (item, child, ref, ref->next);
- }
+ if (!ref) {
+ group->children = nr_arena_item_attach (item, child, NULL, group->children);
+ } else {
+ ref->next = nr_arena_item_attach (item, child, ref, ref->next);
+ }
- if (ref == group->last) group->last = child;
+ if (ref == group->last) group->last = child;
- nr_arena_item_request_update (item, NR_ARENA_ITEM_STATE_ALL, FALSE);
+ nr_arena_item_request_update (item, NR_ARENA_ITEM_STATE_ALL, FALSE);
}
static void
nr_arena_group_remove_child (NRArenaItem *item, NRArenaItem *child)
{
- NRArenaGroup *group = NR_ARENA_GROUP (item);
+ NRArenaGroup *group = NR_ARENA_GROUP (item);
- if (child == group->last) group->last = child->prev;
+ if (child == group->last) group->last = child->prev;
- if (child->prev) {
- nr_arena_item_detach (item, child);
- } else {
- group->children = nr_arena_item_detach (item, child);
- }
+ if (child->prev) {
+ nr_arena_item_detach (item, child);
+ } else {
+ group->children = nr_arena_item_detach (item, child);
+ }
- nr_arena_item_request_update (item, NR_ARENA_ITEM_STATE_ALL, FALSE);
+ nr_arena_item_request_update (item, NR_ARENA_ITEM_STATE_ALL, FALSE);
}
static void
nr_arena_group_set_child_position (NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref)
{
- NRArenaGroup *group = NR_ARENA_GROUP (item);
+ NRArenaGroup *group = NR_ARENA_GROUP (item);
- if (child == group->last) group->last = child->prev;
+ if (child == group->last) group->last = child->prev;
- if (child->prev) {
- nr_arena_item_detach (item, child);
- } else {
- group->children = nr_arena_item_detach (item, child);
- }
+ if (child->prev) {
+ nr_arena_item_detach (item, child);
+ } else {
+ group->children = nr_arena_item_detach (item, child);
+ }
- if (!ref) {
- group->children = nr_arena_item_attach (item, child, NULL, group->children);
- } else {
- ref->next = nr_arena_item_attach (item, child, ref, ref->next);
- }
+ if (!ref) {
+ group->children = nr_arena_item_attach (item, child, NULL, group->children);
+ } else {
+ ref->next = nr_arena_item_attach (item, child, ref, ref->next);
+ }
- if (ref == group->last) group->last = child;
+ if (ref == group->last) group->last = child;
- nr_arena_item_request_render (child);
+ nr_arena_item_request_render (child);
}
static unsigned int
nr_arena_group_update (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int state, unsigned int reset)
{
- unsigned int newstate;
+ unsigned int newstate;
- NRArenaGroup *group = NR_ARENA_GROUP (item);
+ NRArenaGroup *group = NR_ARENA_GROUP (item);
- unsigned int beststate = NR_ARENA_ITEM_STATE_ALL;
+ unsigned int beststate = NR_ARENA_ITEM_STATE_ALL;
- for (NRArenaItem *child = group->children; child != NULL; child = child->next) {
- NRGC cgc(gc);
- nr_matrix_multiply (&cgc.transform, &group->child_transform, &gc->transform);
- newstate = nr_arena_item_invoke_update (child, area, &cgc, state, reset);
- beststate = beststate & newstate;
- }
+ for (NRArenaItem *child = group->children; child != NULL; child = child->next) {
+ NRGC cgc(gc);
+ nr_matrix_multiply (&cgc.transform, &group->child_transform, &gc->transform);
+ newstate = nr_arena_item_invoke_update (child, area, &cgc, state, reset);
+ beststate = beststate & newstate;
+ }
- if (beststate & NR_ARENA_ITEM_STATE_BBOX) {
- nr_rect_l_set_empty (&item->bbox);
- for (NRArenaItem *child = group->children; child != NULL; child = child->next) {
- nr_rect_l_union (&item->bbox, &item->bbox, &child->bbox);
- }
- }
+ if (beststate & NR_ARENA_ITEM_STATE_BBOX) {
+ nr_rect_l_set_empty (&item->bbox);
+ for (NRArenaItem *child = group->children; child != NULL; child = child->next) {
+ nr_rect_l_union (&item->bbox, &item->bbox, &child->bbox);
+ }
+ }
- return beststate;
+ return beststate;
}
void nr_arena_group_set_style (NRArenaGroup *group, SPStyle *style)
delete group->filter;
group->filter = NULL;
}
-
+
if (style && style->enable_background.set
&& style->enable_background.value == SP_CSS_BACKGROUND_NEW) {
group->background_new = true;
static unsigned int
nr_arena_group_render (cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags)
{
- NRArenaGroup *group = NR_ARENA_GROUP (item);
+ NRArenaGroup *group = NR_ARENA_GROUP (item);
- unsigned int ret = item->state;
+ unsigned int ret = item->state;
- /* Just compose children into parent buffer */
- for (NRArenaItem *child = group->children; child != NULL; child = child->next) {
- ret = nr_arena_item_invoke_render (ct, child, area, pb, flags);
- if (ret & NR_ARENA_ITEM_STATE_INVALID) break;
- }
+ /* Just compose children into parent buffer */
+ for (NRArenaItem *child = group->children; child != NULL; child = child->next) {
+ ret = nr_arena_item_invoke_render (ct, child, area, pb, flags);
+ if (ret & NR_ARENA_ITEM_STATE_INVALID) break;
+ }
- return ret;
+ return ret;
}
static unsigned int
nr_arena_group_clip (NRArenaItem *item, NRRectL *area, NRPixBlock *pb)
{
- NRArenaGroup *group = NR_ARENA_GROUP (item);
+ NRArenaGroup *group = NR_ARENA_GROUP (item);
- unsigned int ret = item->state;
+ unsigned int ret = item->state;
- /* Just compose children into parent buffer */
- for (NRArenaItem *child = group->children; child != NULL; child = child->next) {
- ret = nr_arena_item_invoke_clip (child, area, pb);
- if (ret & NR_ARENA_ITEM_STATE_INVALID) break;
- }
+ /* Just compose children into parent buffer */
+ for (NRArenaItem *child = group->children; child != NULL; child = child->next) {
+ ret = nr_arena_item_invoke_clip (child, area, pb);
+ if (ret & NR_ARENA_ITEM_STATE_INVALID) break;
+ }
- return ret;
+ return ret;
}
static NRArenaItem *
nr_arena_group_pick (NRArenaItem *item, NR::Point p, double delta, unsigned int sticky)
{
- NRArenaGroup *group = NR_ARENA_GROUP (item);
+ NRArenaGroup *group = NR_ARENA_GROUP (item);
- for (NRArenaItem *child = group->last; child != NULL; child = child->prev) {
- NRArenaItem *picked = nr_arena_item_invoke_pick (child, p, delta, sticky);
- if (picked)
- return (group->transparent) ? picked : item;
- }
+ for (NRArenaItem *child = group->last; child != NULL; child = child->prev) {
+ NRArenaItem *picked = nr_arena_item_invoke_pick (child, p, delta, sticky);
+ if (picked)
+ return (group->transparent) ? picked : item;
+ }
- return NULL;
+ return NULL;
}
void
nr_arena_group_set_transparent (NRArenaGroup *group, unsigned int transparent)
{
- nr_return_if_fail (group != NULL);
- nr_return_if_fail (NR_IS_ARENA_GROUP (group));
+ nr_return_if_fail (group != NULL);
+ nr_return_if_fail (NR_IS_ARENA_GROUP (group));
- group->transparent = transparent;
+ group->transparent = transparent;
}
void nr_arena_group_set_child_transform(NRArenaGroup *group, NR::Matrix const &t)
{
- NRMatrix nt(t);
- nr_arena_group_set_child_transform(group, &nt);
+ NRMatrix nt(t);
+ nr_arena_group_set_child_transform(group, &nt);
}
void nr_arena_group_set_child_transform(NRArenaGroup *group, NRMatrix const *t)
{
- if (!t) t = &NR_MATRIX_IDENTITY;
+ if (!t) t = &NR_MATRIX_IDENTITY;
- if (!NR_MATRIX_DF_TEST_CLOSE (t, &group->child_transform, NR_EPSILON)) {
- nr_arena_item_request_render (NR_ARENA_ITEM (group));
- group->child_transform = *t;
- nr_arena_item_request_update (NR_ARENA_ITEM (group), NR_ARENA_ITEM_STATE_ALL, TRUE);
- }
+ if (!NR_MATRIX_DF_TEST_CLOSE (t, &group->child_transform, NR_EPSILON)) {
+ nr_arena_item_request_render (NR_ARENA_ITEM (group));
+ group->child_transform = *t;
+ nr_arena_item_request_update (NR_ARENA_ITEM (group), NR_ARENA_ITEM_STATE_ALL, TRUE);
+ }
}
+
/*
Local Variables:
mode:c++
index 9da16908d2a3531880426922ef6e9f4ea83a7ee2..1b699fd04f8c25ae2d2d453b29fe2b9e620215fc 100644 (file)
NRType nr_arena_group_get_type (void);
struct NRArenaGroup : public NRArenaItem{
- unsigned int transparent : 1;
- NRArenaItem *children;
- NRArenaItem *last;
- NRMatrix child_transform;
- SPStyle *style;
-
- static NRArenaGroup *create(NRArena *arena) {
- NRArenaGroup *obj=reinterpret_cast<NRArenaGroup *>(nr_object_new(NR_TYPE_ARENA_GROUP));
- obj->init(arena);
- return obj;
- }
+ unsigned int transparent : 1;
+ NRArenaItem *children;
+ NRArenaItem *last;
+ NRMatrix child_transform;
+ SPStyle *style;
+
+ static NRArenaGroup *create(NRArena *arena) {
+ NRArenaGroup *obj = reinterpret_cast<NRArenaGroup *>(nr_object_new(NR_TYPE_ARENA_GROUP));
+ obj->init(arena);
+ return obj;
+ }
};
struct NRArenaGroupClass {
- NRArenaItemClass parent_class;
+ NRArenaItemClass parent_class;
};
-void nr_arena_group_set_transparent (NRArenaGroup *group, unsigned int transparent);
+void nr_arena_group_set_transparent(NRArenaGroup *group, unsigned int transparent);
void nr_arena_group_set_child_transform(NRArenaGroup *group, NR::Matrix const &t);
void nr_arena_group_set_child_transform(NRArenaGroup *group, NRMatrix const *t);
void nr_arena_group_set_style(NRArenaGroup *group, SPStyle *style);
#endif
+
+
+/*
+ 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 :
index 6f30937829e35a7f3aa95dc8bd461671f67b50b2..debd9bd0edbd8275e637b12c93f30c9e3f6372da 100644 (file)
NRType
nr_arena_image_get_type (void)
{
- static NRType type = 0;
- if (!type) {
- type = nr_object_register_type (NR_TYPE_ARENA_ITEM,
- "NRArenaImage",
- sizeof (NRArenaImageClass),
- sizeof (NRArenaImage),
- (void (*) (NRObjectClass *)) nr_arena_image_class_init,
- (void (*) (NRObject *)) nr_arena_image_init);
- }
- return type;
+ static NRType type = 0;
+ if (!type) {
+ type = nr_object_register_type (NR_TYPE_ARENA_ITEM,
+ "NRArenaImage",
+ sizeof (NRArenaImageClass),
+ sizeof (NRArenaImage),
+ (void (*) (NRObjectClass *)) nr_arena_image_class_init,
+ (void (*) (NRObject *)) nr_arena_image_init);
+ }
+ return type;
}
static void
nr_arena_image_class_init (NRArenaImageClass *klass)
{
- NRObjectClass *object_class;
- NRArenaItemClass *item_class;
+ NRObjectClass *object_class;
+ NRArenaItemClass *item_class;
- object_class = (NRObjectClass *) klass;
- item_class = (NRArenaItemClass *) klass;
+ object_class = (NRObjectClass *) klass;
+ item_class = (NRArenaItemClass *) klass;
- parent_class = (NRArenaItemClass *) ((NRObjectClass *) klass)->parent;
+ parent_class = (NRArenaItemClass *) ((NRObjectClass *) klass)->parent;
- object_class->finalize = nr_arena_image_finalize;
- object_class->cpp_ctor = NRObject::invoke_ctor<NRArenaImage>;
+ object_class->finalize = nr_arena_image_finalize;
+ object_class->cpp_ctor = NRObject::invoke_ctor<NRArenaImage>;
- item_class->update = nr_arena_image_update;
- item_class->render = nr_arena_image_render;
- item_class->pick = nr_arena_image_pick;
+ item_class->update = nr_arena_image_update;
+ item_class->render = nr_arena_image_render;
+ item_class->pick = nr_arena_image_pick;
}
static void
nr_arena_image_init (NRArenaImage *image)
{
- image->px = NULL;
+ image->px = NULL;
- image->pxw = image->pxh = image->pxrs = 0;
- image->x = image->y = 0.0;
- image->width = 256.0;
- image->height = 256.0;
+ image->pxw = image->pxh = image->pxrs = 0;
+ image->x = image->y = 0.0;
+ image->width = 256.0;
+ image->height = 256.0;
- nr_matrix_set_identity (&image->grid2px);
+ nr_matrix_set_identity (&image->grid2px);
- image->style = 0;
+ image->style = 0;
}
static void
nr_arena_image_finalize (NRObject *object)
{
- NRArenaImage *image = NR_ARENA_IMAGE (object);
+ NRArenaImage *image = NR_ARENA_IMAGE (object);
- image->px = NULL;
+ image->px = NULL;
- ((NRObjectClass *) parent_class)->finalize (object);
+ ((NRObjectClass *) parent_class)->finalize (object);
}
static unsigned int
nr_arena_image_update (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int state, unsigned int reset)
{
- NRMatrix grid2px;
-
- NRArenaImage *image = NR_ARENA_IMAGE (item);
-
- /* Request render old */
- nr_arena_item_request_render (item);
-
- /* Copy affine */
- nr_matrix_invert (&grid2px, &gc->transform);
- double hscale, vscale; // todo: replace with NR::scale
- if (image->px) {
- hscale = image->pxw / image->width;
- vscale = image->pxh / image->height;
- } else {
- hscale = 1.0;
- vscale = 1.0;
- }
-
- image->grid2px[0] = grid2px.c[0] * hscale;
- image->grid2px[2] = grid2px.c[2] * hscale;
- image->grid2px[4] = grid2px.c[4] * hscale;
- image->grid2px[1] = grid2px.c[1] * vscale;
- image->grid2px[3] = grid2px.c[3] * vscale;
- image->grid2px[5] = grid2px.c[5] * vscale;
-
- image->grid2px[4] -= image->x * hscale;
- image->grid2px[5] -= image->y * vscale;
-
- /* Calculate bbox */
- if (image->px) {
- NRRect bbox;
-
- bbox.x0 = image->x;
- bbox.y0 = image->y;
- bbox.x1 = image->x + image->width;
- bbox.y1 = image->y + image->height;
-
- image->c00 = (NR::Point(bbox.x0, bbox.y0) * gc->transform);
- image->c01 = (NR::Point(bbox.x0, bbox.y1) * gc->transform);
- image->c10 = (NR::Point(bbox.x1, bbox.y0) * gc->transform);
- image->c11 = (NR::Point(bbox.x1, bbox.y1) * gc->transform);
-
- nr_rect_d_matrix_transform (&bbox, &bbox, &gc->transform);
-
- item->bbox.x0 = (int) floor (bbox.x0);
- item->bbox.y0 = (int) floor (bbox.y0);
- item->bbox.x1 = (int) ceil (bbox.x1);
- item->bbox.y1 = (int) ceil (bbox.y1);
- } else {
- item->bbox.x0 = (int) gc->transform[4];
- item->bbox.y0 = (int) gc->transform[5];
- item->bbox.x1 = item->bbox.x0 - 1;
- item->bbox.y1 = item->bbox.y0 - 1;
- }
-
- nr_arena_item_request_render (item);
-
- return NR_ARENA_ITEM_STATE_ALL;
+ NRMatrix grid2px;
+
+ NRArenaImage *image = NR_ARENA_IMAGE (item);
+
+ /* Request render old */
+ nr_arena_item_request_render (item);
+
+ /* Copy affine */
+ nr_matrix_invert (&grid2px, &gc->transform);
+ double hscale, vscale; // todo: replace with NR::scale
+ if (image->px) {
+ hscale = image->pxw / image->width;
+ vscale = image->pxh / image->height;
+ } else {
+ hscale = 1.0;
+ vscale = 1.0;
+ }
+
+ image->grid2px[0] = grid2px.c[0] * hscale;
+ image->grid2px[2] = grid2px.c[2] * hscale;
+ image->grid2px[4] = grid2px.c[4] * hscale;
+ image->grid2px[1] = grid2px.c[1] * vscale;
+ image->grid2px[3] = grid2px.c[3] * vscale;
+ image->grid2px[5] = grid2px.c[5] * vscale;
+
+ image->grid2px[4] -= image->x * hscale;
+ image->grid2px[5] -= image->y * vscale;
+
+ /* Calculate bbox */
+ if (image->px) {
+ NRRect bbox;
+
+ bbox.x0 = image->x;
+ bbox.y0 = image->y;
+ bbox.x1 = image->x + image->width;
+ bbox.y1 = image->y + image->height;
+
+ image->c00 = (NR::Point(bbox.x0, bbox.y0) * gc->transform);
+ image->c01 = (NR::Point(bbox.x0, bbox.y1) * gc->transform);
+ image->c10 = (NR::Point(bbox.x1, bbox.y0) * gc->transform);
+ image->c11 = (NR::Point(bbox.x1, bbox.y1) * gc->transform);
+
+ nr_rect_d_matrix_transform (&bbox, &bbox, &gc->transform);
+
+ item->bbox.x0 = (int) floor (bbox.x0);
+ item->bbox.y0 = (int) floor (bbox.y0);
+ item->bbox.x1 = (int) ceil (bbox.x1);
+ item->bbox.y1 = (int) ceil (bbox.y1);
+ } else {
+ item->bbox.x0 = (int) gc->transform[4];
+ item->bbox.y0 = (int) gc->transform[5];
+ item->bbox.x1 = item->bbox.x0 - 1;
+ item->bbox.y1 = item->bbox.y0 - 1;
+ }
+
+ nr_arena_item_request_render (item);
+
+ return NR_ARENA_ITEM_STATE_ALL;
}
#define FBITS 12
@@ -177,156 +177,156 @@ nr_arena_image_update (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int
static unsigned int
nr_arena_image_render (cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags)
{
- nr_arena_image_x_sample = prefs_get_int_attribute ("options.bitmapoversample", "value", 1);
- nr_arena_image_y_sample = nr_arena_image_x_sample;
+ nr_arena_image_x_sample = prefs_get_int_attribute ("options.bitmapoversample", "value", 1);
+ nr_arena_image_y_sample = nr_arena_image_x_sample;
- bool outline = (item->arena->rendermode == RENDERMODE_OUTLINE);
+ bool outline = (item->arena->rendermode == RENDERMODE_OUTLINE);
- NRArenaImage *image = NR_ARENA_IMAGE (item);
+ NRArenaImage *image = NR_ARENA_IMAGE (item);
- NR::Matrix d2s;
+ NR::Matrix d2s;
- d2s[0] = b2i[0];
- d2s[1] = b2i[1];
- d2s[2] = b2i[2];
- d2s[3] = b2i[3];
- d2s[4] = b2i[0] * pb->area.x0 + b2i[2] * pb->area.y0 + b2i[4];
- d2s[5] = b2i[1] * pb->area.x0 + b2i[3] * pb->area.y0 + b2i[5];
+ d2s[0] = b2i[0];
+ d2s[1] = b2i[1];
+ d2s[2] = b2i[2];
+ d2s[3] = b2i[3];
+ d2s[4] = b2i[0] * pb->area.x0 + b2i[2] * pb->area.y0 + b2i[4];
+ d2s[5] = b2i[1] * pb->area.x0 + b2i[3] * pb->area.y0 + b2i[5];
- if (!outline) {
+ if (!outline) {
- if (!image->px) return item->state;
+ if (!image->px) return item->state;
- guint32 Falpha = item->opacity;
- if (Falpha < 1) return item->state;
+ guint32 Falpha = item->opacity;
+ if (Falpha < 1) return item->state;
- unsigned char * dpx = NR_PIXBLOCK_PX (pb);
- int const drs = pb->rs;
- int const dw = pb->area.x1 - pb->area.x0;
- int const dh = pb->area.y1 - pb->area.y0;
+ unsigned char * dpx = NR_PIXBLOCK_PX (pb);
+ int const drs = pb->rs;
+ int const dw = pb->area.x1 - pb->area.x0;
+ int const dh = pb->area.y1 - pb->area.y0;
- unsigned char * spx = image->px;
- int const srs = image->pxrs;
- int const sw = image->pxw;
- int const sh = image->pxh;
+ unsigned char * spx = image->px;
+ int const srs = image->pxrs;
+ int const sw = image->pxw;
+ int const sh = image->pxh;
- if (pb->mode == NR_PIXBLOCK_MODE_R8G8B8) {
- /* fixme: This is not implemented yet (Lauris) */
- /* nr_R8G8B8_R8G8B8_R8G8B8A8_N_TRANSFORM (dpx, dw, dh, drs, spx, sw, sh, srs, d2s, Falpha, nr_arena_image_x_sample, nr_arena_image_y_sample); */
- } else if (pb->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) {
- nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_TRANSFORM (dpx, dw, dh, drs, spx, sw, sh, srs, d2s, Falpha, nr_arena_image_x_sample, nr_arena_image_y_sample);
- } else if (pb->mode == NR_PIXBLOCK_MODE_R8G8B8A8N) {
+ if (pb->mode == NR_PIXBLOCK_MODE_R8G8B8) {
+ /* fixme: This is not implemented yet (Lauris) */
+ /* nr_R8G8B8_R8G8B8_R8G8B8A8_N_TRANSFORM (dpx, dw, dh, drs, spx, sw, sh, srs, d2s, Falpha, nr_arena_image_x_sample, nr_arena_image_y_sample); */
+ } else if (pb->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) {
+ nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_TRANSFORM (dpx, dw, dh, drs, spx, sw, sh, srs, d2s, Falpha, nr_arena_image_x_sample, nr_arena_image_y_sample);
+ } else if (pb->mode == NR_PIXBLOCK_MODE_R8G8B8A8N) {
- //FIXME: The _N_N_N_ version gives a gray border around images, see bug 906376
- // This mode is only used when exporting, screen rendering always has _P_P_P_, so I decided to simply replace it for now
- // Feel free to propose a better fix
+ //FIXME: The _N_N_N_ version gives a gray border around images, see bug 906376
+ // This mode is only used when exporting, screen rendering always has _P_P_P_, so I decided to simply replace it for now
+ // Feel free to propose a better fix
- //nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_TRANSFORM (dpx, dw, dh, drs, spx, sw, sh, srs, d2s, Falpha, nr_arena_image_x_sample, nr_arena_image_y_sample);
- nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_TRANSFORM (dpx, dw, dh, drs, spx, sw, sh, srs, d2s, Falpha, nr_arena_image_x_sample, nr_arena_image_y_sample);
- }
+ //nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_TRANSFORM (dpx, dw, dh, drs, spx, sw, sh, srs, d2s, Falpha, nr_arena_image_x_sample, nr_arena_image_y_sample);
+ nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_TRANSFORM (dpx, dw, dh, drs, spx, sw, sh, srs, d2s, Falpha, nr_arena_image_x_sample, nr_arena_image_y_sample);
+ }
- pb->empty = FALSE;
+ pb->empty = FALSE;
- } else { // outline; draw a rect instead
+ } else { // outline; draw a rect instead
- if (!ct)
- return item->state;
+ if (!ct)
+ return item->state;
- guint32 rgba = prefs_get_int_attribute("options.wireframecolors", "images", 0xff0000ff);
- // 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));
+ guint32 rgba = prefs_get_int_attribute("options.wireframecolors", "images", 0xff0000ff);
+ // 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));
- cairo_set_line_width(ct, 0.5);
- cairo_new_path(ct);
+ cairo_set_line_width(ct, 0.5);
+ cairo_new_path(ct);
- NR::Point shift(pb->area.x0, pb->area.y0);
- NR::Point c00 = image->c00 - shift;
- NR::Point c01 = image->c01 - shift;
- NR::Point c11 = image->c11 - shift;
- NR::Point c10 = image->c10 - shift;
+ NR::Point shift(pb->area.x0, pb->area.y0);
+ NR::Point c00 = image->c00 - shift;
+ NR::Point c01 = image->c01 - shift;
+ NR::Point c11 = image->c11 - shift;
+ NR::Point c10 = image->c10 - shift;
- cairo_move_to (ct, c00[NR::X], c00[NR::Y]);
+ cairo_move_to (ct, c00[NR::X], c00[NR::Y]);
- // the box
- cairo_line_to (ct, c10[NR::X], c10[NR::Y]);
- cairo_line_to (ct, c11[NR::X], c11[NR::Y]);
- cairo_line_to (ct, c01[NR::X], c01[NR::Y]);
- cairo_line_to (ct, c00[NR::X], c00[NR::Y]);
- // the diagonals
- cairo_line_to (ct, c11[NR::X], c11[NR::Y]);
- cairo_move_to (ct, c10[NR::X], c10[NR::Y]);
- cairo_line_to (ct, c01[NR::X], c01[NR::Y]);
+ // the box
+ cairo_line_to (ct, c10[NR::X], c10[NR::Y]);
+ cairo_line_to (ct, c11[NR::X], c11[NR::Y]);
+ cairo_line_to (ct, c01[NR::X], c01[NR::Y]);
+ cairo_line_to (ct, c00[NR::X], c00[NR::Y]);
+ // the diagonals
+ cairo_line_to (ct, c11[NR::X], c11[NR::Y]);
+ cairo_move_to (ct, c10[NR::X], c10[NR::Y]);
+ cairo_line_to (ct, c01[NR::X], c01[NR::Y]);
- cairo_stroke(ct);
+ cairo_stroke(ct);
- pb->empty = FALSE;
- }
+ pb->empty = FALSE;
+ }
- return item->state;
+ return item->state;
}
/** Calculates the closest distance from p to the segment a1-a2*/
-double
+double
distance_to_segment (NR::Point p, NR::Point a1, NR::Point a2)
{
- // calculate sides of the triangle and their squares
- double d1 = NR::L2(p - a1);
- double d1_2 = d1 * d1;
- double d2 = NR::L2(p - a2);
- double d2_2 = d2 * d2;
- double a = NR::L2(a1 - a2);
- double a_2 = a * a;
-
- // if one of the angles at the base is > 90, return the corresponding side
- if (d1_2 + a_2 <= d2_2) return d1;
- if (d2_2 + a_2 <= d1_2) return d2;
-
- // otherwise calculate the height to the base
- double peri = (a + d1 + d2)/2;
- return (2*sqrt(peri * (peri - a) * (peri - d1) * (peri - d2))/a);
+ // calculate sides of the triangle and their squares
+ double d1 = NR::L2(p - a1);
+ double d1_2 = d1 * d1;
+ double d2 = NR::L2(p - a2);
+ double d2_2 = d2 * d2;
+ double a = NR::L2(a1 - a2);
+ double a_2 = a * a;
+
+ // if one of the angles at the base is > 90, return the corresponding side
+ if (d1_2 + a_2 <= d2_2) return d1;
+ if (d2_2 + a_2 <= d1_2) return d2;
+
+ // otherwise calculate the height to the base
+ double peri = (a + d1 + d2)/2;
+ return (2*sqrt(peri * (peri - a) * (peri - d1) * (peri - d2))/a);
}
static NRArenaItem *
nr_arena_image_pick (NRArenaItem *item, NR::Point p, double delta, unsigned int sticky)
{
- NRArenaImage *image = NR_ARENA_IMAGE (item);
+ NRArenaImage *image = NR_ARENA_IMAGE (item);
- if (!image->px) return NULL;
+ if (!image->px) return NULL;
- bool outline = (item->arena->rendermode == RENDERMODE_OUTLINE);
+ bool outline = (item->arena->rendermode == RENDERMODE_OUTLINE);
- if (outline) {
+ if (outline) {
- // frame
- if (distance_to_segment (p, image->c00, image->c10) < delta) return item;
- if (distance_to_segment (p, image->c10, image->c11) < delta) return item;
- if (distance_to_segment (p, image->c11, image->c01) < delta) return item;
- if (distance_to_segment (p, image->c01, image->c00) < delta) return item;
+ // frame
+ if (distance_to_segment (p, image->c00, image->c10) < delta) return item;
+ if (distance_to_segment (p, image->c10, image->c11) < delta) return item;
+ if (distance_to_segment (p, image->c11, image->c01) < delta) return item;
+ if (distance_to_segment (p, image->c01, image->c00) < delta) return item;
- // diagonals
- if (distance_to_segment (p, image->c00, image->c11) < delta) return item;
- if (distance_to_segment (p, image->c10, image->c01) < delta) return item;
+ // diagonals
+ if (distance_to_segment (p, image->c00, image->c11) < delta) return item;
+ if (distance_to_segment (p, image->c10, image->c01) < delta) return item;
- return NULL;
+ return NULL;
- } else {
+ } else {
- unsigned char *const pixels = image->px;
- int const width = image->pxw;
- int const height = image->pxh;
- int const rowstride = image->pxrs;
- NR::Point tp = p * image->grid2px;
- int const ix = (int)(tp[NR::X]);
- int const iy = (int)(tp[NR::Y]);
+ unsigned char *const pixels = image->px;
+ int const width = image->pxw;
+ int const height = image->pxh;
+ int const rowstride = image->pxrs;
+ NR::Point tp = p * image->grid2px;
+ int const ix = (int)(tp[NR::X]);
+ int const iy = (int)(tp[NR::Y]);
- if ((ix < 0) || (iy < 0) || (ix >= width) || (iy >= height))
- return NULL;
+ if ((ix < 0) || (iy < 0) || (ix >= width) || (iy >= height))
+ return NULL;
- unsigned char *pix_ptr = pixels + iy * rowstride + ix * 4;
- // is the alpha not transparent?
- return (pix_ptr[3] > 0) ? item : NULL;
- }
+ unsigned char *pix_ptr = pixels + iy * rowstride + ix * 4;
+ // is the alpha not transparent?
+ return (pix_ptr[3] > 0) ? item : NULL;
+ }
}
/* Utility */
@@ -334,29 +334,29 @@ nr_arena_image_pick (NRArenaItem *item, NR::Point p, double delta, unsigned int
void
nr_arena_image_set_pixels (NRArenaImage *image, unsigned char const *px, unsigned int pxw, unsigned int pxh, unsigned int pxrs)
{
- nr_return_if_fail (image != NULL);
- nr_return_if_fail (NR_IS_ARENA_IMAGE (image));
+ nr_return_if_fail (image != NULL);
+ nr_return_if_fail (NR_IS_ARENA_IMAGE (image));
- image->px = (unsigned char *) px;
- image->pxw = pxw;
- image->pxh = pxh;
- image->pxrs = pxrs;
+ image->px = (unsigned char *) px;
+ image->pxw = pxw;
+ image->pxh = pxh;
+ image->pxrs = pxrs;
- nr_arena_item_request_update (NR_ARENA_ITEM (image), NR_ARENA_ITEM_STATE_ALL, FALSE);
+ nr_arena_item_request_update (NR_ARENA_ITEM (image), NR_ARENA_ITEM_STATE_ALL, FALSE);
}
void
nr_arena_image_set_geometry (NRArenaImage *image, double x, double y, double width, double height)
{
- nr_return_if_fail (image != NULL);
- nr_return_if_fail (NR_IS_ARENA_IMAGE (image));
+ nr_return_if_fail (image != NULL);
+ nr_return_if_fail (NR_IS_ARENA_IMAGE (image));
- image->x = x;
- image->y = y;
- image->width = width;
- image->height = height;
+ image->x = x;
+ image->y = y;
+ image->width = width;
+ image->height = height;
- nr_arena_item_request_update (NR_ARENA_ITEM (image), NR_ARENA_ITEM_STATE_ALL, FALSE);
+ nr_arena_item_request_update (NR_ARENA_ITEM (image), NR_ARENA_ITEM_STATE_ALL, FALSE);
}
void nr_arena_image_set_style (NRArenaImage *image, SPStyle *style)
}
}
+
/*
Local Variables:
mode:c++
index f9861b2ff596e36d79a6d4d148fa74fb7e90759d..2d7328263b68fd49835caa2905eaf51ff78207a5 100644 (file)
NRType nr_arena_image_get_type (void);
struct NRArenaImage : public NRArenaItem {
- unsigned char *px;
- unsigned int pxw;
- unsigned int pxh;
- unsigned int pxrs;
+ unsigned char *px;
+ unsigned int pxw;
+ unsigned int pxh;
+ unsigned int pxrs;
- double x, y;
- double width, height;
+ double x, y;
+ double width, height;
- NR::Point c00, c01, c11, c10; // all 4 corners of the image, for outline mode rect
+ NR::Point c00, c01, c11, c10; // all 4 corners of the image, for outline mode rect
- /* From GRID to PIXELS */
- NR::Matrix grid2px;
+ /* From GRID to PIXELS */
+ NR::Matrix grid2px;
- SPStyle *style;
+ SPStyle *style;
- static NRArenaImage *create(NRArena *arena) {
- NRArenaImage *obj=reinterpret_cast<NRArenaImage *>(nr_object_new(NR_TYPE_ARENA_IMAGE));
- obj->init(arena);
- return obj;
- }
+ static NRArenaImage *create(NRArena *arena) {
+ NRArenaImage *obj=reinterpret_cast<NRArenaImage *>(nr_object_new(NR_TYPE_ARENA_IMAGE));
+ obj->init(arena);
+ return obj;
+ }
};
struct NRArenaImageClass {
- NRArenaItemClass parent_class;
+ NRArenaItemClass parent_class;
};
void nr_arena_image_set_pixels (NRArenaImage *image, unsigned char const *px, unsigned int pxw, unsigned int pxh, unsigned int pxrs);
void nr_arena_image_set_geometry (NRArenaImage *image, double x, double y, double width, double height);
void nr_arena_image_set_style (NRArenaImage *image, SPStyle *style);
+
#endif
+
+/*
+ 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 :
index 801657cf3403e946a41441ea2d1d07f891cf5b07..6ca1564a171a718e9e78553fa43d86fd43740939 100644 (file)
#include <cairo.h>
struct NRGC {
- NRGC(NRGC const *p) : parent(p) {}
- NRGC const *parent;
- NRMatrix transform;
+ NRGC(NRGC const *p) : parent(p) {}
+ NRGC const *parent;
+ NRMatrix transform;
};
struct NRArenaItem : public NRObject {
- NRArena *arena;
- Inkscape::GC::soft_ptr<NRArenaItem> parent;
- NRArenaItem *next;
- Inkscape::GC::soft_ptr<NRArenaItem> prev;
-
- /* Item state */
- unsigned int state : 16;
- unsigned int propagate : 1;
- unsigned int sensitive : 1;
- unsigned int visible : 1;
- /* Whether items renders opacity itself */
- unsigned int render_opacity : 1;
- /* Opacity itself */
- unsigned int opacity : 8;
-
- /* Key for secondary rendering */
- unsigned int key;
-
- /* BBox in grid coordinates */
- NRRectL bbox;
- /* BBox in item coordinates - this should be a bounding box as
- * specified in SVG standard. Required by filters. */
- NR::Maybe<NR::Rect> item_bbox;
- /* Our affine */
- NRMatrix *transform;
- /* Clip item */
- NRArenaItem *clip;
- /* Mask item */
- NRArenaItem *mask;
- /* Filter to be applied after rendering this object, NULL if none */
- NR::Filter *filter;
- /* Rendered buffer */
- unsigned char *px;
-
- /* Single data member */
- void *data;
-
- /* Current Transformation Matrix */
- NR::Matrix ctm;
-
- /* These hold background buffer state for filter rendering */
- NRPixBlock *background_pb;
- bool background_new;
-
- void init(NRArena *arena) {
- this->arena = arena;
- }
+ NRArena *arena;
+ Inkscape::GC::soft_ptr<NRArenaItem> parent;
+ NRArenaItem *next;
+ Inkscape::GC::soft_ptr<NRArenaItem> prev;
+
+ /* Item state */
+ unsigned int state : 16;
+ unsigned int propagate : 1;
+ unsigned int sensitive : 1;
+ unsigned int visible : 1;
+ /* Whether items renders opacity itself */
+ unsigned int render_opacity : 1;
+ /* Opacity itself */
+ unsigned int opacity : 8;
+
+ /* Key for secondary rendering */
+ unsigned int key;
+
+ /* BBox in grid coordinates */
+ NRRectL bbox;
+ /* BBox in item coordinates - this should be a bounding box as
+ * specified in SVG standard. Required by filters. */
+ NR::Maybe<NR::Rect> item_bbox;
+ /* Our affine */
+ NRMatrix *transform;
+ /* Clip item */
+ NRArenaItem *clip;
+ /* Mask item */
+ NRArenaItem *mask;
+ /* Filter to be applied after rendering this object, NULL if none */
+ NR::Filter *filter;
+ /* Rendered buffer */
+ unsigned char *px;
+
+ /* Single data member */
+ void *data;
+
+ /* Current Transformation Matrix */
+ NR::Matrix ctm;
+
+ /* These hold background buffer state for filter rendering */
+ NRPixBlock *background_pb;
+ bool background_new;
+
+ void init(NRArena *arena) {
+ this->arena = arena;
+ }
};
struct NRArenaItemClass : public NRObjectClass {
- NRArenaItem * (* children) (NRArenaItem *item);
- NRArenaItem * (* last_child) (NRArenaItem *item);
- void (* add_child) (NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref);
- void (* remove_child) (NRArenaItem *item, NRArenaItem *child);
- void (* set_child_position) (NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref);
-
- unsigned int (* update) (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int state, unsigned int reset);
- unsigned int (* render) (cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags);
- unsigned int (* clip) (NRArenaItem *item, NRRectL *area, NRPixBlock *pb);
- NRArenaItem * (* pick) (NRArenaItem *item, NR::Point p, double delta, unsigned int sticky);
+ NRArenaItem * (* children) (NRArenaItem *item);
+ NRArenaItem * (* last_child) (NRArenaItem *item);
+ void (* add_child) (NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref);
+ void (* remove_child) (NRArenaItem *item, NRArenaItem *child);
+ void (* set_child_position) (NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref);
+
+ unsigned int (* update) (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int state, unsigned int reset);
+ unsigned int (* render) (cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags);
+ unsigned int (* clip) (NRArenaItem *item, NRRectL *area, NRPixBlock *pb);
+ NRArenaItem * (* pick) (NRArenaItem *item, NR::Point p, double delta, unsigned int sticky);
};
#define NR_ARENA_ITEM_ARENA(ai) (((NRArenaItem *) (ai))->arena)
#define NR_ARENA_ITEM_SET_KEY(i,k) (((NRArenaItem *) (i))->key = (k))
#define NR_ARENA_ITEM_GET_KEY(i) (((NRArenaItem *) (i))->key)
-#endif
+
+#endif /* !__NR_ARENA_ITEM_H__ */
+
+/*
+ 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 :
index c3ff59b3975dd13b6b6cde52b071fade5279b5f7..d36815a74a00acab6c5f380cd0cfce4d247791a3 100644 (file)
NRType nr_arena_shape_get_type (void);
struct NRArenaShape : public NRArenaItem {
- class Paint {
- public:
- enum Type {
- NONE,
- COLOR,
- SERVER
- };
-
- Paint() : _type(NONE), _color(0), _server(NULL) {}
- Paint(Paint const &p) { _assign(p); }
- ~Paint() { clear(); }
-
- Type type() const { return _type; }
- SPPaintServer *server() const { return _server; }
- SPColor const &color() const { return _color; }
-
- Paint &operator=(Paint const &p) {
- set(p);
- return *this;
- }
-
- void set(Paint const &p) {
- clear();
- _assign(p);
- }
- void set(SPColor const &color) {
- clear();
- _type = COLOR;
- _color = color;
- }
- void set(SPPaintServer *server) {
- clear();
- if (server) {
- _type = SERVER;
- _server = server;
- sp_object_ref(_server, NULL);
- }
- }
- void clear() {
- if ( _type == SERVER ) {
- sp_object_unref(_server, NULL);
- _server = NULL;
- }
- _type = NONE;
- }
-
- private:
- Type _type;
- SPColor _color;
- SPPaintServer *_server;
-
- void _assign(Paint const &p) {
- _type = p._type;
- _server = p._server;
- _color = p._color;
- if (_server) {
- sp_object_ref(_server, NULL);
- }
- }
- };
-
- enum FillRule {
- EVEN_ODD,
- NONZERO
- };
-
- enum CapType {
- ROUND_CAP,
- SQUARE_CAP,
- BUTT_CAP
- };
-
- enum JoinType {
- ROUND_JOIN,
- BEVEL_JOIN,
- MITRE_JOIN
- };
-
- /* Shape data */
- SPCurve *curve;
- SPStyle *style;
- NRRect paintbox;
- /* State data */
- NR::Matrix ctm;
-
- SPPainter *fill_painter;
- SPPainter *stroke_painter;
- // the 2 cached polygons, for rasterizations uses
- Shape *fill_shp;
- Shape *stroke_shp;
- // the stroke width of stroke_shp, to detect when it changes (on normal/outline switching) and rebuild
- float cached_width;
- // delayed_shp=true means the *_shp polygons are not computed yet
- // they'll be computed on demand in *_render(), *_pick() or *_clip()
- // the goal is to not uncross polygons that are outside the viewing region
- bool delayed_shp;
- // approximate bounding box, for the case when the polygons have been delayed
- NRRectL approx_bbox;
- // cache for transformations: cached_fill and cached_stroke are
- // polygons computed for the cached_fctm and cache_sctm respectively
- // when the transformation changes interactively (tracked by the
- // SP_OBJECT_USER_MODIFIED_FLAG_B), we check if it's an isometry wrt
- // the cached ctm. if it's an isometry, just apply it to the cached
- // polygon to get the *_shp polygon. Otherwise, recompute so this
- // works fine for translation and rotation, but not scaling and
- // skewing
- NR::Matrix cached_fctm;
- NR::Matrix cached_sctm;
- NRRectL cached_farea;
- NRRectL cached_sarea;
- bool cached_fpartialy;
- bool cached_spartialy;
-
- Shape *cached_fill;
- Shape *cached_stroke;
- /* Markers */
- NRArenaItem *markers;
-
- NRArenaItem *last_pick;
- guint repick_after;
-
- static NRArenaShape *create(NRArena *arena) {
- NRArenaShape *obj=reinterpret_cast<NRArenaShape *>(nr_object_new(NR_TYPE_ARENA_SHAPE));
- obj->init(arena);
- return obj;
- }
-
- void setFill(SPPaintServer *server);
- void setFill(SPColor const &color);
- void setFillOpacity(double opacity);
- void setFillRule(FillRule rule);
-
- void setStroke(SPPaintServer *server);
- void setStroke(SPColor const &color);
- void setStrokeOpacity(double opacity);
- void setStrokeWidth(double width);
- void setLineCap(CapType cap);
- void setLineJoin(JoinType join);
- void setMitreLimit(double limit);
-
- void setPaintBox(NR::Rect const &pbox);
-
- void _invalidateCachedFill() {
- if (cached_fill) {
- delete cached_fill;
- cached_fill = NULL;
- }
- }
- void _invalidateCachedStroke() {
- if (cached_stroke) {
- delete cached_stroke;
- cached_stroke = NULL;
- }
- }
-
- struct Style {
- Style() : opacity(0.0) {}
- Paint paint;
- double opacity;
- };
- struct FillStyle : public Style {
- FillStyle() : rule(EVEN_ODD) {}
- FillRule rule;
- } _fill;
- struct StrokeStyle : public Style {
- StrokeStyle()
- : cap(ROUND_CAP), join(ROUND_JOIN),
- width(0.0), mitre_limit(0.0)
- {}
-
- CapType cap;
- JoinType join;
- double width;
- double mitre_limit;
- } _stroke;
+ class Paint {
+ public:
+ enum Type {
+ NONE,
+ COLOR,
+ SERVER
+ };
+
+ Paint() : _type(NONE), _color(0), _server(NULL) {}
+ Paint(Paint const &p) { _assign(p); }
+ ~Paint() { clear(); }
+
+ Type type() const { return _type; }
+ SPPaintServer *server() const { return _server; }
+ SPColor const &color() const { return _color; }
+
+ Paint &operator=(Paint const &p) {
+ set(p);
+ return *this;
+ }
+
+ void set(Paint const &p) {
+ clear();
+ _assign(p);
+ }
+ void set(SPColor const &color) {
+ clear();
+ _type = COLOR;
+ _color = color;
+ }
+ void set(SPPaintServer *server) {
+ clear();
+ if (server) {
+ _type = SERVER;
+ _server = server;
+ sp_object_ref(_server, NULL);
+ }
+ }
+ void clear() {
+ if ( _type == SERVER ) {
+ sp_object_unref(_server, NULL);
+ _server = NULL;
+ }
+ _type = NONE;
+ }
+
+ private:
+ Type _type;
+ SPColor _color;
+ SPPaintServer *_server;
+
+ void _assign(Paint const &p) {
+ _type = p._type;
+ _server = p._server;
+ _color = p._color;
+ if (_server) {
+ sp_object_ref(_server, NULL);
+ }
+ }
+ };
+
+ enum FillRule {
+ EVEN_ODD,
+ NONZERO
+ };
+
+ enum CapType {
+ ROUND_CAP,
+ SQUARE_CAP,
+ BUTT_CAP
+ };
+
+ enum JoinType {
+ ROUND_JOIN,
+ BEVEL_JOIN,
+ MITRE_JOIN
+ };
+
+ /* Shape data */
+ SPCurve *curve;
+ SPStyle *style;
+ NRRect paintbox;
+ /* State data */
+ NR::Matrix ctm;
+
+ SPPainter *fill_painter;
+ SPPainter *stroke_painter;
+ // the 2 cached polygons, for rasterizations uses
+ Shape *fill_shp;
+ Shape *stroke_shp;
+ // the stroke width of stroke_shp, to detect when it changes (on normal/outline switching) and rebuild
+ float cached_width;
+ // delayed_shp=true means the *_shp polygons are not computed yet
+ // they'll be computed on demand in *_render(), *_pick() or *_clip()
+ // the goal is to not uncross polygons that are outside the viewing region
+ bool delayed_shp;
+ // approximate bounding box, for the case when the polygons have been delayed
+ NRRectL approx_bbox;
+ // cache for transformations: cached_fill and cached_stroke are
+ // polygons computed for the cached_fctm and cache_sctm respectively
+ // when the transformation changes interactively (tracked by the
+ // SP_OBJECT_USER_MODIFIED_FLAG_B), we check if it's an isometry wrt
+ // the cached ctm. if it's an isometry, just apply it to the cached
+ // polygon to get the *_shp polygon. Otherwise, recompute so this
+ // works fine for translation and rotation, but not scaling and
+ // skewing
+ NR::Matrix cached_fctm;
+ NR::Matrix cached_sctm;
+ NRRectL cached_farea;
+ NRRectL cached_sarea;
+ bool cached_fpartialy;
+ bool cached_spartialy;
+
+ Shape *cached_fill;
+ Shape *cached_stroke;
+ /* Markers */
+ NRArenaItem *markers;
+
+ NRArenaItem *last_pick;
+ guint repick_after;
+
+ static NRArenaShape *create(NRArena *arena) {
+ NRArenaShape *obj=reinterpret_cast<NRArenaShape *>(nr_object_new(NR_TYPE_ARENA_SHAPE));
+ obj->init(arena);
+ return obj;
+ }
+
+ void setFill(SPPaintServer *server);
+ void setFill(SPColor const &color);
+ void setFillOpacity(double opacity);
+ void setFillRule(FillRule rule);
+
+ void setStroke(SPPaintServer *server);
+ void setStroke(SPColor const &color);
+ void setStrokeOpacity(double opacity);
+ void setStrokeWidth(double width);
+ void setLineCap(CapType cap);
+ void setLineJoin(JoinType join);
+ void setMitreLimit(double limit);
+
+ void setPaintBox(NR::Rect const &pbox);
+
+ void _invalidateCachedFill() {
+ if (cached_fill) {
+ delete cached_fill;
+ cached_fill = NULL;
+ }
+ }
+ void _invalidateCachedStroke() {
+ if (cached_stroke) {
+ delete cached_stroke;
+ cached_stroke = NULL;
+ }
+ }
+
+ struct Style {
+ Style() : opacity(0.0) {}
+ Paint paint;
+ double opacity;
+ };
+ struct FillStyle : public Style {
+ FillStyle() : rule(EVEN_ODD) {}
+ FillRule rule;
+ } _fill;
+ struct StrokeStyle : public Style {
+ StrokeStyle()
+ : cap(ROUND_CAP), join(ROUND_JOIN),
+ width(0.0), mitre_limit(0.0)
+ {}
+
+ CapType cap;
+ JoinType join;
+ double width;
+ double mitre_limit;
+ } _stroke;
};
struct NRArenaShapeClass {
- NRArenaItemClass parent_class;
+ NRArenaItemClass parent_class;
};
void nr_arena_shape_set_path(NRArenaShape *shape, SPCurve *curve, bool justTrans);
void nr_arena_shape_set_style(NRArenaShape *shape, SPStyle *style);
void nr_arena_shape_set_paintbox(NRArenaShape *shape, NRRect const *pbox);
-#endif
+
+#endif /* !__NR_ARENA_SHAPE_H__ */
+
+/*
+ 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 :
index 7c0664d16a6b394164e2ec3cc1016ab977aa563b..f125cd0f89c7340975768690f9377727b88dae39 100644 (file)
--- a/src/display/nr-arena.cpp
+++ b/src/display/nr-arena.cpp
NRType
nr_arena_get_type (void)
{
- static NRType type = 0;
- if (!type) {
- type = nr_object_register_type (NR_TYPE_ACTIVE_OBJECT,
- "NRArena",
- sizeof (NRArenaClass),
- sizeof (NRArena),
- (void (*) (NRObjectClass *)) nr_arena_class_init,
- (void (*) (NRObject *)) nr_arena_init);
- }
- return type;
+ static NRType type = 0;
+ if (!type) {
+ type = nr_object_register_type (NR_TYPE_ACTIVE_OBJECT,
+ "NRArena",
+ sizeof (NRArenaClass),
+ sizeof (NRArena),
+ (void (*) (NRObjectClass *)) nr_arena_class_init,
+ (void (*) (NRObject *)) nr_arena_init);
+ }
+ return type;
}
static void
nr_arena_class_init (NRArenaClass *klass)
{
- NRObjectClass *object_class = (NRObjectClass *) klass;
+ NRObjectClass *object_class = (NRObjectClass *) klass;
- parent_class = (NRActiveObjectClass *) (((NRObjectClass *) klass)->parent);
+ parent_class = (NRActiveObjectClass *) (((NRObjectClass *) klass)->parent);
- object_class->finalize = nr_arena_finalize;
- object_class->cpp_ctor = NRObject::invoke_ctor<NRArena>;
+ object_class->finalize = nr_arena_finalize;
+ object_class->cpp_ctor = NRObject::invoke_ctor<NRArena>;
}
static void
nr_arena_init (NRArena *arena)
{
- arena->delta = 0; // to be set by desktop from prefs
- arena->rendermode = RENDERMODE_NORMAL; // default is normal render
- arena->outlinecolor = 0xff; // black; to be set by desktop from bg color
- arena->canvasarena = NULL;
+ arena->delta = 0; // to be set by desktop from prefs
+ arena->rendermode = RENDERMODE_NORMAL; // default is normal render
+ arena->outlinecolor = 0xff; // black; to be set by desktop from bg color
+ arena->canvasarena = NULL;
}
static void
nr_arena_finalize (NRObject *object)
{
- ((NRObjectClass *) (parent_class))->finalize (object);
+ ((NRObjectClass *) (parent_class))->finalize (object);
}
void
nr_arena_request_update (NRArena *arena, NRArenaItem *item)
{
- NRActiveObject *aobject = (NRActiveObject *) arena;
-
- nr_return_if_fail (arena != NULL);
- nr_return_if_fail (NR_IS_ARENA (arena));
- nr_return_if_fail (item != NULL);
- nr_return_if_fail (NR_IS_ARENA_ITEM (item));
-
- if (aobject->callbacks) {
- for (unsigned int i = 0; i < aobject->callbacks->length; i++) {
- NRObjectListener *listener = aobject->callbacks->listeners + i;
- NRArenaEventVector *avector = (NRArenaEventVector *) listener->vector;
- if ((listener->size >= sizeof (NRArenaEventVector)) && avector->request_update) {
- avector->request_update (arena, item, listener->data);
- }
- }
- }
+ NRActiveObject *aobject = (NRActiveObject *) arena;
+
+ nr_return_if_fail (arena != NULL);
+ nr_return_if_fail (NR_IS_ARENA (arena));
+ nr_return_if_fail (item != NULL);
+ nr_return_if_fail (NR_IS_ARENA_ITEM (item));
+
+ if (aobject->callbacks) {
+ for (unsigned int i = 0; i < aobject->callbacks->length; i++) {
+ NRObjectListener *listener = aobject->callbacks->listeners + i;
+ NRArenaEventVector *avector = (NRArenaEventVector *) listener->vector;
+ if ((listener->size >= sizeof (NRArenaEventVector)) && avector->request_update) {
+ avector->request_update (arena, item, listener->data);
+ }
+ }
+ }
}
void
nr_arena_request_render_rect (NRArena *arena, NRRectL *area)
{
- NRActiveObject *aobject = (NRActiveObject *) arena;
-
- nr_return_if_fail (arena != NULL);
- nr_return_if_fail (NR_IS_ARENA (arena));
- nr_return_if_fail (area != NULL);
-
- if (aobject->callbacks && area && !nr_rect_l_test_empty (area)) {
- for (unsigned int i = 0; i < aobject->callbacks->length; i++) {
- NRObjectListener *listener = aobject->callbacks->listeners + i;
- NRArenaEventVector *avector = (NRArenaEventVector *) listener->vector;
- if ((listener->size >= sizeof (NRArenaEventVector)) && avector->request_render) {
- avector->request_render (arena, area, listener->data);
- }
- }
- }
+ NRActiveObject *aobject = (NRActiveObject *) arena;
+
+ nr_return_if_fail (arena != NULL);
+ nr_return_if_fail (NR_IS_ARENA (arena));
+ nr_return_if_fail (area != NULL);
+
+ if (aobject->callbacks && area && !nr_rect_l_test_empty (area)) {
+ for (unsigned int i = 0; i < aobject->callbacks->length; i++) {
+ NRObjectListener *listener = aobject->callbacks->listeners + i;
+ NRArenaEventVector *avector = (NRArenaEventVector *) listener->vector;
+ if ((listener->size >= sizeof (NRArenaEventVector)) && avector->request_render) {
+ avector->request_render (arena, area, listener->data);
+ }
+ }
+ }
}
-void
+void
nr_arena_render_paintserver_fill (NRPixBlock *pb, NRRectL *area, SPPainter *painter, float opacity, NRPixBlock *mask)
{
- NRPixBlock cb, cb_opa;
- nr_pixblock_setup_fast (&cb, NR_PIXBLOCK_MODE_R8G8B8A8N, area->x0, area->y0, area->x1, area->y1, TRUE);
- nr_pixblock_setup_fast (&cb_opa, NR_PIXBLOCK_MODE_R8G8B8A8N, area->x0, area->y0, area->x1, area->y1, TRUE);
-
- // if memory allocation failed, abort
- if ((cb.size != NR_PIXBLOCK_SIZE_TINY && cb.data.px == NULL) || (cb_opa.size != NR_PIXBLOCK_SIZE_TINY && cb_opa.data.px == NULL)) {
- return;
- }
-
- cb.visible_area = pb->visible_area;
- cb_opa.visible_area = pb->visible_area;
-
- /* Need separate gradient buffer (lauris)*/
- // do the filling
- painter->fill (painter, &cb);
- cb.empty = FALSE;
-
- // do the fill-opacity and mask composite
- if (opacity < 1.0) {
- nr_blit_pixblock_pixblock_alpha (&cb_opa, &cb, (int) floor (255 * opacity));
- cb_opa.empty = FALSE;
- nr_blit_pixblock_pixblock_mask (pb, &cb_opa, mask);
- } else {
- nr_blit_pixblock_pixblock_mask (pb, &cb, mask);
- }
+ NRPixBlock cb, cb_opa;
+ nr_pixblock_setup_fast (&cb, NR_PIXBLOCK_MODE_R8G8B8A8N, area->x0, area->y0, area->x1, area->y1, TRUE);
+ nr_pixblock_setup_fast (&cb_opa, NR_PIXBLOCK_MODE_R8G8B8A8N, area->x0, area->y0, area->x1, area->y1, TRUE);
+
+ // if memory allocation failed, abort
+ if ((cb.size != NR_PIXBLOCK_SIZE_TINY && cb.data.px == NULL) || (cb_opa.size != NR_PIXBLOCK_SIZE_TINY && cb_opa.data.px == NULL)) {
+ return;
+ }
+
+ cb.visible_area = pb->visible_area;
+ cb_opa.visible_area = pb->visible_area;
+
+ /* Need separate gradient buffer (lauris)*/
+ // do the filling
+ painter->fill (painter, &cb);
+ cb.empty = FALSE;
+
+ // do the fill-opacity and mask composite
+ if (opacity < 1.0) {
+ nr_blit_pixblock_pixblock_alpha (&cb_opa, &cb, (int) floor (255 * opacity));
+ cb_opa.empty = FALSE;
+ nr_blit_pixblock_pixblock_mask (pb, &cb_opa, mask);
+ } else {
+ nr_blit_pixblock_pixblock_mask (pb, &cb, mask);
+ }
+
+ pb->empty = FALSE;
+
+ nr_pixblock_release (&cb);
+ nr_pixblock_release (&cb_opa);
+}
- pb->empty = FALSE;
- nr_pixblock_release (&cb);
- nr_pixblock_release (&cb_opa);
-}
+/*
+ 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 :
index 5d79b1c3eba120ad608a851098776d20a7bd953e..fb94a654b68695a05afa2c073e609dc8bb031c02 100644 (file)
// Using the backwards-pass initialization procedure from:
// Boundary Conditions for Young - van Vliet Recursive Filtering
// Bill Triggs, Michael Sdika
-// IEEE Transactions on Signal Processing, Volume 54, Number 5 - may 2006
+// IEEE Transactions on Signal Processing, Volume 54, Number 5 - may 2006
// Number of IIR filter coefficients used. Currently only 3 is supported.
// "Recursive Gaussian Derivative Filters" says this is enough though (and
}
// Type used for IIR filter coefficients (can be 10.21 signed fixed point, see Anisotropic Gaussian Filtering Using Fixed Point Arithmetic, Christoph H. Lampert & Oliver Wirjadi, 2006)
-typedef double IIRValue;
+typedef double IIRValue;
// Type used for FIR filter coefficients (can be 16.16 unsigned fixed point, should have 8 or more bits in the fractional part, the integer part should be capable of storing approximately 20*255)
typedef Inkscape::Util::FixedPoint<unsigned int,16> FIRValue;
template<typename Tt, typename Ts>
static inline Tt round_cast(Ts const& v) {
- static Ts const rndoffset(.5);
- return static_cast<Tt>(v+rndoffset);
+ static Ts const rndoffset(.5);
+ return static_cast<Tt>(v+rndoffset);
}
template<typename Tt, typename Ts>
static inline Tt clip_round_cast(Ts const& v, Tt const minval=std::numeric_limits<Tt>::min(), Tt const maxval=std::numeric_limits<Tt>::max()) {
if ( v < minval ) return minval;
if ( v > maxval ) return maxval;
- return round_cast<Tt>(v);
+ return round_cast<Tt>(v);
}
namespace NR {
// store the result in bufx
dst[dst_disp + byte] = round_cast<PT>(sum);
- // optimization: if there was no variation within this point's neighborhood,
- // skip ahead while we keep seeing the same last_in byte:
+ // optimization: if there was no variation within this point's neighborhood,
+ // skip ahead while we keep seeing the same last_in byte:
// blurring flat color would not change it anyway
if (different_count <= 1) {
int pos = c1 + 1;
index fd655edb054eb681ccb95c19cdc10d7a0de42df7..0172cc8bb3899a963c1221e43e478550aff4d320 100644 (file)
#include "sodipodi-ctrl.h"
enum {
- ARG_0,
- ARG_SHAPE,
- ARG_MODE,
- ARG_ANCHOR,
- ARG_SIZE,
- ARG_FILLED,
- ARG_FILL_COLOR,
- ARG_STROKED,
- ARG_STROKE_COLOR,
- ARG_PIXBUF
+ ARG_0,
+ ARG_SHAPE,
+ ARG_MODE,
+ ARG_ANCHOR,
+ ARG_SIZE,
+ ARG_FILLED,
+ ARG_FILL_COLOR,
+ ARG_STROKED,
+ ARG_STROKE_COLOR,
+ ARG_PIXBUF
};
GtkType
sp_ctrl_get_type (void)
{
- static GtkType ctrl_type = 0;
- if (!ctrl_type) {
- static GTypeInfo const ctrl_info = {
- sizeof (SPCtrlClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) sp_ctrl_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (SPCtrl),
- 0, /* n_preallocs */
- (GInstanceInitFunc) sp_ctrl_init,
- NULL
- };
- ctrl_type = g_type_register_static (SP_TYPE_CANVAS_ITEM, "SPCtrl", &ctrl_info, (GTypeFlags)0);
- }
- return ctrl_type;
+ static GtkType ctrl_type = 0;
+ if (!ctrl_type) {
+ static GTypeInfo const ctrl_info = {
+ sizeof (SPCtrlClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) sp_ctrl_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (SPCtrl),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) sp_ctrl_init,
+ NULL
+ };
+ ctrl_type = g_type_register_static (SP_TYPE_CANVAS_ITEM, "SPCtrl", &ctrl_info, (GTypeFlags)0);
+ }
+ return ctrl_type;
}
static void
sp_ctrl_class_init (SPCtrlClass *klass)
{
- GtkObjectClass *object_class;
- SPCanvasItemClass *item_class;
-
- object_class = (GtkObjectClass *) klass;
- item_class = (SPCanvasItemClass *) klass;
-
- parent_class = (SPCanvasItemClass *)gtk_type_class (sp_canvas_item_get_type ());
-
- gtk_object_add_arg_type ("SPCtrl::shape", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_SHAPE);
- gtk_object_add_arg_type ("SPCtrl::mode", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_MODE);
- gtk_object_add_arg_type ("SPCtrl::anchor", GTK_TYPE_ANCHOR_TYPE, GTK_ARG_READWRITE, ARG_ANCHOR);
- gtk_object_add_arg_type ("SPCtrl::size", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_SIZE);
- gtk_object_add_arg_type ("SPCtrl::pixbuf", GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_PIXBUF);
- gtk_object_add_arg_type ("SPCtrl::filled", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_FILLED);
- gtk_object_add_arg_type ("SPCtrl::fill_color", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_FILL_COLOR);
- gtk_object_add_arg_type ("SPCtrl::stroked", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_STROKED);
- gtk_object_add_arg_type ("SPCtrl::stroke_color", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_STROKE_COLOR);
-
- object_class->destroy = sp_ctrl_destroy;
- object_class->set_arg = sp_ctrl_set_arg;
-
- item_class->update = sp_ctrl_update;
- item_class->render = sp_ctrl_render;
- item_class->point = sp_ctrl_point;
+ GtkObjectClass *object_class;
+ SPCanvasItemClass *item_class;
+
+ object_class = (GtkObjectClass *) klass;
+ item_class = (SPCanvasItemClass *) klass;
+
+ parent_class = (SPCanvasItemClass *)gtk_type_class (sp_canvas_item_get_type ());
+
+ gtk_object_add_arg_type ("SPCtrl::shape", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_SHAPE);
+ gtk_object_add_arg_type ("SPCtrl::mode", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_MODE);
+ gtk_object_add_arg_type ("SPCtrl::anchor", GTK_TYPE_ANCHOR_TYPE, GTK_ARG_READWRITE, ARG_ANCHOR);
+ gtk_object_add_arg_type ("SPCtrl::size", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_SIZE);
+ gtk_object_add_arg_type ("SPCtrl::pixbuf", GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_PIXBUF);
+ gtk_object_add_arg_type ("SPCtrl::filled", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_FILLED);
+ gtk_object_add_arg_type ("SPCtrl::fill_color", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_FILL_COLOR);
+ gtk_object_add_arg_type ("SPCtrl::stroked", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_STROKED);
+ gtk_object_add_arg_type ("SPCtrl::stroke_color", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_STROKE_COLOR);
+
+ object_class->destroy = sp_ctrl_destroy;
+ object_class->set_arg = sp_ctrl_set_arg;
+
+ item_class->update = sp_ctrl_update;
+ item_class->render = sp_ctrl_render;
+ item_class->point = sp_ctrl_point;
}
static void
sp_ctrl_init (SPCtrl *ctrl)
{
- ctrl->shape = SP_CTRL_SHAPE_SQUARE;
- ctrl->mode = SP_CTRL_MODE_COLOR;
- ctrl->anchor = GTK_ANCHOR_CENTER;
- ctrl->span = 3;
- ctrl->defined = TRUE;
- ctrl->shown = FALSE;
- ctrl->build = FALSE;
- ctrl->filled = 1;
- ctrl->stroked = 0;
- ctrl->fill_color = 0x000000ff;
- ctrl->stroke_color = 0x000000ff;
- ctrl->_moved = false;
-
- ctrl->box.x0 = ctrl->box.y0 = ctrl->box.x1 = ctrl->box.y1 = 0;
- ctrl->cache = NULL;
- ctrl->pixbuf = NULL;
+ ctrl->shape = SP_CTRL_SHAPE_SQUARE;
+ ctrl->mode = SP_CTRL_MODE_COLOR;
+ ctrl->anchor = GTK_ANCHOR_CENTER;
+ ctrl->span = 3;
+ ctrl->defined = TRUE;
+ ctrl->shown = FALSE;
+ ctrl->build = FALSE;
+ ctrl->filled = 1;
+ ctrl->stroked = 0;
+ ctrl->fill_color = 0x000000ff;
+ ctrl->stroke_color = 0x000000ff;
+ ctrl->_moved = false;
+
+ ctrl->box.x0 = ctrl->box.y0 = ctrl->box.x1 = ctrl->box.y1 = 0;
+ ctrl->cache = NULL;
+ ctrl->pixbuf = NULL;
}
static void
sp_ctrl_destroy (GtkObject *object)
{
- SPCtrl *ctrl;
+ SPCtrl *ctrl;
- g_return_if_fail (object != NULL);
- g_return_if_fail (SP_IS_CTRL (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (SP_IS_CTRL (object));
- ctrl = SP_CTRL (object);
+ ctrl = SP_CTRL (object);
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+ if (GTK_OBJECT_CLASS (parent_class)->destroy)
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
sp_ctrl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
{
- SPCanvasItem *item;
- SPCtrl *ctrl;
- GdkPixbuf * pixbuf = NULL;
-
- item = SP_CANVAS_ITEM (object);
- ctrl = SP_CTRL (object);
-
- switch (arg_id) {
- case ARG_SHAPE:
- ctrl->shape = (SPCtrlShapeType)(GTK_VALUE_INT (*arg));
- ctrl->build = FALSE;
- sp_canvas_item_request_update (item);
- break;
- case ARG_MODE:
- ctrl->mode = (SPCtrlModeType)(GTK_VALUE_INT (*arg));
- ctrl->build = FALSE;
- sp_canvas_item_request_update (item);
- break;
- case ARG_ANCHOR:
- ctrl->anchor = (GtkAnchorType)(GTK_VALUE_INT (*arg));
- ctrl->build = FALSE;
- sp_canvas_item_request_update (item);
- break;
- case ARG_SIZE:
- ctrl->span = (gint) ((GTK_VALUE_DOUBLE (*arg) - 1.0) / 2.0 + 0.5);
- ctrl->defined = (ctrl->span > 0);
- ctrl->build = FALSE;
- sp_canvas_item_request_update (item);
- break;
- case ARG_FILLED:
- ctrl->filled = GTK_VALUE_BOOL (*arg);
- ctrl->build = FALSE;
- sp_canvas_item_request_update (item);
- break;
- case ARG_FILL_COLOR:
- ctrl->fill_color = GTK_VALUE_INT (*arg);
- ctrl->build = FALSE;
- sp_canvas_item_request_update (item);
- break;
- case ARG_STROKED:
- ctrl->stroked = GTK_VALUE_BOOL (*arg);
- ctrl->build = FALSE;
- sp_canvas_item_request_update (item);
- break;
- case ARG_STROKE_COLOR:
- ctrl->stroke_color = GTK_VALUE_INT (*arg);
- ctrl->build = FALSE;
- sp_canvas_item_request_update (item);
- break;
- case ARG_PIXBUF:
- pixbuf = (GdkPixbuf*)(GTK_VALUE_POINTER (*arg));
- if (gdk_pixbuf_get_has_alpha (pixbuf)) {
- ctrl->pixbuf = pixbuf;
- } else {
- ctrl->pixbuf = gdk_pixbuf_add_alpha (pixbuf, FALSE, 0, 0, 0);
- gdk_pixbuf_unref (pixbuf);
- }
- ctrl->build = FALSE;
- break;
- default:
- break;
- }
+ SPCanvasItem *item;
+ SPCtrl *ctrl;
+ GdkPixbuf * pixbuf = NULL;
+
+ item = SP_CANVAS_ITEM (object);
+ ctrl = SP_CTRL (object);
+
+ switch (arg_id) {
+ case ARG_SHAPE:
+ ctrl->shape = (SPCtrlShapeType)(GTK_VALUE_INT (*arg));
+ ctrl->build = FALSE;
+ sp_canvas_item_request_update (item);
+ break;
+
+ case ARG_MODE:
+ ctrl->mode = (SPCtrlModeType)(GTK_VALUE_INT (*arg));
+ ctrl->build = FALSE;
+ sp_canvas_item_request_update (item);
+ break;
+
+ case ARG_ANCHOR:
+ ctrl->anchor = (GtkAnchorType)(GTK_VALUE_INT (*arg));
+ ctrl->build = FALSE;
+ sp_canvas_item_request_update (item);
+ break;
+
+ case ARG_SIZE:
+ ctrl->span = (gint) ((GTK_VALUE_DOUBLE (*arg) - 1.0) / 2.0 + 0.5);
+ ctrl->defined = (ctrl->span > 0);
+ ctrl->build = FALSE;
+ sp_canvas_item_request_update (item);
+ break;
+
+ case ARG_FILLED:
+ ctrl->filled = GTK_VALUE_BOOL (*arg);
+ ctrl->build = FALSE;
+ sp_canvas_item_request_update (item);
+ break;
+
+ case ARG_FILL_COLOR:
+ ctrl->fill_color = GTK_VALUE_INT (*arg);
+ ctrl->build = FALSE;
+ sp_canvas_item_request_update (item);
+ break;
+
+ case ARG_STROKED:
+ ctrl->stroked = GTK_VALUE_BOOL (*arg);
+ ctrl->build = FALSE;
+ sp_canvas_item_request_update (item);
+ break;
+
+ case ARG_STROKE_COLOR:
+ ctrl->stroke_color = GTK_VALUE_INT (*arg);
+ ctrl->build = FALSE;
+ sp_canvas_item_request_update (item);
+ break;
+
+ case ARG_PIXBUF:
+ pixbuf = (GdkPixbuf*)(GTK_VALUE_POINTER (*arg));
+ if (gdk_pixbuf_get_has_alpha (pixbuf)) {
+ ctrl->pixbuf = pixbuf;
+ } else {
+ ctrl->pixbuf = gdk_pixbuf_add_alpha (pixbuf, FALSE, 0, 0, 0);
+ gdk_pixbuf_unref (pixbuf);
+ }
+ ctrl->build = FALSE;
+ break;
+
+ default:
+ break;
+ }
}
static void
sp_ctrl_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags)
{
- SPCtrl *ctrl;
- gint x, y;
-
- ctrl = SP_CTRL (item);
-
- if (((SPCanvasItemClass *) parent_class)->update)
- (* ((SPCanvasItemClass *) parent_class)->update) (item, affine, flags);
-
- sp_canvas_item_reset_bounds (item);
-
- if (!ctrl->_moved) return;
-
- if (ctrl->shown) {
- sp_canvas_request_redraw (item->canvas, ctrl->box.x0, ctrl->box.y0, ctrl->box.x1 + 1, ctrl->box.y1 + 1);
- }
-
- if (!ctrl->defined) return;
-
- x = (gint) ((affine[4] > 0) ? (affine[4] + 0.5) : (affine[4] - 0.5)) - ctrl->span;
- y = (gint) ((affine[5] > 0) ? (affine[5] + 0.5) : (affine[5] - 0.5)) - ctrl->span;
-
- switch (ctrl->anchor) {
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_S:
- break;
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_SW:
- x += ctrl->span;
- break;
- case GTK_ANCHOR_NE:
- case GTK_ANCHOR_E:
- case GTK_ANCHOR_SE:
- x -= (ctrl->span + 1);
- break;
- }
-
- switch (ctrl->anchor) {
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_E:
- break;
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_NE:
- y += ctrl->span;
- break;
- case GTK_ANCHOR_SW:
- case GTK_ANCHOR_S:
- case GTK_ANCHOR_SE:
- y -= (ctrl->span + 1);
- break;
- }
-
- ctrl->box.x0 = x;
- ctrl->box.y0 = y;
- ctrl->box.x1 = ctrl->box.x0 + 2 * ctrl->span;
- ctrl->box.y1 = ctrl->box.y0 + 2 * ctrl->span;
-
- sp_canvas_update_bbox (item, ctrl->box.x0, ctrl->box.y0, ctrl->box.x1 + 1, ctrl->box.y1 + 1);
-
+ SPCtrl *ctrl;
+ gint x, y;
+
+ ctrl = SP_CTRL (item);
+
+ if (((SPCanvasItemClass *) parent_class)->update)
+ (* ((SPCanvasItemClass *) parent_class)->update) (item, affine, flags);
+
+ sp_canvas_item_reset_bounds (item);
+
+ if (!ctrl->_moved) return;
+
+ if (ctrl->shown) {
+ sp_canvas_request_redraw (item->canvas, ctrl->box.x0, ctrl->box.y0, ctrl->box.x1 + 1, ctrl->box.y1 + 1);
+ }
+
+ if (!ctrl->defined) return;
+
+ x = (gint) ((affine[4] > 0) ? (affine[4] + 0.5) : (affine[4] - 0.5)) - ctrl->span;
+ y = (gint) ((affine[5] > 0) ? (affine[5] + 0.5) : (affine[5] - 0.5)) - ctrl->span;
+
+ switch (ctrl->anchor) {
+ case GTK_ANCHOR_N:
+ case GTK_ANCHOR_CENTER:
+ case GTK_ANCHOR_S:
+ break;
+
+ case GTK_ANCHOR_NW:
+ case GTK_ANCHOR_W:
+ case GTK_ANCHOR_SW:
+ x += ctrl->span;
+ break;
+
+ case GTK_ANCHOR_NE:
+ case GTK_ANCHOR_E:
+ case GTK_ANCHOR_SE:
+ x -= (ctrl->span + 1);
+ break;
+ }
+
+ switch (ctrl->anchor) {
+ case GTK_ANCHOR_W:
+ case GTK_ANCHOR_CENTER:
+ case GTK_ANCHOR_E:
+ break;
+
+ case GTK_ANCHOR_NW:
+ case GTK_ANCHOR_N:
+ case GTK_ANCHOR_NE:
+ y += ctrl->span;
+ break;
+
+ case GTK_ANCHOR_SW:
+ case GTK_ANCHOR_S:
+ case GTK_ANCHOR_SE:
+ y -= (ctrl->span + 1);
+ break;
+ }
+
+ ctrl->box.x0 = x;
+ ctrl->box.y0 = y;
+ ctrl->box.x1 = ctrl->box.x0 + 2 * ctrl->span;
+ ctrl->box.y1 = ctrl->box.y0 + 2 * ctrl->span;
+
+ sp_canvas_update_bbox (item, ctrl->box.x0, ctrl->box.y0, ctrl->box.x1 + 1, ctrl->box.y1 + 1);
}
static double
sp_ctrl_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item)
{
- SPCtrl *ctrl = SP_CTRL (item);
+ SPCtrl *ctrl = SP_CTRL (item);
+
+ *actual_item = item;
- *actual_item = item;
-
- double const x = p[NR::X];
- double const y = p[NR::Y];
-
- if ((x >= ctrl->box.x0) && (x <= ctrl->box.x1) && (y >= ctrl->box.y0) && (y <= ctrl->box.y1)) return 0.0;
+ double const x = p[NR::X];
+ double const y = p[NR::Y];
- return 1e18;
+ if ((x >= ctrl->box.x0) && (x <= ctrl->box.x1) && (y >= ctrl->box.y0) && (y <= ctrl->box.y1)) return 0.0;
+
+ return 1e18;
}
static void
sp_ctrl_build_cache (SPCtrl *ctrl)
{
- guchar * p, *q;
- gint size, x, y, z, s, a, side, c;
- guint8 fr, fg, fb, fa, sr, sg, sb, sa;
-
- if (ctrl->filled) {
- fr = (ctrl->fill_color >> 24) & 0xff;
- fg = (ctrl->fill_color >> 16) & 0xff;
- fb = (ctrl->fill_color >> 8) & 0xff;
- fa = (ctrl->fill_color) & 0xff;
- } else { fr = 0x00; fg = 0x00; fb = 0x00; fa = 0x00; }
- if (ctrl->stroked) {
- sr = (ctrl->stroke_color >> 24) & 0xff;
- sg = (ctrl->stroke_color >> 16) & 0xff;
- sb = (ctrl->stroke_color >> 8) & 0xff;
- sa = (ctrl->stroke_color) & 0xff;
- } else { sr = fr; sg = fg; sb = fb; sa = fa; }
-
-
- side = (ctrl->span * 2 +1);
- c = ctrl->span ;
- g_free (ctrl->cache);
- size = (side) * (side) * 4;
- ctrl->cache = (guchar*)g_malloc (size);
- if (side < 2) return;
-
- switch (ctrl->shape) {
- case SP_CTRL_SHAPE_SQUARE:
- p = ctrl->cache;
- for (x=0; x < side; x++) { *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa; }
- for (y = 2; y < side; y++) {
- *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa;
- for (x=2; x < side; x++) { *p++ = fr; *p++ = fg; *p++ = fb; *p++ = fa; }
- *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa;
- }
- for (x=0; x < side; x++) { *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa; }
- ctrl->build = TRUE;
- break;
- case SP_CTRL_SHAPE_DIAMOND:
- p = ctrl->cache;
- for (y = 0; y < side; y++) {
- z = abs (c - y);
- for (x = 0; x < z; x++) {*p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;}
- *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa; x++;
- for (; x < side - z -1; x++) { *p++ = fr; *p++ = fg; *p++ = fb; *p++ = fa; }
- if (z != c) {*p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa; x++;}
- for (; x < side; x++) {*p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;}
- }
- break;
- case SP_CTRL_SHAPE_CIRCLE:
- p = ctrl->cache;
- q = p + size -1;
- s = -1;
- for (y = 0; y <= c ; y++) {
- a = abs (c - y);
- z = (gint)(0.0 + sqrt ((c+.4)*(c+.4) - a*a));
- x = 0;
- while (x < c-z) {
- *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
- *q-- = 0x00; *q-- = 0x00; *q-- = 0x00; *q-- = 0x00;
- x++;
- }
- do {
- *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa;
- *q-- = sa; *q-- = sb; *q-- = sg; *q-- = sr;
- x++;
- } while (x < c-s);
- while (x < MIN(c+s+1, c+z)) {
- *p++ = fr; *p++ = fg; *p++ = fb; *p++ = fa;
- *q-- = fa; *q-- = fb; *q-- = fg; *q-- = fr;
- x++;
- }
- do {
- *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa;
- *q-- = sa; *q-- = sb; *q-- = sg; *q-- = sr;
- x++;
- } while (x <= c+z);
- while (x < side) {
- *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
- *q-- = 0x00; *q-- = 0x00; *q-- = 0x00; *q-- = 0x00;
- x++;
- }
- s = z;
- }
- ctrl->build = TRUE;
- break;
- case SP_CTRL_SHAPE_CROSS:
- p = ctrl->cache;
- for (y = 0; y < side; y++) {
- z = abs (c - y);
- for (x = 0; x < c-z; x++) {*p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;}
- *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa; x++;
- for (; x < c + z; x++) {*p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;}
- if (z != 0) {*p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa; x++;}
- for (; x < side; x++) {*p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;}
- }
- ctrl->build = TRUE;
- break;
- case SP_CTRL_SHAPE_BITMAP:
- if (ctrl->pixbuf) {
- unsigned char *px;
- unsigned int rs;
- px = gdk_pixbuf_get_pixels (ctrl->pixbuf);
- rs = gdk_pixbuf_get_rowstride (ctrl->pixbuf);
- for (y = 0; y < side; y++){
- unsigned char *s, *d;
- s = px + y * rs;
- d = ctrl->cache + 4 * side * y;
- for (x = 0; x < side; x++) {
- if (s[3] < 0x80) {
- d[0] = 0x00;
- d[1] = 0x00;
- d[2] = 0x00;
- d[3] = 0x00;
- } else if (s[0] < 0x80) {
- d[0] = sr;
- d[1] = sg;
- d[2] = sb;
- d[3] = sa;
- } else {
- d[0] = fr;
- d[1] = fg;
- d[2] = fb;
- d[3] = fa;
- }
- s += 4;
- d += 4;
- }
- }
- } else {
- g_print ("control has no pixmap\n");
- }
- ctrl->build = TRUE;
- break;
- case SP_CTRL_SHAPE_IMAGE:
- if (ctrl->pixbuf) {
- guint r = gdk_pixbuf_get_rowstride (ctrl->pixbuf);
- guchar * pix;
- q = gdk_pixbuf_get_pixels (ctrl->pixbuf);
- p = ctrl->cache;
- for (y = 0; y < side; y++){
- pix = q + (y * r);
- for (x = 0; x < side; x++) {
- *p++ = *pix++;
- *p++ = *pix++;
- *p++ = *pix++;
- *p++ = *pix++;
- }
- }
- } else { g_print ("control has no pixmap\n"); }
- ctrl->build = TRUE;
- break;
- default:
- break;
- }
-
+ guchar * p, *q;
+ gint size, x, y, z, s, a, side, c;
+ guint8 fr, fg, fb, fa, sr, sg, sb, sa;
+
+ if (ctrl->filled) {
+ fr = (ctrl->fill_color >> 24) & 0xff;
+ fg = (ctrl->fill_color >> 16) & 0xff;
+ fb = (ctrl->fill_color >> 8) & 0xff;
+ fa = (ctrl->fill_color) & 0xff;
+ } else {
+ fr = 0x00; fg = 0x00; fb = 0x00; fa = 0x00;
+ }
+ if (ctrl->stroked) {
+ sr = (ctrl->stroke_color >> 24) & 0xff;
+ sg = (ctrl->stroke_color >> 16) & 0xff;
+ sb = (ctrl->stroke_color >> 8) & 0xff;
+ sa = (ctrl->stroke_color) & 0xff;
+ } else {
+ sr = fr; sg = fg; sb = fb; sa = fa;
+ }
+
+
+ side = (ctrl->span * 2 +1);
+ c = ctrl->span ;
+ g_free (ctrl->cache);
+ size = (side) * (side) * 4;
+ ctrl->cache = (guchar*)g_malloc (size);
+ if (side < 2) return;
+
+ switch (ctrl->shape) {
+ case SP_CTRL_SHAPE_SQUARE:
+ p = ctrl->cache;
+ for (x=0; x < side; x++) {
+ *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa;
+ }
+ for (y = 2; y < side; y++) {
+ *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa;
+ for (x=2; x < side; x++) {
+ *p++ = fr; *p++ = fg; *p++ = fb; *p++ = fa;
+ }
+ *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa;
+ }
+ for (x=0; x < side; x++) {
+ *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa;
+ }
+ ctrl->build = TRUE;
+ break;
+
+ case SP_CTRL_SHAPE_DIAMOND:
+ p = ctrl->cache;
+ for (y = 0; y < side; y++) {
+ z = abs (c - y);
+ for (x = 0; x < z; x++) {
+ *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
+ }
+ *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa; x++;
+ for (; x < side - z -1; x++) {
+ *p++ = fr; *p++ = fg; *p++ = fb; *p++ = fa;
+ }
+ if (z != c) {
+ *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa; x++;
+ }
+ for (; x < side; x++) {
+ *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
+ }
+ }
+ break;
+
+ case SP_CTRL_SHAPE_CIRCLE:
+ p = ctrl->cache;
+ q = p + size -1;
+ s = -1;
+ for (y = 0; y <= c ; y++) {
+ a = abs (c - y);
+ z = (gint)(0.0 + sqrt ((c+.4)*(c+.4) - a*a));
+ x = 0;
+ while (x < c-z) {
+ *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
+ *q-- = 0x00; *q-- = 0x00; *q-- = 0x00; *q-- = 0x00;
+ x++;
+ }
+ do {
+ *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa;
+ *q-- = sa; *q-- = sb; *q-- = sg; *q-- = sr;
+ x++;
+ } while (x < c-s);
+ while (x < MIN(c+s+1, c+z)) {
+ *p++ = fr; *p++ = fg; *p++ = fb; *p++ = fa;
+ *q-- = fa; *q-- = fb; *q-- = fg; *q-- = fr;
+ x++;
+ }
+ do {
+ *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa;
+ *q-- = sa; *q-- = sb; *q-- = sg; *q-- = sr;
+ x++;
+ } while (x <= c+z);
+ while (x < side) {
+ *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
+ *q-- = 0x00; *q-- = 0x00; *q-- = 0x00; *q-- = 0x00;
+ x++;
+ }
+ s = z;
+ }
+ ctrl->build = TRUE;
+ break;
+
+ case SP_CTRL_SHAPE_CROSS:
+ p = ctrl->cache;
+ for (y = 0; y < side; y++) {
+ z = abs (c - y);
+ for (x = 0; x < c-z; x++) {
+ *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
+ }
+ *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa; x++;
+ for (; x < c + z; x++) {
+ *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
+ }
+ if (z != 0) {
+ *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa; x++;
+ }
+ for (; x < side; x++) {
+ *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
+ }
+ }
+ ctrl->build = TRUE;
+ break;
+
+ case SP_CTRL_SHAPE_BITMAP:
+ if (ctrl->pixbuf) {
+ unsigned char *px;
+ unsigned int rs;
+ px = gdk_pixbuf_get_pixels (ctrl->pixbuf);
+ rs = gdk_pixbuf_get_rowstride (ctrl->pixbuf);
+ for (y = 0; y < side; y++){
+ unsigned char *s, *d;
+ s = px + y * rs;
+ d = ctrl->cache + 4 * side * y;
+ for (x = 0; x < side; x++) {
+ if (s[3] < 0x80) {
+ d[0] = 0x00;
+ d[1] = 0x00;
+ d[2] = 0x00;
+ d[3] = 0x00;
+ } else if (s[0] < 0x80) {
+ d[0] = sr;
+ d[1] = sg;
+ d[2] = sb;
+ d[3] = sa;
+ } else {
+ d[0] = fr;
+ d[1] = fg;
+ d[2] = fb;
+ d[3] = fa;
+ }
+ s += 4;
+ d += 4;
+ }
+ }
+ } else {
+ g_print ("control has no pixmap\n");
+ }
+ ctrl->build = TRUE;
+ break;
+
+ case SP_CTRL_SHAPE_IMAGE:
+ if (ctrl->pixbuf) {
+ guint r = gdk_pixbuf_get_rowstride (ctrl->pixbuf);
+ guchar * pix;
+ q = gdk_pixbuf_get_pixels (ctrl->pixbuf);
+ p = ctrl->cache;
+ for (y = 0; y < side; y++){
+ pix = q + (y * r);
+ for (x = 0; x < side; x++) {
+ *p++ = *pix++;
+ *p++ = *pix++;
+ *p++ = *pix++;
+ *p++ = *pix++;
+ }
+ }
+ } else {
+ g_print ("control has no pixmap\n");
+ }
+ ctrl->build = TRUE;
+ break;
+
+ default:
+ break;
+ }
+
}
// composite background, foreground, alpha for xor mode
static void
sp_ctrl_render (SPCanvasItem *item, SPCanvasBuf *buf)
{
- gint y0, y1, y, x0,x1,x;
- guchar * p, * q, a;
-
- SPCtrl *ctrl = SP_CTRL (item);
-
- if (!ctrl->defined) return;
- if ((!ctrl->filled) && (!ctrl->stroked)) return;
-
- sp_canvas_prepare_buffer (buf);
-
- // the control-image is rendered into ctrl->cache
- if (!ctrl->build) sp_ctrl_build_cache (ctrl);
-
- // then we render from ctrl->cache
- y0 = MAX (ctrl->box.y0, buf->rect.y0);
- y1 = MIN (ctrl->box.y1, buf->rect.y1 - 1);
- x0 = MAX (ctrl->box.x0, buf->rect.x0);
- x1 = MIN (ctrl->box.x1, buf->rect.x1 - 1);
-
- bool colormode;
-
- for (y = y0; y <= y1; y++) {
- p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 3;
- q = ctrl->cache + ((y - ctrl->box.y0) * (ctrl->span*2+1) + (x0 - ctrl->box.x0)) * 4;
- for (x = x0; x <= x1; x++) {
- a = *(q + 3);
- // 00000000 is the only way to get invisible; all other colors with alpha 00 are treated as mode_color with alpha ff
- colormode = false;
- if (a == 0x00 && !(q[0] == 0x00 && q[1] == 0x00 && q[2] == 0x00)) {
- a = 0xff;
- colormode = true;
- }
- if (ctrl->mode == SP_CTRL_MODE_COLOR || colormode) {
- p[0] = COMPOSE_N (p[0], q[0], a);
- p[1] = COMPOSE_N (p[1], q[1], a);
- p[2] = COMPOSE_N (p[2], q[2], a);
- q += 4;
- p += 3;
- } else if (ctrl->mode == SP_CTRL_MODE_XOR) {
- p[0] = COMPOSE_X (p[0], q[0], a);
- p[1] = COMPOSE_X (p[1], q[1], a);
- p[2] = COMPOSE_X (p[2], q[2], a);
- q += 4;
- p += 3;
- }
- }
- }
- ctrl->shown = TRUE;
+ gint y0, y1, y, x0,x1,x;
+ guchar *p, *q, a;
+
+ SPCtrl *ctrl = SP_CTRL (item);
+
+ if (!ctrl->defined) return;
+ if ((!ctrl->filled) && (!ctrl->stroked)) return;
+
+ sp_canvas_prepare_buffer (buf);
+
+ // the control-image is rendered into ctrl->cache
+ if (!ctrl->build) {
+ sp_ctrl_build_cache (ctrl);
+ }
+
+ // then we render from ctrl->cache
+ y0 = MAX (ctrl->box.y0, buf->rect.y0);
+ y1 = MIN (ctrl->box.y1, buf->rect.y1 - 1);
+ x0 = MAX (ctrl->box.x0, buf->rect.x0);
+ x1 = MIN (ctrl->box.x1, buf->rect.x1 - 1);
+
+ bool colormode;
+
+ for (y = y0; y <= y1; y++) {
+ p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 3;
+ q = ctrl->cache + ((y - ctrl->box.y0) * (ctrl->span*2+1) + (x0 - ctrl->box.x0)) * 4;
+ for (x = x0; x <= x1; x++) {
+ a = *(q + 3);
+ // 00000000 is the only way to get invisible; all other colors with alpha 00 are treated as mode_color with alpha ff
+ colormode = false;
+ if (a == 0x00 && !(q[0] == 0x00 && q[1] == 0x00 && q[2] == 0x00)) {
+ a = 0xff;
+ colormode = true;
+ }
+ if (ctrl->mode == SP_CTRL_MODE_COLOR || colormode) {
+ p[0] = COMPOSE_N (p[0], q[0], a);
+ p[1] = COMPOSE_N (p[1], q[1], a);
+ p[2] = COMPOSE_N (p[2], q[2], a);
+ q += 4;
+ p += 3;
+ } else if (ctrl->mode == SP_CTRL_MODE_XOR) {
+ p[0] = COMPOSE_X (p[0], q[0], a);
+ p[1] = COMPOSE_X (p[1], q[1], a);
+ p[2] = COMPOSE_X (p[2], q[2], a);
+ q += 4;
+ p += 3;
+ }
+ }
+ }
+ ctrl->shown = TRUE;
}
void SPCtrl::moveto (NR::Point const p) {
- sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (this), NR::Matrix(NR::translate (p)));
- _moved = true;
+ sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (this), NR::Matrix(NR::translate (p)));
+ _moved = true;
}
+
+
+/*
+ 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 :
index 2b2254d14249f78cc0d1a6556ccd14a6993a41ab..2a68d19431debe0ceb9eb645d3bcd41417565e3c 100644 (file)
#define SP_IS_CTRL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_CTRL))
typedef enum {
- SP_CTRL_SHAPE_SQUARE,
- SP_CTRL_SHAPE_DIAMOND,
- SP_CTRL_SHAPE_CIRCLE,
- SP_CTRL_SHAPE_CROSS,
- SP_CTRL_SHAPE_BITMAP,
- SP_CTRL_SHAPE_IMAGE
+ SP_CTRL_SHAPE_SQUARE,
+ SP_CTRL_SHAPE_DIAMOND,
+ SP_CTRL_SHAPE_CIRCLE,
+ SP_CTRL_SHAPE_CROSS,
+ SP_CTRL_SHAPE_BITMAP,
+ SP_CTRL_SHAPE_IMAGE
} SPCtrlShapeType;
typedef enum {
- SP_CTRL_MODE_COLOR,
- SP_CTRL_MODE_XOR
+ SP_CTRL_MODE_COLOR,
+ SP_CTRL_MODE_XOR
} SPCtrlModeType;
struct SPCtrl : public SPCanvasItem{
- SPCtrlShapeType shape;
- SPCtrlModeType mode;
- GtkAnchorType anchor;
- gint span;
- guint defined : 1;
- guint shown : 1;
- guint build : 1;
- guint filled : 1;
- guint stroked : 1;
- guint32 fill_color;
- guint32 stroke_color;
- bool _moved;
-
- NRRectL box; /* NB! x1 & y1 are included */
- guchar *cache;
- GdkPixbuf * pixbuf;
-
- void moveto(NR::Point const p);
+ SPCtrlShapeType shape;
+ SPCtrlModeType mode;
+ GtkAnchorType anchor;
+ gint span;
+ guint defined : 1;
+ guint shown : 1;
+ guint build : 1;
+ guint filled : 1;
+ guint stroked : 1;
+ guint32 fill_color;
+ guint32 stroke_color;
+ bool _moved;
+
+ NRRectL box; /* NB! x1 & y1 are included */
+ guchar *cache;
+ GdkPixbuf * pixbuf;
+
+ void moveto(NR::Point const p);
};
struct SPCtrlClass : public SPCanvasItemClass{
/* Standard Gtk function */
GtkType sp_ctrl_get_type (void);
-#endif
+
+
+#endif /* !INKSCAPE_CTRL_H */
+
+/*
+ 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 :
index 0e4887f59608547f50c9f07cf9b8253cc14ce377..cce921b3cecb5b2ca7fbe45dd396b87dc404e8c4 100644 (file)
GtkType sp_ctrlrect_get_type()
{
static GtkType ctrlrect_type = 0;
-
+
if (!ctrlrect_type) {
GtkTypeInfo ctrlrect_info = {
"SPCtrlRect",
guint const b = RGBA_B(rgba);
guint const a = RGBA_A(rgba);
gint const x0 = MAX(buf->rect.x0, xs);
- gint const x1 = MIN(buf->rect.x1, xe + 1);
+ gint const x1 = MIN(buf->rect.x1, xe + 1);
guchar *p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 3;
for (gint x = x0; x < x1; x++) {
if (!dashed || ((x / DASH_LENGTH) % 2)) {
}
NR::Rect bbox(_rect.min() * affine, _rect.max() * affine);
-
+
_area.x0 = (int) floor(bbox.min()[NR::X] + 0.5);
_area.y0 = (int) floor(bbox.min()[NR::Y] + 0.5);
_area.x1 = (int) floor(bbox.max()[NR::X] + 0.5);
_area.y1 = (int) floor(bbox.max()[NR::Y] + 0.5);
-
+
_shadow_size = _shadow;
if (_area.x0 != 0 || _area.x1 != 0 || _area.y0 != 0 || _area.y1 != 0) {
x2 = _area.x1 + _shadow_size + 1;
y2 = _area.y1 + _shadow_size + 1;
}
-
}
index a0c74b2c3fed1332fec51f5fbc646a8bd7c9989a..9b3e53f207b7577a8ea7191c1b6616152c3d70cc 100644 (file)
void
sp_canvas_update_bbox (SPCanvasItem *item, int x1, int y1, int x2, int y2)
{
- sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
- item->x1 = x1;
- item->y1 = y1;
- item->x2 = x2;
- item->y2 = y2;
- sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
+ sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
+ item->x1 = x1;
+ item->y1 = y1;
+ item->x2 = x2;
+ item->y2 = y2;
+ sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
}
void
sp_canvas_item_reset_bounds (SPCanvasItem *item)
{
- item->x1 = 0.0;
- item->y1 = 0.0;
- item->x2 = 0.0;
- item->y2 = 0.0;
+ item->x1 = 0.0;
+ item->y1 = 0.0;
+ item->x2 = 0.0;
+ item->y2 = 0.0;
}
void
sp_canvas_prepare_buffer (SPCanvasBuf *buf)
{
- if (buf->is_empty) {
- sp_canvas_clear_buffer(buf);
- buf->is_empty = false;
- }
+ if (buf->is_empty) {
+ sp_canvas_clear_buffer(buf);
+ buf->is_empty = false;
+ }
}
void
sp_canvas_clear_buffer (SPCanvasBuf *buf)
{
- unsigned char r, g, b;
-
- r = (buf->bg_color >> 16) & 0xff;
- g = (buf->bg_color >> 8) & 0xff;
- b = buf->bg_color & 0xff;
-
- if ((r != g) || (r != b)) {
- int x, y;
- for (y = buf->rect.y0; y < buf->rect.y1; y++) {
- unsigned char *p;
- p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride;
- for (x = buf->rect.x0; x < buf->rect.x1; x++) {
- *p++ = r;
- *p++ = g;
- *p++ = b;
- }
- }
- } else {
- int y;
- for (y = buf->rect.y0; y < buf->rect.y1; y++) {
- memset (buf->buf + (y - buf->rect.y0) * buf->buf_rowstride, r, 3 * (buf->rect.x1 - buf->rect.x0)); // CAIRO FIXME: for cairo output we need 32bpp, so it will be 4 * ...
- }
- }
+ unsigned char r, g, b;
+
+ r = (buf->bg_color >> 16) & 0xff;
+ g = (buf->bg_color >> 8) & 0xff;
+ b = buf->bg_color & 0xff;
+
+ if ((r != g) || (r != b)) {
+ int x, y;
+ for (y = buf->rect.y0; y < buf->rect.y1; y++) {
+ unsigned char *p;
+ p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride;
+ for (x = buf->rect.x0; x < buf->rect.x1; x++) {
+ *p++ = r;
+ *p++ = g;
+ *p++ = b;
+ }
+ }
+ } else {
+ int y;
+ for (y = buf->rect.y0; y < buf->rect.y1; y++) {
+ memset (buf->buf + (y - buf->rect.y0) * buf->buf_rowstride, r, 3 * (buf->rect.x1 - buf->rect.x0)); // CAIRO FIXME: for cairo output we need 32bpp, so it will be 4 * ...
+ }
+ }
}
NR::Matrix sp_canvas_item_i2p_affine (SPCanvasItem * item)
{
- g_assert (item != NULL); // this may be overly zealous - it is
- // plausible that this gets called
- // with item == 0
-
- return item->xform;
+ g_assert (item != NULL); /* this may be overly zealous - it is
+ * plausible that this gets called
+ * with item == 0. */
+
+ return item->xform;
}
NR::Matrix sp_canvas_item_i2i_affine (SPCanvasItem * from, SPCanvasItem * to)
{
- g_assert (from != NULL);
- g_assert (to != NULL);
+ g_assert (from != NULL);
+ g_assert (to != NULL);
- return sp_canvas_item_i2w_affine(from) / sp_canvas_item_i2w_affine(to);
+ return sp_canvas_item_i2w_affine(from) / sp_canvas_item_i2w_affine(to);
}
void sp_canvas_item_set_i2w_affine (SPCanvasItem * item, NR::Matrix const &i2w)
{
- g_assert (item != NULL);
+ g_assert (item != NULL);
- sp_canvas_item_affine_absolute(item, i2w / sp_canvas_item_i2w_affine(item->parent));
+ sp_canvas_item_affine_absolute(item, i2w / sp_canvas_item_i2w_affine(item->parent));
}
void sp_canvas_item_move_to_z (SPCanvasItem * item, gint z)
{
- g_assert (item != NULL);
+ g_assert (item != NULL);
- gint current_z = sp_canvas_item_order (item);
+ gint current_z = sp_canvas_item_order (item);
- if (current_z == -1) // not found in its parent
- return;
+ if (current_z == -1) // not found in its parent
+ return;
- if (z == current_z)
- return;
+ if (z == current_z)
+ return;
- if (z > current_z)
- sp_canvas_item_raise (item, z - current_z);
+ if (z > current_z)
+ sp_canvas_item_raise (item, z - current_z);
- sp_canvas_item_lower (item, current_z - z);
+ sp_canvas_item_lower (item, current_z - z);
}
gint
sp_canvas_item_compare_z (SPCanvasItem * a, SPCanvasItem * b)
{
- gint const o_a = sp_canvas_item_order (a);
- gint const o_b = sp_canvas_item_order (b);
+ gint const o_a = sp_canvas_item_order (a);
+ gint const o_b = sp_canvas_item_order (b);
- if (o_a > o_b) return -1;
- if (o_a < o_b) return 1;
+ if (o_a > o_b) return -1;
+ if (o_a < o_b) return 1;
- return 0;
+ return 0;
}
// These two functions are used by canvasitems that use livarot (currently ctrlline and ctrlquadr)
@@ -143,17 +143,17 @@ ctrl_run_A8_OR (raster_info &dest,void *data,int st,float vst,int en,float ven)
} tempCol;
if ( st >= en ) return;
tempCol.col=*(uint32_t*)data;
-
+
unsigned int r, g, b, a;
r = NR_RGBA32_R (tempCol.col);
g = NR_RGBA32_G (tempCol.col);
b = NR_RGBA32_B (tempCol.col);
a = NR_RGBA32_A (tempCol.col);
if (a == 0) return;
-
+
vst*=a;
ven*=a;
-
+
if ( vst < 0 ) vst=0;
if ( vst > 255 ) vst=255;
if ( ven < 0 ) ven=0;
float dv=ven-vst;
int len=en-st;
uint8_t* d=(uint8_t*)dest.buffer;
-
+
d+=3*(st-dest.startPix);
if ( fabs(dv) < 0.001 ) {
if ( sv > 249.999 ) {
void nr_pixblock_render_ctrl_rgba (Shape* theS,uint32_t color,NRRectL &area,char* destBuf,int stride)
{
-
+
theS->CalcBBox();
float l=theS->leftX,r=theS->rightX,t=theS->topY,b=theS->bottomY;
int il,ir,it,ib;
@@ -227,25 +227,25 @@ void nr_pixblock_render_ctrl_rgba (Shape* theS,uint32_t color,NRRectL &area,char
ir=(int)ceil(r);
it=(int)floor(t);
ib=(int)ceil(b);
-
+
// printf("bbox %i %i %i %i render %i %i %i %i\n",il,it,ir,ib,area.x0,area.y0,area.x1,area.y1);
-
+
if ( il >= area.x1 || ir <= area.x0 || it >= area.y1 || ib <= area.y0 ) return;
if ( il < area.x0 ) il=area.x0;
if ( it < area.y0 ) it=area.y0;
if ( ir > area.x1 ) ir=area.x1;
if ( ib > area.y1 ) ib=area.y1;
-
+
/* // version par FloatLigne
int curPt;
float curY;
theS->BeginRaster(curY,curPt,1.0);
-
+
FloatLigne* theI=new FloatLigne();
IntLigne* theIL=new IntLigne();
-
+
theS->Scan(curY,curPt,(float)(it),1.0);
-
+
char* mdata=(char*)destBuf;
uint32_t* ligStart=((uint32_t*)(mdata+(3*(il-area.x0)+stride*(it-area.y0))));
for (int y=it;y<ib;y++) {
@@ -257,7 +257,7 @@ void nr_pixblock_render_ctrl_rgba (Shape* theS,uint32_t color,NRRectL &area,char
}
theI->Flatten();
theIL->Copy(theI);
-
+
raster_info dest;
dest.startPix=il;
dest.endPix=ir;
@@ -270,18 +270,18 @@ void nr_pixblock_render_ctrl_rgba (Shape* theS,uint32_t color,NRRectL &area,char
theS->EndRaster();
delete theI;
delete theIL; */
-
+
// version par BitLigne directe
int curPt;
float curY;
theS->BeginQuickRaster(curY, curPt);
-
+
BitLigne* theI[4];
for (int i=0;i<4;i++) theI[i]=new BitLigne(il,ir);
IntLigne* theIL=new IntLigne();
-
+
theS->QuickScan(curY,curPt,(float)(it),true,0.25);
-
+
char* mdata=(char*)destBuf;
uint32_t* ligStart=((uint32_t*)(mdata+(3*(il-area.x0)+stride*(it-area.y0))));
for (int y=it;y<ib;y++) {
@@ -291,7 +291,7 @@ void nr_pixblock_render_ctrl_rgba (Shape* theS,uint32_t color,NRRectL &area,char
theS->QuickScan(curY,curPt,((float)(y+0.75)),fill_oddEven,theI[2],0.25);
theS->QuickScan(curY,curPt,((float)(y+1.0)),fill_oddEven,theI[3],0.25);
theIL->Copy(4,theI);
-
+
raster_info dest;
dest.startPix=il;
dest.endPix=ir;
@@ -303,5 +303,17 @@ void nr_pixblock_render_ctrl_rgba (Shape* theS,uint32_t color,NRRectL &area,char
}
theS->EndQuickRaster();
for (int i=0;i<4;i++) delete theI[i];
- delete theIL;
+ 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 :
index f6a27b076bde56aebbedfefbc30b76c191c0a001..3c647aa1c3d4e08f17769694806f1fe6f70b4810 100644 (file)
// Define this to visualize the regions to be redrawn
//#define DEBUG_REDRAW 1;
-// Tiles are a way to minimize the number of redraws, eliminating too small redraws.
+// Tiles are a way to minimize the number of redraws, eliminating too small redraws.
// The canvas stores a 2D array of ints, each representing a TILE_SIZExTILE_SIZE pixels tile.
// If any part of it is dirtied, the entire tile is dirtied (its int is nonzero) and repainted.
#define TILE_SIZE 16
enum {
- RENDERMODE_NORMAL,
- RENDERMODE_NOAA,
- RENDERMODE_OUTLINE
+ RENDERMODE_NORMAL,
+ RENDERMODE_NOAA,
+ RENDERMODE_OUTLINE
};
static gint const sp_canvas_update_priority = G_PRIORITY_HIGH_IDLE;
@@ -299,11 +299,11 @@ sp_canvas_item_invoke_update (SPCanvasItem *item, NR::Matrix const &affine, unsi
GTK_OBJECT_UNSET_FLAGS (item, SP_CANVAS_ITEM_NEED_AFFINE);
}
-/**
- * Helper function to invoke the point method of the item.
+/**
+ * Helper function to invoke the point method of the item.
*
- * The argument x, y should be in the parent's item-relative coordinate
- * system. This routine applies the inverse of the item's transform,
+ * The argument x, y should be in the parent's item-relative coordinate
+ * system. This routine applies the inverse of the item's transform,
* maintaining the affine invariant.
*/
static double
@@ -318,7 +318,7 @@ sp_canvas_item_invoke_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **act
/**
* Makes the item's affine transformation matrix be equal to the specified
* matrix.
- *
+ *
* @item: A canvas item.
* @affine: An affine transformation matrix.
*/
}
/**
- * Convenience function to reorder items in a group's child list.
+ * Convenience function to reorder items in a group's child list.
*
* This puts the specified link after the "before" link.
*/
/**
* Raises the item in its parent's stack by the specified number of positions.
- *
+ *
* \param item A canvas item.
* \param positions Number of steps to raise the item.
*
/**
* Grab item under cursor.
- *
+ *
* \pre !canvas->grabbed_item && item->flags & SP_CANVAS_ITEM_VISIBLE
*/
int
@@ -552,7 +552,7 @@ sp_canvas_item_grab (SPCanvasItem *item, guint event_mask, GdkCursor *cursor, gu
/**
* Ungrabs the item, which must have been grabbed in the canvas, and ungrabs the
* mouse.
- *
+ *
* \param item A canvas item that holds a grab.
* \param etime The timestamp for ungrabbing the mouse.
*/
/**
* Requests that the canvas queue an update for the specified item.
- *
+ *
* To be used only by item implementations.
*/
void
}
/**
- * Callback that destroys all items in group and calls group's virtual
+ * Callback that destroys all items in group and calls group's virtual
* destroy() function.
*/
static void
sp_canvas_item_request_update (item);
}
-/**
+/**
* Removes an item from a canvas group
*/
static void
widget_class->focus_out_event = sp_canvas_focus_out;
}
-/**
+/**
* Callback: object initialization for SPCanvas.
*/
static void
}
/**
- * Helper that emits an event for an item in the canvas, be it the current
+ * Helper that emits an event for an item in the canvas, be it the current
* item, grabbed item, or focused item, as appropriate.
*/
static int
}
/**
- * Helper that re-picks the current item in the canvas, based on the event's
+ * Helper that re-picks the current item in the canvas, based on the event's
* coordinates and emits enter/leave events for items as appropriate.
*/
static int
/* dispatch normally regardless of the event's window if an item has
has a pointer grab in effect */
- if (!canvas->grabbed_item &&
+ if (!canvas->grabbed_item &&
event->window != SP_CANVAS_WINDOW (canvas))
return retval;
@@ -1610,8 +1610,8 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1,
// CAIRO FIXME: after SPCanvasBuf is made 32bpp throughout, this rgb_draw below can be replaced with the below.
// Why this must not be done currently:
// - all canvas items (handles, nodes etc) paint themselves assuming 24bpp
-// - cairo assumes bgra, but we have rgba, so r and b get swapped (until we paint all with cairo too)
-// - it does not seem to be any faster; in fact since with 32bpp, buf contains less pixels,
+// - cairo assumes bgra, but we have rgba, so r and b get swapped (until we paint all with cairo too)
+// - it does not seem to be any faster; in fact since with 32bpp, buf contains less pixels,
// we need more bufs to paint a given area and as a result it's even a bit slower
cairo_surface_t* cst = cairo_image_surface_create_for_data (
@@ -1695,12 +1695,12 @@ sp_canvas_paint_rect_internal (PaintRectSetup const *setup, NRRectL this_rect)
// Interrupting redraw isn't always good.
// For example, when you drag one node of a big path, only the buffer containing
// the mouse cursor will be redrawn again and again, and the rest of the path
- // will remain stale because Inkscape never has enough idle time to redraw all
- // of the screen. To work around this, such operations set a forced_redraw_limit > 0.
+ // will remain stale because Inkscape never has enough idle time to redraw all
+ // of the screen. To work around this, such operations set a forced_redraw_limit > 0.
// If this limit is set, and if we have aborted redraw more times than is allowed,
- // interrupting is blocked and we're forced to redraw full screen once
+ // interrupting is blocked and we're forced to redraw full screen once
// (after which we can again interrupt forced_redraw_limit times).
- if (setup->canvas->forced_redraw_limit < 0 ||
+ if (setup->canvas->forced_redraw_limit < 0 ||
setup->canvas->forced_redraw_count < setup->canvas->forced_redraw_limit) {
if (setup->canvas->forced_redraw_limit != -1) {
@@ -1730,8 +1730,8 @@ sp_canvas_paint_rect_internal (PaintRectSetup const *setup, NRRectL this_rect)
NRRectL lo = this_rect;
NRRectL hi = this_rect;
-/*
-This test determines the redraw strategy:
+/*
+This test determines the redraw strategy:
bw < bh (strips mode) splits across the smaller dimension of the rect and therefore (on
horizontally-stretched windows) results in redrawing in horizontal strips (from cursor point, in
The default for now is the strips mode.
*/
- if (bw < bh || bh < 2 * TILE_SIZE) {
+ if (bw < bh || bh < 2 * TILE_SIZE) {
int mid = (this_rect.x0 + this_rect.x1) / 2;
// Make sure that mid lies on a tile boundary
mid = (mid / TILE_SIZE) * TILE_SIZE;
sp_canvas_paint_rect (SPCanvas *canvas, int xx0, int yy0, int xx1, int yy1)
{
g_return_val_if_fail (!canvas->need_update, false);
-
+
NRRectL rect;
rect.x0 = xx0;
rect.x1 = xx1;
// paint the area to redraw yellow
gdk_rgb_gc_set_foreground (canvas->pixmap_gc, 0xFFFF00);
gdk_draw_rectangle (SP_CANVAS_WINDOW (canvas),
- canvas->pixmap_gc,
- TRUE,
- rect.x0 - canvas->x0, rect.y0 - canvas->y0,
- rect.x1 - rect.x0, rect.y1 - rect.y0);
-#endif
+ canvas->pixmap_gc,
+ TRUE,
+ rect.x0 - canvas->x0, rect.y0 - canvas->y0,
+ rect.x1 - rect.x0, rect.y1 - rect.y0);
+#endif
PaintRectSetup setup;
void
sp_canvas_force_full_redraw_after_interruptions(SPCanvas *canvas, unsigned int count) {
g_return_if_fail(canvas != NULL);
-
+
canvas->forced_redraw_limit = count;
canvas->forced_redraw_count = 0;
}
{
SPCanvas *canvas = SP_CANVAS (widget);
- if (!GTK_WIDGET_DRAWABLE (widget) ||
+ if (!GTK_WIDGET_DRAWABLE (widget) ||
(event->window != SP_CANVAS_WINDOW (canvas)))
return FALSE;
for (int i = 0; i < n_rects; i++) {
NRRectL rect;
-
+
rect.x0 = rects[i].x + canvas->x0;
rect.y0 = rects[i].y + canvas->y0;
rect.x1 = rect.x0 + rects[i].width;
Gdk::Region to_paint;
- for (int j=canvas->tTop; j<canvas->tBottom; j++) {
- for (int i=canvas->tLeft; i<canvas->tRight; i++) {
+ for (int j=canvas->tTop; j<canvas->tBottom; j++) {
+ for (int i=canvas->tLeft; i<canvas->tRight; i++) {
int tile_index = (i - canvas->tLeft) + (j - canvas->tTop)*canvas->tileH;
if ( canvas->tiles[tile_index] ) { // if this tile is dirtied (nonzero)
@@ -2125,7 +2125,7 @@ sp_canvas_scroll_to (SPCanvas *canvas, double cx, double cy, unsigned int clear,
}
}
-/**
+/**
* Updates canvas if necessary.
*/
void
@@ -2350,4 +2350,4 @@ void sp_canvas_mark_rect(SPCanvas* canvas, int nl, int nt, int nr, int nb, uint8
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :