summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJon A. Cruz <jon@joncruz.org>2008-08-03 07:37:06 +0000
committerjoncruz <joncruz@users.sourceforge.net>2008-08-03 07:37:06 +0000
commit4f99bb24de6643f57c6075c18bb0b441b4ce0c23 (patch)
tree8d9486c4b0aa563fc13438e4c543e235a3a0954f /src
parentFixed const-correctness (diff)
downloadinkscape-4f99bb24de6643f57c6075c18bb0b441b4ce0c23.tar.gz
inkscape-4f99bb24de6643f57c6075c18bb0b441b4ce0c23.zip
Minor cleanup work on macros
(bzr r6546)
Diffstat (limited to 'src')
-rw-r--r--src/display/inkscape-cairo.cpp2
-rw-r--r--src/display/nr-arena-glyphs.cpp6
-rw-r--r--src/display/nr-arena-item.cpp6
-rw-r--r--src/display/nr-arena-shape.cpp6
-rw-r--r--src/display/nr-arena.cpp2
-rw-r--r--src/libnr/nr-blit.cpp6
-rw-r--r--src/libnr/nr-macros.h2
-rw-r--r--src/libnr/nr-pixblock-pattern.cpp2
-rw-r--r--src/libnr/nr-rect-l.cpp2
-rw-r--r--src/libnr/nr-rect.cpp4
-rw-r--r--src/libnr/nr-rect.h16
11 files changed, 33 insertions, 21 deletions
diff --git a/src/display/inkscape-cairo.cpp b/src/display/inkscape-cairo.cpp
index c52404b23..d4a9f7062 100644
--- a/src/display/inkscape-cairo.cpp
+++ b/src/display/inkscape-cairo.cpp
@@ -32,7 +32,7 @@
cairo_t *
nr_create_cairo_context_for_data (NRRectL *area, NRRectL *buf_area, unsigned char *px, unsigned int rowstride)
{
- if (!nr_rect_l_test_intersect (buf_area, area))
+ if (!nr_rect_l_test_intersect_ptr(buf_area, area))
return NULL;
NRRectL clip;
diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp
index 0fbc068a1..a1a14ef1a 100644
--- a/src/display/nr-arena-glyphs.cpp
+++ b/src/display/nr-arena-glyphs.cpp
@@ -211,7 +211,7 @@ nr_arena_glyphs_update(NRArenaItem *item, NRRectL */*area*/, NRGC *gc, guint /*s
bbox.y1 = narea.y1 + glyphs->y;
}
}
- if (nr_rect_d_test_empty(&bbox)) return NR_ARENA_ITEM_STATE_ALL;
+ if (nr_rect_d_test_empty(bbox)) return NR_ARENA_ITEM_STATE_ALL;
item->bbox.x0 = (gint32)(bbox.x0 - 1.0);
item->bbox.y0 = (gint32)(bbox.y0 - 1.0);
@@ -296,7 +296,7 @@ nr_arena_glyphs_fill_mask(NRArenaGlyphs *glyphs, NRRectL *area, NRPixBlock *m)
NRArenaItem *item = NR_ARENA_ITEM(glyphs);
- if (glyphs->rfont && nr_rect_l_test_intersect(area, &item->bbox)) {
+ if (glyphs->rfont && nr_rect_l_test_intersect_ptr(area, &item->bbox)) {
raster_glyph *g = glyphs->rfont->GetGlyph(glyphs->glyph);
if ( g ) g->Blit(NR::Point(glyphs->x, glyphs->y), *m);
}
@@ -308,7 +308,7 @@ static guint
nr_arena_glyphs_stroke_mask(NRArenaGlyphs *glyphs, NRRectL *area, NRPixBlock *m)
{
NRArenaItem *item = NR_ARENA_ITEM(glyphs);
- if (glyphs->sfont && nr_rect_l_test_intersect(area, &item->bbox)) {
+ if (glyphs->sfont && nr_rect_l_test_intersect_ptr(area, &item->bbox)) {
raster_glyph *g=glyphs->sfont->GetGlyph(glyphs->glyph);
if ( g ) g->Blit(NR::Point(glyphs->x, glyphs->y),*m);
}
diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp
index 195dba2f0..a6a04bb8b 100644
--- a/src/display/nr-arena-item.cpp
+++ b/src/display/nr-arena-item.cpp
@@ -236,7 +236,7 @@ nr_arena_item_invoke_update (NRArenaItem *item, NRRectL *area, NRGC *gc,
return item->state;
/* Test whether to return immediately */
if (area && (item->state & NR_ARENA_ITEM_STATE_BBOX)) {
- if (!nr_rect_l_test_intersect (area, &item->bbox))
+ if (!nr_rect_l_test_intersect_ptr(area, &item->bbox))
return item->state;
}
@@ -321,7 +321,7 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area
NRRectL carea;
nr_rect_l_intersect (&carea, area, &item->bbox);
- if (nr_rect_l_test_empty (&carea))
+ if (nr_rect_l_test_empty(carea))
return item->state | NR_ARENA_ITEM_STATE_RENDER;
if (item->filter && filter) {
item->filter->area_enlarge (carea, item->ctm);
@@ -607,7 +607,7 @@ nr_arena_item_invoke_clip (NRArenaItem *item, NRRectL *area, NRPixBlock *pb)
(&item->bbox)->y0, (&item->bbox)->x1, (&item->bbox)->y1);
#endif
- if (item->visible && nr_rect_l_test_intersect (area, &item->bbox)) {
+ if (item->visible && nr_rect_l_test_intersect_ptr(area, &item->bbox)) {
/* Need render that item */
if (((NRArenaItemClass *) NR_OBJECT_GET_CLASS (item))->clip) {
return ((NRArenaItemClass *) NR_OBJECT_GET_CLASS (item))->
diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp
index b8723e635..325681650 100644
--- a/src/display/nr-arena-shape.cpp
+++ b/src/display/nr-arena-shape.cpp
@@ -299,7 +299,7 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g
shape->approx_bbox.y0 = (gint32)(boundingbox[1][0] - 1.0F);
shape->approx_bbox.x1 = (gint32)(boundingbox[0][1] + 1.9999F);
shape->approx_bbox.y1 = (gint32)(boundingbox[1][1] + 1.9999F);
- if ( area && nr_rect_l_test_intersect(area, &shape->approx_bbox) ) shape->delayed_shp=false;
+ if ( area && nr_rect_l_test_intersect_ptr(area, &shape->approx_bbox) ) shape->delayed_shp=false;
/* Release state data */
if (TRUE || !NR::transform_equalp(gc->transform, shape->ctm, NR_EPSILON)) {
@@ -850,7 +850,7 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock
} else {
if ( shape->delayed_shp ) {
- if ( nr_rect_l_test_intersect(area, &item->bbox) ) {
+ if ( nr_rect_l_test_intersect_ptr(area, &item->bbox) ) {
NRGC tempGC(NULL);
tempGC.transform=shape->ctm;
shape->delayed_shp = false;
@@ -1015,7 +1015,7 @@ nr_arena_shape_clip(NRArenaItem *item, NRRectL *area, NRPixBlock *pb)
if (!shape->curve) return item->state;
if ( shape->delayed_shp || shape->fill_shp == NULL) { // we need a fill shape no matter what
- if ( nr_rect_l_test_intersect(area, &item->bbox) ) {
+ if ( nr_rect_l_test_intersect_ptr(area, &item->bbox) ) {
NRGC tempGC(NULL);
tempGC.transform=shape->ctm;
shape->delayed_shp = false;
diff --git a/src/display/nr-arena.cpp b/src/display/nr-arena.cpp
index 77701d249..ce13072b9 100644
--- a/src/display/nr-arena.cpp
+++ b/src/display/nr-arena.cpp
@@ -93,7 +93,7 @@ nr_arena_request_render_rect (NRArena *arena, NRRectL *area)
nr_return_if_fail (NR_IS_ARENA (arena));
nr_return_if_fail (area != NULL);
- if (aobject->callbacks && area && !nr_rect_l_test_empty (area)) {
+ if (aobject->callbacks && area && !nr_rect_l_test_empty_ptr(area)) {
for (unsigned int i = 0; i < aobject->callbacks->length; i++) {
NRObjectListener *listener = aobject->callbacks->listeners + i;
NRArenaEventVector *avector = (NRArenaEventVector *) listener->vector;
diff --git a/src/libnr/nr-blit.cpp b/src/libnr/nr-blit.cpp
index b25f0e2a7..144caa597 100644
--- a/src/libnr/nr-blit.cpp
+++ b/src/libnr/nr-blit.cpp
@@ -52,7 +52,7 @@ nr_blit_pixblock_pixblock_alpha (NRPixBlock *d, NRPixBlock *s, unsigned int alph
nr_rect_l_intersect (&clip, &d->area, &s->area);
- if (nr_rect_l_test_empty (&clip)) return;
+ if (nr_rect_l_test_empty(clip)) return;
/* Pointers */
dbpp = NR_PIXBLOCK_BPP (d);
@@ -153,7 +153,7 @@ nr_blit_pixblock_pixblock_mask (NRPixBlock *d, NRPixBlock *s, NRPixBlock *m)
nr_rect_l_intersect (&clip, &d->area, &s->area);
nr_rect_l_intersect (&clip, &clip, &m->area);
- if (nr_rect_l_test_empty (&clip)) return;
+ if (nr_rect_l_test_empty(clip)) return;
/* Pointers */
dbpp = NR_PIXBLOCK_BPP (d);
@@ -228,7 +228,7 @@ nr_blit_pixblock_mask_rgba32 (NRPixBlock *d, NRPixBlock *m, unsigned long rgba)
if (m->mode != NR_PIXBLOCK_MODE_A8) return;
- if (!nr_rect_l_test_intersect (&d->area, &m->area)) return;
+ if (!nr_rect_l_test_intersect(d->area, m->area)) return;
nr_rect_l_intersect (&clip, &d->area, &m->area);
diff --git a/src/libnr/nr-macros.h b/src/libnr/nr-macros.h
index e0d3dabfb..0e0307916 100644
--- a/src/libnr/nr-macros.h
+++ b/src/libnr/nr-macros.h
@@ -48,7 +48,9 @@
// Todo: move these into nr-matrix.h
#define NR_RECT_DFLS_TEST_EMPTY(a) (((a)->x0 >= (a)->x1) || ((a)->y0 >= (a)->y1))
+#define NR_RECT_DFLS_TEST_EMPTY_REF(a) (((a).x0 >= (a).x1) || ((a).y0 >= (a).y1))
#define NR_RECT_DFLS_TEST_INTERSECT(a,b) (((a)->x0 < (b)->x1) && ((a)->x1 > (b)->x0) && ((a)->y0 < (b)->y1) && ((a)->y1 > (b)->y0))
+#define NR_RECT_DFLS_TEST_INTERSECT_REF(a,b) (((a).x0 < (b).x1) && ((a).x1 > (b).x0) && ((a).y0 < (b).y1) && ((a).y1 > (b).y0))
#define NR_RECT_DF_POINT_DF_TEST_INSIDE(r,p) (((p)->x >= (r)->x0) && ((p)->x < (r)->x1) && ((p)->y >= (r)->y0) && ((p)->y < (r)->y1))
#define NR_RECT_LS_POINT_LS_TEST_INSIDE(r,p) (((p)->x >= (r)->x0) && ((p)->x < (r)->x1) && ((p)->y >= (r)->y0) && ((p)->y < (r)->y1))
#define NR_RECT_LS_TEST_INSIDE(r,x,y) ((x >= (r)->x0) && (x < (r)->x1) && (y >= (r)->y0) && (y < (r)->y1))
diff --git a/src/libnr/nr-pixblock-pattern.cpp b/src/libnr/nr-pixblock-pattern.cpp
index 771786584..aa3246297 100644
--- a/src/libnr/nr-pixblock-pattern.cpp
+++ b/src/libnr/nr-pixblock-pattern.cpp
@@ -28,7 +28,7 @@ nr_pixblock_render_gray_noise (NRPixBlock *pb, NRPixBlock *mask)
if (mask) {
if (mask->empty) return;
nr_rect_l_intersect (&clip, &pb->area, &mask->area);
- if (nr_rect_l_test_empty (&clip)) return;
+ if (nr_rect_l_test_empty(clip)) return;
} else {
clip = pb->area;
}
diff --git a/src/libnr/nr-rect-l.cpp b/src/libnr/nr-rect-l.cpp
index 3b00acd03..fa3c687c5 100644
--- a/src/libnr/nr-rect-l.cpp
+++ b/src/libnr/nr-rect-l.cpp
@@ -1,7 +1,7 @@
#include <libnr/nr-rect-l.h>
NR::Maybe<NR::Rect> NRRectL::upgrade() const {
- if (nr_rect_l_test_empty(this)) {
+ if (nr_rect_l_test_empty_ptr(this)) {
return NR::Nothing();
} else {
return NR::Rect(NR::Point(x0, y0), NR::Point(x1, y1));
diff --git a/src/libnr/nr-rect.cpp b/src/libnr/nr-rect.cpp
index a1c8c93b2..04d93ae04 100644
--- a/src/libnr/nr-rect.cpp
+++ b/src/libnr/nr-rect.cpp
@@ -29,7 +29,7 @@ NRRect::NRRect(NR::Maybe<NR::Rect> const &rect) {
}
NR::Maybe<NR::Rect> NRRect::upgrade() const {
- if (nr_rect_d_test_empty(this)) {
+ if (nr_rect_d_test_empty_ptr(this)) {
return NR::Nothing();
} else {
return NR::Rect(NR::Point(x0, y0), NR::Point(x1, y1));
@@ -204,7 +204,7 @@ nr_rect_d_matrix_transform(NRRect *d, NRRect const *const s, NR::Matrix const &m
using NR::X;
using NR::Y;
- if (nr_rect_d_test_empty(s)) {
+ if (nr_rect_d_test_empty_ptr(s)) {
nr_rect_d_set_empty(d);
} else {
NR::Point const c00(NR::Point(s->x0, s->y0) * m);
diff --git a/src/libnr/nr-rect.h b/src/libnr/nr-rect.h
index c61083b4b..da1299b2b 100644
--- a/src/libnr/nr-rect.h
+++ b/src/libnr/nr-rect.h
@@ -268,15 +268,25 @@ struct NRRect {
#define nr_rect_l_set_empty(r) (*(r) = NR_RECT_L_EMPTY)
/** "Empty" here includes the case of zero width or zero height. */
-#define nr_rect_d_test_empty(r) ((r) && NR_RECT_DFLS_TEST_EMPTY(r))
-#define nr_rect_l_test_empty(r) ((r) && NR_RECT_DFLS_TEST_EMPTY(r))
+// TODO convert to static overloaded functions (pointer and ref) once performance can be tested:
+#define nr_rect_d_test_empty_ptr(r) ((r) && NR_RECT_DFLS_TEST_EMPTY(r))
+#define nr_rect_d_test_empty(r) NR_RECT_DFLS_TEST_EMPTY_REF(r)
+
+// TODO convert to static overloaded functions (pointer and ref) once performance can be tested:
+#define nr_rect_l_test_empty_ptr(r) ((r) && NR_RECT_DFLS_TEST_EMPTY(r))
+#define nr_rect_l_test_empty(r) NR_RECT_DFLS_TEST_EMPTY_REF(r)
#define nr_rect_d_test_intersect(r0,r1) \
(!nr_rect_d_test_empty(r0) && !nr_rect_d_test_empty(r1) && \
!((r0) && (r1) && !NR_RECT_DFLS_TEST_INTERSECT(r0, r1)))
+
+// TODO convert to static overloaded functions (pointer and ref) once performance can be tested:
+#define nr_rect_l_test_intersect_ptr(r0,r1) \
+ (!nr_rect_l_test_empty_ptr(r0) && !nr_rect_l_test_empty_ptr(r1) && \
+ !((r0) && (r1) && !NR_RECT_DFLS_TEST_INTERSECT(r0, r1)))
#define nr_rect_l_test_intersect(r0,r1) \
(!nr_rect_l_test_empty(r0) && !nr_rect_l_test_empty(r1) && \
- !((r0) && (r1) && !NR_RECT_DFLS_TEST_INTERSECT(r0, r1)))
+ !(!NR_RECT_DFLS_TEST_INTERSECT_REF(r0, r1)))
#define nr_rect_d_point_d_test_inside(r,p) ((p) && (!(r) || (!NR_RECT_DF_TEST_EMPTY(r) && NR_RECT_DF_POINT_DF_TEST_INSIDE(r,p))))
#define nr_rect_l_point_l_test_inside(r,p) ((p) && (!(r) || (!NR_RECT_DFLS_TEST_EMPTY(r) && NR_RECT_LS_POINT_LS_TEST_INSIDE(r,p))))