summaryrefslogtreecommitdiffstats
path: root/src/libnr
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnr')
-rw-r--r--src/libnr/Makefile_insert72
-rw-r--r--src/libnr/nr-blit.cpp300
-rw-r--r--src/libnr/nr-blit.h32
-rw-r--r--src/libnr/nr-compose-reference.cpp266
-rw-r--r--src/libnr/nr-compose-reference.h69
-rw-r--r--src/libnr/nr-compose-test.h457
-rw-r--r--src/libnr/nr-compose-transform.cpp367
-rw-r--r--src/libnr/nr-compose-transform.h43
-rw-r--r--src/libnr/nr-compose.cpp1197
-rw-r--r--src/libnr/nr-compose.h69
-rw-r--r--src/libnr/nr-convert2geom.h21
-rw-r--r--src/libnr/nr-convex-hull-ops.h29
-rw-r--r--src/libnr/nr-convex-hull.h59
-rw-r--r--src/libnr/nr-gradient.cpp554
-rw-r--r--src/libnr/nr-gradient.h81
-rw-r--r--src/libnr/nr-matrix-div.cpp22
-rw-r--r--src/libnr/nr-matrix-div.h21
-rw-r--r--src/libnr/nr-matrix-fns.cpp55
-rw-r--r--src/libnr/nr-matrix-fns.h53
-rw-r--r--src/libnr/nr-matrix-ops.h41
-rw-r--r--src/libnr/nr-matrix-rotate-ops.cpp18
-rw-r--r--src/libnr/nr-matrix-rotate-ops.h20
-rw-r--r--src/libnr/nr-matrix-scale-ops.h31
-rw-r--r--src/libnr/nr-matrix-test.h191
-rw-r--r--src/libnr/nr-matrix-translate-ops.h37
-rw-r--r--src/libnr/nr-matrix.cpp291
-rw-r--r--src/libnr/nr-matrix.h313
-rw-r--r--src/libnr/nr-maybe.h201
-rw-r--r--src/libnr/nr-path-code.h28
-rw-r--r--src/libnr/nr-pixblock-line.cpp92
-rw-r--r--src/libnr/nr-pixblock-line.h28
-rw-r--r--src/libnr/nr-pixblock-pattern.cpp127
-rw-r--r--src/libnr/nr-pixblock-pattern.h28
-rw-r--r--src/libnr/nr-pixblock-pixel.cpp230
-rw-r--r--src/libnr/nr-pixblock-pixel.h28
-rw-r--r--src/libnr/nr-pixblock.cpp465
-rw-r--r--src/libnr/nr-pixblock.h103
-rw-r--r--src/libnr/nr-pixops.h148
-rw-r--r--src/libnr/nr-point-matrix-ops.h49
-rw-r--r--src/libnr/nr-rect.cpp5
-rw-r--r--src/libnr/nr-rect.h11
-rw-r--r--src/libnr/nr-rotate-fns-test.h54
-rw-r--r--src/libnr/nr-rotate-fns.cpp66
-rw-r--r--src/libnr/nr-rotate-fns.h29
-rw-r--r--src/libnr/nr-rotate-matrix-ops.cpp19
-rw-r--r--src/libnr/nr-rotate-matrix-ops.h21
-rw-r--r--src/libnr/nr-rotate-ops.h43
-rw-r--r--src/libnr/nr-rotate-test.h110
-rw-r--r--src/libnr/nr-rotate.h66
-rw-r--r--src/libnr/nr-scale-matrix-ops.cpp25
-rw-r--r--src/libnr/nr-scale-matrix-ops.h13
-rw-r--r--src/libnr/nr-scale-ops.h40
-rw-r--r--src/libnr/nr-scale-test.h90
-rw-r--r--src/libnr/nr-scale-translate-ops.cpp19
-rw-r--r--src/libnr/nr-scale-translate-ops.h20
-rw-r--r--src/libnr/nr-scale.h55
-rw-r--r--src/libnr/nr-translate-matrix-ops.cpp26
-rw-r--r--src/libnr/nr-translate-matrix-ops.h22
-rw-r--r--src/libnr/nr-translate-ops.h43
-rw-r--r--src/libnr/nr-translate-rotate-ops.cpp20
-rw-r--r--src/libnr/nr-translate-rotate-ops.h21
-rw-r--r--src/libnr/nr-translate-scale-ops.cpp24
-rw-r--r--src/libnr/nr-translate-scale-ops.h20
-rw-r--r--src/libnr/nr-translate-test.h85
-rw-r--r--src/libnr/nr-translate.h34
-rw-r--r--src/libnr/nr-types.h1
-rw-r--r--src/libnr/nr-values.cpp4
-rw-r--r--src/libnr/nr-values.h1
-rw-r--r--src/libnr/testnr.cpp94
69 files changed, 11 insertions, 7306 deletions
diff --git a/src/libnr/Makefile_insert b/src/libnr/Makefile_insert
index 8dd3c46e3..1027e0600 100644
--- a/src/libnr/Makefile_insert
+++ b/src/libnr/Makefile_insert
@@ -2,50 +2,17 @@
ink_common_sources += \
libnr/in-svg-plane.h \
- libnr/nr-blit.cpp \
- libnr/nr-blit.h \
- libnr/nr-compose-transform.cpp \
- libnr/nr-compose-transform.h \
- libnr/nr-compose-reference.h \
- libnr/nr-compose.cpp \
- libnr/nr-compose.h \
libnr/nr-convert2geom.h \
- libnr/nr-convex-hull.h \
libnr/nr-coord.h \
libnr/nr-dim2.h \
libnr/nr-forward.h \
- libnr/nr-gradient.cpp \
- libnr/nr-gradient.h \
libnr/nr-i-coord.h \
libnr/nr-macros.h \
- libnr/nr-matrix-div.cpp \
- libnr/nr-matrix-div.h \
- libnr/nr-matrix-fns.cpp \
- libnr/nr-matrix-fns.h \
- libnr/nr-matrix-ops.h \
- libnr/nr-matrix-rotate-ops.cpp \
- libnr/nr-matrix-rotate-ops.h \
- libnr/nr-matrix-scale-ops.h \
- libnr/nr-matrix-translate-ops.h \
- libnr/nr-matrix.cpp \
- libnr/nr-matrix.h \
- libnr/nr-maybe.h \
libnr/nr-object.cpp \
libnr/nr-object.h \
- libnr/nr-path-code.h \
- libnr/nr-pixblock-line.cpp \
- libnr/nr-pixblock-line.h \
- libnr/nr-pixblock-pattern.cpp \
- libnr/nr-pixblock-pattern.h \
- libnr/nr-pixblock-pixel.cpp \
- libnr/nr-pixblock-pixel.h \
- libnr/nr-pixblock.cpp \
- libnr/nr-pixblock.h \
- libnr/nr-pixops.h \
libnr/nr-point-fns.cpp \
libnr/nr-point-fns.h \
libnr/nr-point-l.h \
- libnr/nr-point-matrix-ops.h \
libnr/nr-point-ops.h \
libnr/nr-point.h \
libnr/nr-rect-l.cpp \
@@ -53,52 +20,15 @@ ink_common_sources += \
libnr/nr-rect.cpp \
libnr/nr-rect.h \
libnr/nr-rect-ops.h \
- libnr/nr-render.h \
- libnr/nr-rotate-fns.cpp \
- libnr/nr-rotate-fns.h \
- libnr/nr-rotate-ops.h \
- libnr/nr-rotate-matrix-ops.cpp \
- libnr/nr-rotate-matrix-ops.h \
- libnr/nr-rotate.h \
- libnr/nr-scale-matrix-ops.cpp \
- libnr/nr-scale-matrix-ops.h \
- libnr/nr-scale-translate-ops.cpp \
- libnr/nr-scale-translate-ops.h \
- libnr/nr-scale-ops.h \
- libnr/nr-scale.h \
- libnr/nr-translate-matrix-ops.cpp \
- libnr/nr-translate-matrix-ops.h \
- libnr/nr-translate-scale-ops.cpp \
- libnr/nr-translate-scale-ops.h \
- libnr/nr-translate-ops.h \
- libnr/nr-translate.h \
- libnr/nr-translate-rotate-ops.cpp \
- libnr/nr-translate-rotate-ops.h \
libnr/nr-types.cpp \
libnr/nr-types.h \
libnr/nr-values.cpp \
- libnr/nr-values.h \
- $(libnr_mmx_sources)
-
-# Ancient performance test (?)
-# Won't work anymore.
-#libnr_testnr_SOURCES = \
-# libnr/testnr.cpp
-
-#libnr_testnr_LDADD = \
-# libnr/libnr.a \
-# -lglib-2.0
+ libnr/nr-values.h
# ######################
# ### CxxTest stuff ####
# ######################
CXXTEST_TESTSUITES += \
$(srcdir)/libnr/in-svg-plane-test.h \
- $(srcdir)/libnr/nr-compose-test.h \
- $(srcdir)/libnr/nr-matrix-test.h \
$(srcdir)/libnr/nr-point-fns-test.h \
- $(srcdir)/libnr/nr-rotate-test.h \
- $(srcdir)/libnr/nr-rotate-fns-test.h \
- $(srcdir)/libnr/nr-scale-test.h \
- $(srcdir)/libnr/nr-translate-test.h \
$(srcdir)/libnr/nr-types-test.h
diff --git a/src/libnr/nr-blit.cpp b/src/libnr/nr-blit.cpp
deleted file mode 100644
index 144caa597..000000000
--- a/src/libnr/nr-blit.cpp
+++ /dev/null
@@ -1,300 +0,0 @@
-#define __NR_BLIT_C__
-
-/*
- * Pixel buffer rendering library
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * This code is in public domain
- */
-
-#include "nr-pixops.h"
-#include "nr-compose.h"
-#include "nr-blit.h"
-
-void
-nr_blit_pixblock_pixblock_alpha (NRPixBlock *d, NRPixBlock *s, unsigned int alpha)
-{
- NRRectL clip;
- unsigned char *dpx, *spx;
- int dbpp, sbpp;
- int w, h;
-
- if (alpha == 0) return;
- if (s->empty) return;
- /* fixme: */
- if (s->mode == NR_PIXBLOCK_MODE_A8) return;
- /* fixme: */
- if (s->mode == NR_PIXBLOCK_MODE_R8G8B8) return;
-
- /*
- * Possible variants as of now:
- *
- * 0. SRC EP - DST EP *
- * 1. SRC EP - DST EN *
- * 2. SRC EP - DST P *
- * 3. SRC EP - DST N *
- * 4. SRC EN - DST EP *
- * 5. SRC EN - DST EN *
- * 6. SRC EN - DST P *
- * 7. SRC EN - DST N *
- * 8. SRC P - DST EP *
- * 9. SRC P - DST EN *
- * A. SRC P - DST P *
- * B. SRC P - DST N *
- * C. SRC N - DST EP *
- * D. SRC N - DST EN *
- * E. SRC N - DST P *
- * F. SRC N - DST N *
- *
- */
-
- nr_rect_l_intersect (&clip, &d->area, &s->area);
-
- if (nr_rect_l_test_empty(clip)) return;
-
- /* Pointers */
- dbpp = NR_PIXBLOCK_BPP (d);
- dpx = NR_PIXBLOCK_PX (d) + (clip.y0 - d->area.y0) * d->rs + dbpp * (clip.x0 - d->area.x0);
- sbpp = NR_PIXBLOCK_BPP (s);
- spx = NR_PIXBLOCK_PX (s) + (clip.y0 - s->area.y0) * s->rs + sbpp * (clip.x0 - s->area.x0);
- w = clip.x1 - clip.x0;
- h = clip.y1 - clip.y0;
-
- switch (d->mode) {
- case NR_PIXBLOCK_MODE_A8:
- /* No rendering into alpha at moment */
- break;
- case NR_PIXBLOCK_MODE_R8G8B8:
- if (s->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) {
- nr_R8G8B8_R8G8B8_R8G8B8A8_P (dpx, w, h, d->rs, spx, s->rs, alpha);
- } else {
- nr_R8G8B8_R8G8B8_R8G8B8A8_N (dpx, w, h, d->rs, spx, s->rs, alpha);
- }
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8P:
- if (d->empty) {
- if (s->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) {
- /* Case 8 */
- nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P (dpx, w, h, d->rs, spx, s->rs, alpha);
- } else {
- /* Case C */
- nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N (dpx, w, h, d->rs, spx, s->rs, alpha);
- }
- } else {
- if (s->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) {
- /* case A */
- nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P (dpx, w, h, d->rs, spx, s->rs, alpha);
- } else {
- /* case E */
- nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N (dpx, w, h, d->rs, spx, s->rs, alpha);
- }
- }
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8N:
- if (d->empty) {
- if (s->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) {
- /* Case 9 */
- nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P (dpx, w, h, d->rs, spx, s->rs, alpha);
- } else {
- /* Case D */
- nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N (dpx, w, h, d->rs, spx, s->rs, alpha);
- }
- } else {
- if (s->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) {
- /* case B */
- nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P (dpx, w, h, d->rs, spx, s->rs, alpha);
- } else {
- /* case F */
- nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N (dpx, w, h, d->rs, spx, s->rs, alpha);
- }
- }
- break;
- }
-}
-
-void
-nr_blit_pixblock_pixblock_mask (NRPixBlock *d, NRPixBlock *s, NRPixBlock *m)
-{
- NRRectL clip;
- unsigned char *dpx, *spx, *mpx;
- int dbpp, sbpp;
- int w, h;
-
- if (s->empty) return;
- /* fixme: */
- if (s->mode == NR_PIXBLOCK_MODE_A8) return;
- /* fixme: */
- if (s->mode == NR_PIXBLOCK_MODE_R8G8B8) return;
-
- /*
- * Possible variants as of now:
- *
- * 0. SRC EP - DST EP *
- * 1. SRC EP - DST EN *
- * 2. SRC EP - DST P *
- * 3. SRC EP - DST N *
- * 4. SRC EN - DST EP *
- * 5. SRC EN - DST EN *
- * 6. SRC EN - DST P *
- * 7. SRC EN - DST N *
- * 8. SRC P - DST EP *
- * 9. SRC P - DST EN *
- * A. SRC P - DST P *
- * B. SRC P - DST N *
- * C. SRC N - DST EP *
- * D. SRC N - DST EN *
- * E. SRC N - DST P *
- * F. SRC N - DST N *
- *
- */
-
- 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;
-
- /* Pointers */
- dbpp = NR_PIXBLOCK_BPP (d);
- dpx = NR_PIXBLOCK_PX (d) + (clip.y0 - d->area.y0) * d->rs + dbpp * (clip.x0 - d->area.x0);
- sbpp = NR_PIXBLOCK_BPP (s);
- spx = NR_PIXBLOCK_PX (s) + (clip.y0 - s->area.y0) * s->rs + sbpp * (clip.x0 - s->area.x0);
- mpx = NR_PIXBLOCK_PX (m) + (clip.y0 - m->area.y0) * m->rs + 1 * (clip.x0 - m->area.x0);
- w = clip.x1 - clip.x0;
- h = clip.y1 - clip.y0;
-
- switch (d->mode) {
- case NR_PIXBLOCK_MODE_A8:
- /* No rendering into alpha at moment */
- break;
- case NR_PIXBLOCK_MODE_R8G8B8:
- if (s->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) {
- nr_R8G8B8_R8G8B8_R8G8B8A8_P_A8 (dpx, w, h, d->rs, spx, s->rs, mpx, m->rs);
- } else {
- nr_R8G8B8_R8G8B8_R8G8B8A8_N_A8 (dpx, w, h, d->rs, spx, s->rs, mpx, m->rs);
- }
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8P:
- if (d->empty) {
- if (s->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) {
- /* Case 8 */
- nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_A8 (dpx, w, h, d->rs, spx, s->rs, mpx, m->rs);
- } else {
- /* Case C */
- nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_A8 (dpx, w, h, d->rs, spx, s->rs, mpx, m->rs);
- }
- } else {
- if (s->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) {
- /* case A */
- nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_A8 (dpx, w, h, d->rs, spx, s->rs, mpx, m->rs);
- } else {
- /* case E */
- nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_A8 (dpx, w, h, d->rs, spx, s->rs, mpx, m->rs);
- }
- }
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8N:
- if (d->empty) {
- if (s->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) {
- /* Case 9 */
- nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_A8 (dpx, w, h, d->rs, spx, s->rs, mpx, m->rs);
- } else {
- /* Case D */
- nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_A8 (dpx, w, h, d->rs, spx, s->rs, mpx, m->rs);
- }
- } else {
- if (s->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) {
- /* case B */
- nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_A8 (dpx, w, h, d->rs, spx, s->rs, mpx, m->rs);
- } else {
- /* case F */
- nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_A8 (dpx, w, h, d->rs, spx, s->rs, mpx, m->rs);
- }
- }
- break;
- }
-}
-
-void
-nr_blit_pixblock_mask_rgba32 (NRPixBlock *d, NRPixBlock *m, unsigned long rgba)
-{
- if (!(rgba & 0xff)) return;
-
- if (m) {
- NRRectL clip;
- unsigned char *dpx, *mpx;
- int w, h;
-
- if (m->mode != NR_PIXBLOCK_MODE_A8) return;
-
- if (!nr_rect_l_test_intersect(d->area, m->area)) return;
-
- nr_rect_l_intersect (&clip, &d->area, &m->area);
-
- /* Pointers */
- dpx = NR_PIXBLOCK_PX (d) + (clip.y0 - d->area.y0) * d->rs + NR_PIXBLOCK_BPP (d) * (clip.x0 - d->area.x0);
- mpx = NR_PIXBLOCK_PX (m) + (clip.y0 - m->area.y0) * m->rs + (clip.x0 - m->area.x0);
- w = clip.x1 - clip.x0;
- h = clip.y1 - clip.y0;
-
- if (d->empty) {
- if (d->mode == NR_PIXBLOCK_MODE_R8G8B8) {
- nr_R8G8B8_R8G8B8_A8_RGBA32 (dpx, w, h, d->rs, mpx, m->rs, rgba);
- } else if (d->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) {
- nr_R8G8B8A8_P_EMPTY_A8_RGBA32 (dpx, w, h, d->rs, mpx, m->rs, rgba);
- } else {
- nr_R8G8B8A8_N_EMPTY_A8_RGBA32 (dpx, w, h, d->rs, mpx, m->rs, rgba);
- }
- d->empty = 0;
- } else {
- if (d->mode == NR_PIXBLOCK_MODE_R8G8B8) {
- nr_R8G8B8_R8G8B8_A8_RGBA32 (dpx, w, h, d->rs, mpx, m->rs, rgba);
- } else if (d->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) {
- nr_R8G8B8A8_P_R8G8B8A8_P_A8_RGBA32 (dpx, w, h, d->rs, mpx, m->rs, rgba);
- } else {
- nr_R8G8B8A8_N_R8G8B8A8_N_A8_RGBA32 (dpx, w, h, d->rs, mpx, m->rs, rgba);
- }
- }
- } else {
- unsigned int r, g, b, a;
- int x, y;
- r = NR_RGBA32_R (rgba);
- g = NR_RGBA32_G (rgba);
- b = NR_RGBA32_B (rgba);
- a = NR_RGBA32_A (rgba);
- for (y = d->area.y0; y < d->area.y1; y++) {
- unsigned char *p;
- p = NR_PIXBLOCK_PX (d) + (y - d->area.y0) * d->rs;
- for (x = d->area.x0; x < d->area.x1; x++) {
- unsigned int da;
- switch (d->mode) {
- case NR_PIXBLOCK_MODE_R8G8B8:
- 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 += 3;
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8P:
- p[0] = NR_COMPOSENPP_1111 (r, a, p[0]);
- p[1] = NR_COMPOSENPP_1111 (g, a, p[1]);
- p[2] = NR_COMPOSENPP_1111 (b, a, p[2]);
- p[3] = NR_COMPOSEA_111(a, p[3]);
- p += 4;
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8N:
- da = NR_COMPOSEA_112(a, p[3]);
- p[0] = NR_COMPOSENNN_111121 (r, a, p[0], p[3], da);
- p[1] = NR_COMPOSENNN_111121 (g, a, p[1], p[3], da);
- p[2] = NR_COMPOSENNN_111121 (b, a, p[2], p[3], da);
- p[3] = NR_NORMALIZE_21(da);
- p += 4;
- break;
- default:
- break;
- }
- }
- }
- }
-}
-
diff --git a/src/libnr/nr-blit.h b/src/libnr/nr-blit.h
deleted file mode 100644
index 9c2def114..000000000
--- a/src/libnr/nr-blit.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef __NR_BLIT_H__
-#define __NR_BLIT_H__
-
-/*
- * Pixel buffer rendering library
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * This code is in public domain
- */
-
-#include <libnr/nr-pixblock.h>
-
-#define nr_blit_pixblock_pixblock(d,s) nr_blit_pixblock_pixblock_alpha (d, s, 255)
-
-void nr_blit_pixblock_pixblock_alpha (NRPixBlock *d, NRPixBlock *s, unsigned int alpha);
-void nr_blit_pixblock_pixblock_mask (NRPixBlock *d, NRPixBlock *s, NRPixBlock *m);
-void nr_blit_pixblock_mask_rgba32 (NRPixBlock *d, NRPixBlock *m, unsigned long rgba32);
-
-#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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-compose-reference.cpp b/src/libnr/nr-compose-reference.cpp
deleted file mode 100644
index b4ff5851a..000000000
--- a/src/libnr/nr-compose-reference.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-
-// This is a reference implementation of the compositing functions in nr-compose.cpp.
-
-#include "nr-compose-reference.h"
-
-#define NR_RGBA32_R(v) (unsigned char) (((v) >> 24) & 0xff)
-#define NR_RGBA32_G(v) (unsigned char) (((v) >> 16) & 0xff)
-#define NR_RGBA32_B(v) (unsigned char) (((v) >> 8) & 0xff)
-#define NR_RGBA32_A(v) (unsigned char) ((v) & 0xff)
-
-static inline unsigned int DIV_ROUND(unsigned int v, unsigned int divisor) { return (v+divisor/2)/divisor; }
-
-static unsigned int pixelSize[] = { 1, 3, 4, 4 };
-
-// Computes :
-// dc' = (1 - alpha*sa) * dc + alpha*sc
-// da' = 1 - (1 - alpha*sa) * (1 - da)
-// Assuming premultiplied color values
-template<PIXEL_FORMAT resultFormat, PIXEL_FORMAT backgroundFormat, PIXEL_FORMAT foregroundFormat>
-static void composePixel(unsigned char *d, const unsigned char *s, unsigned int alpha);
-
-template<> void composePixel<R8G8B8, R8G8B8, R8G8B8A8N>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
- d[0] = DIV_ROUND((255*255 - alpha*s[3]) * d[0] + alpha*s[3]*s[0], 255*255);
- d[1] = DIV_ROUND((255*255 - alpha*s[3]) * d[1] + alpha*s[3]*s[1], 255*255);
- d[2] = DIV_ROUND((255*255 - alpha*s[3]) * d[2] + alpha*s[3]*s[2], 255*255);
-}
-
-template<> void composePixel<R8G8B8, R8G8B8, R8G8B8A8P>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
- d[0] = DIV_ROUND((255*255 - alpha*s[3]) * d[0] + 255*alpha*s[0], 255*255);
- d[1] = DIV_ROUND((255*255 - alpha*s[3]) * d[1] + 255*alpha*s[1], 255*255);
- d[2] = DIV_ROUND((255*255 - alpha*s[3]) * d[2] + 255*alpha*s[2], 255*255);
-}
-
-template<> void composePixel<R8G8B8A8N, EMPTY, R8G8B8A8N>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
- unsigned int newa = 255*255 - (255*255 - alpha*s[3]);
- d[0] = s[0];//newa == 0 ? 0 : DIV_ROUND(alpha*s[3]*s[0], newa);
- d[1] = s[1];//newa == 0 ? 0 : DIV_ROUND(alpha*s[3]*s[1], newa);
- d[2] = s[2];//newa == 0 ? 0 : DIV_ROUND(alpha*s[3]*s[2], newa);
- d[3] = DIV_ROUND(newa, 255);
-}
-
-template<> void composePixel<R8G8B8A8N, EMPTY, R8G8B8A8P>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
- unsigned int newa = 255*255 - (255*255 - alpha*s[3]);
- d[0] = s[3] == 0 ? 0 : DIV_ROUND(255*s[0], s[3]);//newa == 0 ? 0 : DIV_ROUND(255*alpha*s[0], newa);
- d[1] = s[3] == 0 ? 0 : DIV_ROUND(255*s[1], s[3]);//newa == 0 ? 0 : DIV_ROUND(255*alpha*s[1], newa);
- d[2] = s[3] == 0 ? 0 : DIV_ROUND(255*s[2], s[3]);//newa == 0 ? 0 : DIV_ROUND(255*alpha*s[2], newa);
- d[3] = DIV_ROUND(newa, 255);
-}
-
-template<> void composePixel<R8G8B8A8N, R8G8B8A8N, R8G8B8A8N>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
- if ( d[3] == 0 ) {
- composePixel<R8G8B8A8N, EMPTY, R8G8B8A8N>(d, s, alpha);
- } else if ( alpha*s[3] == 0 ) {
- /* NOP */
- } else {
- unsigned int newa = 255*255*255 - (255*255 - alpha*s[3]) * (255 - d[3]);
- d[0] = DIV_ROUND((255*255 - alpha*s[3]) * d[3]*d[0] + 255 * alpha*s[3]*s[0], newa);
- d[1] = DIV_ROUND((255*255 - alpha*s[3]) * d[3]*d[1] + 255 * alpha*s[3]*s[1], newa);
- d[2] = DIV_ROUND((255*255 - alpha*s[3]) * d[3]*d[2] + 255 * alpha*s[3]*s[2], newa);
- d[3] = DIV_ROUND(newa, 255*255);
- }
-}
-
-template<> void composePixel<R8G8B8A8N, R8G8B8A8N, R8G8B8A8P>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
- if ( d[3] == 0 ) {
- composePixel<R8G8B8A8N, EMPTY, R8G8B8A8P>(d, s, alpha);
- } else if ( alpha*s[3] == 0 ) {
- /* NOP */
- } else {
- unsigned int newa = 255*255*255 - (255*255 - alpha*s[3]) * (255 - d[3]);
- d[0] = DIV_ROUND((255*255 - alpha*s[3]) * d[3]*d[0] + 255*255 * alpha*s[0], newa);
- d[1] = DIV_ROUND((255*255 - alpha*s[3]) * d[3]*d[1] + 255*255 * alpha*s[1], newa);
- d[2] = DIV_ROUND((255*255 - alpha*s[3]) * d[3]*d[2] + 255*255 * alpha*s[2], newa);
- d[3] = DIV_ROUND(newa, 255*255);
- }
-}
-
-template<> void composePixel<R8G8B8A8P, EMPTY, R8G8B8A8N>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
- d[0] = DIV_ROUND(alpha*s[3]*s[0], 255*255);
- d[1] = DIV_ROUND(alpha*s[3]*s[1], 255*255);
- d[2] = DIV_ROUND(alpha*s[3]*s[2], 255*255);
- d[3] = DIV_ROUND(255*255 - (255*255 - alpha*s[3]), 255);
-}
-
-template<> void composePixel<R8G8B8A8P, EMPTY, R8G8B8A8P>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
- d[0] = DIV_ROUND(alpha*s[0], 255);
- d[1] = DIV_ROUND(alpha*s[1], 255);
- d[2] = DIV_ROUND(alpha*s[2], 255);
- d[3] = DIV_ROUND(255*255 - (255*255 - alpha*s[3]), 255);
-}
-
-template<> void composePixel<R8G8B8A8P, R8G8B8A8P, R8G8B8A8N>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
- d[0] = DIV_ROUND((255*255 - alpha*s[3]) * d[0] + alpha*s[3]*s[0], 255*255);
- d[1] = DIV_ROUND((255*255 - alpha*s[3]) * d[1] + alpha*s[3]*s[1], 255*255);
- d[2] = DIV_ROUND((255*255 - alpha*s[3]) * d[2] + alpha*s[3]*s[2], 255*255);
- d[3] = DIV_ROUND(255*255*255 - (255*255 - alpha*s[3]) * (255 - d[3]), 255*255);
-}
-
-template<> void composePixel<R8G8B8A8P, R8G8B8A8P, R8G8B8A8P>(unsigned char *d, const unsigned char *s, unsigned int alpha) {
- d[0] = DIV_ROUND((255*255 - alpha*s[3]) * d[0] + 255 * alpha*s[0], 255*255);
- d[1] = DIV_ROUND((255*255 - alpha*s[3]) * d[1] + 255 * alpha*s[1], 255*255);
- d[2] = DIV_ROUND((255*255 - alpha*s[3]) * d[2] + 255 * alpha*s[2], 255*255);
- d[3] = DIV_ROUND(255*255*255 - (255*255 - alpha*s[3]) * (255 - d[3]), 255*255);
-}
-
-
-// composeAlpha, iterates over all pixels and applies composePixel to each of them
-template<PIXEL_FORMAT resultFormat, PIXEL_FORMAT backgroundFormat, PIXEL_FORMAT foregroundFormat>
-static void composeAlpha(unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) {
- for(int y=0; y<h; y++) {
- unsigned char* d = px;
- const unsigned char* s = spx;
- for(int x=0; x<w; x++) {
- composePixel<resultFormat, backgroundFormat, foregroundFormat>(d, s, alpha);
- d += pixelSize[resultFormat];
- s += pixelSize[foregroundFormat];
- }
- px += rs;
- spx += srs;
- }
-}
-
-template<PIXEL_FORMAT resultFormat, PIXEL_FORMAT backgroundFormat, PIXEL_FORMAT foregroundFormat>
-static void composeMask(unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) {
- for(int y=0; y<h; y++) {
- unsigned char* d = px;
- const unsigned char* s = spx;
- const unsigned char* m = mpx;
- for(int x=0; x<w; x++) {
- composePixel<resultFormat, backgroundFormat, foregroundFormat>(d, s, *m);
- d += pixelSize[resultFormat];
- s += pixelSize[foregroundFormat];
- m += 1;
- }
- px += rs;
- spx += srs;
- mpx += mrs;
- }
-}
-
-template<PIXEL_FORMAT resultFormat, PIXEL_FORMAT backgroundFormat>
-static void composeColor(unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba) {
- const unsigned char rgba_array[4] = {NR_RGBA32_R(rgba), NR_RGBA32_G(rgba), NR_RGBA32_B(rgba), NR_RGBA32_A(rgba)};
- for(int y=0; y<h; y++) {
- unsigned char* d = px;
- const unsigned char* m = mpx;
- for(int x=0; x<w; x++) {
- composePixel<resultFormat, backgroundFormat, R8G8B8A8N>(d, rgba_array, *m);
- d += pixelSize[resultFormat];
- m += 1;
- }
- px += rs;
- mpx += mrs;
- }
-}
-
-/* FINAL DST SRC */
-
-void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) {
- composeAlpha<R8G8B8A8N, EMPTY, R8G8B8A8N>(px, w, h, rs, spx, srs, alpha);
-}
-
-void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) {
- composeAlpha<R8G8B8A8N, EMPTY, R8G8B8A8P>(px, w, h, rs, spx, srs, alpha);
-}
-
-void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) {
- composeAlpha<R8G8B8A8P, EMPTY, R8G8B8A8N>(px, w, h, rs, spx, srs, alpha);
-}
-
-void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) {
- composeAlpha<R8G8B8A8P, EMPTY, R8G8B8A8P>(px, w, h, rs, spx, srs, alpha);
-}
-
-
-void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) {
- composeAlpha<R8G8B8A8N, R8G8B8A8N, R8G8B8A8N>(px, w, h, rs, spx, srs, alpha);
-}
-
-void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) {
- composeAlpha<R8G8B8A8N, R8G8B8A8N, R8G8B8A8P>(px, w, h, rs, spx, srs, alpha);
-}
-
-void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) {
- composeAlpha<R8G8B8A8P, R8G8B8A8P, R8G8B8A8N>(px, w, h, rs, spx, srs, alpha);
-}
-
-void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) {
- composeAlpha<R8G8B8A8P, R8G8B8A8P, R8G8B8A8P>(px, w, h, rs, spx, srs, alpha);
-}
-
-/* FINAL DST SRC MASK */
-
-void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_A8_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) {
- composeMask<R8G8B8A8N, EMPTY, R8G8B8A8N>(px, w, h, rs, spx, srs, mpx, mrs);
-}
-
-void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_A8_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) {
- composeMask<R8G8B8A8N, EMPTY, R8G8B8A8P>(px, w, h, rs, spx, srs, mpx, mrs);
-}
-
-void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_A8_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) {
- composeMask<R8G8B8A8P, EMPTY, R8G8B8A8N>(px, w, h, rs, spx, srs, mpx, mrs);
-}
-
-void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_A8_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) {
- composeMask<R8G8B8A8P, EMPTY, R8G8B8A8P>(px, w, h, rs, spx, srs, mpx, mrs);
-}
-
-
-void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_A8_ref (unsigned char *p, int w, int h, int rs, const unsigned char *s, int srs, const unsigned char *m, int mrs) {
- composeMask<R8G8B8A8N, R8G8B8A8N, R8G8B8A8N>(p, w, h, rs, s, srs, m, mrs);
-}
-
-void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_A8_ref (unsigned char *p, int w, int h, int rs, const unsigned char *s, int srs, const unsigned char *m, int mrs) {
- composeMask<R8G8B8A8N, R8G8B8A8N, R8G8B8A8P>(p, w, h, rs, s, srs, m, mrs);
-}
-
-void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_A8_ref (unsigned char *p, int w, int h, int rs, const unsigned char *s, int srs, const unsigned char *m, int mrs) {
- composeMask<R8G8B8A8P, R8G8B8A8P, R8G8B8A8N>(p, w, h, rs, s, srs, m, mrs);
-}
-
-void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_A8_ref (unsigned char *p, int w, int h, int rs, const unsigned char *s, int srs, const unsigned char *m, int mrs) {
- composeMask<R8G8B8A8P, R8G8B8A8P, R8G8B8A8P>(p, w, h, rs, s, srs, m, mrs);
-}
-
-/* FINAL DST MASK COLOR */
-
-void nr_R8G8B8A8_N_EMPTY_A8_RGBA32_ref (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba) {
- composeColor<R8G8B8A8N, EMPTY>(px, w, h, rs, mpx, mrs, rgba);
-}
-
-void nr_R8G8B8A8_P_EMPTY_A8_RGBA32_ref (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba) {
- composeColor<R8G8B8A8P, EMPTY>(px, w, h, rs, mpx, mrs, rgba);
-}
-
-
-void nr_R8G8B8_R8G8B8_A8_RGBA32_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned long rgba) {
- composeColor<R8G8B8, R8G8B8>(px, w, h, rs, spx, srs, rgba);
-}
-
-void nr_R8G8B8A8_N_R8G8B8A8_N_A8_RGBA32_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned long rgba) {
- composeColor<R8G8B8A8N, R8G8B8A8N>(px, w, h, rs, spx, srs, rgba);
-}
-
-void nr_R8G8B8A8_P_R8G8B8A8_P_A8_RGBA32_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned long rgba) {
- composeColor<R8G8B8A8P, R8G8B8A8P>(px, w, h, rs, spx, srs, rgba);
-}
-
-/* RGB */
-
-void nr_R8G8B8_R8G8B8_R8G8B8A8_P_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) {
- composeAlpha<R8G8B8, R8G8B8, R8G8B8A8P>(px, w, h, rs, spx, srs, alpha);
-}
-
-void nr_R8G8B8_R8G8B8_R8G8B8A8_N_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) {
- composeAlpha<R8G8B8, R8G8B8, R8G8B8A8N>(px, w, h, rs, spx, srs, alpha);
-}
-
-void nr_R8G8B8_R8G8B8_R8G8B8A8_P_A8_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) {
- composeMask<R8G8B8, R8G8B8, R8G8B8A8P>(px, w, h, rs, spx, srs, mpx, mrs);
-}
-
-void nr_R8G8B8_R8G8B8_R8G8B8A8_N_A8_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) {
- composeMask<R8G8B8, R8G8B8, R8G8B8A8N>(px, w, h, rs, spx, srs, mpx, mrs);
-}
diff --git a/src/libnr/nr-compose-reference.h b/src/libnr/nr-compose-reference.h
deleted file mode 100644
index 8d004a135..000000000
--- a/src/libnr/nr-compose-reference.h
+++ /dev/null
@@ -1,69 +0,0 @@
-#ifndef __NR_COMPOSE_REFERENCE_H__
-#define __NR_COMPOSE_REFERENCE_H__
-
-// Based on nr-pixblock.h
-typedef enum {
- A8 = 0,
- R8G8B8,
- R8G8B8A8N,
- R8G8B8A8P,
- EMPTY = -1
-} PIXEL_FORMAT;
-
-/* FINAL DST SRC */
-
-void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha);
-void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha);
-void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha);
-void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha);
-
-void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha);
-void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha);
-void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha);
-void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha);
-
-/* FINAL DST SRC MASK */
-
-void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_A8_ref (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int srs,
- const unsigned char *mpx, int mrs);
-void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_A8_ref (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int srs,
- const unsigned char *mpx, int mrs);
-void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_A8_ref (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int srs,
- const unsigned char *mpx, int mrs);
-void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_A8_ref (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int srs,
- const unsigned char *mpx, int mrs);
-
-void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_A8_ref (unsigned char *p, int w, int h, int rs,
- const unsigned char *s, int srs,
- const unsigned char *m, int mrs);
-void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_A8_ref (unsigned char *p, int w, int h, int rs,
- const unsigned char *s, int srs,
- const unsigned char *m, int mrs);
-void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_A8_ref (unsigned char *p, int w, int h, int rs,
- const unsigned char *s, int srs,
- const unsigned char *m, int mrs);
-void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_A8_ref (unsigned char *p, int w, int h, int rs,
- const unsigned char *s, int srs,
- const unsigned char *m, int mrs);
-
-/* FINAL DST MASK COLOR */
-
-void nr_R8G8B8A8_N_EMPTY_A8_RGBA32_ref (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba);
-void nr_R8G8B8A8_P_EMPTY_A8_RGBA32_ref (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba);
-
-void nr_R8G8B8_R8G8B8_A8_RGBA32_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned long rgba);
-void nr_R8G8B8A8_N_R8G8B8A8_N_A8_RGBA32_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned long rgba);
-void nr_R8G8B8A8_P_R8G8B8A8_P_A8_RGBA32_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned long rgba);
-
-/* RGB */
-
-void nr_R8G8B8_R8G8B8_R8G8B8A8_P_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha);
-void nr_R8G8B8_R8G8B8_R8G8B8A8_N_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha);
-void nr_R8G8B8_R8G8B8_R8G8B8A8_P_A8_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs);
-void nr_R8G8B8_R8G8B8_R8G8B8A8_N_A8_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs);
-
-#endif//__NR_COMPOSE_REFERENCE_H__
diff --git a/src/libnr/nr-compose-test.h b/src/libnr/nr-compose-test.h
deleted file mode 100644
index 2164e1bf4..000000000
--- a/src/libnr/nr-compose-test.h
+++ /dev/null
@@ -1,457 +0,0 @@
-
-#include <cxxtest/TestSuite.h>
-
-#include "nr-compose.h"
-#include "nr-compose-reference.h"
-#include <glib.h>
-#include <memory.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-static inline unsigned int DIV_ROUND(unsigned int v, unsigned int divisor) { return (v+divisor/2)/divisor; }
-static inline unsigned char NR_PREMUL_111(unsigned int c, unsigned int a) { return static_cast<unsigned char>(DIV_ROUND(c*a, 255)); }
-
-template<PIXEL_FORMAT format>
-int IMGCMP(const unsigned char* a, const unsigned char* b, size_t n) { return memcmp(a, b, n); }
-
-template<>
-int IMGCMP<R8G8B8A8N>(const unsigned char* a, const unsigned char* b, size_t n)
-{
- // If two pixels each have their alpha channel set to zero they're equivalent
- // Note that this doesn't work for premultiplied values, as their color values should
- // be zero when alpha is zero.
- int cr = 0;
- while(n && cr == 0) {
- if ( a[3] != 0 || b[3] != 0 ) {
- cr = memcmp(a, b, 4);
- }
- a+=4;
- b+=4;
- n-=4;
- }
- return cr;
-}
-
-class NrComposeTest : public CxxTest::TestSuite {
-private:
- int const w, h;
-
- unsigned char* const dst_rgba_n_org;
- unsigned char* const dst_rgba_p_org;
- unsigned char* const dst_rgb_org;
-
- unsigned char* const dst1_rgba;
- unsigned char* const dst2_rgba;
- unsigned char* const src_rgba_n;
- unsigned char* const src_rgba_p;
- unsigned char* const dst1_rgb;
- unsigned char* const dst2_rgb;
- unsigned char* const src_rgb;
- unsigned char* const mask;
-
- static unsigned int const alpha_vals[7];
- static unsigned int const rgb_vals[3];
-
-public:
- NrComposeTest() :
- w(13),
- h(5),
-
- dst_rgba_n_org(new unsigned char[w*h*4]),
- dst_rgba_p_org(new unsigned char[w*h*4]),
- dst_rgb_org(new unsigned char[w*h*3]),
-
- dst1_rgba(new unsigned char[w*h*4]),
- dst2_rgba(new unsigned char[w*h*4]),
- src_rgba_n(new unsigned char[w*h*4]),
- src_rgba_p(new unsigned char[w*h*4]),
- dst1_rgb(new unsigned char[w*h*3]),
- dst2_rgb(new unsigned char[w*h*3]),
- src_rgb(new unsigned char[w*h*3]),
- mask(new unsigned char[w*h])
- {
- srand(23874683); // It shouldn't really matter what this is, as long as it's always the same (to be reproducible)
-
- for(int y=0; y<h; y++) {
- for(int x=0; x<w; x++) {
- dst_rgba_n_org[(x+y*w)*4+3] = 255*rand()/RAND_MAX;
- dst_rgba_p_org[(x+y*w)*4+3] = 255*rand()/RAND_MAX;
- src_rgba_n[(x+y*w)*4+3] = 255*rand()/RAND_MAX;
- src_rgba_p[(x+y*w)*4+3] = 255*rand()/RAND_MAX;
- for(int i=0; i<3; i++) {
- dst_rgba_n_org[(x+y*w)*4+i] = 255*rand()/RAND_MAX;
- dst_rgba_p_org[(x+y*w)*4+i] = NR_PREMUL_111(255*rand()/RAND_MAX, dst_rgba_p_org[(x+y*w)*4+3]);
- src_rgba_n[(x+y*w)*4+i] = 255*rand()/RAND_MAX;
- src_rgba_p[(x+y*w)*4+i] = NR_PREMUL_111(255*rand()/RAND_MAX, src_rgba_p[(x+y*w)*4+3]);
- dst_rgb_org[(x+y*w)*3+i] = 255*rand()/RAND_MAX;
- }
- mask[x+y*w] = 255*rand()/RAND_MAX;
- }
- }
- }
- virtual ~NrComposeTest()
- {
- delete[] dst_rgba_n_org;
- delete[] dst_rgba_p_org;
- delete[] dst_rgb_org;
-
- delete[] dst1_rgba;
- delete[] dst2_rgba;
- delete[] src_rgba_n;
- delete[] src_rgba_p;
- delete[] dst1_rgb;
- delete[] dst2_rgb;
- delete[] src_rgb;
- delete[] mask;
- }
-
-// createSuite and destroySuite get us per-suite setup and teardown
-// without us having to worry about static initialization order, etc.
- static NrComposeTest *createSuite() { return new NrComposeTest(); }
- static void destroySuite( NrComposeTest *suite ) { delete suite; }
-
- // FINAL DST SRC
-
- void testnr_R8G8B8A8_N_EMPTY_R8G8B8A8_N()
- {
- for(size_t i=0; i<G_N_ELEMENTS(alpha_vals); i++) {
- unsigned int alpha = alpha_vals[i];
- char msg[40];
- sprintf(msg, "alpha = %u", alpha);
- memcpy(dst1_rgba, dst_rgba_n_org, w*h*4);
- memcpy(dst2_rgba, dst_rgba_n_org, w*h*4);
- nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N(dst1_rgba, w, h, w*4, src_rgba_n, w*4, alpha);
- nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_ref(dst2_rgba, w, h, w*4, src_rgba_n, w*4, alpha);
- TSM_ASSERT(msg, IMGCMP<R8G8B8A8N>(dst1_rgba, dst2_rgba, w*h*4) == 0 );
- }
- }
-
- void testnr_R8G8B8A8_N_EMPTY_R8G8B8A8_P()
- {
- for(size_t i=0; i<G_N_ELEMENTS(alpha_vals); i++) {
- unsigned int alpha = alpha_vals[i];
- char msg[40];
- sprintf(msg, "alpha = %u", alpha);
- memcpy(dst1_rgba, dst_rgba_n_org, w*h*4);
- memcpy(dst2_rgba, dst_rgba_n_org, w*h*4);
- nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P(dst1_rgba, w, h, w*4, src_rgba_p, w*4, alpha);
- nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_ref(dst2_rgba, w, h, w*4, src_rgba_p, w*4, alpha);
- TSM_ASSERT(msg, IMGCMP<R8G8B8A8N>(dst1_rgba, dst2_rgba, w*h*4) == 0 );
- }
- }
-
- void testnr_R8G8B8A8_P_EMPTY_R8G8B8A8_N()
- {
- for(size_t i=0; i<G_N_ELEMENTS(alpha_vals); i++) {
- unsigned int alpha = alpha_vals[i];
- char msg[40];
- sprintf(msg, "alpha = %u", alpha);
- memcpy(dst1_rgba, dst_rgba_p_org, w*h*4);
- memcpy(dst2_rgba, dst_rgba_p_org, w*h*4);
- nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N(dst1_rgba, w, h, w*4, src_rgba_n, w*4, alpha);
- nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_ref(dst2_rgba, w, h, w*4, src_rgba_n, w*4, alpha);
- TSM_ASSERT(msg, IMGCMP<R8G8B8A8P>(dst1_rgba, dst2_rgba, w*h*4) == 0 );
- }
- }
-
- void testnr_R8G8B8A8_P_EMPTY_R8G8B8A8_P()
- {
- for(size_t i=0; i<G_N_ELEMENTS(alpha_vals); i++) {
- unsigned int alpha = alpha_vals[i];
- char msg[40];
- sprintf(msg, "alpha = %u", alpha);
- memcpy(dst1_rgba, dst_rgba_p_org, w*h*4);
- memcpy(dst2_rgba, dst_rgba_p_org, w*h*4);
- nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P(dst1_rgba, w, h, w*4, src_rgba_p, w*4, alpha);
- nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_ref(dst2_rgba, w, h, w*4, src_rgba_p, w*4, alpha);
- TSM_ASSERT(msg, IMGCMP<R8G8B8A8P>(dst1_rgba, dst2_rgba, w*h*4) == 0 );
- }
- }
-
- void testnr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N()
- {
- for(size_t i=0; i<G_N_ELEMENTS(alpha_vals); i++) {
- unsigned int alpha = alpha_vals[i];
- char msg[40];
- sprintf(msg, "alpha = %u", alpha);
- memcpy(dst1_rgba, dst_rgba_n_org, w*h*4);
- memcpy(dst2_rgba, dst_rgba_n_org, w*h*4);
- nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N(dst1_rgba, w, h, w*4, src_rgba_n, w*4, alpha);
- nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_ref(dst2_rgba, w, h, w*4, src_rgba_n, w*4, alpha);
- TSM_ASSERT(msg, IMGCMP<R8G8B8A8N>(dst1_rgba, dst2_rgba, w*h*4) == 0 );
- }
- }
-
- void testnr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P()
- {
- for(size_t i=0; i<G_N_ELEMENTS(alpha_vals); i++) {
- unsigned int alpha = alpha_vals[i];
- char msg[40];
- sprintf(msg, "alpha = %u", alpha);
- memcpy(dst1_rgba, dst_rgba_n_org, w*h*4);
- memcpy(dst2_rgba, dst_rgba_n_org, w*h*4);
- nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P(dst1_rgba, w, h, w*4, src_rgba_p, w*4, alpha);
- nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_ref(dst2_rgba, w, h, w*4, src_rgba_p, w*4, alpha);
- TSM_ASSERT(msg, IMGCMP<R8G8B8A8N>(dst1_rgba, dst2_rgba, w*h*4) == 0 );
- }
- }
-
- void testnr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N()
- {
- for(size_t i=0; i<G_N_ELEMENTS(alpha_vals); i++) {
- unsigned int alpha = alpha_vals[i];
- char msg[40];
- sprintf(msg, "alpha = %u", alpha);
- memcpy(dst1_rgba, dst_rgba_p_org, w*h*4);
- memcpy(dst2_rgba, dst_rgba_p_org, w*h*4);
- nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N(dst1_rgba, w, h, w*4, src_rgba_n, w*4, alpha);
- nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_ref(dst2_rgba, w, h, w*4, src_rgba_n, w*4, alpha);
- TSM_ASSERT(msg, IMGCMP<R8G8B8A8P>(dst1_rgba, dst2_rgba, w*h*4) == 0 );
- }
- }
-
- void testnr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P()
- {
- for(size_t i=0; i<G_N_ELEMENTS(alpha_vals); i++) {
- unsigned int alpha = alpha_vals[i];
- char msg[40];
- sprintf(msg, "alpha = %u", alpha);
- memcpy(dst1_rgba, dst_rgba_p_org, w*h*4);
- memcpy(dst2_rgba, dst_rgba_p_org, w*h*4);
- nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P(dst1_rgba, w, h, w*4, src_rgba_p, w*4, alpha);
- nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_ref(dst2_rgba, w, h, w*4, src_rgba_p, w*4, alpha);
- TSM_ASSERT(msg, IMGCMP<R8G8B8A8P>(dst1_rgba, dst2_rgba, w*h*4) == 0 );
- }
- }
-
- // FINAL DST SRC MASK
-
- void testnr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_A8()
- {
- memcpy(dst1_rgba, dst_rgba_n_org, w*h*4);
- memcpy(dst2_rgba, dst_rgba_n_org, w*h*4);
- nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_A8(dst1_rgba, w, h, w*4, src_rgba_n, w*4, mask, w);
- nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_A8_ref(dst2_rgba, w, h, w*4, src_rgba_n, w*4, mask, w);
- TS_ASSERT( IMGCMP<R8G8B8A8N>(dst1_rgba, dst2_rgba, w*h*4) == 0 );
- }
-
- void testnr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_A8()
- {
- memcpy(dst1_rgba, dst_rgba_n_org, w*h*4);
- memcpy(dst2_rgba, dst_rgba_n_org, w*h*4);
- nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_A8(dst1_rgba, w, h, w*4, src_rgba_p, w*4, mask, w);
- nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_A8_ref(dst2_rgba, w, h, w*4, src_rgba_p, w*4, mask, w);
- TS_ASSERT( IMGCMP<R8G8B8A8N>(dst1_rgba, dst2_rgba, w*h*4) == 0 );
- }
-
- void testnr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_A8()
- {
- memcpy(dst1_rgba, dst_rgba_p_org, w*h*4);
- memcpy(dst2_rgba, dst_rgba_p_org, w*h*4);
- nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_A8(dst1_rgba, w, h, w*4, src_rgba_n, w*4, mask, w);
- nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_A8_ref(dst2_rgba, w, h, w*4, src_rgba_n, w*4, mask, w);
- TS_ASSERT( IMGCMP<R8G8B8A8P>(dst1_rgba, dst2_rgba, w*h*4) == 0 );
- }
-
- void testnr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_A8()
- {
- memcpy(dst1_rgba, dst_rgba_p_org, w*h*4);
- memcpy(dst2_rgba, dst_rgba_p_org, w*h*4);
- nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_A8(dst1_rgba, w, h, w*4, src_rgba_p, w*4, mask, w);
- nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_A8_ref(dst2_rgba, w, h, w*4, src_rgba_p, w*4, mask, w);
- TS_ASSERT( IMGCMP<R8G8B8A8P>(dst1_rgba, dst2_rgba, w*h*4) == 0 );
- }
-
- void testnr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_A8()
- {
- memcpy(dst1_rgba, dst_rgba_n_org, w*h*4);
- memcpy(dst2_rgba, dst_rgba_n_org, w*h*4);
- nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_A8(dst1_rgba, w, h, w*4, src_rgba_n, w*4, mask, w);
- nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_A8_ref(dst2_rgba, w, h, w*4, src_rgba_n, w*4, mask, w);
- TS_ASSERT( IMGCMP<R8G8B8A8N>(dst1_rgba, dst2_rgba, w*h*4) == 0 );
- }
-
- void testnr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_A8()
- {
- memcpy(dst1_rgba, dst_rgba_n_org, w*h*4);
- memcpy(dst2_rgba, dst_rgba_n_org, w*h*4);
- nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_A8(dst1_rgba, w, h, w*4, src_rgba_p, w*4, mask, w);
- nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_A8_ref(dst2_rgba, w, h, w*4, src_rgba_p, w*4, mask, w);
- TS_ASSERT( IMGCMP<R8G8B8A8N>(dst1_rgba, dst2_rgba, w*h*4) == 0 );
- }
-
- void testnr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_A8()
- {
- memcpy(dst1_rgba, dst_rgba_p_org, w*h*4);
- memcpy(dst2_rgba, dst_rgba_p_org, w*h*4);
- nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_A8(dst1_rgba, w, h, w*4, src_rgba_n, w*4, mask, w);
- nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_A8_ref(dst2_rgba, w, h, w*4, src_rgba_n, w*4, mask, w);
- TS_ASSERT( IMGCMP<R8G8B8A8P>(dst1_rgba, dst2_rgba, w*h*4) == 0 );
- }
-
- void testnr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_A8()
- {
- memcpy(dst1_rgba, dst_rgba_p_org, w*h*4);
- memcpy(dst2_rgba, dst_rgba_p_org, w*h*4);
- nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_A8(dst1_rgba, w, h, w*4, src_rgba_p, w*4, mask, w);
- nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_A8_ref(dst2_rgba, w, h, w*4, src_rgba_p, w*4, mask, w);
- TS_ASSERT( IMGCMP<R8G8B8A8P>(dst1_rgba, dst2_rgba, w*h*4) == 0 );
- }
-
- // FINAL DST MASK COLOR
-
- void testnr_R8G8B8A8_N_EMPTY_A8_RGBA32()
- {
- for(size_t j=0; j<G_N_ELEMENTS(rgb_vals); j++) {
- for(size_t i=0; i<G_N_ELEMENTS(alpha_vals); i++) {
- unsigned int rgba = rgb_vals[j]+alpha_vals[i];
- char msg[100];
- sprintf(msg, "color = (%u,%u,%u,%u)", (rgba>>24u)&0xff, (rgba>>16u)&0xff, (rgba>>8u)&0xff, rgba&0xff);
- memcpy(dst1_rgba, dst_rgba_n_org, w*h*4);
- memcpy(dst2_rgba, dst_rgba_n_org, w*h*4);
- nr_R8G8B8A8_N_EMPTY_A8_RGBA32(dst1_rgba, w, h, w*4, mask, w, rgba);
- nr_R8G8B8A8_N_EMPTY_A8_RGBA32_ref(dst2_rgba, w, h, w*4, mask, w, rgba);
- TSM_ASSERT(msg, IMGCMP<R8G8B8A8N>(dst1_rgba, dst2_rgba, w*h*4) == 0 );
- }
- }
- }
-
- void testnr_R8G8B8A8_P_EMPTY_A8_RGBA32()
- {
- for(size_t j=0; j<G_N_ELEMENTS(rgb_vals); j++) {
- for(size_t i=0; i<G_N_ELEMENTS(alpha_vals); i++) {
- unsigned int rgba = rgb_vals[j]+alpha_vals[i];
- char msg[100];
- sprintf(msg, "color = (%u,%u,%u,%u)", (rgba>>24u)&0xff, (rgba>>16u)&0xff, (rgba>>8u)&0xff, rgba&0xff);
- memcpy(dst1_rgba, dst_rgba_p_org, w*h*4);
- memcpy(dst2_rgba, dst_rgba_p_org, w*h*4);
- nr_R8G8B8A8_P_EMPTY_A8_RGBA32(dst1_rgba, w, h, w*4, mask, w, rgba);
- nr_R8G8B8A8_P_EMPTY_A8_RGBA32_ref(dst2_rgba, w, h, w*4, mask, w, rgba);
- TSM_ASSERT(msg, IMGCMP<R8G8B8A8P>(dst1_rgba, dst2_rgba, w*h*4) == 0 );
- }
- }
- }
-
- void testnr_R8G8B8_R8G8B8_A8_RGBA32()
- {
- for(size_t j=0; j<G_N_ELEMENTS(rgb_vals); j++) {
- for(size_t i=0; i<G_N_ELEMENTS(alpha_vals); i++) {
- unsigned int rgba = rgb_vals[j]+alpha_vals[i];
- char msg[100];
- sprintf(msg, "color = (%u,%u,%u,%u)", (rgba>>24u)&0xff, (rgba>>16u)&0xff, (rgba>>8u)&0xff, rgba&0xff);
- memcpy(dst1_rgb, dst_rgb_org, w*h*3);
- memcpy(dst2_rgb, dst_rgb_org, w*h*3);
- nr_R8G8B8_R8G8B8_A8_RGBA32(dst1_rgb, w, h, w*3, mask, w, rgba);
- nr_R8G8B8_R8G8B8_A8_RGBA32_ref(dst2_rgb, w, h, w*3, mask, w, rgba);
- TSM_ASSERT(msg, IMGCMP<R8G8B8>(dst1_rgb, dst2_rgb, w*h*3) == 0 );
- }
- }
- }
-
- void testnr_R8G8B8A8_N_R8G8B8A8_N_A8_RGBA32()
- {
- for(size_t j=0; j<G_N_ELEMENTS(rgb_vals); j++) {
- for(size_t i=0; i<G_N_ELEMENTS(alpha_vals); i++) {
- unsigned int rgba = rgb_vals[j]+alpha_vals[i];
- char msg[100];
- sprintf(msg, "color = (%u,%u,%u,%u)", (rgba>>24u)&0xff, (rgba>>16u)&0xff, (rgba>>8u)&0xff, rgba&0xff);
- memcpy(dst1_rgba, dst_rgba_n_org, w*h*4);
- memcpy(dst2_rgba, dst_rgba_n_org, w*h*4);
- nr_R8G8B8A8_N_R8G8B8A8_N_A8_RGBA32(dst1_rgba, w, h, w*4, mask, w, rgba);
- nr_R8G8B8A8_N_R8G8B8A8_N_A8_RGBA32_ref(dst2_rgba, w, h, w*4, mask, w, rgba);
- TSM_ASSERT(msg, IMGCMP<R8G8B8A8N>(dst1_rgba, dst2_rgba, w*h*4) == 0 );
- }
- }
- }
-
- void testnr_R8G8B8A8_P_R8G8B8A8_P_A8_RGBA32()
- {
- for(size_t j=0; j<G_N_ELEMENTS(rgb_vals); j++) {
- for(size_t i=0; i<G_N_ELEMENTS(alpha_vals); i++) {
- unsigned int rgba = rgb_vals[j]+alpha_vals[i];
- char msg[100];
- sprintf(msg, "color = (%u,%u,%u,%u)", (rgba>>24u)&0xff, (rgba>>16u)&0xff, (rgba>>8u)&0xff, rgba&0xff);
- memcpy(dst1_rgba, dst_rgba_p_org, w*h*4);
- memcpy(dst2_rgba, dst_rgba_p_org, w*h*4);
- nr_R8G8B8A8_P_R8G8B8A8_P_A8_RGBA32(dst1_rgba, w, h, w*4, mask, w, rgba);
- nr_R8G8B8A8_P_R8G8B8A8_P_A8_RGBA32_ref(dst2_rgba, w, h, w*4, mask, w, rgba);
- TSM_ASSERT(msg, IMGCMP<R8G8B8A8P>(dst1_rgba, dst2_rgba, w*h*4) == 0 );
- }
- }
- }
-
- // RGB
-
- void testnr_R8G8B8_R8G8B8_R8G8B8A8_N()
- {
- for(size_t i=0; i<G_N_ELEMENTS(alpha_vals); i++) {
- unsigned int alpha = alpha_vals[i];
- char msg[40];
- sprintf(msg, "alpha = %u", alpha);
- memcpy(dst1_rgb, dst_rgb_org, w*h*3);
- memcpy(dst2_rgb, dst_rgb_org, w*h*3);
- nr_R8G8B8_R8G8B8_R8G8B8A8_N(dst1_rgb, w, h, w*3, src_rgba_n, w*4, alpha);
- nr_R8G8B8_R8G8B8_R8G8B8A8_N_ref(dst2_rgb, w, h, w*3, src_rgba_n, w*4, alpha);
- TSM_ASSERT(msg, IMGCMP<R8G8B8>(dst1_rgb, dst2_rgb, w*h*3) == 0 );
- }
- }
-
- void testnr_R8G8B8_R8G8B8_R8G8B8A8_P()
- {
- for(size_t i=0; i<G_N_ELEMENTS(alpha_vals); i++) {
- unsigned int alpha = alpha_vals[i];
- char msg[40];
- sprintf(msg, "alpha = %u", alpha);
- memcpy(dst1_rgb, dst_rgb_org, w*h*3);
- memcpy(dst2_rgb, dst_rgb_org, w*h*3);
- nr_R8G8B8_R8G8B8_R8G8B8A8_P(dst1_rgb, w, h, w*3, src_rgba_p, w*4, alpha);
- nr_R8G8B8_R8G8B8_R8G8B8A8_P_ref(dst2_rgb, w, h, w*3, src_rgba_p, w*4, alpha);
- TSM_ASSERT(msg, IMGCMP<R8G8B8>(dst1_rgb, dst2_rgb, w*h*3) == 0 );
- }
- }
-
- void testnr_R8G8B8_R8G8B8_R8G8B8A8_N_A8()
- {
- for(size_t i=0; i<G_N_ELEMENTS(alpha_vals); i++) {
- unsigned int alpha = alpha_vals[i];
- char msg[40];
- sprintf(msg, "alpha = %u", alpha);
- memcpy(dst1_rgb, dst_rgb_org, w*h*3);
- memcpy(dst2_rgb, dst_rgb_org, w*h*3);
- nr_R8G8B8_R8G8B8_R8G8B8A8_N_A8(dst1_rgb, w, h, w*3, src_rgba_n, w*4, mask, w);
- nr_R8G8B8_R8G8B8_R8G8B8A8_N_A8_ref(dst2_rgb, w, h, w*3, src_rgba_n, w*4, mask, w);
- TSM_ASSERT(msg, IMGCMP<R8G8B8>(dst1_rgb, dst2_rgb, w*h*3) == 0 );
- }
- }
-
- void testnr_R8G8B8_R8G8B8_R8G8B8A8_P_A8()
- {
- for(size_t i=0; i<G_N_ELEMENTS(alpha_vals); i++) {
- unsigned int alpha = alpha_vals[i];
- char msg[40];
- sprintf(msg, "alpha = %u", alpha);
- memcpy(dst1_rgb, dst_rgb_org, w*h*3);
- memcpy(dst2_rgb, dst_rgb_org, w*h*3);
- nr_R8G8B8_R8G8B8_R8G8B8A8_P_A8(dst1_rgb, w, h, w*3, src_rgba_p, w*4, mask, w);
- nr_R8G8B8_R8G8B8_R8G8B8A8_P_A8_ref(dst2_rgb, w, h, w*3, src_rgba_p, w*4, mask, w);
- TSM_ASSERT(msg, IMGCMP<R8G8B8>(dst1_rgb, dst2_rgb, w*h*3) == 0 );
- }
- }
-};
-
-unsigned int const NrComposeTest::alpha_vals[7] = {0, 1, 127, 128, 129, 254, 255};
-unsigned int const NrComposeTest::rgb_vals[3] = {
- ( 0u<<24u)+( 1u<<16u)+( 92u<<8u),
- (127u<<24u)+(128u<<16u)+(129u<<8u),
- (163u<<24u)+(254u<<16u)+(255u<<8u)};
-
-/*
-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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-compose-transform.cpp b/src/libnr/nr-compose-transform.cpp
deleted file mode 100644
index 05852bf07..000000000
--- a/src/libnr/nr-compose-transform.cpp
+++ /dev/null
@@ -1,367 +0,0 @@
-#define __NR_COMPOSE_TRANSFORM_C__
-
-/*
- * Pixel buffer rendering library
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * This code is in public domain
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "nr-pixops.h"
-#include "nr-matrix.h"
-
-/*#ifdef WITH_MMX
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-/ * fixme: * /
-/ *int nr_have_mmx (void);
-#define NR_PIXOPS_MMX (1 && nr_have_mmx ())
-#ifdef __cplusplus
-}
-#endif //__cplusplus
-#endif
-*/
-
-/* fixme: Implement missing (Lauris) */
-/* fixme: PREMUL colors before calculating average (Lauris) */
-
-/* Fixed point precision */
-#define FBITS 12
-#define FBITS_HP 18 // In some places we need a higher precision
-
-void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_TRANSFORM (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int sw, int sh, int srs,
- const NR::Matrix &d2s, unsigned int alpha, int xd, int yd);
-void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_TRANSFORM (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int sw, int sh, int srs,
- const NR::Matrix &d2s, unsigned int alpha, int xd, int yd);
-void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_TRANSFORM (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int sw, int sh, int srs,
- const NR::Matrix &d2s, unsigned int alpha, int xd, int yd);
-void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_TRANSFORM (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int sw, int sh, int srs,
- const NR::Matrix &d2s, unsigned int alpha, int xd, int yd);
-
-void
-nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_TRANSFORM (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int sw, int sh, int srs,
- const NR::Matrix &d2s, unsigned int alpha, int xd, int yd)
-{
- int xsize, ysize, size, dbits;
- long FFs_x_x, FFs_x_y, FFs_y_x, FFs_y_y, FFs__x, FFs__y;
- long FFs_x_x_S, FFs_x_y_S, FFs_y_x_S, FFs_y_y_S;
- /* Subpixel positions */
- int FF_sx_S[256];
- int FF_sy_S[256];
- unsigned char *d0;
- int FFsx0, FFsy0;
- int x, y;
-
- if (alpha == 0) return;
- if (alpha>255) {
- g_warning("In transform PPN alpha=%u>255",alpha);
- }
-
- // The color component is stored temporarily with a range of [0,255^3], so more supersampling and we get an overflow (fortunately Inkscape's preferences also doesn't allow a higher setting)
- if (xd+yd>8) {
- xd = 4;
- yd = 4;
- }
-
- xsize = (1 << xd);
- ysize = (1 << yd);
- size = xsize * ysize;
- dbits = xd + yd;
- unsigned int rounding_fix = size/2;
-
- /* Set up fixed point matrix */
- FFs_x_x = (long) floor(d2s[0] * (1 << FBITS) + 0.5);
- FFs_x_y = (long) floor(d2s[1] * (1 << FBITS) + 0.5);
- FFs_y_x = (long) floor(d2s[2] * (1 << FBITS) + 0.5);
- FFs_y_y = (long) floor(d2s[3] * (1 << FBITS) + 0.5);
- FFs__x = (long) floor(d2s[4] * (1 << FBITS) + 0.5);
- FFs__y = (long) floor(d2s[5] * (1 << FBITS) + 0.5);
-
- FFs_x_x_S = FFs_x_x >> xd;
- FFs_x_y_S = FFs_x_y >> xd;
- FFs_y_x_S = FFs_y_x >> yd;
- FFs_y_y_S = FFs_y_y >> yd;
-
- /* Set up subpixel matrix */
- /* fixme: We can calculate that in floating point (Lauris) */
- for (y = 0; y < ysize; y++) {
- for (x = 0; x < xsize; x++) {
- FF_sx_S[y * xsize + x] = FFs_x_x_S * x + FFs_y_x_S * y;
- FF_sy_S[y * xsize + x] = FFs_x_y_S * x + FFs_y_y_S * y;
- }
- }
-
- d0 = px;
- FFsx0 = FFs__x;
- FFsy0 = FFs__y;
-
- for (y = 0; y < h; y++) {
- unsigned char *d;
- long FFsx, FFsy;
- d = d0;
- FFsx = FFsx0;
- FFsy = FFsy0;
- for (x = 0; x < w; x++) {
- unsigned int r, g, b, a;
- long sx, sy;
- int i;
- r = g = b = a = 0;
- for (i = 0; i < size; i++) {
- sx = (FFsx + FF_sx_S[i]) >> FBITS;
- if ((sx >= 0) && (sx < sw)) {
- sy = (FFsy + FF_sy_S[i]) >> FBITS;
- if ((sy >= 0) && (sy < sh)) {
- const unsigned char *s;
- s = spx + sy * srs + sx * 4;
- r += NR_PREMUL_112 (s[0], s[3]); // s in [0,255]
- g += NR_PREMUL_112 (s[1], s[3]);
- b += NR_PREMUL_112 (s[2], s[3]);
- a += s[3];
- // a=sum(s3)
- // r,g,b in [0,sum(s3)*255]
- }
- }
- }
- a = (a*alpha + rounding_fix) >> dbits;
- // a=sum(s3)*alpha/size=avg(s3)*alpha
- // Compare to nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P
- if (a != 0) {
- r = (r*alpha + rounding_fix) >> dbits;
- g = (g*alpha + rounding_fix) >> dbits;
- b = (b*alpha + rounding_fix) >> dbits;
- // r,g,b in [0,avg(s3)*alpha*255]=[0,a*255]
- if (a == 255*255) {
- /* Full coverage, demul src */
- d[0] = NR_NORMALIZE_31(r);
- d[1] = NR_NORMALIZE_31(g);
- d[2] = NR_NORMALIZE_31(b);
- d[3] = NR_NORMALIZE_21(a);
- } else if (d[3] == 0) {
- /* Only foreground, demul src */
- d[0] = NR_DEMUL_321(r,a);
- d[1] = NR_DEMUL_321(g,a);
- d[2] = NR_DEMUL_321(b,a);
- d[3] = NR_NORMALIZE_21(a);
- } else {
- unsigned int ca;
- /* Full composition */
- ca = NR_COMPOSEA_213(a, d[3]);
- d[0] = NR_COMPOSEPNN_321131 (r, a, d[0], d[3], ca);
- d[1] = NR_COMPOSEPNN_321131 (g, a, d[1], d[3], ca);
- d[2] = NR_COMPOSEPNN_321131 (b, a, d[2], d[3], ca);
- d[3] = NR_NORMALIZE_31(ca);
- }
- }
- /* Advance pointers */
- FFsx += FFs_x_x;
- FFsy += FFs_x_y;
- d += 4;
- }
- FFsx0 += FFs_y_x;
- FFsy0 += FFs_y_y;
- d0 += rs;
- }
-}
-
-void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_TRANSFORM (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int sw, int sh, int srs,
- const NR::Matrix &d2s, unsigned int alpha, int xd, int yd);
-
-static void
-nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_TRANSFORM_0 (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int sw, int sh, int srs,
- const long long *FFd2s, unsigned int alpha)
-{
- unsigned char *d0;
- long long FFsx0, FFsy0;
- int x, y;
-
- d0 = px;
- FFsx0 = FFd2s[4];
- FFsy0 = FFd2s[5];
-
- for (y = 0; y < h; y++) {
- unsigned char *d;
- long long FFsx, FFsy;
- d = d0;
- FFsx = FFsx0;
- FFsy = FFsy0;
- for (x = 0; x < w; x++) {
- long sx, sy;
- sx = long(FFsx >> FBITS_HP);
- if ((sx >= 0) && (sx < sw)) {
- sy = long(FFsy >> FBITS_HP);
- if ((sy >= 0) && (sy < sh)) {
- const unsigned char *s;
- unsigned int a;
- s = spx + sy * srs + sx * 4;
- a = NR_PREMUL_112 (s[3], alpha);
- if (a != 0) {
- if ((a == 255*255) || (d[3] == 0)) {
- /* Transparent BG, premul src */
- d[0] = NR_PREMUL_121 (s[0], a);
- d[1] = NR_PREMUL_121 (s[1], a);
- d[2] = NR_PREMUL_121 (s[2], a);
- d[3] = NR_NORMALIZE_21(a);
- } else {
- d[0] = NR_COMPOSENPP_1211 (s[0], a, d[0]);
- d[1] = NR_COMPOSENPP_1211 (s[1], a, d[1]);
- d[2] = NR_COMPOSENPP_1211 (s[2], a, d[2]);
- d[3] = NR_COMPOSEA_211(a, d[3]);
- }
- }
- }
- }
- /* Advance pointers */
- FFsx += FFd2s[0];
- FFsy += FFd2s[1];
- d += 4;
- }
- FFsx0 += FFd2s[2];
- FFsy0 += FFd2s[3];
- d0 += rs;
- }
-}
-
-static void
-nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_TRANSFORM_n (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int sw, int sh, int srs,
- const long long *FFd2s, const long *FF_S, unsigned int alpha, int dbits)
-{
- int size;
- unsigned char *d0;
- long long FFsx0, FFsy0;
- int x, y;
-
- size = (1 << dbits);
- unsigned int rounding_fix = size/2;
-
- d0 = px;
- FFsx0 = FFd2s[4];
- FFsy0 = FFd2s[5];
-
- for (y = 0; y < h; y++) {
- unsigned char *d;
- long long FFsx, FFsy;
- d = d0;
- FFsx = FFsx0;
- FFsy = FFsy0;
- for (x = 0; x < w; x++) {
- unsigned int r, g, b, a;
- int i;
- r = g = b = a = 0;
- for (i = 0; i < size; i++) {
- long sx, sy;
- sx = (long (FFsx >> (FBITS_HP - FBITS)) + FF_S[2 * i]) >> FBITS;
- if ((sx >= 0) && (sx < sw)) {
- sy = (long (FFsy >> (FBITS_HP - FBITS)) + FF_S[2 * i + 1]) >> FBITS;
- if ((sy >= 0) && (sy < sh)) {
- const unsigned char *s;
- s = spx + sy * srs + sx * 4;
- r += NR_PREMUL_112(s[0], s[3]);
- g += NR_PREMUL_112(s[1], s[3]);
- b += NR_PREMUL_112(s[2], s[3]);
- a += s[3];
- }
- }
- }
- a = (a*alpha + rounding_fix) >> dbits;
- if (a != 0) {
- r = (r*alpha + rounding_fix) >> dbits;
- g = (g*alpha + rounding_fix) >> dbits;
- b = (b*alpha + rounding_fix) >> dbits;
- if ((a == 255*255) || (d[3] == 0)) {
- /* Transparent BG, premul src */
- d[0] = NR_NORMALIZE_31(r);
- d[1] = NR_NORMALIZE_31(g);
- d[2] = NR_NORMALIZE_31(b);
- d[3] = NR_NORMALIZE_21(a);
- } else {
- d[0] = NR_COMPOSEPPP_3211 (r, a, d[0]);
- d[1] = NR_COMPOSEPPP_3211 (g, a, d[1]);
- d[2] = NR_COMPOSEPPP_3211 (b, a, d[2]);
- d[3] = NR_COMPOSEA_211(a, d[3]);
- }
- }
- /* Advance pointers */
- FFsx += FFd2s[0];
- FFsy += FFd2s[1];
- d += 4;
- }
- FFsx0 += FFd2s[2];
- FFsy0 += FFd2s[3];
- d0 += rs;
- }
-}
-
-void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_TRANSFORM (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int sw, int sh, int srs,
- const NR::Matrix &d2s, unsigned int alpha, int xd, int yd)
-{
- int dbits;
- long FFd2s[6];
- long long FFd2s_HP[6]; // with higher precision
- int i;
-
- if (alpha == 0) return;
- if (alpha>255) {
- g_warning("In transform PPN alpha=%u>255",alpha);
- }
-
- // The color component is stored temporarily with a range of [0,255^3], so more supersampling and we get an overflow (fortunately Inkscape's preferences also doesn't allow a higher setting)
- if (xd+yd>8) {
- xd = 4;
- yd = 4;
- }
-
- dbits = xd + yd;
-
- for (i = 0; i < 6; i++) {
- FFd2s[i] = (long) floor(d2s[i] * (1 << FBITS) + 0.5);
- FFd2s_HP[i] = (long long) floor(d2s[i] * (1 << FBITS_HP) + 0.5);;
- }
-
- if (dbits == 0) {
- nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_TRANSFORM_0 (px, w, h, rs, spx, sw, sh, srs, FFd2s_HP, alpha);
- } else {
- int xsize, ysize;
- long FFs_x_x_S, FFs_x_y_S, FFs_y_x_S, FFs_y_y_S;
- long FF_S[2 * 256];
- int x, y;
-
- xsize = (1 << xd);
- ysize = (1 << yd);
-
- FFs_x_x_S = FFd2s[0] >> xd;
- FFs_x_y_S = FFd2s[1] >> xd;
- FFs_y_x_S = FFd2s[2] >> yd;
- FFs_y_y_S = FFd2s[3] >> yd;
-
- /* Set up subpixel matrix */
- /* fixme: We can calculate that in floating point (Lauris) */
- for (y = 0; y < ysize; y++) {
- for (x = 0; x < xsize; x++) {
- FF_S[2 * (y * xsize + x)] = FFs_x_x_S * x + FFs_y_x_S * y;
- FF_S[2 * (y * xsize + x) + 1] = FFs_x_y_S * x + FFs_y_y_S * y;
- }
- }
-
- nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_TRANSFORM_n (px, w, h, rs, spx, sw, sh, srs, FFd2s_HP, FF_S, alpha, dbits);
- }
-}
-
-void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_TRANSFORM (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int sw, int sh, int srs,
- const NR::Matrix &d2s, unsigned int alpha, int xd, int yd);
diff --git a/src/libnr/nr-compose-transform.h b/src/libnr/nr-compose-transform.h
deleted file mode 100644
index 7ffb20074..000000000
--- a/src/libnr/nr-compose-transform.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef __NR_COMPOSE_TRANSFORM_H__
-#define __NR_COMPOSE_TRANSFORM_H__
-
-/*
- * Pixel buffer rendering library
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * This code is in public domain
- */
-
-#include <libnr/nr-forward.h>
-
-/* FINAL DST SRC */
-
-void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_TRANSFORM (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int sw, int sh, int srs,
- const NR::Matrix &d2s, unsigned int alpha, int xd, int yd);
-void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_TRANSFORM (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int sw, int sh, int srs,
- const NR::Matrix &d2s, unsigned int alpha, int xd, int yd);
-void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_TRANSFORM (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int sw, int sh, int srs,
- const NR::Matrix &d2s, unsigned int alpha, int xd, int yd);
-void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_TRANSFORM (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int sw, int sh, int srs,
- const NR::Matrix &d2s, unsigned int alpha, int xd, int yd);
-
-void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_TRANSFORM (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int sw, int sh, int srs,
- const NR::Matrix &d2s, unsigned int alpha, int xd, int yd);
-void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_TRANSFORM (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int sw, int sh, int srs,
- const NR::Matrix &d2s, unsigned int alpha, int xd, int yd);
-void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_TRANSFORM (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int sw, int sh, int srs,
- const NR::Matrix &d2s, unsigned int alpha, int xd, int yd);
-void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_TRANSFORM (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int sw, int sh, int srs,
- const NR::Matrix &d2s, unsigned int alpha, int xd, int yd);
-
-#endif
diff --git a/src/libnr/nr-compose.cpp b/src/libnr/nr-compose.cpp
deleted file mode 100644
index 74f9d036b..000000000
--- a/src/libnr/nr-compose.cpp
+++ /dev/null
@@ -1,1197 +0,0 @@
-#define __NR_COMPOSE_C__
-
-/*
- * Pixel buffer rendering library
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * This code is in public domain
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <string.h>
-#include "nr-pixops.h"
-
-#ifdef WITH_MMX
-/* fixme: */
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-int nr_have_mmx (void);
-void nr_mmx_R8G8B8A8_P_EMPTY_A8_RGBAP (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned char *c);
-void nr_mmx_R8G8B8A8_P_R8G8B8A8_P_A8_RGBAP (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned char *c);
-void nr_mmx_R8G8B8_R8G8B8_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha);
-#define NR_PIXOPS_MMX nr_have_mmx ()
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif
-
-// Naming: nr_RESULT_BACKGROUND_FOREGROUND_extra
-
-void
-nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha)
-{
- unsigned int r, c;
-
- for (r = h; r > 0; r--) {
- if (alpha == 0) {
- memset(px, 0x0, 4 * w);
- } else if (alpha == 255) {
- memcpy(px, spx, 4 * w);
- } else {
- unsigned char *d = px;
- const unsigned char *s = spx;
- for (c = w; c > 0; c--) {
- *d++ = *s++;
- *d++ = *s++;
- *d++ = *s++;
- *d++ = NR_PREMUL_111(*s, alpha);
- s++;
- }
- }
- px += rs;
- spx += srs;
- }
-}
-
-void
-nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha)
-{
- unsigned int r, c;
-
- for (r = h; r > 0; r--) {
- if (alpha == 0) {
- memset(px, 0x0, 4 * w);
- } else {
- unsigned char *d = px;
- const unsigned char *s = spx;
- for (c = w; c > 0; c--) {
- if (s[3] == 0) {
- d[3] = 0;
- } else if (s[3] == 255) {
- memcpy(d, s, 4);
- } else {
- d[0] = NR_DEMUL_111(s[0], s[3]);
- d[1] = NR_DEMUL_111(s[1], s[3]);
- d[2] = NR_DEMUL_111(s[2], s[3]);
- d[3] = NR_PREMUL_111(s[3], alpha);
- }
- d += 4;
- s += 4;
- }
- }
- px += rs;
- spx += srs;
- }
-}
-
-void
-nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha)
-{
- unsigned int r, c;
-
- for (r = h; r > 0; r--) {
- unsigned char *d = px;
- const unsigned char *s = spx;
- if (alpha == 0) {
- memset(px, 0x0, 4 * w);
- } else if (alpha == 255) {
- for (c = w; c > 0; c--) {
- d[0] = NR_PREMUL_111(s[0], s[3]);
- d[1] = NR_PREMUL_111(s[1], s[3]);
- d[2] = NR_PREMUL_111(s[2], s[3]);
- d[3] = s[3];
- d += 4;
- s += 4;
- }
- } else {
- for (c = w; c > 0; c--) {
- if (s[3] == 0) {
- memset(d, 0, 4);
- } else {
- unsigned int a;
- a = NR_PREMUL_112(s[3], alpha);
- d[0] = NR_PREMUL_121(s[0], a);
- d[1] = NR_PREMUL_121(s[1], a);
- d[2] = NR_PREMUL_121(s[2], a);
- d[3] = NR_NORMALIZE_21(a);
- }
- d += 4;
- s += 4;
- }
- }
- px += rs;
- spx += srs;
- }
-}
-
-void
-nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha)
-{
- unsigned int r, c;
-
- for (r = h; r > 0; r--) {
- if (alpha == 0) {
- memset(px, 0x0, 4 * w);
- } else if (alpha == 255) {
- memcpy(px, spx, 4 * w);
- } else {
- unsigned char *d = px;
- const unsigned char *s = spx;
- for (c = w; c > 0; c--) {
- d[0] = NR_PREMUL_111(s[0], alpha);
- d[1] = NR_PREMUL_111(s[1], alpha);
- d[2] = NR_PREMUL_111(s[2], alpha);
- d[3] = NR_PREMUL_111(s[3], alpha);
- d += 4;
- s += 4;
- }
- }
- px += rs;
- spx += srs;
- }
-}
-
-void
-nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha)
-{
- unsigned int r, c;
-
- if (alpha == 0) {
- /* NOP */
- } else if (alpha == 255) {
- for (r = h; r > 0; r--) {
- unsigned char *d = px;
- const unsigned char *s = spx;
- for (c = w; c > 0; c--) {
- if (s[3] == 0) {
- /* Transparent FG, NOP */
- } else if ((s[3] == 255) || (d[3] == 0)) {
- /* Full coverage, COPY */
- memcpy(d, s, 4);
- } else {
- /* Full composition */
- unsigned int ca;
- ca = NR_COMPOSEA_112(s[3], d[3]);
- d[0] = NR_COMPOSENNN_111121(s[0], s[3], d[0], d[3], ca);
- d[1] = NR_COMPOSENNN_111121(s[1], s[3], d[1], d[3], ca);
- d[2] = NR_COMPOSENNN_111121(s[2], s[3], d[2], d[3], ca);
- d[3] = NR_NORMALIZE_21(ca);
- }
- d += 4;
- s += 4;
- }
- px += rs;
- spx += srs;
- }
- } else {
- for (r = h; r > 0; r--) {
- unsigned char *d = px;
- const unsigned char *s = spx;
- for (c = w; c > 0; c--) {
- unsigned int a;
- a = NR_PREMUL_112(s[3], alpha);
- if (a == 0) {
- /* Transparent FG, NOP */
- } else if ((a == 255*255) || (d[3] == 0)) {
- /* Full coverage, COPY */
- d[0] = s[0];
- d[1] = s[1];
- d[2] = s[2];
- d[3] = NR_NORMALIZE_21(a);
- } else {
- /* Full composition */
- unsigned int ca;
- ca = NR_COMPOSEA_213(a, d[3]);
- d[0] = NR_COMPOSENNN_121131(s[0], a, d[0], d[3], ca);
- d[1] = NR_COMPOSENNN_121131(s[1], a, d[1], d[3], ca);
- d[2] = NR_COMPOSENNN_121131(s[2], a, d[2], d[3], ca);
- d[3] = NR_NORMALIZE_31(ca);
- }
- d += 4;
- s += 4;
- }
- px += rs;
- spx += srs;
- }
- }
-}
-
-void
-nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha)
-{
- unsigned int r, c;
-
- if (alpha == 0) {
- /* NOP */
- } else if (alpha == 255) {
- for (r = h; r > 0; r--) {
- unsigned char *d = px;
- const unsigned char *s = spx;
- for (c = w; c > 0; c--) {
- if (s[3] == 0) {
- /* Transparent FG, NOP */
- } else if (s[3] == 255) {
- /* Full coverage, demul src */
- // dc' = ((1 - sa) * da*dc + sc)/da' = sc/da' = sc
- // da' = 1 - (1 - sa) * (1 - da) = 1 - 0 * (1 - da) = 1
- memcpy(d, s, 4);
- } else if (d[3] == 0) {
- /* Full coverage, demul src */
- // dc' = ((1 - sa) * da*dc + sc)/da' = sc/da' = sc/sa = sc/sa
- // da' = 1 - (1 - sa) * (1 - da) = 1 - (1 - sa) = sa
- d[0] = NR_DEMUL_111(s[0], s[3]);
- d[1] = NR_DEMUL_111(s[1], s[3]);
- d[2] = NR_DEMUL_111(s[2], s[3]);
- d[3] = s[3];
- } else {
- /* Full composition */
- // dc' = ((1 - sa) * da*dc + sc)/da' = ((1 - sa) * da*dc + sc)/da'
- // da' = 1 - (1 - sa) * (1 - da) = 1 - (1 - sa) * (1 - da)
- unsigned int da = NR_COMPOSEA_112(s[3], d[3]);
- d[0] = NR_COMPOSEPNN_111121(s[0], s[3], d[0], d[3], da);
- d[1] = NR_COMPOSEPNN_111121(s[1], s[3], d[1], d[3], da);
- d[2] = NR_COMPOSEPNN_111121(s[2], s[3], d[2], d[3], da);
- d[3] = NR_NORMALIZE_21(da);
- }
- d += 4;
- s += 4;
- }
- px += rs;
- spx += srs;
- }
- } else {
- for (r = h; r > 0; r--) {
- unsigned char *d = px;
- const unsigned char *s = spx;
- for (c = w; c > 0; c--) {
- unsigned int a;
- a = NR_PREMUL_112(s[3], alpha);
- if (a == 0) {
- /* Transparent FG, NOP */
- } else if (d[3] == 0) {
- /* Full coverage, demul src */
- // dc' = ((1 - alpha*sa) * da*dc + alpha*sc)/da' = alpha*sc/da' = alpha*sc/(alpha*sa) = sc/sa
- // da' = 1 - (1 - alpha*sa) * (1 - da) = 1 - (1 - alpha*sa) = alpha*sa
- d[0] = NR_DEMUL_111(s[0], s[3]);
- d[1] = NR_DEMUL_111(s[1], s[3]);
- d[2] = NR_DEMUL_111(s[2], s[3]);
- d[3] = NR_NORMALIZE_21(a);
- } else {
- // dc' = ((1 - alpha*sa) * da*dc + alpha*sc)/da'
- // da' = 1 - (1 - alpha*sa) * (1 - da)
- unsigned int da = NR_COMPOSEA_213(a, d[3]);
- d[0] = NR_COMPOSEPNN_221131(NR_PREMUL_112(s[0], alpha), a, d[0], d[3], da);
- d[1] = NR_COMPOSEPNN_221131(NR_PREMUL_112(s[1], alpha), a, d[1], d[3], da);
- d[2] = NR_COMPOSEPNN_221131(NR_PREMUL_112(s[2], alpha), a, d[2], d[3], da);
- d[3] = NR_NORMALIZE_31(da);
- }
- d += 4;
- s += 4;
- }
- px += rs;
- spx += srs;
- }
- }
-}
-
-void
-nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha)
-{
- unsigned int r, c;
-
- if (alpha == 0) {
- /* NOP */
- } else if (alpha == 255) {
- for (r = h; r > 0; r--) {
- unsigned char *d = px;
- const unsigned char *s = spx;
- for (c = w; c > 0; c--) {
- if (s[3] == 0) {
- /* Transparent FG, NOP */
- } else if (s[3] == 255) {
- /* Opaque FG, COPY */
- // dc' = (1 - sa) * dc + sa*sc = sa*sc = sc
- // da' = 1 - (1 - sa) * (1 - da) = 1 - 0 * (1 - da) = 1 (= sa)
- memcpy(d, s, 4);
- } else if (d[3] == 0) {
- /* Transparent BG, premul src */
- // dc' = (1 - sa) * dc + sa*sc = sa*sc
- // da' = 1 - (1 - sa) * (1 - da) = 1 - (1 - sa) = sa
- d[0] = NR_PREMUL_111(s[0], s[3]);
- d[1] = NR_PREMUL_111(s[1], s[3]);
- d[2] = NR_PREMUL_111(s[2], s[3]);
- d[3] = s[3];
- } else {
- // dc' = (1 - sa) * dc + sa*sc
- // da' = 1 - (1 - sa) * (1 - da)
- d[0] = NR_COMPOSENPP_1111(s[0], s[3], d[0]);
- d[1] = NR_COMPOSENPP_1111(s[1], s[3], d[1]);
- d[2] = NR_COMPOSENPP_1111(s[2], s[3], d[2]);
- d[3] = NR_COMPOSEA_111(s[3], d[3]);
- }
- d += 4;
- s += 4;
- }
- px += rs;
- spx += srs;
- }
- } else {
- for (r = h; r > 0; r--) {
- unsigned char *d = px;
- const unsigned char *s = spx;
- for (c = w; c > 0; c--) {
- unsigned int a;
- a = NR_PREMUL_112 (s[3], alpha);
- if (a == 0) {
- /* Transparent FG, NOP */
- } else if (d[3] == 0) {
- /* Transparent BG, premul src */
- // dc' = (1 - alpha*sa) * dc + alpha*sa*sc = alpha*sa*sc
- // da' = 1 - (1 - alpha*sa) * (1 - da) = 1 - (1 - alpha*sa) = alpha*sa
- d[0] = NR_PREMUL_121(s[0], a);
- d[1] = NR_PREMUL_121(s[1], a);
- d[2] = NR_PREMUL_121(s[2], a);
- d[3] = NR_NORMALIZE_21(a);
- } else {
- // dc' = (1 - alpha*sa) * dc + alpha*sa*sc
- // da' = 1 - (1 - alpha*sa) * (1 - da)
- d[0] = NR_COMPOSENPP_1211(s[0], a, d[0]);
- d[1] = NR_COMPOSENPP_1211(s[1], a, d[1]);
- d[2] = NR_COMPOSENPP_1211(s[2], a, d[2]);
- d[3] = NR_COMPOSEA_211(a, d[3]);
- }
- d += 4;
- s += 4;
- }
- px += rs;
- spx += srs;
- }
- }
-}
-
-void
-nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha)
-{
- unsigned int r, c;
-
- if (alpha == 0) {
- /* Transparent FG, NOP */
- } else if (alpha == 255) {
- /* Simple */
- for (r = h; r > 0; r--) {
- unsigned char *d = px;
- const unsigned char *s = spx;
- for (c = w; c > 0; c--) {
- if (s[3] == 0) {
- /* Transparent FG, NOP */
- } else if ((s[3] == 255) || (d[3] == 0)) {
- /* Transparent BG, COPY */
- memcpy(d, s, 4);
- } else {
- d[0] = NR_COMPOSEPPP_1111(s[0], s[3], d[0]);
- d[1] = NR_COMPOSEPPP_1111(s[1], s[3], d[1]);
- d[2] = NR_COMPOSEPPP_1111(s[2], s[3], d[2]);
- d[3] = NR_COMPOSEA_111(s[3], d[3]);
- }
- d += 4;
- s += 4;
- }
- px += rs;
- spx += srs;
- }
- } else {
- for (r = h; r > 0; r--) {
- unsigned char *d = px;
- const unsigned char *s = spx;
- for (c = w; c > 0; c--) {
- if (s[3] == 0) {
- /* Transparent FG, NOP */
- } else if (d[3] == 0) {
- /* Transparent BG, COPY */
- d[0] = NR_PREMUL_111(s[0], alpha);
- d[1] = NR_PREMUL_111(s[1], alpha);
- d[2] = NR_PREMUL_111(s[2], alpha);
- d[3] = NR_PREMUL_111(s[3], alpha);
- } else {
- // dc' = (1 - alpha*sa) * dc + alpha*sc
- // da' = 1 - (1 - alpha*sa) * (1 - da)
- unsigned int a;
- a = NR_PREMUL_112(s[3], alpha);
- d[0] = NR_COMPOSEPPP_2211(NR_PREMUL_112(alpha, s[0]), a, d[0]);
- d[1] = NR_COMPOSEPPP_2211(NR_PREMUL_112(alpha, s[1]), a, d[1]);
- d[2] = NR_COMPOSEPPP_2211(NR_PREMUL_112(alpha, s[2]), a, d[2]);
- d[3] = NR_COMPOSEA_211(a, d[3]);
- }
- d += 4;
- s += 4;
- }
- px += rs;
- spx += srs;
- }
- }
-}
-
-/* Masked operations */
-
-void
-nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs)
-{
- unsigned int r, c;
-
- for (r = h; r > 0; r--) {
- unsigned char *d = px;
- const unsigned char *s = spx;
- const unsigned char *m = mpx;
- for (c = w; c > 0; c--) {
- d[0] = s[0];
- d[1] = s[1];
- d[2] = s[2];
- d[3] = NR_PREMUL_111(s[3], m[0]);
- d += 4;
- s += 4;
- m += 1;
- }
- px += rs;
- spx += srs;
- mpx += mrs;
- }
-}
-
-void
-nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs)
-{
- unsigned int r, c;
-
- for (r = h; r > 0; r--) {
- unsigned char *d = px;
- const unsigned char *s = spx;
- const unsigned char *m = mpx;
- for (c = w; c > 0; c--) {
- unsigned int a;
- a = NR_PREMUL_112 (s[3], m[0]);
- if (a == 0) {
- d[3] = 0;
- } else if (a == 255*255) {
- memcpy(d, s, 4);
- } else {
- // dc' = ((1 - m*sa) * da*dc + m*sc)/da' = m*sc/da' = m*sc/(m*sa) = sc/sa
- // da' = 1 - (1 - m*sa) * (1 - da) = 1 - (1 - m*sa) = m*sa
- d[0] = NR_DEMUL_111(s[0], s[3]);
- d[1] = NR_DEMUL_111(s[1], s[3]);
- d[2] = NR_DEMUL_111(s[2], s[3]);
- d[3] = NR_NORMALIZE_21(a);
- }
- d += 4;
- s += 4;
- m += 1;
- }
- px += rs;
- spx += srs;
- mpx += mrs;
- }
-}
-
-void
-nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs)
-{
- unsigned int r, c;
-
- for (r = h; r > 0; r--) {
- unsigned char *d = px;
- const unsigned char *s = spx;
- const unsigned char *m = mpx;
- for (c = w; c > 0; c--) {
- unsigned int a;
- a = NR_PREMUL_112(s[3], m[0]);
- if (a == 0) {
- memset(d, 0, 4);
- } else if (a == 255*255) {
- memcpy(d, s, 4);
- } else {
- d[0] = NR_PREMUL_121(s[0], a);
- d[1] = NR_PREMUL_121(s[1], a);
- d[2] = NR_PREMUL_121(s[2], a);
- d[3] = NR_NORMALIZE_21(a);
- }
- d += 4;
- s += 4;
- m += 1;
- }
- px += rs;
- spx += srs;
- mpx += mrs;
- }
-}
-
-void
-nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs)
-{
- unsigned int r, c;
-
- for (r = h; r > 0; r--) {
- unsigned char *d = px;
- const unsigned char *s = spx;
- const unsigned char *m = mpx;
- for (c = w; c > 0; c--) {
- d[0] = NR_PREMUL_111(s[0], m[0]);
- d[1] = NR_PREMUL_111(s[1], m[0]);
- d[2] = NR_PREMUL_111(s[2], m[0]);
- d[3] = NR_PREMUL_111(s[3], m[0]);
- d += 4;
- s += 4;
- m += 1;
- }
- px += rs;
- spx += srs;
- mpx += mrs;
- }
-}
-
-void
-nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs)
-{
- unsigned int r, c;
-
- for (r = h; r > 0; r--) {
- unsigned char *d = px;
- const unsigned char *s = spx;
- const unsigned char *m = mpx;
- for (c = w; c > 0; c--) {
- unsigned int a;
- a = NR_PREMUL_112(s[3], m[0]);
- if (a == 0) {
- /* Transparent FG, NOP */
- } else if ((a == 255*255) || (d[3] == 0)) {
- /* Full coverage, COPY */
- d[0] = s[0];
- d[1] = s[1];
- d[2] = s[2];
- d[3] = NR_NORMALIZE_21(a);
- } else {
- /* Full composition */
- unsigned int ca;
- ca = NR_COMPOSEA_213(a, d[3]);
- d[0] = NR_COMPOSENNN_121131(s[0], a, d[0], d[3], ca);
- d[1] = NR_COMPOSENNN_121131(s[1], a, d[1], d[3], ca);
- d[2] = NR_COMPOSENNN_121131(s[2], a, d[2], d[3], ca);
- d[3] = NR_NORMALIZE_31(ca);
- }
- d += 4;
- s += 4;
- m += 1;
- }
- px += rs;
- spx += srs;
- mpx += mrs;
- }
-}
-
-void
-nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs)
-{
- unsigned int r, c;
-
- for (r = h; r > 0; r--) {
- unsigned char *d = px;
- const unsigned char *s = spx;
- const unsigned char *m = mpx;
- for (c = w; c > 0; c--) {
- unsigned int a;
- a = NR_PREMUL_112(s[3], m[0]);
- if (a == 0) {
- /* Transparent FG, NOP */
- } else if (a == 255*255) {
- /* Opaque FG, COPY */
- memcpy(d, s, 4);
- } else if (d[3] == 0) {
- /* Full coverage, demul src */
- // dc' = ((1 - m*sa) * da*dc + m*sc)/da' = m*sc/da' = m*sc/(m*sa) = sc/sa
- // da' = 1 - (1 - m*sa) * (1 - da) = 1 - (1 - m*sa) = m*sa
- d[0] = NR_DEMUL_111(s[0], s[3]);
- d[1] = NR_DEMUL_111(s[1], s[3]);
- d[2] = NR_DEMUL_111(s[2], s[3]);
- d[3] = NR_NORMALIZE_21(a);
- } else if (m[0] == 255) {
- /* Full composition */
- // dc' = ((1 - m*sa) * da*dc + m*sc)/da' = ((1 - sa) * da*dc + sc)/da'
- // da' = 1 - (1 - m*sa) * (1 - da) = 1 - (1 - sa) * (1 - da)
- unsigned int da = NR_COMPOSEA_112(s[3], d[3]);
- d[0] = NR_COMPOSEPNN_111121(s[0], s[3], d[0], d[3], da);
- d[1] = NR_COMPOSEPNN_111121(s[1], s[3], d[1], d[3], da);
- d[2] = NR_COMPOSEPNN_111121(s[2], s[3], d[2], d[3], da);
- d[3] = NR_NORMALIZE_21(da);
- } else {
- // dc' = ((1 - m*sa) * da*dc + m*sc)/da'
- // da' = 1 - (1 - m*sa) * (1 - da)
- unsigned int da = NR_COMPOSEA_213(a, d[3]);
- d[0] = NR_COMPOSEPNN_221131(NR_PREMUL_112(s[0], m[0]), a, d[0], d[3], da);
- d[1] = NR_COMPOSEPNN_221131(NR_PREMUL_112(s[1], m[0]), a, d[1], d[3], da);
- d[2] = NR_COMPOSEPNN_221131(NR_PREMUL_112(s[2], m[0]), a, d[2], d[3], da);
- d[3] = NR_NORMALIZE_31(da);
- }
- d += 4;
- s += 4;
- m += 1;
- }
- px += rs;
- spx += srs;
- mpx += mrs;
- }
-}
-
-void
-nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs)
-{
- unsigned int r, c;
-
- for (r = h; r>0; r--) {
- unsigned char *d = px;
- const unsigned char *s = spx;
- const unsigned char *m = mpx;
- for (c = w; c>0; c--) {
- unsigned int a;
- a = NR_PREMUL_112(s[3], m[0]);
- if (a == 0) {
- /* Transparent FG, NOP */
- } else if (a == 255*255) {
- memcpy(d, s, 4);
- } else {
- d[0] = NR_COMPOSENPP_1211(s[0], a, d[0]);
- d[1] = NR_COMPOSENPP_1211(s[1], a, d[1]);
- d[2] = NR_COMPOSENPP_1211(s[2], a, d[2]);
- d[3] = NR_COMPOSEA_211(a, d[3]);
- }
- d += 4;
- s += 4;
- m += 1;
- }
- px += rs;
- spx += srs;
- mpx += mrs;
- }
-}
-
-void
-nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs)
-{
- unsigned int r, c;
-
- for (r = h; r > 0; r--) {
- unsigned char *d = px;
- const unsigned char *s = spx;
- const unsigned char *m = mpx;
- for (c = w; c > 0; c--) {
- unsigned int a;
- a = NR_PREMUL_112 (s[3], m[0]);
- if (a == 0) {
- /* Transparent FG, NOP */
- } else if (a == 255*255) {
- /* Opaque FG, COPY */
- memcpy(d, s, 4);
- } else if (d[3] == 0) {
- /* Transparent BG, COPY */
- // dc' = (1 - m*sa) * dc + m*sc = m*sc
- // da' = 1 - (1 - m*sa) * (1 - da) = 1 - (1 - m*sa) = m*sa
- d[0] = NR_PREMUL_111 (s[0], m[0]);
- d[1] = NR_PREMUL_111 (s[1], m[0]);
- d[2] = NR_PREMUL_111 (s[2], m[0]);
- d[3] = NR_NORMALIZE_21(a);
- } else {
- // dc' = (1 - m*sa) * dc + m*sc
- // da' = 1 - (1 - m*sa) * (1 - da)
- d[0] = NR_COMPOSEPPP_2211 (NR_PREMUL_112 (s[0], m[0]), a, d[0]);
- d[1] = NR_COMPOSEPPP_2211 (NR_PREMUL_112 (s[1], m[0]), a, d[1]);
- d[2] = NR_COMPOSEPPP_2211 (NR_PREMUL_112 (s[2], m[0]), a, d[2]);
- d[3] = NR_COMPOSEA_211(a, d[3]);
- }
- d += 4;
- s += 4;
- m += 1;
- }
- px += rs;
- spx += srs;
- mpx += mrs;
- }
-}
-
-/* FINAL DST MASK COLOR */
-
-void
-nr_R8G8B8A8_N_EMPTY_A8_RGBA32 (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba)
-{
- unsigned int r, g, b, a;
- unsigned int x, y;
-
- r = NR_RGBA32_R (rgba);
- g = NR_RGBA32_G (rgba);
- b = NR_RGBA32_B (rgba);
- a = NR_RGBA32_A (rgba);
-
- for (y = h; y > 0; y--) {
- if (a == 0) {
- memset(px, 0, w*4);
- } else {
- unsigned char *d = px;
- const unsigned char *m = mpx;
- for (x = w; x > 0; x--) {
- d[0] = r;
- d[1] = g;
- d[2] = b;
- d[3] = NR_PREMUL_111 (m[0], a);
- d += 4;
- m += 1;
- }
- }
- px += rs;
- mpx += mrs;
- }
-}
-
-void
-nr_R8G8B8A8_P_EMPTY_A8_RGBA32 (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba)
-{
- unsigned int r, g, b, a;
- unsigned int x, y;
-
- r = NR_RGBA32_R (rgba);
- g = NR_RGBA32_G (rgba);
- b = NR_RGBA32_B (rgba);
- a = NR_RGBA32_A (rgba);
-
-#ifdef WITH_MMX
- if (NR_PIXOPS_MMX) {
- unsigned char c[4];
- c[0] = NR_PREMUL_111 (r, a);
- c[1] = NR_PREMUL_111 (g, a);
- c[2] = NR_PREMUL_111 (b, a);
- c[3] = a;
- /* WARNING: MMX composer REQUIRES w > 0 and h > 0 */
- nr_mmx_R8G8B8A8_P_EMPTY_A8_RGBAP (px, w, h, rs, mpx, mrs, c);
- // This mmx optimized code is approx. 2x faster than the non-optimized code below (Measured by Diederik van Lierop, 2009-12-17)
- return;
- }
-#endif
-
- if ( a != 255 ){
- // Pre-premultiply color values
- r *= a;
- g *= a;
- b *= a;
- }
-
- for (y = h; y > 0; y--) {
- unsigned char *d = px;
- const unsigned char *m = mpx;
- if (a == 0) {
- memset(px, 0, w*4);
- } else if (a == 255) {
- for (x = w; x > 0; x--) {
- d[0] = NR_PREMUL_111(m[0], r);
- d[1] = NR_PREMUL_111(m[0], g);
- d[2] = NR_PREMUL_111(m[0], b);
- d[3] = m[0];
- d += 4;
- m += 1;
- }
- } else {
- for (x = w; x > 0; x--) {
- // Color values are already premultiplied with a
- d[0] = NR_PREMUL_121(m[0], r);
- d[1] = NR_PREMUL_121(m[0], g);
- d[2] = NR_PREMUL_121(m[0], b);
- d[3] = NR_PREMUL_111(m[0], a);
- d += 4;
- m += 1;
- }
- }
- px += rs;
- mpx += mrs;
- }
-}
-
-void
-nr_R8G8B8_R8G8B8_A8_RGBA32 (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba)
-{
- unsigned int r, g, b, a;
- unsigned int x, y;
-
- r = NR_RGBA32_R (rgba);
- g = NR_RGBA32_G (rgba);
- b = NR_RGBA32_B (rgba);
- a = NR_RGBA32_A (rgba);
-
- if (a == 0) {
- /* NOP */
- } else if (a == 255) {
- for (y = h; y > 0; y--) {
- unsigned char *d = px;
- const unsigned char *m = mpx;
- for (x = w; x > 0; x--) {
- d[0] = NR_COMPOSEN11_1111 (r, m[0], d[0]);
- d[1] = NR_COMPOSEN11_1111 (g, m[0], d[1]);
- d[2] = NR_COMPOSEN11_1111 (b, m[0], d[2]);
- d += 3;
- m += 1;
- }
- px += rs;
- mpx += mrs;
- }
- } else {
- for (y = h; y > 0; y--) {
- unsigned char *d = px;
- const unsigned char *m = mpx;
- for (x = w; x > 0; x--) {
- // dc' = (1 - m*sa) * dc + m*sa*sc
- unsigned int alpha;
- alpha = NR_PREMUL_112 (a, m[0]);
- d[0] = NR_COMPOSEN11_1211 (r, alpha, d[0]);
- d[1] = NR_COMPOSEN11_1211 (g, alpha, d[1]);
- d[2] = NR_COMPOSEN11_1211 (b, alpha, d[2]);
- d += 3;
- m += 1;
- }
- px += rs;
- mpx += mrs;
- }
- }
-}
-
-void
-nr_R8G8B8A8_N_R8G8B8A8_N_A8_RGBA32 (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba)
-{
- unsigned int r, g, b, a;
- unsigned int x, y;
-
- r = NR_RGBA32_R (rgba);
- g = NR_RGBA32_G (rgba);
- b = NR_RGBA32_B (rgba);
- a = NR_RGBA32_A (rgba);
-
- if (a == 0) {
- /* NOP */
- } else if (a == 255) {
- for (y = h; y > 0; y--) {
- unsigned char *d = px;
- const unsigned char *m = mpx;
- for (x = w; x > 0; x--) {
- if (m[0] == 0) {
- /* Transparent FG, NOP */
- } else if (m[0] == 255 || d[3] == 0) {
- /* Full coverage, COPY */
- d[0] = r;
- d[1] = g;
- d[2] = b;
- d[3] = m[0];
- } else {
- /* Full composition */
- unsigned int da = NR_COMPOSEA_112(m[0], d[3]);
- d[0] = NR_COMPOSENNN_111121(r, m[0], d[0], d[3], da);
- d[1] = NR_COMPOSENNN_111121(g, m[0], d[1], d[3], da);
- d[2] = NR_COMPOSENNN_111121(b, m[0], d[2], d[3], da);
- d[3] = NR_NORMALIZE_21(da);
- }
- d += 4;
- m += 1;
- }
- px += rs;
- mpx += mrs;
- }
- } else {
- for (y = h; y > 0; y--) {
- unsigned char *d = px;
- const unsigned char *m = mpx;
- for (x = w; x > 0; x--) {
- unsigned int ca;
- ca = NR_PREMUL_112 (m[0], a);
- if (ca == 0) {
- /* Transparent FG, NOP */
- } else if (d[3] == 0) {
- /* Full coverage, COPY */
- d[0] = r;
- d[1] = g;
- d[2] = b;
- d[3] = NR_NORMALIZE_21(ca);
- } else {
- /* Full composition */
- unsigned int da = NR_COMPOSEA_213(ca, d[3]);
- d[0] = NR_COMPOSENNN_121131(r, ca, d[0], d[3], da);
- d[1] = NR_COMPOSENNN_121131(g, ca, d[1], d[3], da);
- d[2] = NR_COMPOSENNN_121131(b, ca, d[2], d[3], da);
- d[3] = NR_NORMALIZE_31(da);
- }
- d += 4;
- m += 1;
- }
- px += rs;
- mpx += mrs;
- }
- }
-}
-
-void
-nr_R8G8B8A8_P_R8G8B8A8_P_A8_RGBA32 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned long rgba)
-{
- unsigned int r, g, b, a;
- unsigned int x, y;
-
- r = NR_RGBA32_R (rgba);
- g = NR_RGBA32_G (rgba);
- b = NR_RGBA32_B (rgba);
- a = NR_RGBA32_A (rgba);
-
-#ifdef WITH_MMX
- if (NR_PIXOPS_MMX && a != 0) {
- unsigned char c[4];
- c[0] = NR_PREMUL_111 (r, a);
- c[1] = NR_PREMUL_111 (g, a);
- c[2] = NR_PREMUL_111 (b, a);
- c[3] = a;
- /* WARNING: MMX composer REQUIRES w > 0 and h > 0 */
- nr_mmx_R8G8B8A8_P_R8G8B8A8_P_A8_RGBAP (px, w, h, rs, spx, srs, c);
- return;
- }
-#endif
-
- if (a == 0) {
- /* Transparent FG, NOP */
- } else if (a == 255) {
- /* Simple */
- for (y = h; y > 0; y--) {
- unsigned char *d, *s;
- d = (unsigned char *) px;
- s = (unsigned char *) spx;
- for (x = w; x > 0; x--) {
- if (s[0] == 0) {
- /* Transparent FG, NOP */
- } else {
- /* Full composition */
- unsigned int invca = 255-s[0]; // By swapping the arguments GCC can better optimize these calls
- d[0] = NR_COMPOSENPP_1111(d[0], invca, r);
- d[1] = NR_COMPOSENPP_1111(d[1], invca, g);
- d[2] = NR_COMPOSENPP_1111(d[2], invca, b);
- d[3] = NR_COMPOSEA_111(s[0], d[3]);
- }
- d += 4;
- s += 1;
- }
- px += rs;
- spx += srs;
- }
- } else {
- for (y = h; y > 0; y--) {
- unsigned char *d, *s;
- d = (unsigned char *) px;
- s = (unsigned char *) spx;
- for (x = w; x > 0; x--) {
- unsigned int ca;
- ca = NR_PREMUL_112 (s[0], a);
- if (ca == 0) {
- /* Transparent FG, NOP */
- } else {
- /* Full composition */
- unsigned int invca = 255*255-ca; // By swapping the arguments GCC can better optimize these calls
- d[0] = NR_COMPOSENPP_1211(d[0], invca, r);
- d[1] = NR_COMPOSENPP_1211(d[1], invca, g);
- d[2] = NR_COMPOSENPP_1211(d[2], invca, b);
- d[3] = NR_COMPOSEA_211(ca, d[3]);
- }
- d += 4;
- s += 1;
- }
- px += rs;
- spx += srs;
- }
- }
-}
-
-/* RGB */
-
-void
-nr_R8G8B8_R8G8B8_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha)
-{
- unsigned int r, c;
-
-#ifdef WITH_MMX
- if (NR_PIXOPS_MMX && alpha != 0) {
- /* WARNING: MMX composer REQUIRES w > 0 and h > 0 */
- nr_mmx_R8G8B8_R8G8B8_R8G8B8A8_P (px, w, h, rs, spx, srs, alpha);
- return;
- }
-#endif
-
- if (alpha == 0) {
- /* NOP */
- } else if (alpha == 255) {
- for (r = h; r > 0; r--) {
- unsigned char *d = px;
- const unsigned char *s = spx;
- for (c = w; c > 0; c--) {
- // dc' = (1 - alpha*sa) * dc + alpha*sc = (1 - sa) * dc + sc
- if (s[3] == 0) {
- /* NOP */
- } else if (s[3] == 255) {
- d[0] = s[0];
- d[1] = s[1];
- d[2] = s[2];
- } else {
- d[0] = NR_COMPOSEP11_1111(s[0], s[3], d[0]);
- d[1] = NR_COMPOSEP11_1111(s[1], s[3], d[1]);
- d[2] = NR_COMPOSEP11_1111(s[2], s[3], d[2]);
- }
- d += 3;
- s += 4;
- }
- px += rs;
- spx += srs;
- }
- } else {
- for (r = h; r > 0; r--) {
- unsigned char *d = px;
- const unsigned char *s = spx;
- for (c = w; c > 0; c--) {
- unsigned int a;
- a = NR_PREMUL_112(s[3], alpha);
- // dc' = (1 - alpha*sa) * dc + alpha*sc
- if (a == 0) {
- /* NOP */
- } else {
- d[0] = NR_COMPOSEP11_2211(NR_PREMUL_112(s[0], alpha), a, d[0]);
- d[1] = NR_COMPOSEP11_2211(NR_PREMUL_112(s[1], alpha), a, d[1]);
- d[2] = NR_COMPOSEP11_2211(NR_PREMUL_112(s[2], alpha), a, d[2]);
- }
- /* a == 255 is impossible, because alpha < 255 */
- d += 3;
- s += 4;
- }
- px += rs;
- spx += srs;
- }
- }
-}
-
-void
-nr_R8G8B8_R8G8B8_R8G8B8A8_N (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha)
-{
- unsigned int r, c;
-
- if (alpha == 0) {
- /* NOP */
- } else if (alpha == 255) {
- for (r = h; r > 0; r--) {
- unsigned char *d = px;
- const unsigned char *s = spx;
- for (c = w; c > 0; c--) {
- // dc' = (1 - alpha*sa) * dc + alpha*sa*sc = (1 - sa) * dc + sa*sc
- if (s[3] == 0) {
- /* NOP */
- } else if (s[3] == 255) {
- d[0] = s[0];
- d[1] = s[1];
- d[2] = s[2];
- } else {
- d[0] = NR_COMPOSEN11_1111(s[0], s[3], d[0]);
- d[1] = NR_COMPOSEN11_1111(s[1], s[3], d[1]);
- d[2] = NR_COMPOSEN11_1111(s[2], s[3], d[2]);
- }
- d += 3;
- s += 4;
- }
- px += rs;
- spx += srs;
- }
- } else {
- for (r = h; r > 0; r--) {
- unsigned char *d = px;
- const unsigned char *s = spx;
- for (c = w; c > 0; c--) {
- unsigned int a;
- a = NR_PREMUL_112(s[3], alpha);
- // dc' = (1 - alpha*sa) * dc + alpha*sa*sc
- if (a == 0) {
- /* NOP */
- } else {
- d[0] = NR_COMPOSEN11_1211(s[0], a, d[0]);
- d[1] = NR_COMPOSEN11_1211(s[1], a, d[1]);
- d[2] = NR_COMPOSEN11_1211(s[2], a, d[2]);
- }
- /* a == 255 is impossible, because alpha < 255 */
- d += 3;
- s += 4;
- }
- px += rs;
- spx += srs;
- }
- }
-}
-
-void
-nr_R8G8B8_R8G8B8_R8G8B8A8_P_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs)
-{
- unsigned int x, y;
-
- for (y = h; y > 0; y--) {
- unsigned char* d = px;
- const unsigned char* s = spx;
- const unsigned char* m = mpx;
- for (x = w; x > 0; x--) {
- unsigned int a;
- a = NR_PREMUL_112(s[3], m[0]);
- if (a == 0) {
- /* NOP */
- } else if (a == 255*255) {
- memcpy(d, s, 3);
- } else {
- // dc' = (1 - m*sa) * dc + m*sc
- d[0] = NR_COMPOSEP11_2211(NR_PREMUL_112(s[0], m[0]), a, d[0]);
- d[1] = NR_COMPOSEP11_2211(NR_PREMUL_112(s[1], m[0]), a, d[1]);
- d[2] = NR_COMPOSEP11_2211(NR_PREMUL_112(s[2], m[0]), a, d[2]);
- }
- d += 3;
- s += 4;
- m += 1;
- }
- px += rs;
- spx += srs;
- mpx += mrs;
- }
-}
-
-void
-nr_R8G8B8_R8G8B8_R8G8B8A8_N_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs)
-{
- unsigned int x, y;
-
- for (y = h; y > 0; y--) {
- unsigned char* d = px;
- const unsigned char* s = spx;
- const unsigned char* m = mpx;
- for (x = w; x > 0; x--) {
- unsigned int a;
- a = NR_PREMUL_112(s[3], m[0]);
- if (a == 0) {
- /* NOP */
- } else if (a == 255*255) {
- memcpy(d, s, 3);
- } else {
- // dc' = (1 - m*sa) * dc + m*sa*sc
- d[0] = NR_COMPOSEN11_1211(s[0], a, d[0]);
- d[1] = NR_COMPOSEN11_1211(s[1], a, d[1]);
- d[2] = NR_COMPOSEN11_1211(s[2], a, d[2]);
- }
- d += 3;
- s += 4;
- m += 1;
- }
- px += rs;
- spx += srs;
- mpx += mrs;
- }
-}
-
-
diff --git a/src/libnr/nr-compose.h b/src/libnr/nr-compose.h
deleted file mode 100644
index 4cecfac60..000000000
--- a/src/libnr/nr-compose.h
+++ /dev/null
@@ -1,69 +0,0 @@
-#ifndef __NR_COMPOSE_H__
-#define __NR_COMPOSE_H__
-
-/*
- * Pixel buffer rendering library
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * This code is in public domain
- */
-
-/* FINAL DST SRC */
-
-void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha);
-void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha);
-void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha);
-void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha);
-
-void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha);
-void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha);
-void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha);
-void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha);
-
-/* FINAL DST SRC MASK */
-
-void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_A8 (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int srs,
- const unsigned char *mpx, int mrs);
-void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_A8 (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int srs,
- const unsigned char *mpx, int mrs);
-void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_A8 (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int srs,
- const unsigned char *mpx, int mrs);
-void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_A8 (unsigned char *px, int w, int h, int rs,
- const unsigned char *spx, int srs,
- const unsigned char *mpx, int mrs);
-
-void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_A8 (unsigned char *p, int w, int h, int rs,
- const unsigned char *s, int srs,
- const unsigned char *m, int mrs);
-void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_A8 (unsigned char *p, int w, int h, int rs,
- const unsigned char *s, int srs,
- const unsigned char *m, int mrs);
-void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_A8 (unsigned char *p, int w, int h, int rs,
- const unsigned char *s, int srs,
- const unsigned char *m, int mrs);
-void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_A8 (unsigned char *p, int w, int h, int rs,
- const unsigned char *s, int srs,
- const unsigned char *m, int mrs);
-
-/* FINAL DST MASK COLOR */
-
-void nr_R8G8B8A8_N_EMPTY_A8_RGBA32 (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba);
-void nr_R8G8B8A8_P_EMPTY_A8_RGBA32 (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba);
-
-void nr_R8G8B8_R8G8B8_A8_RGBA32 (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba);
-void nr_R8G8B8A8_N_R8G8B8A8_N_A8_RGBA32 (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba);
-void nr_R8G8B8A8_P_R8G8B8A8_P_A8_RGBA32 (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba);
-
-/* RGB */
-
-void nr_R8G8B8_R8G8B8_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha);
-void nr_R8G8B8_R8G8B8_R8G8B8A8_N (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha);
-void nr_R8G8B8_R8G8B8_R8G8B8A8_P_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs);
-void nr_R8G8B8_R8G8B8_R8G8B8A8_N_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs);
-
-#endif
diff --git a/src/libnr/nr-convert2geom.h b/src/libnr/nr-convert2geom.h
index 2f87632fb..75098ce2b 100644
--- a/src/libnr/nr-convert2geom.h
+++ b/src/libnr/nr-convert2geom.h
@@ -9,7 +9,6 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include <libnr/nr-matrix.h>
#include <libnr/nr-rect.h>
#include <libnr/nr-point.h>
#include <2geom/affine.h>
@@ -24,19 +23,6 @@ inline NR::Point from_2geom(Geom::Point const & _pt) {
return NR::Point(_pt[0], _pt[1]);
}
-inline Geom::Affine to_2geom(NR::Matrix const & mat) {
- Geom::Affine mat2geom(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]);
- return mat2geom;
-}
-inline NR::Matrix from_2geom(Geom::Affine const & mat) {
- NR::Matrix mat2geom(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]);
- return mat2geom;
-}
-
-inline Geom::Translate to_2geom(NR::translate const & mat) {
- return Geom::Translate( mat.offset[0], mat.offset[1] );
-}
-
inline Geom::Rect to_2geom(NR::Rect const & rect) {
Geom::Rect rect2geom(to_2geom(rect.min()), to_2geom(rect.max()));
return rect2geom;
@@ -54,13 +40,6 @@ inline Geom::OptRect to_2geom(boost::optional<NR::Rect> const & rect) {
return rect2geom;
}
-inline NR::scale from_2geom(Geom::Scale const & in) {
- return NR::scale(in[Geom::X], in[Geom::Y]);
-}
-inline Geom::Scale to_2geom(NR::scale const & in) {
- return Geom::Scale(in[NR::X], in[NR::Y]);
-}
-
#endif
/*
diff --git a/src/libnr/nr-convex-hull-ops.h b/src/libnr/nr-convex-hull-ops.h
deleted file mode 100644
index 2e96bf367..000000000
--- a/src/libnr/nr-convex-hull-ops.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef SEEN_NR_CONVEX_HULL_FNS_H
-#define SEEN_NR_CONVEX_HULL_FNS_H
-
-/* ex:set et ts=4 sw=4: */
-
-/*
- * A class representing the convex hull of a set of points.
- *
- * Copyright 2004 MenTaLguY <mental@rydia.net>
- *
- * This code is licensed under the GNU GPL; see COPYING for more information.
- */
-
-#include <libnr/nr-matrix-fns.h>
-#include <libnr/nr-convex-hull.h>
-
-namespace NR {
-
-ConvexHull operator*(const Rect &r, const Matrix &m) {
- ConvexHull points(r.corner(0));
- for ( unsigned i = 1 ; i < 4 ; i++ ) {
- points.add(r.corner(i));
- }
- return points;
-}
-
-} /* namespace NR */
-
-#endif
diff --git a/src/libnr/nr-convex-hull.h b/src/libnr/nr-convex-hull.h
deleted file mode 100644
index dafdd8840..000000000
--- a/src/libnr/nr-convex-hull.h
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef SEEN_NR_CONVEX_HULL_H
-#define SEEN_NR_CONVEX_HULL_H
-
-/* ex:set et ts=4 sw=4: */
-
-/*
- * A class representing the convex hull of a set of points.
- *
- * Copyright 2004 MenTaLguY <mental@rydia.net>
- *
- * This code is licensed under the GNU GPL; see COPYING for more information.
- */
-
-#include <libnr/nr-rect.h>
-
-namespace NR {
-
-class ConvexHull {
-public:
- ConvexHull() : _bounds() {}
- explicit ConvexHull(Point const &p) : _bounds(Rect(p, p)) {}
-
- boost::optional<Point> midpoint() const {
- if (_bounds) {
- return _bounds->midpoint();
- } else {
- return boost::optional<Point>();
- }
- }
-
- void add(Point const &p) {
- if (_bounds) {
- _bounds->expandTo(p);
- } else {
- _bounds = Rect(p, p);
- }
- }
- void add(Rect const &r) {
- // Note that this is a hack. when convexhull actually works
- // you will need to add all four points.
- _bounds = union_bounds(_bounds, r);
- }
- void add(ConvexHull const &h) {
- if (h._bounds) {
- add(*h._bounds);
- }
- }
-
- boost::optional<Rect> const &bounds() const {
- return _bounds;
- }
-
-private:
- boost::optional<Rect> _bounds;
-};
-
-} /* namespace NR */
-
-#endif
diff --git a/src/libnr/nr-gradient.cpp b/src/libnr/nr-gradient.cpp
deleted file mode 100644
index cb03c048b..000000000
--- a/src/libnr/nr-gradient.cpp
+++ /dev/null
@@ -1,554 +0,0 @@
-#define __NR_GRADIENT_C__
-
-/*
- * Pixel buffer rendering library
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- * MenTaLguY <mental@rydia.net>
- *...Jasper van de Gronde <th.v.d.gronde@hccnet.nl>
- *
- * Copyright (C) 2009 Jasper van de Gronde
- * Copyright (C) 2007 MenTaLguY
- * Copyright (C) 2001-2002 Lauris Kaplinski
- * Copyright (C) 2001-2002 Ximian, Inc.
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-/*
- * Derived in part from public domain code by Lauris Kaplinski
- */
-
-#include <cstring>
-#include <libnr/nr-pixops.h>
-#include <libnr/nr-pixblock-pixel.h>
-#include <libnr/nr-blit.h>
-#include <libnr/nr-gradient.h>
-#include <libnr/nr-matrix-ops.h>
-#include <glib/gtypes.h>
-#include <stdio.h>
-
-/* Common */
-
-#define NRG_MASK (NR_GRADIENT_VECTOR_LENGTH - 1)
-#define NRG_2MASK ((long long) ((NR_GRADIENT_VECTOR_LENGTH << 1) - 1))
-
-namespace {
-inline unsigned char const *vector_index(int idx,
- unsigned char const *vector)
-{
- return vector + 4 * idx;
-}
-
-template <NRGradientSpread spread> struct Spread;
-
-template <>
-struct Spread<NR_GRADIENT_SPREAD_PAD> {
-static double index_at(NR::Coord r, double const unity = 1.0) {
- return r<0.0?0.0:r>unity?unity:r;
-}
-static unsigned char const *color_at(NR::Coord r,
- unsigned char const *vector)
-{
- return vector_index((int)(index_at(r, NR_GRADIENT_VECTOR_LENGTH - 1)+.5), vector);
- //return vector_index((int)CLAMP(r, 0, (double)(NR_GRADIENT_VECTOR_LENGTH - 1)), vector);
-}
-};
-
-template <>
-struct Spread<NR_GRADIENT_SPREAD_REPEAT> {
-static double index_at(NR::Coord r, double const unity = 1.0) {
- return r<0.0?(unity+fmod(r,unity)):fmod(r,unity);
-}
-static unsigned char const *color_at(NR::Coord r,
- unsigned char const *vector)
-{
- return vector_index((int)(index_at(r, NR_GRADIENT_VECTOR_LENGTH - 1)+.5), vector);
- //return vector_index((int)((long long)r & NRG_MASK), vector);
-}
-};
-
-template <>
-struct Spread<NR_GRADIENT_SPREAD_REFLECT> {
-static double index_at(NR::Coord r, double const unity = 1.0) {
- r = r<0.0?(2*unity+fmod(r,2*unity)):fmod(r,2*unity);
- if (r>unity) r=2*unity-r;
- return r;
-}
-static unsigned char const *color_at(NR::Coord r,
- unsigned char const *vector)
-{
- return vector_index((int)(index_at(r, NR_GRADIENT_VECTOR_LENGTH - 1)+.5), vector);
- //int idx = (int) ((long long)r & NRG_2MASK);
- //if (idx > NRG_MASK) idx = NRG_2MASK - idx;
- //return vector_index(idx, vector);
-}
-};
-
-template <NR_PIXBLOCK_MODE mode> struct ModeTraits;
-
-template <>
-struct ModeTraits<NR_PIXBLOCK_MODE_R8G8B8A8N> {
-static const unsigned bpp=4;
-};
-
-template <>
-struct ModeTraits<NR_PIXBLOCK_MODE_R8G8B8A8P> {
-static const unsigned bpp=4;
-};
-
-template <>
-struct ModeTraits<NR_PIXBLOCK_MODE_R8G8B8> {
-static const unsigned bpp=3;
-};
-
-template <>
-struct ModeTraits<NR_PIXBLOCK_MODE_A8> {
-static const unsigned bpp=1;
-};
-
-template <NR_PIXBLOCK_MODE mode, bool empty>
-struct Compose {
-static const unsigned bpp=ModeTraits<mode>::bpp;
-static void compose(NRPixBlock *pb, unsigned char *dest,
- NRPixBlock *spb, unsigned char const *src)
-{
- nr_compose_pixblock_pixblock_pixel(pb, dest, spb, src);
-}
-};
-
-template <>
-struct Compose<NR_PIXBLOCK_MODE_R8G8B8A8N, true> {
-static const unsigned bpp=4;
-static void compose(NRPixBlock */*pb*/, unsigned char *dest,
- NRPixBlock */*spb*/, unsigned char const *src)
-{
- std::memcpy(dest, src, 4);
-}
-};
-
-template <>
-struct Compose<NR_PIXBLOCK_MODE_R8G8B8A8P, true> {
-static const unsigned bpp=4;
-static void compose(NRPixBlock */*pb*/, unsigned char *dest,
- NRPixBlock */*spb*/, unsigned char const *src)
-{
- dest[0] = NR_PREMUL_111(src[0], src[3]);
- dest[1] = NR_PREMUL_111(src[1], src[3]);
- dest[2] = NR_PREMUL_111(src[2], src[3]);
- dest[3] = src[3];
-}
-};
-
-template <>
-struct Compose<NR_PIXBLOCK_MODE_R8G8B8, true> {
-static const unsigned bpp=3;
-static void compose(NRPixBlock */*pb*/, unsigned char *dest,
- NRPixBlock */*spb*/, unsigned char const *src)
-{
- dest[0] = NR_COMPOSEN11_1111(src[0], src[3], 255);
- dest[1] = NR_COMPOSEN11_1111(src[1], src[3], 255);
- dest[2] = NR_COMPOSEN11_1111(src[2], src[3], 255);
-}
-};
-
-template <>
-struct Compose<NR_PIXBLOCK_MODE_A8, true> {
-static const unsigned bpp=1;
-static void compose(NRPixBlock */*pb*/, unsigned char *dest,
- NRPixBlock */*spb*/, unsigned char const *src)
-{
- dest[0] = src[3];
-}
-};
-
-template <>
-struct Compose<NR_PIXBLOCK_MODE_R8G8B8A8N, false> {
-static const unsigned bpp=4;
-static void compose(NRPixBlock */*pb*/, unsigned char *dest,
- NRPixBlock */*spb*/, unsigned char const *src)
-{
- unsigned int ca;
- ca = NR_COMPOSEA_112(src[3], dest[3]);
- dest[0] = NR_COMPOSENNN_111121(src[0], src[3], dest[0], dest[3], ca);
- dest[1] = NR_COMPOSENNN_111121(src[1], src[3], dest[1], dest[3], ca);
- dest[2] = NR_COMPOSENNN_111121(src[2], src[3], dest[2], dest[3], ca);
- dest[3] = NR_NORMALIZE_21(ca);
-}
-};
-
-template <>
-struct Compose<NR_PIXBLOCK_MODE_R8G8B8A8P, false> {
-static const unsigned bpp=4;
-static void compose(NRPixBlock */*pb*/, unsigned char *dest,
- NRPixBlock */*spb*/, unsigned char const *src)
-{
- dest[0] = NR_COMPOSENPP_1111(src[0], src[3], dest[0]);
- dest[1] = NR_COMPOSENPP_1111(src[1], src[3], dest[1]);
- dest[2] = NR_COMPOSENPP_1111(src[2], src[3], dest[2]);
- dest[3] = NR_COMPOSEA_111(src[3], dest[3]);
-}
-};
-
-template <>
-struct Compose<NR_PIXBLOCK_MODE_R8G8B8, false> {
-static const unsigned bpp=3;
-static void compose(NRPixBlock */*pb*/, unsigned char *dest,
- NRPixBlock */*spb*/, unsigned char const *src)
-{
- dest[0] = NR_COMPOSEN11_1111(src[0], src[3], dest[0]);
- dest[1] = NR_COMPOSEN11_1111(src[1], src[3], dest[1]);
- dest[2] = NR_COMPOSEN11_1111(src[2], src[3], dest[2]);
-}
-};
-
-template <typename Subtype, typename spread>
-static void
-render_spread(NRGradientRenderer *gr, NRPixBlock *pb)
-{
- switch (pb->mode) {
- case NR_PIXBLOCK_MODE_R8G8B8A8N:
- if (pb->empty) {
- typedef Compose<NR_PIXBLOCK_MODE_R8G8B8A8N, true> compose;
- Subtype::template render<compose, spread>(gr, pb);
- } else {
- typedef Compose<NR_PIXBLOCK_MODE_R8G8B8A8N, false> compose;
- Subtype::template render<compose, spread>(gr, pb);
- }
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8P:
- if (pb->empty) {
- typedef Compose<NR_PIXBLOCK_MODE_R8G8B8A8P, true> compose;
- Subtype::template render<compose, spread>(gr, pb);
- } else {
- typedef Compose<NR_PIXBLOCK_MODE_R8G8B8A8P, false> compose;
- Subtype::template render<compose, spread>(gr, pb);
- }
- break;
- case NR_PIXBLOCK_MODE_R8G8B8:
- if (pb->empty) {
- typedef Compose<NR_PIXBLOCK_MODE_R8G8B8, true> compose;
- Subtype::template render<compose, spread>(gr, pb);
- } else {
- typedef Compose<NR_PIXBLOCK_MODE_R8G8B8, false> compose;
- Subtype::template render<compose, spread>(gr, pb);
- }
- break;
- case NR_PIXBLOCK_MODE_A8:
- if (pb->empty) {
- typedef Compose<NR_PIXBLOCK_MODE_A8, true> compose;
- Subtype::template render<compose, spread>(gr, pb);
- } else {
- typedef Compose<NR_PIXBLOCK_MODE_A8, false> compose;
- Subtype::template render<compose, spread>(gr, pb);
- }
- break;
- }
-}
-
-template <typename Subtype>
-static void
-render(NRRenderer *r, NRPixBlock *pb, NRPixBlock */*m*/)
-{
- NRGradientRenderer *gr = static_cast<NRGradientRenderer *>(r);
-
- switch (gr->spread) {
- case NR_GRADIENT_SPREAD_REPEAT:
- render_spread<Subtype, Spread<NR_GRADIENT_SPREAD_REPEAT> >(gr, pb);
- break;
- case NR_GRADIENT_SPREAD_REFLECT:
- render_spread<Subtype, Spread<NR_GRADIENT_SPREAD_REFLECT> >(gr, pb);
- break;
- case NR_GRADIENT_SPREAD_PAD:
- default:
- render_spread<Subtype, Spread<NR_GRADIENT_SPREAD_PAD> >(gr, pb);
- }
-}
-}
-
-/* Linear */
-
-namespace {
-
-struct Linear {
-template <typename compose, typename spread>
-static void render(NRGradientRenderer *gr, NRPixBlock *pb) {
- NRLGradientRenderer *lgr = static_cast<NRLGradientRenderer *>(gr);
-
- int x, y;
- unsigned char *d;
- double pos;
- NRPixBlock spb;
- int x0, y0, width, height, rs;
-
- x0 = pb->area.x0;
- y0 = pb->area.y0;
- width = pb->area.x1 - pb->area.x0;
- height = pb->area.y1 - pb->area.y0;
- rs = pb->rs;
-
- nr_pixblock_setup_extern(&spb, NR_PIXBLOCK_MODE_R8G8B8A8N,
- 0, 0, NR_GRADIENT_VECTOR_LENGTH, 1,
- (unsigned char *) lgr->vector,
- 4 * NR_GRADIENT_VECTOR_LENGTH, 0, 0);
-
- for (y = 0; y < height; y++) {
- d = NR_PIXBLOCK_PX(pb) + y * rs;
- pos = (y + y0 - lgr->y0) * lgr->dy + (0 + x0 - lgr->x0) * lgr->dx;
- for (x = 0; x < width; x++) {
- unsigned char const *s=spread::color_at(pos, lgr->vector);
- compose::compose(pb, d, &spb, s);
- d += compose::bpp;
- pos += lgr->dx;
- }
- }
-
- nr_pixblock_release(&spb);
-}
-};
-
-}
-
-NRRenderer *
-nr_lgradient_renderer_setup (NRLGradientRenderer *lgr,
- const unsigned char *cv,
- unsigned int spread,
- const NR::Matrix *gs2px,
- float x0, float y0,
- float x1, float y1)
-{
- NR::Matrix n2gs, n2px, px2n;
-
- lgr->render = &render<Linear>;
-
- lgr->vector = cv;
- lgr->spread = spread;
-
- n2gs[0] = x1 - x0;
- n2gs[1] = y1 - y0;
- n2gs[2] = y1 - y0;
- n2gs[3] = x0 - x1;
- n2gs[4] = x0;
- n2gs[5] = y0;
-
- n2px = n2gs * (*gs2px);
- px2n = n2px.inverse();
-
- lgr->x0 = n2px[4] - 0.5; // These -0.5 offsets make sure that the gradient is sampled in the MIDDLE of each pixel.
- lgr->y0 = n2px[5] - 0.5;
- lgr->dx = px2n[0] * (NR_GRADIENT_VECTOR_LENGTH-1);
- lgr->dy = px2n[2] * (NR_GRADIENT_VECTOR_LENGTH-1);
-
- return (NRRenderer *) lgr;
-}
-
-/* Radial */
-
-/*
- * The archetype is following
- *
- * gx gy - pixel coordinates
- * Px Py - coordinates, where Fx Fy - gx gy line intersects with circle
- *
- * (1) (gx - fx) * (Py - fy) = (gy - fy) * (Px - fx)
- * (2) (Px - cx) * (Px - cx) + (Py - cy) * (Py - cy) = r * r
- *
- * (3) Py = (Px - fx) * (gy - fy) / (gx - fx) + fy
- * (4) (gy - fy) / (gx - fx) = D
- * (5) Py = D * Px - D * fx + fy
- *
- * (6) D * fx - fy + cy = N
- * (7) Px * Px - 2 * Px * cx + cx * cx + (D * Px) * (D * Px) - 2 * (D * Px) * N + N * N = r * r
- * (8) (D * D + 1) * (Px * Px) - 2 * (cx + D * N) * Px + cx * cx + N * N = r * r
- *
- * (9) A = D * D + 1
- * (10) B = -2 * (cx + D * N)
- * (11) C = cx * cx + N * N - r * r
- *
- * (12) Px = (-B +- SQRT(B * B - 4 * A * C)) / 2 * A
- */
-
-namespace {
-
-struct SymmetricRadial {
-template <typename compose, typename spread>
-static void render(NRGradientRenderer *gr, NRPixBlock *pb)
-{
- NRRGradientRenderer *rgr = static_cast<NRRGradientRenderer *>(gr);
-
- NR::Coord const dx = rgr->px2gs[0];
- NR::Coord const dy = rgr->px2gs[1];
-
- NRPixBlock spb;
- nr_pixblock_setup_extern(&spb, NR_PIXBLOCK_MODE_R8G8B8A8N,
- 0, 0, NR_GRADIENT_VECTOR_LENGTH, 1,
- (unsigned char *) rgr->vector,
- 4 * NR_GRADIENT_VECTOR_LENGTH,
- 0, 0);
-
- for (int y = pb->area.y0; y < pb->area.y1; y++) {
- unsigned char *d = NR_PIXBLOCK_PX(pb) + (y - pb->area.y0) * pb->rs;
- NR::Coord gx = rgr->px2gs[0] * pb->area.x0 + rgr->px2gs[2] * y + rgr->px2gs[4];
- NR::Coord gy = rgr->px2gs[1] * pb->area.x0 + rgr->px2gs[3] * y + rgr->px2gs[5];
- for (int x = pb->area.x0; x < pb->area.x1; x++) {
- NR::Coord const pos = sqrt(((gx*gx) + (gy*gy)));
- unsigned char const *s=spread::color_at(pos, rgr->vector);
- compose::compose(pb, d, &spb, s);
- d += compose::bpp;
- gx += dx;
- gy += dy;
- }
- }
-
- nr_pixblock_release(&spb);
-}
-};
-
-struct Radial {
-template <typename compose, typename spread>
-static void render(NRGradientRenderer *gr, NRPixBlock *pb)
-{
- NRRGradientRenderer *rgr = static_cast<NRRGradientRenderer *>(gr);
- int const x0 = pb->area.x0;
- int const y0 = pb->area.y0;
- int const x1 = pb->area.x1;
- int const y1 = pb->area.y1;
- int const rs = pb->rs;
-
- NRPixBlock spb;
- nr_pixblock_setup_extern(&spb, NR_PIXBLOCK_MODE_R8G8B8A8N,
- 0, 0, NR_GRADIENT_VECTOR_LENGTH, 1,
- (unsigned char *) rgr->vector,
- 4 * NR_GRADIENT_VECTOR_LENGTH,
- 0, 0);
-
- for (int y = y0; y < y1; y++) {
- unsigned char *d = NR_PIXBLOCK_PX(pb) + (y - y0) * rs;
- NR::Coord gx = rgr->px2gs[0] * x0 + rgr->px2gs[2] * y + rgr->px2gs[4];
- NR::Coord gy = rgr->px2gs[1] * x0 + rgr->px2gs[3] * y + rgr->px2gs[5];
- NR::Coord const dx = rgr->px2gs[0];
- NR::Coord const dy = rgr->px2gs[1];
- for (int x = x0; x < x1; x++) {
- NR::Coord const gx2 = gx * gx;
- NR::Coord const gxy2 = gx2 + gy * gy;
- NR::Coord const qgx2_4 = gx2 - rgr->C * gxy2;
- /* INVARIANT: qgx2_4 >= 0.0 */
- /* qgx2_4 = MAX(qgx2_4, 0.0); */
- NR::Coord const pxgx = gx + sqrt(qgx2_4);
- /* We can safely divide by 0 here */
- /* If we are sure pxgx cannot be -0 */
- NR::Coord const pos = gxy2 / pxgx * (NR_GRADIENT_VECTOR_LENGTH-1);
-
- unsigned char const *s;
- if (pos < (1U << 31)) {
- s = spread::color_at(pos, rgr->vector);
- } else {
- s = vector_index(NR_GRADIENT_VECTOR_LENGTH - 1, rgr->vector);
- }
-
- compose::compose(pb, d, &spb, s);
- d += compose::bpp;
-
- gx += dx;
- gy += dy;
- }
- }
-
- nr_pixblock_release(&spb);
-}
-};
-
-}
-
-static void nr_rgradient_render_block_end(NRRenderer *r, NRPixBlock *pb, NRPixBlock *m);
-
-NRRenderer *
-nr_rgradient_renderer_setup(NRRGradientRenderer *rgr,
- unsigned char const *cv,
- unsigned spread,
- NR::Matrix const *gs2px,
- float cx, float cy,
- float fx, float fy,
- float r)
-{
- rgr->vector = cv;
- rgr->spread = spread;
-
- if (r < NR_EPSILON) {
- rgr->render = nr_rgradient_render_block_end;
- } else if (NR_DF_TEST_CLOSE(cx, fx, NR_EPSILON) &&
- NR_DF_TEST_CLOSE(cy, fy, NR_EPSILON)) {
- rgr->render = render<SymmetricRadial>;
-
- rgr->px2gs = gs2px->inverse();
- rgr->px2gs[0] *= (NR_GRADIENT_VECTOR_LENGTH-1) / r;
- rgr->px2gs[1] *= (NR_GRADIENT_VECTOR_LENGTH-1) / r;
- rgr->px2gs[2] *= (NR_GRADIENT_VECTOR_LENGTH-1) / r;
- rgr->px2gs[3] *= (NR_GRADIENT_VECTOR_LENGTH-1) / r;
- rgr->px2gs[4] -= cx;
- rgr->px2gs[5] -= cy;
- rgr->px2gs[4] *= (NR_GRADIENT_VECTOR_LENGTH-1) / r;
- rgr->px2gs[5] *= (NR_GRADIENT_VECTOR_LENGTH-1) / r;
- rgr->px2gs[4] += 0.5*(rgr->px2gs[0]+rgr->px2gs[2]); // These offsets make sure the gradient is sampled in the MIDDLE of each pixel
- rgr->px2gs[5] += 0.5*(rgr->px2gs[1]+rgr->px2gs[3]);
-
- rgr->cx = 0.0;
- rgr->cy = 0.0;
- rgr->fx = rgr->cx;
- rgr->fy = rgr->cy;
- rgr->r = 1.0;
- } else {
- rgr->render = render<Radial>;
-
- NR::Coord const df = hypot(fx - cx, fy - cy);
- if (df >= r) {
- fx = cx + (fx - cx ) * r / (float) df;
- fy = cy + (fy - cy ) * r / (float) df;
- }
-
- NR::Matrix n2gs;
- n2gs[0] = cx - fx;
- n2gs[1] = cy - fy;
- n2gs[2] = cy - fy;
- n2gs[3] = fx - cx;
- n2gs[4] = fx;
- n2gs[5] = fy;
-
- NR::Matrix n2px;
- n2px = n2gs * (*gs2px);
- rgr->px2gs = n2px.inverse();
- rgr->px2gs[4] += 0.5*(rgr->px2gs[0]+rgr->px2gs[2]); // These offsets make sure the gradient is sampled in the MIDDLE of each pixel
- rgr->px2gs[5] += 0.5*(rgr->px2gs[1]+rgr->px2gs[3]);
-
- rgr->cx = 1.0;
- rgr->cy = 0.0;
- rgr->fx = 0.0;
- rgr->fy = 0.0;
- rgr->r = r / (float) hypot(fx - cx, fy - cy);
- rgr->C = 1.0F - rgr->r * rgr->r;
- /* INVARIANT: C < 0 */
- rgr->C = MIN(rgr->C, -NR_EPSILON);
- }
-
- return (NRRenderer *) rgr;
-}
-
-static void
-nr_rgradient_render_block_end(NRRenderer *r, NRPixBlock *pb, NRPixBlock *m)
-{
- unsigned char const *c = ((NRRGradientRenderer *) r)->vector + 4 * (NR_GRADIENT_VECTOR_LENGTH - 1);
-
- nr_blit_pixblock_mask_rgba32(pb, m, (c[0] << 24) | (c[1] << 16) | (c[2] << 8) | c[3]);
-}
-
-/*
- 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-gradient.h b/src/libnr/nr-gradient.h
deleted file mode 100644
index f5afdc98d..000000000
--- a/src/libnr/nr-gradient.h
+++ /dev/null
@@ -1,81 +0,0 @@
-#ifndef __NR_GRADIENT_H__
-#define __NR_GRADIENT_H__
-
-/*
- * Pixel buffer rendering library
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * Copyright (C) 2001-2002 Lauris Kaplinski
- * Copyright (C) 2001-2002 Ximian, Inc.
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-/*
- * Derived in part from public domain code by Lauris Kaplinski
- */
-
-#include <libnr/nr-matrix.h>
-#include <libnr/nr-render.h>
-
-#define NR_GRADIENT_VECTOR_BITS 10
-#define NR_GRADIENT_VECTOR_LENGTH (1<<NR_GRADIENT_VECTOR_BITS)
-
-enum NRGradientSpread {
- NR_GRADIENT_SPREAD_PAD,
- NR_GRADIENT_SPREAD_REFLECT,
- NR_GRADIENT_SPREAD_REPEAT
-};
-
-struct NRGradientRenderer : public NRRenderer {
- const unsigned char *vector;
- unsigned int spread;
-};
-
-/* Linear */
-
-struct NRLGradientRenderer : public NRGradientRenderer {
- double x0, y0;
- double dx, dy;
-};
-
-NRRenderer *nr_lgradient_renderer_setup (NRLGradientRenderer *lgr,
- const unsigned char *cv,
- unsigned int spread,
- const NR::Matrix *gs2px,
- float x0, float y0,
- float x1, float y1);
-
-/* Radial */
-
-struct NRRGradientRenderer : public NRGradientRenderer {
- NR::Matrix px2gs;
- float cx, cy;
- float fx, fy;
- float r;
- float C;
-};
-
-NRRenderer *nr_rgradient_renderer_setup (NRRGradientRenderer *rgr,
- const unsigned char *cv,
- unsigned int spread,
- const NR::Matrix *gs2px,
- float cx, float cy,
- float fx, float fy,
- float r);
-
-
-
-#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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-matrix-div.cpp b/src/libnr/nr-matrix-div.cpp
deleted file mode 100644
index d6fb598b8..000000000
--- a/src/libnr/nr-matrix-div.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-#include "libnr/nr-matrix-ops.h"
-#include "libnr/nr-point-matrix-ops.h"
-
-NR::Point operator/(NR::Point const &p, NR::Matrix const &m) {
- return p * m.inverse();
-}
-
-NR::Matrix operator/(NR::Matrix const &a, NR::Matrix const &b) {
- return a * b.inverse();
-}
-
-
-/*
- 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 :
diff --git a/src/libnr/nr-matrix-div.h b/src/libnr/nr-matrix-div.h
deleted file mode 100644
index 8669e2ce2..000000000
--- a/src/libnr/nr-matrix-div.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef SEEN_LIBNR_NR_MATRIX_DIV_H
-#define SEEN_LIBNR_NR_MATRIX_DIV_H
-
-#include "libnr/nr-forward.h"
-
-NR::Point operator/(NR::Point const &, NR::Matrix const &);
-
-NR::Matrix operator/(NR::Matrix const &, NR::Matrix const &);
-
-#endif /* !SEEN_LIBNR_NR_MATRIX_DIV_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 :
diff --git a/src/libnr/nr-matrix-fns.cpp b/src/libnr/nr-matrix-fns.cpp
deleted file mode 100644
index c8eb986fa..000000000
--- a/src/libnr/nr-matrix-fns.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-#include <libnr/nr-matrix-fns.h>
-#include <cstdio>
-
-namespace NR {
-
-Matrix elliptic_quadratic_form(Matrix const &m) {
- double const od = m[0] * m[1] + m[2] * m[3];
- return Matrix((m[0]*m[0] + m[1]*m[1]), od,
- od, (m[2]*m[2] + m[3]*m[3]),
- 0, 0);
-/* def quadratic_form((a, b), (c, d)):
- return ((a*a + c*c), a*c+b*d),(a*c+b*d, (b*b + d*d)) */
-}
-
-Eigen::Eigen(Matrix const &m) {
- double const B = -m[0] - m[3];
- double const C = m[0]*m[3] - m[1]*m[2];
- double const center = -B/2.0;
- double const delta = sqrt(B*B-4*C)/2.0;
- values = Point(center + delta, center - delta);
- for (int i = 0; i < 2; i++) {
- vectors[i] = unit_vector(rot90(Point(m[0]-values[i], m[1])));
- }
-}
-
-/** Returns just the scale/rotate/skew part of the matrix without the translation part. */
-Matrix transform(Matrix const &m) {
- Matrix const ret(m[0], m[1],
- m[2], m[3],
- 0, 0);
- return ret;
-}
-
-translate get_translation(Matrix const &m) {
- return translate(m[4], m[5]);
-}
-
-void matrix_print(const gchar *say, Matrix const &m)
-{
- printf ("%s %g %g %g %g %g %g\n", say, m[0], m[1], m[2], m[3], m[4], m[5]);
-}
-
-} // namespace NR
-
-
-/*
- 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 :
diff --git a/src/libnr/nr-matrix-fns.h b/src/libnr/nr-matrix-fns.h
deleted file mode 100644
index a46aca909..000000000
--- a/src/libnr/nr-matrix-fns.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef SEEN_NR_MATRIX_FNS_H
-#define SEEN_NR_MATRIX_FNS_H
-
-#include "nr-matrix.h"
-#include <math.h>
-
-namespace NR {
-
-/** Given a matrix m such that unit_circle = m*x, this returns the
- * quadratic form x*A*x = 1. */
-Matrix elliptic_quadratic_form(Matrix const &m);
-
-/** Given a matrix (ignoring the translation) this returns the eigen
- * values and vectors. */
-class Eigen{
-public:
- Point vectors[2];
- Point values;
- Eigen(Matrix const &m);
-};
-
-// Matrix factories
-Matrix from_basis(const Point x_basis, const Point y_basis, const Point offset=Point(0,0));
-
-Matrix identity();
-
-double expansion(Matrix const &m);
-inline double expansionX(Matrix const &m) { return hypot(m[0], m[1]); }
-inline double expansionY(Matrix const &m) { return hypot(m[2], m[3]); }
-
-bool transform_equalp(Matrix const &m0, Matrix const &m1, NR::Coord const epsilon);
-bool translate_equalp(Matrix const &m0, Matrix const &m1, NR::Coord const epsilon);
-bool matrix_equalp(Matrix const &m0, Matrix const &m1, NR::Coord const epsilon);
-
-Matrix transform(Matrix const &m);
-translate get_translation(Matrix const &m);
-
-void matrix_print(const gchar *say, Matrix const &m);
-
-} // namespace NR
-
-#endif /* !SEEN_NR_MATRIX_FNS_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 :
diff --git a/src/libnr/nr-matrix-ops.h b/src/libnr/nr-matrix-ops.h
deleted file mode 100644
index 2c9c93124..000000000
--- a/src/libnr/nr-matrix-ops.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* operator functions for NR::Matrix. */
-#ifndef SEEN_NR_MATRIX_OPS_H
-#define SEEN_NR_MATRIX_OPS_H
-
-#include <libnr/nr-matrix.h>
-
-namespace NR {
-
-inline bool operator==(Matrix const &a, Matrix const &b)
-{
- for(unsigned i = 0; i < 6; ++i) {
- if ( a[i] != b[i] ) {
- return false;
- }
- }
- return true;
-}
-
-inline bool operator!=(Matrix const &a, Matrix const &b)
-{
- return !( a == b );
-}
-
-Matrix operator*(Matrix const &a, Matrix const &b);
-
-inline Matrix &operator*=(Matrix &a, Matrix const &b) { a = a * b; return a; }
-
-} /* namespace NR */
-
-#endif /* !SEEN_NR_MATRIX_OPS_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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-matrix-rotate-ops.cpp b/src/libnr/nr-matrix-rotate-ops.cpp
deleted file mode 100644
index d16809318..000000000
--- a/src/libnr/nr-matrix-rotate-ops.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-#include "libnr/nr-matrix-ops.h"
-
-NR::Matrix operator*(NR::Matrix const &m, NR::rotate const &r)
-{
- return m * NR::Matrix(r);
-}
-
-
-/*
- 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-matrix-rotate-ops.h b/src/libnr/nr-matrix-rotate-ops.h
deleted file mode 100644
index a3cc4c806..000000000
--- a/src/libnr/nr-matrix-rotate-ops.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef SEEN_LIBNR_NR_MATRIX_ROTATE_OPS_H
-#define SEEN_LIBNR_NR_MATRIX_ROTATE_OPS_H
-
-#include "libnr/nr-forward.h"
-
-NR::Matrix operator*(NR::Matrix const &m, NR::rotate const &r);
-
-
-#endif /* !SEEN_LIBNR_NR_MATRIX_ROTATE_OPS_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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-matrix-scale-ops.h b/src/libnr/nr-matrix-scale-ops.h
deleted file mode 100644
index d030bb66c..000000000
--- a/src/libnr/nr-matrix-scale-ops.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef SEEN_LIBNR_NR_MATRIX_SCALE_OPS_H
-#define SEEN_LIBNR_NR_MATRIX_SCALE_OPS_H
-/** \file
- * Declarations (and definition if inline) of operator blah (NR::Matrix, NR::scale).
- */
-
-#include "libnr/nr-forward.h"
-
-namespace NR {
-
-inline Matrix &operator/=(Matrix &m, scale const &s) {
- m[0] /= s[X]; m[1] /= s[Y];
- m[2] /= s[X]; m[3] /= s[Y];
- m[4] /= s[X]; m[5] /= s[Y];
- return m;
-}
-
-inline Matrix &operator*=(Matrix &m, scale const &s) {
- m[0] *= s[X]; m[1] *= s[Y];
- m[2] *= s[X]; m[3] *= s[Y];
- m[4] *= s[X]; m[5] *= s[Y];
- return m;
-}
-
-inline Matrix operator/(Matrix const &m, scale const &s) { Matrix ret(m); ret /= s; return ret; }
-
-inline Matrix operator*(Matrix const &m, scale const &s) { Matrix ret(m); ret *= s; return ret; }
-
-}
-
-#endif /* !SEEN_LIBNR_NR_MATRIX_SCALE_OPS_H */
diff --git a/src/libnr/nr-matrix-test.h b/src/libnr/nr-matrix-test.h
deleted file mode 100644
index 6477523fc..000000000
--- a/src/libnr/nr-matrix-test.h
+++ /dev/null
@@ -1,191 +0,0 @@
-#include <cxxtest/TestSuite.h>
-
-#include <libnr/nr-matrix.h>
-#include <libnr/nr-matrix-fns.h>
-#include <libnr/nr-matrix-ops.h>
-#include <libnr/nr-matrix-rotate-ops.h>
-#include <libnr/nr-matrix-scale-ops.h>
-#include <libnr/nr-point-matrix-ops.h>
-#include <libnr/nr-rotate.h>
-#include <libnr/nr-rotate-ops.h>
-#include <libnr/nr-scale-ops.h>
-#include <libnr/nr-scale-translate-ops.h>
-#include <libnr/nr-translate.h>
-#include <libnr/nr-translate-ops.h>
-#include <libnr/nr-translate-scale-ops.h>
-
-inline bool point_equalp(NR::Point const &a, NR::Point const &b)
-{
- return ( NR_DF_TEST_CLOSE(a[NR::X], b[NR::X], 1e-5) &&
- NR_DF_TEST_CLOSE(a[NR::Y], b[NR::Y], 1e-5) );
-}
-
-class NrMatrixTest : public CxxTest::TestSuite
-{
-public:
-
- NrMatrixTest() :
- m_id( NR::identity() ),
- r_id( NR::Point(1, 0) ),
- t_id( 0, 0 ),
- c16( 1.0, 2.0,
- 3.0, 4.0,
- 5.0, 6.0),
- r86( NR::Point(.8, .6) ),
- mr86( r86 ),
- t23( 2.0, 3.0 ),
- s_id( 1.0, 1.0 )
- {
- }
- virtual ~NrMatrixTest() {}
-
-// createSuite and destroySuite get us per-suite setup and teardown
-// without us having to worry about static initialization order, etc.
- static NrMatrixTest *createSuite() { return new NrMatrixTest(); }
- static void destroySuite( NrMatrixTest *suite ) { delete suite; }
-
- NR::Matrix const m_id;
- NR::rotate const r_id;
- NR::translate const t_id;
- NR::Matrix const c16;
- NR::rotate const r86;
- NR::Matrix const mr86;
- NR::translate const t23;
- NR::scale const s_id;
-
-
-
-
- void testCtorsAssignmentOp(void)
- {
- NR::Matrix const c16_copy(c16);
- NR::Matrix c16_eq(m_id);
- c16_eq = c16;
- for(unsigned i = 0; i < 6; ++i) {
- TS_ASSERT_EQUALS( c16[i], 1.0 + i );
- TS_ASSERT_EQUALS( c16[i], c16_copy[i] );
- TS_ASSERT_EQUALS( c16[i], c16_eq[i] );
- TS_ASSERT_EQUALS( m_id[i], double( i == 0 || i == 3 ) );
- }
- }
-
- void testScaleCtor(void)
- {
- NR::scale const s(2.0, 3.0);
- NR::Matrix const ms(s);
- NR::Point const p(5.0, 7.0);
- TS_ASSERT_EQUALS( p * s, NR::Point(10.0, 21.0) );
- TS_ASSERT_EQUALS( p * ms, NR::Point(10.0, 21.0) );
- }
-
- void testRotateCtor(void)
- {
- NR::Point const p0(1.0, 0.0);
- NR::Point const p90(0.0, 1.0);
- TS_ASSERT_EQUALS( p0 * r86, NR::Point(.8, .6) );
- TS_ASSERT_EQUALS( p0 * mr86, NR::Point(.8, .6) );
- TS_ASSERT_EQUALS( p90 * r86, NR::Point(-.6, .8) );
- TS_ASSERT_EQUALS( p90 * mr86, NR::Point(-.6, .8) );
- TS_ASSERT( matrix_equalp(NR::Matrix( r86 * r86 ),
- mr86 * mr86,
- 1e-14) );
- }
-
- void testTranslateCtor(void)
- {
- NR::Matrix const mt23(t23);
- NR::Point const b(-2.0, 3.0);
- TS_ASSERT_EQUALS( b * t23, b * mt23 );
- }
-
- void testIdentity(void)
- {
- TS_ASSERT( m_id.test_identity() );
- TS_ASSERT( NR::Matrix(t_id).test_identity() );
- TS_ASSERT( !(NR::Matrix(NR::translate(-2, 3)).test_identity()) );
- TS_ASSERT( NR::Matrix(r_id).test_identity() );
- NR::rotate const rot180(NR::Point(-1, 0));
- TS_ASSERT( !(NR::Matrix(rot180).test_identity()) );
- TS_ASSERT( NR::Matrix(s_id).test_identity() );
- TS_ASSERT( !(NR::Matrix(NR::scale(1.0, 0.0)).test_identity()) );
- TS_ASSERT( !(NR::Matrix(NR::scale(0.0, 1.0)).test_identity()) );
- TS_ASSERT( !(NR::Matrix(NR::scale(1.0, -1.0)).test_identity()) );
- TS_ASSERT( !(NR::Matrix(NR::scale(-1.0, -1.0)).test_identity()) );
- }
-
- void testInverse(void)
- {
- TS_ASSERT_EQUALS( m_id.inverse(), m_id );
- TS_ASSERT_EQUALS( NR::Matrix(t23).inverse(), NR::Matrix(NR::translate(-2.0, -3.0)) );
- NR::scale const s2(-4.0, 2.0);
- NR::scale const sp5(-.25, .5);
- TS_ASSERT_EQUALS( NR::Matrix(s2).inverse(), NR::Matrix(sp5) );
- TS_ASSERT_EQUALS( NR::Matrix(sp5).inverse(), NR::Matrix(s2) );
- }
-
- void testEllipticQuadraticForm(void)
- {
- NR::Matrix const aff(1.0, 1.0,
- 0.0, 1.0,
- 5.0, 6.0);
- NR::Matrix const invaff = aff.inverse();
- TS_ASSERT_EQUALS( invaff[1], -1.0 );
-
- NR::Matrix const ef(elliptic_quadratic_form(invaff));
- NR::Matrix const exp_ef(2, -1,
- -1, 1,
- 0, 0);
- TS_ASSERT_EQUALS( ef, exp_ef );
- }
-
- void testMatrixStarRotate(void)
- {
- NR::Matrix const ma(2.0, -1.0,
- 4.0, 4.0,
- -0.5, 2.0);
- NR::Matrix const a_r86( ma * r86 );
- NR::Matrix const ma1( a_r86 * r86.inverse() );
- TS_ASSERT( matrix_equalp(ma1, ma, 1e-12) );
- NR::Matrix const exp_a_r86( 2*.8 + -1*-.6, 2*.6 + -1*.8,
- 4*.8 + 4*-.6, 4*.6 + 4*.8,
- -.5*.8 + 2*-.6, -.5*.6 + 2*.8 );
- TS_ASSERT( matrix_equalp(a_r86, exp_a_r86, 1e-12) );
- }
-
- void testTranslateStarScale_ScaleStarTranslate(void)
- {
- NR::translate const t2n4(2, -4);
- NR::scale const sn2_8(-2, 8);
- NR::Matrix const exp_ts(-2, 0,
- 0, 8,
- -4, -32);
- NR::Matrix const exp_st(-2, 0,
- 0, 8,
- 2, -4);
- TS_ASSERT_EQUALS( exp_ts, t2n4 * sn2_8 );
- TS_ASSERT_EQUALS( exp_st, sn2_8 * t2n4 );
- }
-
- void testMatrixStarScale(void)
- {
- NR::Matrix const ma(2.0, -1.0,
- 4.0, 4.0,
- -0.5, 2.0);
- NR::scale const sn2_8(-2, 8);
- NR::Matrix const exp_as(-4, -8,
- -8, 32,
- 1, 16);
- TS_ASSERT_EQUALS( ma * sn2_8, exp_as );
- }
-};
-
-/*
- 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-matrix-translate-ops.h b/src/libnr/nr-matrix-translate-ops.h
deleted file mode 100644
index 3d944651f..000000000
--- a/src/libnr/nr-matrix-translate-ops.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef SEEN_LIBNR_NR_MATRIX_TRANSLATE_OPS_H
-#define SEEN_LIBNR_NR_MATRIX_TRANSLATE_OPS_H
-
-/** \file
- * Declarations (and definition if inline) of operator
- * blah (NR::Matrix, NR::translate).
- */
-
-#include "libnr/nr-matrix.h"
-#include "libnr/nr-translate.h"
-
-namespace NR {
-
-inline Matrix &operator*=(Matrix &m, translate const &t) {
- m[4] += t[X];
- m[5] += t[Y];
- return m;
-}
-
-inline Matrix operator*(Matrix const &m, translate const &t) { Matrix ret(m); ret *= t; return ret; }
-
-inline Matrix operator/(Matrix const &numer, translate const &denom) { return numer * translate(-denom.offset); }
-
-}
-
-#endif /* !SEEN_LIBNR_NR_MATRIX_TRANSLATE_OPS_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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-matrix.cpp b/src/libnr/nr-matrix.cpp
deleted file mode 100644
index 4f94dd3df..000000000
--- a/src/libnr/nr-matrix.cpp
+++ /dev/null
@@ -1,291 +0,0 @@
-#define __NR_MATRIX_C__
-
-/** \file
- * Various matrix routines. Currently includes some NR::rotate etc. routines too.
- */
-
-/*
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * This code is in public domain
- */
-
-#include <cstdlib>
-#include "nr-matrix.h"
-#include "nr-matrix-fns.h"
-
-
-
-/**
- * Implement NR functions and methods
- */
-namespace NR {
-
-
-
-
-
-/**
- * Multiply two matrices together
- */
-Matrix operator*(Matrix const &m0, Matrix const &m1)
-{
- NR::Coord const d0 = m0[0] * m1[0] + m0[1] * m1[2];
- NR::Coord const d1 = m0[0] * m1[1] + m0[1] * m1[3];
- NR::Coord const d2 = m0[2] * m1[0] + m0[3] * m1[2];
- NR::Coord const d3 = m0[2] * m1[1] + m0[3] * m1[3];
- NR::Coord const d4 = m0[4] * m1[0] + m0[5] * m1[2] + m1[4];
- NR::Coord const d5 = m0[4] * m1[1] + m0[5] * m1[3] + m1[5];
-
- Matrix ret( d0, d1, d2, d3, d4, d5 );
-
- return ret;
-}
-
-
-
-
-
-/**
- * Return the inverse of this matrix. If an inverse is not defined,
- * then return the identity matrix.
- */
-Matrix Matrix::inverse() const
-{
- Matrix d(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
-
- NR::Coord const det = _c[0] * _c[3] - _c[1] * _c[2];
- if (!NR_DF_TEST_CLOSE(det, 0.0, NR_EPSILON)) {
-
- NR::Coord const idet = 1.0 / det;
- NR::Coord *dest = d._c;
-
- /*0*/ *dest++ = _c[3] * idet;
- /*1*/ *dest++ = -_c[1] * idet;
- /*2*/ *dest++ = -_c[2] * idet;
- /*3*/ *dest++ = _c[0] * idet;
- /*4*/ *dest++ = -_c[4] * d._c[0] - _c[5] * d._c[2];
- /*5*/ *dest = -_c[4] * d._c[1] - _c[5] * d._c[3];
-
- } else {
- d.set_identity();
- }
-
- return d;
-}
-
-
-
-
-
-/**
- * Set this matrix to Identity
- */
-void Matrix::set_identity()
-{
- NR::Coord *dest = _c;
-
- *dest++ = 1.0; //0
- *dest++ = 0.0; //1
- *dest++ = 0.0; //2
- *dest++ = 1.0; //3
- // translation
- *dest++ = 0.0; //4
- *dest = 0.0; //5
-}
-
-
-
-
-
-/**
- * return an Identity matrix
- */
-Matrix identity()
-{
- Matrix ret(1.0, 0.0,
- 0.0, 1.0,
- 0.0, 0.0);
- return ret;
-}
-
-
-
-
-
-/**
- *
- */
-Matrix from_basis(Point const x_basis, Point const y_basis, Point const offset)
-{
- Matrix const ret(x_basis[X], y_basis[X],
- x_basis[Y], y_basis[Y],
- offset[X], offset[Y]);
- return ret;
-}
-
-
-
-
-/**
- * Returns a rotation matrix corresponding by the specified angle (in radians) about the origin.
- *
- * \see NR::rotate_degrees
- *
- * Angle direction in Inkscape code: If you use the traditional mathematics convention that y
- * increases upwards, then positive angles are anticlockwise as per the mathematics convention. If
- * you take the common non-mathematical convention that y increases downwards, then positive angles
- * are clockwise, as is common outside of mathematics.
- */
-rotate::rotate(NR::Coord const theta) :
- vec(cos(theta),
- sin(theta))
-{
-}
-
-
-
-
-
-/**
- * Return the determinant of the Matrix
- */
-NR::Coord Matrix::det() const
-{
- return _c[0] * _c[3] - _c[1] * _c[2];
-}
-
-
-
-
-
-/**
- * Return the scalar of the descriminant of the Matrix
- */
-NR::Coord Matrix::descrim2() const
-{
- return fabs(det());
-}
-
-
-
-
-
-/**
- * Return the descriminant of the Matrix
- */
-NR::Coord Matrix::descrim() const
-{
- return sqrt(descrim2());
-}
-
-
-
-
-
-/**
- *
- */
-bool Matrix::is_translation(Coord const eps) const {
- return ( fabs(_c[0] - 1.0) < eps &&
- fabs(_c[3] - 1.0) < eps &&
- fabs(_c[1]) < eps &&
- fabs(_c[2]) < eps );
-}
-
-
-/**
- *
- */
-bool Matrix::is_scale(Coord const eps) const {
- return ( (fabs(_c[0] - 1.0) > eps || fabs(_c[3] - 1.0) > eps) &&
- fabs(_c[1]) < eps &&
- fabs(_c[2]) < eps );
-}
-
-
-/**
- *
- */
-bool Matrix::is_rotation(Coord const eps) const {
- return ( fabs(_c[1]) > eps &&
- fabs(_c[2]) > eps &&
- fabs(_c[1] + _c[2]) < 2 * eps);
-}
-
-
-
-
-
-/**
- * test whether the matrix is the identity matrix (true). (2geom's Matrix::isIdentity() does the same)
- */
-bool Matrix::test_identity() const {
- return matrix_equalp(*this, NR_MATRIX_IDENTITY, NR_EPSILON);
-}
-
-
-
-
-
-/**
- * calculates the descriminant of the matrix. (Geom::Coord Matrix::descrim() does the same)
- */
-double expansion(Matrix const &m) {
- return sqrt(fabs(m.det()));
-}
-
-
-
-
-
-/**
- *
- */
-bool transform_equalp(Matrix const &m0, Matrix const &m1, NR::Coord const epsilon) {
- return
- NR_DF_TEST_CLOSE(m0[0], m1[0], epsilon) &&
- NR_DF_TEST_CLOSE(m0[1], m1[1], epsilon) &&
- NR_DF_TEST_CLOSE(m0[2], m1[2], epsilon) &&
- NR_DF_TEST_CLOSE(m0[3], m1[3], epsilon);
-}
-
-
-
-
-
-/**
- *
- */
-bool translate_equalp(Matrix const &m0, Matrix const &m1, NR::Coord const epsilon) {
- return NR_DF_TEST_CLOSE(m0[4], m1[4], epsilon) && NR_DF_TEST_CLOSE(m0[5], m1[5], epsilon);
-}
-
-
-
-
-
-/**
- *
- */
-bool matrix_equalp(Matrix const &m0, Matrix const &m1, NR::Coord const epsilon) {
- return transform_equalp(m0, m1, epsilon) && translate_equalp(m0, m1, epsilon);
-}
-
-
-
-} //namespace NR
-
-
-
-/*
- 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-matrix.h b/src/libnr/nr-matrix.h
deleted file mode 100644
index 5d62dfafe..000000000
--- a/src/libnr/nr-matrix.h
+++ /dev/null
@@ -1,313 +0,0 @@
-#ifndef __NR_MATRIX_H__
-#define __NR_MATRIX_H__
-
-/** \file
- * Definition of NR::Matrix type.
- *
- * \note Operator functions (e.g. Matrix * Matrix etc.) are mostly in
- * libnr/nr-matrix-ops.h. See end of file for discussion.
- *
- * Main authors:
- * Lauris Kaplinski <lauris@kaplinski.com>:
- * Original NRMatrix definition and related macros.
- *
- * Nathan Hurst <njh@mail.csse.monash.edu.au>:
- * NR::Matrix class version of the above.
- *
- * This code is in public domain.
- */
-
-#include <glib.h> // g_assert()
-#include <glib/gmessages.h>
-
-#include "libnr/nr-coord.h"
-#include "libnr/nr-values.h"
-#include <libnr/nr-rotate.h>
-#include <libnr/nr-scale.h>
-#include <libnr/nr-translate.h>
-#include <2geom/affine.h>
-
-namespace NR {
-
-/**
- * The Matrix class.
- *
- * For purposes of multiplication, points should be thought of as row vectors
- *
- * p = ( p[X] p[Y] 1 )
- *
- * to be right-multiplied by transformation matrices
- * \verbatim
- c[] = | c[0] c[1] 0 |
- | c[2] c[3] 0 |
- | c[4] c[5] 1 | \endverbatim
- *
- * (so the columns of the matrix correspond to the columns (elements) of the result,
- * and the rows of the matrix correspond to columns (elements) of the "input").
- */
-class Matrix {
-
-
- public:
-
- /**
- * Various forms of constructor
- */
-
- /**
- *
- */
- explicit Matrix() { }
-
-
- /**
- *
- */
- Matrix(Matrix const &m) {
-
- NR::Coord const *src = m._c;
- NR::Coord *dest = _c;
-
- *dest++ = *src++; //0
- *dest++ = *src++; //1
- *dest++ = *src++; //2
- *dest++ = *src++; //3
- *dest++ = *src++; //4
- *dest = *src ; //5
-
- }
-
-
- Matrix(Geom::Affine const &m) {
- NR::Coord *dest = _c;
-
- *dest++ = m[0];
- *dest++ = m[1];
- *dest++ = m[2];
- *dest++ = m[3];
- *dest++ = m[4];
- *dest = m[5];
- }
-
- /**
- *
- */
- Matrix(double c0, double c1,
- double c2, double c3,
- double c4, double c5) {
-
- NR::Coord *dest = _c;
-
- *dest++ = c0; //0
- *dest++ = c1; //1
- *dest++ = c2; //2
- *dest++ = c3; //3
- *dest++ = c4; //4
- *dest = c5; //5
-
- }
-
-
-
- /**
- *
- */
- Matrix &operator=(Matrix const &m) {
-
- NR::Coord const *src = m._c;
- NR::Coord *dest = _c;
-
- *dest++ = *src++; //0
- *dest++ = *src++; //1
- *dest++ = *src++; //2
- *dest++ = *src++; //3
- *dest++ = *src++; //4
- *dest = *src ; //5
-
- return *this;
- }
-
-
-
-
- /**
- *
- */
- explicit Matrix(scale const &sm) {
-
- NR::Coord *dest = _c;
-
- *dest++ = sm[X]; //0
- *dest++ = 0.0; //1
- *dest++ = 0.0; //2
- *dest++ = sm[Y]; //3
- *dest++ = 0.0; //4
- *dest = 0.0; //5
-
- }
-
-
-
-
-
-
- /**
- *
- */
- explicit Matrix(rotate const &r) {
-
- NR::Coord *dest = _c;
-
- *dest++ = r.vec[X]; //0
- *dest++ = r.vec[Y]; //1
- *dest++ = -r.vec[Y]; //2
- *dest++ = r.vec[X]; //3
- *dest++ = 0.0; //4
- *dest = 0.0; //5
-
- }
-
-
-
-
- /**
- *
- */
- explicit Matrix(translate const &tm) {
-
- NR::Coord *dest = _c;
-
- *dest++ = 1.0; //0
- *dest++ = 0.0; //1
- *dest++ = 0.0; //2
- *dest++ = 1.0; //3
- *dest++ = tm[X]; //4
- *dest = tm[Y]; //5
- }
-
-
- /**
- *
- */
- bool test_identity() const;
-
-
- /**
- *
- */
- bool is_translation(Coord const eps = 1e-6) const;
-
- /**
- *
- */
- bool is_scale(Coord const eps = 1e-6) const;
-
- /**
- *
- */
- bool is_rotation(Coord const eps = 1e-6) const;
-
-
- /**
- *
- */
- Matrix inverse() const;
-
-
-
- /**
- *
- */
- inline Coord &operator[](int const i) {
- return _c[i];
- }
-
-
-
- /**
- *
- */
- inline Coord operator[](int const i) const {
- return _c[i];
- }
-
- inline operator Geom::Affine() const {
- return Geom::Affine(_c[0], _c[1], _c[2], _c[3], _c[4], _c[5]);
- }
-
- /**
- *
- */
- void set_identity();
-
- /**
- *
- */
- Coord det() const;
-
-
- /**
- *
- */
- Coord descrim2() const;
-
-
- /**
- *
- */
- Coord descrim() const;
-
-
- private:
-
-
- NR::Coord _c[6];
-};
-
-/** A function to print out the Matrix (for debugging) */
-inline std::ostream &operator<< (std::ostream &out_file, const NR::Matrix &m) {
- out_file << "A: " << m[0] << " C: " << m[2] << " E: " << m[4] << "\n";
- out_file << "B: " << m[1] << " D: " << m[3] << " F: " << m[5] << "\n";
- return out_file;
-}
-
-} /* namespace NR */
-
-
-
-
-
-
-
-/** \note
- * Discussion of splitting up nr-matrix.h into lots of little files:
- *
- * Advantages:
- *
- * - Reducing amount of recompilation necessary when anything changes.
- *
- * - Hopefully also reducing compilation time by reducing the number of inline
- * function definitions encountered by the compiler for a given .o file.
- * (No timing comparisons done yet. On systems without much memory available
- * for caching, this may be outweighed by additional I/O costs.)
- *
- * Disadvantages:
- *
- * - More #include lines necessary per file. If a compile fails due to
- * not having all the necessary #include lines, then the developer needs
- * to spend some time working out what #include to add.
- */
-
-#endif /* !__NR_MATRIX_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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-maybe.h b/src/libnr/nr-maybe.h
deleted file mode 100644
index 1413f69d2..000000000
--- a/src/libnr/nr-maybe.h
+++ /dev/null
@@ -1,201 +0,0 @@
-#ifndef __NR_MAYBE_H__
-#define __NR_MAYBE_H__
-
-/*
- * Nullable values for C++
- *
- * Copyright 2004, 2007 MenTaLguY <mental@rydia.net>
- *
- * This code is licensed under the GNU GPL; see COPYING for more information.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdexcept>
-#include <string>
-#include <algorithm>
-
-namespace NR {
-
-class IsNothing : public std::domain_error {
-public:
- IsNothing() : domain_error(std::string("Is nothing")) {}
-};
-
-struct Nothing {};
-
-template <typename T>
-class MaybeStorage {
-public:
- MaybeStorage() : _is_nothing(true) {}
- MaybeStorage(T const &value)
- : _value(value), _is_nothing(false) {}
-
- bool is_nothing() const { return _is_nothing; }
- T &value() { return _value; }
- T const &value() const { return _value; }
-
-private:
- T _value;
- bool _is_nothing;
-};
-
-template <typename T>
-class Maybe {
-public:
- Maybe() {}
- Maybe(Nothing) {}
- Maybe(T const &t) : _storage(t) {}
- Maybe(Maybe const &m) : _storage(m._storage) {}
-
- template <typename T2>
- Maybe(Maybe<T2> const &m) {
- if (m) {
- _storage = *m;
- }
- }
-
- template <typename T2>
- Maybe(Maybe<T2 const &> m) {
- if (m) {
- _storage = *m;
- }
- }
-
- operator bool() const { return !_storage.is_nothing(); }
-
- T const &operator*() const throw(IsNothing) {
- if (_storage.is_nothing()) {
- throw IsNothing();
- } else {
- return _storage.value();
- }
- }
- T &operator*() throw(IsNothing) {
- if (_storage.is_nothing()) {
- throw IsNothing();
- } else {
- return _storage.value();
- }
- }
-
- T const *operator->() const throw(IsNothing) {
- if (_storage.is_nothing()) {
- throw IsNothing();
- } else {
- return &_storage.value();
- }
- }
- T *operator->() throw(IsNothing) {
- if (_storage.is_nothing()) {
- throw IsNothing();
- } else {
- return &_storage.value();
- }
- }
-
- template <typename T2>
- bool operator==(Maybe<T2> const &other) const {
- bool is_nothing = _storage.is_nothing();
- if ( is_nothing || !other ) {
- return is_nothing && !other;
- } else {
- return _storage.value() == *other;
- }
- }
- template <typename T2>
- bool operator!=(Maybe<T2> const &other) const {
- bool is_nothing = _storage.is_nothing();
- if ( is_nothing || !other ) {
- return !is_nothing || other;
- } else {
- return _storage.value() != *other;
- }
- }
-
-private:
- MaybeStorage<T> _storage;
-};
-
-template <typename T>
-class Maybe<T &> {
-public:
- Maybe() : _ref(NULL) {}
- Maybe(Nothing) : _ref(NULL) {}
- Maybe(T &t) : _ref(&t) {}
-
- template <typename T2>
- Maybe(Maybe<T2> const &m) {
- if (m) {
- _ref = &*m;
- }
- }
-
- template <typename T2>
- Maybe(Maybe<T2 &> m) {
- if (m) {
- _ref = *m;
- }
- }
-
- template <typename T2>
- Maybe(Maybe<T2 const &> m) {
- if (m) {
- _ref = *m;
- }
- }
-
- operator bool() const { return _ref; }
-
- T &operator*() const throw(IsNothing) {
- if (!_ref) {
- throw IsNothing();
- } else {
- return *_ref;
- }
- }
- T *operator->() const throw(IsNothing) {
- if (!_ref) {
- throw IsNothing();
- } else {
- return _ref;
- }
- }
-
- template <typename T2>
- bool operator==(Maybe<T2> const &other) const {
- if ( !_ref || !other ) {
- return !_ref && !other;
- } else {
- return *_ref == *other;
- }
- }
- template <typename T2>
- bool operator!=(Maybe <T2> const &other) const {
- if ( !_ref || !other ) {
- return _ref || other;
- } else {
- return *_ref != *other;
- }
- }
-
-private:
- T *_ref;
-};
-
-} /* namespace NR */
-
-#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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-path-code.h b/src/libnr/nr-path-code.h
deleted file mode 100644
index cc174d73b..000000000
--- a/src/libnr/nr-path-code.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef SEEN_LIBNR_NR_PATH_CODE_H
-#define SEEN_LIBNR_NR_PATH_CODE_H
-
-/** \file
- * NRPathcode enum definition
- */
-
-typedef enum {
- NR_MOVETO, ///< Start of closed subpath
- NR_MOVETO_OPEN, ///< Start of open subpath
- NR_CURVETO, ///< Bezier curve segment
- NR_LINETO, ///< Line segment
- NR_END ///< End record
-} NRPathcode;
-
-
-#endif /* !SEEN_LIBNR_NR_PATH_CODE_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 :
diff --git a/src/libnr/nr-pixblock-line.cpp b/src/libnr/nr-pixblock-line.cpp
deleted file mode 100644
index eb8b404b4..000000000
--- a/src/libnr/nr-pixblock-line.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-#define __NR_PIXBLOCK_LINE_C__
-
-/*
- * Pixel buffer rendering library
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * This code is in public domain
- */
-
-#include <libnr/nr-pixops.h>
-#include <libnr/nr-pixblock-pixel.h>
-
-void
-nr_pixblock_draw_line_rgba32 (NRPixBlock *d, long x0, long y0, long x1, long y1, short /*first*/, unsigned long rgba)
-{
- long deltax, deltay, xinc1, xinc2, yinc1, yinc2;
- long den, num, numadd, numpixels;
- long x, y, curpixel;
- /* Pixblock */
- int dbpp;
- NRPixBlock spb;
- unsigned char *spx;
-
- if (x1 >= x0) {
- deltax = x1 - x0;
- xinc1 = 1;
- xinc2 = 1;
- } else {
- deltax = x0 - x1;
- xinc1 = -1;
- xinc2 = -1;
- }
-
- if (y1 >= y0) {
- deltay = y1 - y0;
- yinc1 = 1;
- yinc2 = 1;
- } else {
- deltay = y0 - y1;
- yinc1 = -1;
- yinc2 = -1;
- }
-
- if (deltax >= deltay) {
- xinc1 = 0;
- yinc2 = 0;
- den = deltax;
- num = deltax / 2;
- numadd = deltay;
- numpixels = deltax;
- } else {
- xinc2 = 0;
- yinc1 = 0;
- den = deltay;
- num = deltay / 2;
- numadd = deltax;
- numpixels = deltay;
- }
-
- /* We can be quite sure 1x1 pixblock is TINY */
- nr_pixblock_setup_fast (&spb, NR_PIXBLOCK_MODE_R8G8B8A8N, 0, 0, 1, 1, 0);
- spb.empty = 0;
- spx = NR_PIXBLOCK_PX (&spb);
- spx[0] = NR_RGBA32_R (rgba);
- spx[1] = NR_RGBA32_G (rgba);
- spx[2] = NR_RGBA32_B (rgba);
- spx[3] = NR_RGBA32_A (rgba);
-
- dbpp = NR_PIXBLOCK_BPP (d);
-
- x = x0;
- y = y0;
-
- for (curpixel = 0; curpixel <= numpixels; curpixel++) {
- if ((x >= d->area.x0) && (y >= d->area.y0) && (x < d->area.x1) && (y < d->area.y1)) {
- nr_compose_pixblock_pixblock_pixel (d, NR_PIXBLOCK_PX (d) + (y - d->area.y0) * d->rs + (x - d->area.x0) * dbpp, &spb, spx);
- }
- num += numadd;
- if (num >= den) {
- num -= den;
- x += xinc1;
- y += yinc1;
- }
- x += xinc2;
- y += yinc2;
- }
-
- nr_pixblock_release (&spb);
-}
-
diff --git a/src/libnr/nr-pixblock-line.h b/src/libnr/nr-pixblock-line.h
deleted file mode 100644
index cebab31d8..000000000
--- a/src/libnr/nr-pixblock-line.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef __NR_PIXBLOCK_LINE_H__
-#define __NR_PIXBLOCK_LINE_H__
-
-/*
- * Pixel buffer rendering library
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * This code is in public domain
- */
-
-#include <libnr/nr-pixblock.h>
-
-void nr_pixblock_draw_line_rgba32 (NRPixBlock *d, long x0, long y0, long x1, long y1, short first, unsigned long rgba);
-
-#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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-pixblock-pattern.cpp b/src/libnr/nr-pixblock-pattern.cpp
deleted file mode 100644
index aa3246297..000000000
--- a/src/libnr/nr-pixblock-pattern.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-#define __NR_PIXBLOCK_PATTERN_C__
-
-/*
- * Pixel buffer rendering library
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * This code is in public domain
- */
-
-
-#include <glib/gmem.h>
-#include "nr-pixops.h"
-#include "nr-pixblock-pattern.h"
-
-#define NR_NOISE_SIZE 1024
-
-void
-nr_pixblock_render_gray_noise (NRPixBlock *pb, NRPixBlock *mask)
-{
- static unsigned char *noise = NULL;
- static unsigned int seed = 0;
- unsigned int v;
- NRRectL clip;
- int x, y, bpp;
-
- if (mask) {
- if (mask->empty) return;
- nr_rect_l_intersect (&clip, &pb->area, &mask->area);
- if (nr_rect_l_test_empty(clip)) return;
- } else {
- clip = pb->area;
- }
-
- if (!noise) {
- int i;
- noise = g_new (unsigned char, NR_NOISE_SIZE);
- for (i = 0; i < NR_NOISE_SIZE; i++) noise[i] = (rand () / (RAND_MAX >> 8)) & 0xff;
- }
-
- bpp = NR_PIXBLOCK_BPP (pb);
-
- v = (rand () / (RAND_MAX >> 8)) & 0xff;
-
- if (mask) {
- for (y = clip.y0; y < clip.y1; y++) {
- unsigned char *d, *m;
- d = NR_PIXBLOCK_PX (pb) + (y - pb->area.y0) * pb->rs + (clip.x0 - pb->area.x0) * bpp;
- m = NR_PIXBLOCK_PX (mask) + (y - mask->area.y0) * pb->rs + (clip.x0 - mask->area.x0);
- for (x = clip.x0; x < clip.x1; x++) {
- v = v ^ noise[seed];
- switch (pb->mode) {
- case NR_PIXBLOCK_MODE_A8:
- d[0] = NR_COMPOSEA_111(m[0], d[0]);
- break;
- case NR_PIXBLOCK_MODE_R8G8B8:
- d[0] = NR_COMPOSEN11_1111 (v, m[0], d[0]);
- d[1] = NR_COMPOSEN11_1111 (v, m[0], d[1]);
- d[2] = NR_COMPOSEN11_1111 (v, m[0], d[2]);
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8N:
- if (m[0] != 0) {
- unsigned int ca;
- ca = NR_COMPOSEA_112(m[0], d[3]);
- d[0] = NR_COMPOSENNN_111121 (v, m[0], d[0], d[3], ca);
- d[1] = NR_COMPOSENNN_111121 (v, m[0], d[1], d[3], ca);
- d[2] = NR_COMPOSENNN_111121 (v, m[0], d[2], d[3], ca);
- d[3] = NR_NORMALIZE_21(ca);
- }
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8P:
- d[0] = NR_COMPOSENPP_1111 (v, m[0], d[0]);
- d[1] = NR_COMPOSENPP_1111 (v, m[0], d[1]);
- d[2] = NR_COMPOSENPP_1111 (v, m[0], d[2]);
- d[3] = NR_COMPOSEA_111(d[3], m[0]);
- break;
- default:
- break;
- }
- d += bpp;
- m += 1;
- if (++seed >= NR_NOISE_SIZE) {
- int i;
- i = (rand () / (RAND_MAX / NR_NOISE_SIZE)) % NR_NOISE_SIZE;
- noise[i] ^= v;
- seed = i % (NR_NOISE_SIZE >> 2);
- }
- }
- }
- } else {
- for (y = clip.y0; y < clip.y1; y++) {
- unsigned char *d;
- d = NR_PIXBLOCK_PX (pb) + (y - pb->area.y0) * pb->rs + (clip.x0 - pb->area.x0) * bpp;
- for (x = clip.x0; x < clip.x1; x++) {
- v = v ^ noise[seed];
- switch (pb->mode) {
- case NR_PIXBLOCK_MODE_A8:
- d[0] = 255;
- break;
- case NR_PIXBLOCK_MODE_R8G8B8:
- d[0] = v;
- d[1] = v;
- d[2] = v;
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8N:
- case NR_PIXBLOCK_MODE_R8G8B8A8P:
- d[0] = v;
- d[1] = v;
- d[2] = v;
- d[3] = 255;
- default:
- break;
- }
- d += bpp;
- if (++seed >= NR_NOISE_SIZE) {
- int i;
- i = (rand () / (RAND_MAX / NR_NOISE_SIZE)) % NR_NOISE_SIZE;
- noise[i] ^= v;
- seed = i % (NR_NOISE_SIZE >> 2);
- }
- }
- }
- }
-
- pb->empty = 0;
-}
diff --git a/src/libnr/nr-pixblock-pattern.h b/src/libnr/nr-pixblock-pattern.h
deleted file mode 100644
index a79a39f13..000000000
--- a/src/libnr/nr-pixblock-pattern.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef __NR_PIXBLOCK_PATTERN_H__
-#define __NR_PIXBLOCK_PATTERN_H__
-
-/*
- * Pixel buffer rendering library
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * This code is in public domain
- */
-
-#include <libnr/nr-pixblock.h>
-
-void nr_pixblock_render_gray_noise (NRPixBlock *pb, NRPixBlock *mask);
-
-#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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-pixblock-pixel.cpp b/src/libnr/nr-pixblock-pixel.cpp
deleted file mode 100644
index 109ed69dc..000000000
--- a/src/libnr/nr-pixblock-pixel.cpp
+++ /dev/null
@@ -1,230 +0,0 @@
-#define __NR_PIXBLOCK_PIXEL_C__
-
-/*
- * Pixel buffer rendering library
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * This code is in public domain
- */
-
-#include "nr-pixops.h"
-#include "nr-pixblock-pixel.h"
-
-void
-nr_compose_pixblock_pixblock_pixel (NRPixBlock *dpb, unsigned char *d, const NRPixBlock *spb, const unsigned char *s)
-{
- if (spb->empty) return;
-
- if (dpb->empty) {
- /* Empty destination */
- switch (dpb->mode) {
- case NR_PIXBLOCK_MODE_A8:
- switch (spb->mode) {
- case NR_PIXBLOCK_MODE_A8:
- break;
- case NR_PIXBLOCK_MODE_R8G8B8:
- d[0] = 255;
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8N:
- d[0] = s[3];
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8P:
- d[0] = s[3];
- break;
- default:
- break;
- }
- break;
- case NR_PIXBLOCK_MODE_R8G8B8:
- switch (spb->mode) {
- case NR_PIXBLOCK_MODE_A8:
- break;
- case NR_PIXBLOCK_MODE_R8G8B8:
- d[0] = s[0];
- d[1] = s[1];
- d[2] = s[2];
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8N:
- d[0] = NR_COMPOSEN11_1111 (s[0], s[3], 255);
- d[1] = NR_COMPOSEN11_1111 (s[1], s[3], 255);
- d[2] = NR_COMPOSEN11_1111 (s[2], s[3], 255);
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8P:
- d[0] = NR_COMPOSEP11_1111 (s[0], s[3], 255);
- d[1] = NR_COMPOSEP11_1111 (s[1], s[3], 255);
- d[2] = NR_COMPOSEP11_1111 (s[2], s[3], 255);
- break;
- default:
- break;
- }
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8N:
- switch (spb->mode) {
- case NR_PIXBLOCK_MODE_A8:
- break;
- case NR_PIXBLOCK_MODE_R8G8B8:
- d[0] = s[0];
- d[1] = s[1];
- d[2] = s[2];
- d[3] = 255;
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8N:
- d[0] = s[0];
- d[1] = s[1];
- d[2] = s[2];
- d[3] = s[3];
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8P:
- if (s[3] == 0) {
- d[0] = 255;
- d[1] = 255;
- d[2] = 255;
- } else {
- d[0] = NR_DEMUL_111(s[0], s[3]);
- d[1] = NR_DEMUL_111(s[0], s[3]);
- d[2] = NR_DEMUL_111(s[0], s[3]);
- }
- d[3] = s[3];
- break;
- default:
- break;
- }
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8P:
- switch (spb->mode) {
- case NR_PIXBLOCK_MODE_A8:
- break;
- case NR_PIXBLOCK_MODE_R8G8B8:
- d[0] = s[0];
- d[1] = s[1];
- d[2] = s[2];
- d[3] = 255;
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8N:
- d[0] = NR_PREMUL_111 (s[0], s[3]);
- d[1] = NR_PREMUL_111 (s[1], s[3]);
- d[2] = NR_PREMUL_111 (s[2], s[3]);
- d[3] = s[3];
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8P:
- d[0] = s[0];
- d[1] = s[1];
- d[2] = s[2];
- d[3] = s[3];
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- } else {
- /* Image destination */
- switch (dpb->mode) {
- case NR_PIXBLOCK_MODE_A8:
- switch (spb->mode) {
- case NR_PIXBLOCK_MODE_A8:
- break;
- case NR_PIXBLOCK_MODE_R8G8B8:
- d[0] = 255;
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8N:
- d[0] = NR_COMPOSEA_111(s[3], d[0]);
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8P:
- d[0] = NR_COMPOSEA_111(s[3], d[0]);
- break;
- default:
- break;
- }
- break;
- case NR_PIXBLOCK_MODE_R8G8B8:
- switch (spb->mode) {
- case NR_PIXBLOCK_MODE_A8:
- break;
- case NR_PIXBLOCK_MODE_R8G8B8:
- d[0] = s[0];
- d[1] = s[1];
- d[2] = s[2];
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8N:
- d[0] = NR_COMPOSEN11_1111 (s[0], s[3], d[0]);
- d[1] = NR_COMPOSEN11_1111 (s[1], s[3], d[1]);
- d[2] = NR_COMPOSEN11_1111 (s[2], s[3], d[2]);
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8P:
- d[0] = NR_COMPOSEP11_1111 (s[0], s[3], d[0]);
- d[1] = NR_COMPOSEP11_1111 (s[1], s[3], d[1]);
- d[2] = NR_COMPOSEP11_1111 (s[2], s[3], d[2]);
- break;
- default:
- break;
- }
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8N:
- switch (spb->mode) {
- case NR_PIXBLOCK_MODE_A8:
- break;
- case NR_PIXBLOCK_MODE_R8G8B8:
- d[0] = s[0];
- d[1] = s[1];
- d[2] = s[2];
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8N:
- if (s[3] != 0) {
- unsigned int ca;
- ca = NR_COMPOSEA_112(s[3], d[3]);
- d[0] = NR_COMPOSENNN_111121 (s[0], s[3], d[0], d[3], ca);
- d[1] = NR_COMPOSENNN_111121 (s[1], s[3], d[1], d[3], ca);
- d[2] = NR_COMPOSENNN_111121 (s[2], s[3], d[2], d[3], ca);
- d[3] = NR_NORMALIZE_21(ca);
- }
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8P:
- if (s[3] != 0) {
- unsigned int ca;
- ca = NR_COMPOSEA_112(s[3], d[3]);
- d[0] = NR_COMPOSEPNN_111121 (s[0], s[3], d[0], d[3], ca);
- d[1] = NR_COMPOSEPNN_111121 (s[1], s[3], d[0], d[3], ca);
- d[2] = NR_COMPOSEPNN_111121 (s[2], s[3], d[0], d[3], ca);
- d[3] = NR_NORMALIZE_21(ca);
- }
- break;
- default:
- break;
- }
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8P:
- switch (spb->mode) {
- case NR_PIXBLOCK_MODE_A8:
- break;
- case NR_PIXBLOCK_MODE_R8G8B8:
- d[0] = s[0];
- d[1] = s[1];
- d[2] = s[2];
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8N:
- d[0] = NR_COMPOSENPP_1111 (s[0], s[3], d[0]);
- d[1] = NR_COMPOSENPP_1111 (s[1], s[3], d[1]);
- d[2] = NR_COMPOSENPP_1111 (s[2], s[3], d[2]);
- d[3] = NR_COMPOSEA_111(s[3], d[3]);
- break;
- case NR_PIXBLOCK_MODE_R8G8B8A8P:
- d[0] = NR_COMPOSEPPP_1111 (s[0], s[3], d[0]);
- d[1] = NR_COMPOSEPPP_1111 (s[1], s[3], d[1]);
- d[2] = NR_COMPOSEPPP_1111 (s[2], s[3], d[2]);
- d[3] = NR_COMPOSEA_111(s[3], d[3]);
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- }
-}
-
diff --git a/src/libnr/nr-pixblock-pixel.h b/src/libnr/nr-pixblock-pixel.h
deleted file mode 100644
index da64aee4c..000000000
--- a/src/libnr/nr-pixblock-pixel.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef __NR_PIXBLOCK_PIXEL_H__
-#define __NR_PIXBLOCK_PIXEL_H__
-
-/*
- * Pixel buffer rendering library
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * This code is in public domain
- */
-
-#include <libnr/nr-pixblock.h>
-
-void nr_compose_pixblock_pixblock_pixel (NRPixBlock *dpb, unsigned char *d, const NRPixBlock *spb, const unsigned char *s);
-
-#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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-pixblock.cpp b/src/libnr/nr-pixblock.cpp
deleted file mode 100644
index b95d8db8d..000000000
--- a/src/libnr/nr-pixblock.cpp
+++ /dev/null
@@ -1,465 +0,0 @@
-#define __NR_PIXBLOCK_C__
-
-/** \file
- * \brief Allocation/Setup of NRPixBlock objects. Pixel store functions.
- *
- * Authors:
- * (C) 1999-2002 Lauris Kaplinski <lauris@kaplinski.com>
- * 2008, Jasper van de Gronde <th.v.d.gonde@hccnet.nl>
- *
- * This code is in the Public Domain
- */
-
-#include <cstring>
-#include <string>
-#include <string.h>
-#include <glib/gmem.h>
-#include "nr-pixblock.h"
-
-/// Size of buffer that needs no allocation (default 4).
-#define NR_TINY_MAX sizeof (unsigned char *)
-
-/**
- * Pixbuf initialisation using homegrown memory handling ("pixelstore").
- *
- * Pixbuf sizes are differentiated into tiny, <4K, <16K, <64K, and more,
- * with each type having its own method of memory handling. After allocating
- * memory, the buffer is cleared if the clear flag is set. Intended to
- * reduce memory fragmentation.
- * \param pb Pointer to the pixbuf struct.
- * \param mode Indicates grayscale/RGB/RGBA.
- * \param clear True if buffer should be cleared.
- * \pre x1>=x0 && y1>=y0 && pb!=NULL
- */
-void
-nr_pixblock_setup_fast (NRPixBlock *pb, NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear)
-{
- int w, h, bpp;
- size_t size;
-
- w = x1 - x0;
- h = y1 - y0;
- bpp = (mode == NR_PIXBLOCK_MODE_A8) ? 1 : (mode == NR_PIXBLOCK_MODE_R8G8B8) ? 3 : 4;
-
- guint64 sizel = (guint64)bpp * (guint64)w * (guint64)h;
-
- if(sizel > (guint64)G_MAXSIZE) {
- g_warning ("the requested memory exceeds the system limit");
- return;
- }
-
- size = bpp * w * h;
-
- if (size <= NR_TINY_MAX) {
- pb->size = NR_PIXBLOCK_SIZE_TINY;
- if (clear) memset (pb->data.p, 0x0, size);
- } else if (size <= 4096) {
- pb->size = NR_PIXBLOCK_SIZE_4K;
- pb->data.px = nr_pixelstore_4K_new (clear, 0x0);
- } else if (size <= 16384) {
- pb->size = NR_PIXBLOCK_SIZE_16K;
- pb->data.px = nr_pixelstore_16K_new (clear, 0x0);
- } else if (size <= 65536) {
- pb->size = NR_PIXBLOCK_SIZE_64K;
- pb->data.px = nr_pixelstore_64K_new (clear, 0x0);
- } else if (size <= 262144) {
- pb->size = NR_PIXBLOCK_SIZE_256K;
- pb->data.px = nr_pixelstore_256K_new (clear, 0x0);
- } else if (size <= 1048576) {
- pb->size = NR_PIXBLOCK_SIZE_1M;
- pb->data.px = nr_pixelstore_1M_new (clear, 0x0);
- } else {
- pb->size = NR_PIXBLOCK_SIZE_BIG;
- pb->data.px = NULL;
- if (size > 100000000) { // Don't even try to allocate more than 100Mb (5000x5000 RGBA
- // pixels). It'll just bog the system down even if successful. FIXME:
- // Can anyone suggest something better than the magic number?
- g_warning ("%lu bytes requested for pixel buffer, this will slow down the system.", (long unsigned) size);
- // do not quit here, let the system decide for RAM usage
- // return;
- }
- pb->data.px = g_try_new (unsigned char, size);
- if (pb->data.px == NULL) { // memory allocation failed
- g_warning ("Could not allocate %lu bytes for pixel buffer!", (long unsigned) size);
- return;
- }
- if (clear) memset (pb->data.px, 0x0, size);
- }
-
- pb->mode = mode;
- pb->empty = 1;
- pb->visible_area.x0 = pb->area.x0 = x0;
- pb->visible_area.y0 = pb->area.y0 = y0;
- pb->visible_area.x1 = pb->area.x1 = x1;
- pb->visible_area.y1 = pb->area.y1 = y1;
- pb->rs = bpp * w;
-}
-
-/**
- * Pixbuf initialisation using g_new.
- *
- * After allocating memory, the buffer is cleared if the clear flag is set.
- * \param pb Pointer to the pixbuf struct.
- * \param mode Indicates grayscale/RGB/RGBA.
- * \param clear True if buffer should be cleared.
- * \pre x1>=x0 && y1>=y0 && pb!=NULL
- FIXME: currently unused except for nr_pixblock_new and pattern tiles, replace with _fast and delete?
- */
-void
-nr_pixblock_setup (NRPixBlock *pb, NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear)
-{
- int w, h, bpp;
- size_t size;
-
- w = x1 - x0;
- h = y1 - y0;
- bpp = (mode == NR_PIXBLOCK_MODE_A8) ? 1 : (mode == NR_PIXBLOCK_MODE_R8G8B8) ? 3 : 4;
-
- size = bpp * w * h;
-
- if (size <= NR_TINY_MAX) {
- pb->size = NR_PIXBLOCK_SIZE_TINY;
- if (clear) memset (pb->data.p, 0x0, size);
- } else {
- pb->size = NR_PIXBLOCK_SIZE_BIG;
- pb->data.px = g_new (unsigned char, size);
- if (clear) memset (pb->data.px, 0x0, size);
- }
-
- pb->mode = mode;
- pb->empty = 1;
- pb->visible_area.x0 = pb->area.x0 = x0;
- pb->visible_area.y0 = pb->area.y0 = y0;
- pb->visible_area.x1 = pb->area.x1 = x1;
- pb->visible_area.y1 = pb->area.y1 = y1;
- pb->rs = bpp * w;
-}
-
-/**
- * Pixbuf initialisation with preset values.
- *
- * After copying all parameters into the NRPixBlock struct, the pixel buffer is cleared if the clear flag is set.
- * \param pb Pointer to the pixbuf struct.
- * \param mode Indicates grayscale/RGB/RGBA.
- * \param clear True if buffer should be cleared.
- * \pre x1>=x0 && y1>=y0 && pb!=NULL
- */
-void
-nr_pixblock_setup_extern (NRPixBlock *pb, NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, unsigned char *px, int rs, bool empty, bool clear)
-{
- int w, bpp;
-
- w = x1 - x0;
- bpp = (mode == NR_PIXBLOCK_MODE_A8) ? 1 : (mode == NR_PIXBLOCK_MODE_R8G8B8) ? 3 : 4;
-
- pb->size = NR_PIXBLOCK_SIZE_STATIC;
- pb->mode = mode;
- pb->empty = empty;
- pb->visible_area.x0 = pb->area.x0 = x0;
- pb->visible_area.y0 = pb->area.y0 = y0;
- pb->visible_area.x1 = pb->area.x1 = x1;
- pb->visible_area.y1 = pb->area.y1 = y1;
- pb->data.px = px;
- pb->rs = rs;
-
- g_assert (pb->data.px != NULL);
- if (clear) {
- if (rs == bpp * w) {
- /// \todo How do you recognise if
- /// px was an uncleared tiny buffer?
- if (pb->data.px)
- memset (pb->data.px, 0x0, bpp * (y1 - y0) * w);
- } else {
- int y;
- for (y = y0; y < y1; y++) {
- memset (pb->data.px + (y - y0) * rs, 0x0, bpp * w);
- }
- }
- }
-}
-
-/**
- * Frees memory taken by pixel data in NRPixBlock.
- * \param pb Pointer to pixblock.
- * \pre pb and pb->data.px point to valid addresses.
- *
- * According to pb->size, one of the functions for freeing the pixelstore
- * is called. May be called regardless of how pixbuf was set up.
- */
-void
-nr_pixblock_release (NRPixBlock *pb)
-{
- switch (pb->size) {
- case NR_PIXBLOCK_SIZE_TINY:
- break;
- case NR_PIXBLOCK_SIZE_4K:
- nr_pixelstore_4K_free (pb->data.px);
- break;
- case NR_PIXBLOCK_SIZE_16K:
- nr_pixelstore_16K_free (pb->data.px);
- break;
- case NR_PIXBLOCK_SIZE_64K:
- nr_pixelstore_64K_free (pb->data.px);
- break;
- case NR_PIXBLOCK_SIZE_256K:
- nr_pixelstore_256K_free (pb->data.px);
- break;
- case NR_PIXBLOCK_SIZE_1M:
- nr_pixelstore_1M_free (pb->data.px);
- break;
- case NR_PIXBLOCK_SIZE_BIG:
- g_free (pb->data.px);
- break;
- case NR_PIXBLOCK_SIZE_STATIC:
- break;
- default:
- break;
- }
-}
-
-/**
- * Allocates NRPixBlock and sets it up.
- *
- * \return Pointer to fresh pixblock.
- * Calls g_new() and nr_pixblock_setup().
-FIXME: currently unused, delete? JG: Should be used more often! (To simplify memory management.)
- */
-NRPixBlock *
-nr_pixblock_new (NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear)
-{
- NRPixBlock *pb;
-
- pb = g_new (NRPixBlock, 1);
- if (!pb) return 0;
-
- nr_pixblock_setup (pb, mode, x0, y0, x1, y1, clear);
- if (pb->size!=NR_PIXBLOCK_SIZE_TINY && !pb->data.px) {
- g_free(pb);
- return 0;
- }
-
- return pb;
-}
-
-/**
- * Allocates NRPixBlock and sets it up.
- *
- * \return Pointer to fresh pixblock.
- * Calls g_new() and nr_pixblock_setup().
- */
-NRPixBlock *
-nr_pixblock_new_fast (NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear)
-{
- NRPixBlock *pb;
-
- pb = g_new (NRPixBlock, 1);
- if (!pb) return 0;
-
- nr_pixblock_setup_fast (pb, mode, x0, y0, x1, y1, clear);
- if (pb->size!=NR_PIXBLOCK_SIZE_TINY && !pb->data.px) {
- g_free(pb);
- return 0;
- }
-
- return pb;
-}
-
-/**
- * Frees all memory taken by pixblock.
- *
- * \return NULL
- */
-NRPixBlock *
-nr_pixblock_free (NRPixBlock *pb)
-{
- nr_pixblock_release (pb);
-
- g_free (pb);
-
- return NULL;
-}
-
-/* PixelStore operations */
-
-#define NR_4K_BLOCK 32
-static unsigned char **nr_4K_px = NULL;
-static unsigned int nr_4K_len = 0;
-static unsigned int nr_4K_size = 0;
-
-unsigned char *
-nr_pixelstore_4K_new (bool clear, unsigned char val)
-{
- unsigned char *px;
-
- if (nr_4K_len != 0) {
- nr_4K_len -= 1;
- px = nr_4K_px[nr_4K_len];
- } else {
- px = g_new (unsigned char, 4096);
- }
-
- if (clear) memset (px, val, 4096);
-
- return px;
-}
-
-void
-nr_pixelstore_4K_free (unsigned char *px)
-{
- if (nr_4K_len == nr_4K_size) {
- nr_4K_size += NR_4K_BLOCK;
- nr_4K_px = g_renew (unsigned char *, nr_4K_px, nr_4K_size);
- }
-
- nr_4K_px[nr_4K_len] = px;
- nr_4K_len += 1;
-}
-
-#define NR_16K_BLOCK 32
-static unsigned char **nr_16K_px = NULL;
-static unsigned int nr_16K_len = 0;
-static unsigned int nr_16K_size = 0;
-
-unsigned char *
-nr_pixelstore_16K_new (bool clear, unsigned char val)
-{
- unsigned char *px;
-
- if (nr_16K_len != 0) {
- nr_16K_len -= 1;
- px = nr_16K_px[nr_16K_len];
- } else {
- px = g_new (unsigned char, 16384);
- }
-
- if (clear) memset (px, val, 16384);
-
- return px;
-}
-
-void
-nr_pixelstore_16K_free (unsigned char *px)
-{
- if (nr_16K_len == nr_16K_size) {
- nr_16K_size += NR_16K_BLOCK;
- nr_16K_px = g_renew (unsigned char *, nr_16K_px, nr_16K_size);
- }
-
- nr_16K_px[nr_16K_len] = px;
- nr_16K_len += 1;
-}
-
-#define NR_64K_BLOCK 32
-static unsigned char **nr_64K_px = NULL;
-static unsigned int nr_64K_len = 0;
-static unsigned int nr_64K_size = 0;
-
-unsigned char *
-nr_pixelstore_64K_new (bool clear, unsigned char val)
-{
- unsigned char *px;
-
- if (nr_64K_len != 0) {
- nr_64K_len -= 1;
- px = nr_64K_px[nr_64K_len];
- } else {
- px = g_new (unsigned char, 65536);
- }
-
- if (clear) memset (px, val, 65536);
-
- return px;
-}
-
-void
-nr_pixelstore_64K_free (unsigned char *px)
-{
- if (nr_64K_len == nr_64K_size) {
- nr_64K_size += NR_64K_BLOCK;
- nr_64K_px = g_renew (unsigned char *, nr_64K_px, nr_64K_size);
- }
-
- nr_64K_px[nr_64K_len] = px;
- nr_64K_len += 1;
-}
-
-#define NR_256K_BLOCK 32
-#define NR_256K 262144
-static unsigned char **nr_256K_px = NULL;
-static unsigned int nr_256K_len = 0;
-static unsigned int nr_256K_size = 0;
-
-unsigned char *
-nr_pixelstore_256K_new (bool clear, unsigned char val)
-{
- unsigned char *px;
-
- if (nr_256K_len != 0) {
- nr_256K_len -= 1;
- px = nr_256K_px[nr_256K_len];
- } else {
- px = g_new (unsigned char, NR_256K);
- }
-
- if (clear) memset (px, val, NR_256K);
-
- return px;
-}
-
-void
-nr_pixelstore_256K_free (unsigned char *px)
-{
- if (nr_256K_len == nr_256K_size) {
- nr_256K_size += NR_256K_BLOCK;
- nr_256K_px = g_renew (unsigned char *, nr_256K_px, nr_256K_size);
- }
-
- nr_256K_px[nr_256K_len] = px;
- nr_256K_len += 1;
-}
-
-#define NR_1M_BLOCK 32
-#define NR_1M 1048576
-static unsigned char **nr_1M_px = NULL;
-static unsigned int nr_1M_len = 0;
-static unsigned int nr_1M_size = 0;
-
-unsigned char *
-nr_pixelstore_1M_new (bool clear, unsigned char val)
-{
- unsigned char *px;
-
- if (nr_1M_len != 0) {
- nr_1M_len -= 1;
- px = nr_1M_px[nr_1M_len];
- } else {
- px = g_new (unsigned char, NR_1M);
- }
-
- if (clear) memset (px, val, NR_1M);
-
- return px;
-}
-
-void
-nr_pixelstore_1M_free (unsigned char *px)
-{
- if (nr_1M_len == nr_1M_size) {
- nr_1M_size += NR_1M_BLOCK;
- nr_1M_px = g_renew (unsigned char *, nr_1M_px, nr_1M_size);
- }
-
- nr_1M_px[nr_1M_len] = px;
- nr_1M_len += 1;
-}
-
-/*
- 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-pixblock.h b/src/libnr/nr-pixblock.h
deleted file mode 100644
index 404a0fd03..000000000
--- a/src/libnr/nr-pixblock.h
+++ /dev/null
@@ -1,103 +0,0 @@
-#ifndef __NR_PIXBLOCK_H__
-#define __NR_PIXBLOCK_H__
-
-/** \file
- * \brief Pixel block structure. Used for low-level rendering.
- *
- * Authors:
- * (C) 1999-2002 Lauris Kaplinski <lauris@kaplinski.com>
- * (C) 2005 Ralf Stephan <ralf@ark.in-berlin.de> (some cleanup)
- *
- * This code is in the Public Domain.
- */
-
-#include <libnr/nr-rect-l.h>
-#include <libnr/nr-forward.h>
-
-/// Size indicator. Hardcoded to max. 3 bits.
-typedef enum {
- NR_PIXBLOCK_SIZE_TINY, ///< Fits in (unsigned char *)
- NR_PIXBLOCK_SIZE_4K, ///< Pixelstore
- NR_PIXBLOCK_SIZE_16K, ///< Pixelstore
- NR_PIXBLOCK_SIZE_64K, ///< Pixelstore
- NR_PIXBLOCK_SIZE_256K, ///< Pixelstore
- NR_PIXBLOCK_SIZE_1M, ///< Pixelstore
- NR_PIXBLOCK_SIZE_BIG, ///< Normally allocated
- NR_PIXBLOCK_SIZE_STATIC ///< Externally managed
-} NR_PIXBLOCK_SIZE;
-
-/// Mode indicator. Hardcoded to max. 2 bits.
-typedef enum {
- NR_PIXBLOCK_MODE_A8, ///< Grayscale
- NR_PIXBLOCK_MODE_R8G8B8, ///< 8 bit RGB
- NR_PIXBLOCK_MODE_R8G8B8A8N, ///< Normal 8 bit RGBA
- NR_PIXBLOCK_MODE_R8G8B8A8P ///< Premultiplied 8 bit RGBA
-} NR_PIXBLOCK_MODE;
-
-/// The pixel block struct.
-struct NRPixBlock {
- NR_PIXBLOCK_SIZE size : 3; ///< Size indicator
- NR_PIXBLOCK_MODE mode : 2; ///< Mode indicator
- bool empty : 1; ///< Empty flag
- unsigned int rs; ///< Size of line in bytes
- NRRectL area;
- NRRectL visible_area;
- union {
- unsigned char *px; ///< Pointer to buffer
- unsigned char p[sizeof (unsigned char *)]; ///< Tiny buffer
- } data;
-};
-
-/// Returns number of bytes per pixel (1, 3, or 4).
-inline int
-NR_PIXBLOCK_BPP (NRPixBlock *pb)
-{
- return ((pb->mode == NR_PIXBLOCK_MODE_A8) ? 1 :
- (pb->mode == NR_PIXBLOCK_MODE_R8G8B8) ? 3 : 4);
-}
-
-/// Returns pointer to pixel data.
-inline unsigned char*
-NR_PIXBLOCK_PX (NRPixBlock *pb)
-{
- return ((pb->size == NR_PIXBLOCK_SIZE_TINY) ?
- pb->data.p : pb->data.px);
-}
-inline unsigned char const*
-NR_PIXBLOCK_PX (NRPixBlock const *pb)
-{
- return ((pb->size == NR_PIXBLOCK_SIZE_TINY) ?
- pb->data.p : pb->data.px);
-}
-
-void nr_pixblock_setup (NRPixBlock *pb, NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear);
-void nr_pixblock_setup_fast (NRPixBlock *pb, NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear);
-void nr_pixblock_setup_extern (NRPixBlock *pb, NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, unsigned char *px, int rs, bool empty, bool clear);
-void nr_pixblock_release (NRPixBlock *pb);
-
-NRPixBlock *nr_pixblock_new (NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear);
-NRPixBlock *nr_pixblock_new_fast (NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear);
-NRPixBlock *nr_pixblock_free (NRPixBlock *pb);
-
-unsigned char *nr_pixelstore_4K_new (bool clear, unsigned char val);
-void nr_pixelstore_4K_free (unsigned char *px);
-unsigned char *nr_pixelstore_16K_new (bool clear, unsigned char val);
-void nr_pixelstore_16K_free (unsigned char *px);
-unsigned char *nr_pixelstore_64K_new (bool clear, unsigned char val);
-void nr_pixelstore_64K_free (unsigned char *px);
-unsigned char *nr_pixelstore_256K_new (bool clear, unsigned char val);
-void nr_pixelstore_256K_free (unsigned char *px);
-unsigned char *nr_pixelstore_1M_new (bool clear, unsigned char val);
-void nr_pixelstore_1M_free (unsigned char *px);
-
-#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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-pixops.h b/src/libnr/nr-pixops.h
deleted file mode 100644
index 92196928a..000000000
--- a/src/libnr/nr-pixops.h
+++ /dev/null
@@ -1,148 +0,0 @@
-#ifndef __NR_PIXOPS_H__
-#define __NR_PIXOPS_H__
-
-/*
- * Pixel buffer rendering library
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- * bulia byak <buliabyak@users.sf.net>
- *
- * This code is in public domain
- */
-
-#define NR_RGBA32_R(v) (unsigned char) (((v) >> 24) & 0xff)
-#define NR_RGBA32_G(v) (unsigned char) (((v) >> 16) & 0xff)
-#define NR_RGBA32_B(v) (unsigned char) (((v) >> 8) & 0xff)
-#define NR_RGBA32_A(v) (unsigned char) ((v) & 0xff)
-
-// FAST_DIVIDE assumes that 0<=num<=256*denom
-// (this covers the case that num=255*denom+denom/2, which is used by DIV_ROUND)
-template<unsigned int divisor> static inline unsigned int FAST_DIVIDE(unsigned int v) { return v/divisor; }
-template<> inline unsigned int FAST_DIVIDE<255>(unsigned int v) { return ((v+1)*0x101) >> 16; }
-template<> inline unsigned int FAST_DIVIDE<255*255>(unsigned int v) { v=(v+1)<<1; v=v+(v>>7)+((v*0x3)>>16)+(v>>22); return (v>>16)>>1; }
-// FAST_DIV_ROUND assumes that 0<=num<=255*denom (DIV_ROUND should work upto num=2^32-1-(denom/2),
-// but FAST_DIVIDE_BY_255 already fails at num=65790=258*255, which is not too far above 255.5*255)
-template<unsigned int divisor> static inline unsigned int FAST_DIV_ROUND(unsigned int v) { return FAST_DIVIDE<divisor>(v+(divisor)/2); }
-static inline unsigned int DIV_ROUND(unsigned int v, unsigned int divisor) { return (v+divisor/2)/divisor; }
-
-#define INK_COMPOSE(f,a,b) ( ( ((guchar) (b)) * ((guchar) (0xff - (a))) + ((guchar) (((b) ^ ~(f)) + (b)/4 - ((b)>127? 63 : 0))) * ((guchar) (a)) ) >>8)
-
-// Naming: OPb_i+o
-// OP = operation, for example: NORMALIZE, COMPOSEA, COMPOSENNN, PREMUL, etc.
-// i+o = range of input/output as powers of 2^8-1
-// for example, 213 means 0<=a<=255^2, 0<=b<=255, 0<=output<=255^3
-
-// Normalize
-static inline unsigned int NR_NORMALIZE_11(unsigned int v) { return v; }
-static inline unsigned int NR_NORMALIZE_21(unsigned int v) { return FAST_DIV_ROUND<255>(v); }
-static inline unsigned int NR_NORMALIZE_31(unsigned int v) { return FAST_DIV_ROUND<255*255>(v); }
-static inline unsigned int NR_NORMALIZE_41(unsigned int v) { return FAST_DIV_ROUND<255*255*255>(v); }
-
-// Compose alpha channel using (1 - (1-a)*(1-b))
-// Note that these can also be rewritten to NR_COMPOSENPP(255, a, b), slightly slower, but could help if someone
-// decides to use SSE or something similar (for allowing the four components to be treated the same way).
-static inline unsigned int NR_COMPOSEA_213(unsigned int a, unsigned int b) { return 255*255*255 - (255*255-a)*(255-b); }
-static inline unsigned int NR_COMPOSEA_112(unsigned int a, unsigned int b) { return 255*255 - (255-a)*(255-b); }
-static inline unsigned int NR_COMPOSEA_211(unsigned int a, unsigned int b) { return NR_NORMALIZE_31(NR_COMPOSEA_213(a, b)); }
-static inline unsigned int NR_COMPOSEA_111(unsigned int a, unsigned int b) { return NR_NORMALIZE_21(NR_COMPOSEA_112(a, b)); }
-
-// Operation: (1 - fa) * bc * ba + fa * fc
-static inline unsigned int NR_COMPOSENNP_12114(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba) { return (255*255 - fa) * ba * bc + 255 * fa * fc; }
-static inline unsigned int NR_COMPOSENNP_11113(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba) { return (255 - fa) * ba * bc + 255 * fa * fc; }
-static inline unsigned int NR_COMPOSENNP_11111(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba) { return NR_NORMALIZE_31(NR_COMPOSENNP_11113(fc, fa, bc, ba)); }
-
-// Operation: (1 - fa) * bc * ba + fc
-static inline unsigned int NR_COMPOSEPNP_32114(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba) { return (255*255 - fa) * ba * bc + 255 * fc; }
-static inline unsigned int NR_COMPOSEPNP_22114(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba) { return (255*255 - fa) * ba * bc + 255*255 * fc; }
-static inline unsigned int NR_COMPOSEPNP_11113(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba) { return (255 - fa) * ba * bc + 255*255 * fc; }
-static inline unsigned int NR_COMPOSEPNP_22111(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba) { return NR_NORMALIZE_41(NR_COMPOSEPNP_22114(fc, fa, bc, ba)); }
-static inline unsigned int NR_COMPOSEPNP_11111(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba) { return NR_NORMALIZE_31(NR_COMPOSEPNP_11113(fc, fa, bc, ba)); }
-
-// Operation: ((1 - fa) * bc * ba + fa * fc)/a
-// Reuses non-normalized versions of NR_COMPOSENNP
-static inline unsigned int NR_COMPOSENNN_121131(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba, unsigned int a) { return DIV_ROUND(NR_COMPOSENNP_12114(fc, fa, bc, ba), a); }
-static inline unsigned int NR_COMPOSENNN_111121(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba, unsigned int a) { return DIV_ROUND(NR_COMPOSENNP_11113(fc, fa, bc, ba), a); }
-
-// Operation: ((1 - fa) * bc * ba + fc)/a
-// Reuses non-normalized versions of NR_COMPOSEPNP
-static inline unsigned int NR_COMPOSEPNN_321131(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba, unsigned int a) { return DIV_ROUND(NR_COMPOSEPNP_32114(fc, fa, bc, ba), a); }
-static inline unsigned int NR_COMPOSEPNN_221131(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba, unsigned int a) { return DIV_ROUND(NR_COMPOSEPNP_22114(fc, fa, bc, ba), a); }
-static inline unsigned int NR_COMPOSEPNN_111121(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba, unsigned int a) { return DIV_ROUND(NR_COMPOSEPNP_11113(fc, fa, bc, ba), a); }
-
-// Operation: (1 - fa) * bc + fa * fc
-// (1-fa)*bc+fa*fc = bc-fa*bc+fa*fc = bc+fa*(fc-bc)
-// For some reason it's faster to leave the initial 255*bc term in the non-normalized version instead of factoring it out...
-static inline unsigned int NR_COMPOSENPP_1213(unsigned int fc, unsigned int fa, unsigned int bc) { return 255*255*bc + fa*(fc-bc); }
-static inline unsigned int NR_COMPOSENPP_1123(unsigned int fc, unsigned int fa, unsigned int bc) { return 255*bc + fa*(255*fc-bc); }
-static inline unsigned int NR_COMPOSENPP_1112(unsigned int fc, unsigned int fa, unsigned int bc) { return 255*bc + fa*(fc-bc); }
-static inline unsigned int NR_COMPOSENPP_1211(unsigned int fc, unsigned int fa, unsigned int bc) { return NR_NORMALIZE_31(NR_COMPOSENPP_1213(fc, fa, bc)); }
-static inline unsigned int NR_COMPOSENPP_1121(unsigned int fc, unsigned int fa, unsigned int bc) { return NR_NORMALIZE_31(NR_COMPOSENPP_1123(fc, fa, bc)); }
-static inline unsigned int NR_COMPOSENPP_1111(unsigned int fc, unsigned int fa, unsigned int bc) { return NR_NORMALIZE_21(NR_COMPOSENPP_1112(fc, fa, bc)); }
-
-// Operation: (1 - fa) * bc + fc
-// (1-fa)*bc+fc = bc-fa*bc+fc = (bc+fc)-fa*bc
-// This rewritten form results in faster code (found out through testing)
-static inline unsigned int NR_COMPOSEPPP_2224(unsigned int fc, unsigned int fa, unsigned int bc) { return 255*255*(bc+fc) - fa*bc; } // Note that this can temporarily overflow (but it probably doesn't cause problems)
- // NR_COMPOSEPPP_2224 assumes that fa and fc have a common component (fa=a*x and fc=c*x), because then the maximum value is:
- // (255*255-255*x)*255*255 + 255*x*255*255 = 255*255*( (255*255-255*x) + 255*x ) = 255*255*255*( (255-x)+x ) = 255*255*255*255
-static inline unsigned int NR_COMPOSEPPP_3213(unsigned int fc, unsigned int fa, unsigned int bc) { return 255*255*bc + fc - fa*bc; }
-static inline unsigned int NR_COMPOSEPPP_2213(unsigned int fc, unsigned int fa, unsigned int bc) { return 255*(255*bc+fc) - fa*bc; }
-static inline unsigned int NR_COMPOSEPPP_1213(unsigned int fc, unsigned int fa, unsigned int bc) { return 255*255*(bc+fc) - fa*bc; }
-static inline unsigned int NR_COMPOSEPPP_1112(unsigned int fc, unsigned int fa, unsigned int bc) { return 255*(bc+fc) - fa*bc; }
-static inline unsigned int NR_COMPOSEPPP_2221(unsigned int fc, unsigned int fa, unsigned int bc) { return NR_NORMALIZE_41(NR_COMPOSEPPP_2224(fc, fa, bc)); }
-static inline unsigned int NR_COMPOSEPPP_3211(unsigned int fc, unsigned int fa, unsigned int bc) { return NR_NORMALIZE_31(NR_COMPOSEPPP_3213(fc, fa, bc)); }
-static inline unsigned int NR_COMPOSEPPP_2211(unsigned int fc, unsigned int fa, unsigned int bc) { return NR_NORMALIZE_31(NR_COMPOSEPPP_2213(fc, fa, bc)); }
-static inline unsigned int NR_COMPOSEPPP_1211(unsigned int fc, unsigned int fa, unsigned int bc) { return NR_NORMALIZE_21(NR_COMPOSEPPP_1213(fc, fa, bc)); }
-static inline unsigned int NR_COMPOSEPPP_1111(unsigned int fc, unsigned int fa, unsigned int bc) { return NR_NORMALIZE_21(NR_COMPOSEPPP_1112(fc, fa, bc)); }
-
-#define NR_COMPOSEN11_1211 NR_COMPOSENPP_1211
-#define NR_COMPOSEN11_1111 NR_COMPOSENPP_1111
-//inline unsigned int NR_COMPOSEN11_1111(unsigned int fc, unsigned int fa, unsigned int bc) { return NR_NORMALIZE_21((255 - fa) * bc + fa * fc ); }
-
-#define NR_COMPOSEP11_2211 NR_COMPOSEPPP_2211
-#define NR_COMPOSEP11_1211 NR_COMPOSEPPP_1211
-#define NR_COMPOSEP11_1111 NR_COMPOSEPPP_1111
-//inline unsigned int NR_COMPOSEP11_1111(unsigned int fc, unsigned int fa, unsigned int bc) { return NR_NORMALIZE_21((255 - fa) * bc + fc * 255); }
-
-// Premultiply using c*a
-static inline unsigned int NR_PREMUL_134(unsigned int c, unsigned int a) { return c * a; }
-static inline unsigned int NR_PREMUL_224(unsigned int c, unsigned int a) { return c * a; }
-static inline unsigned int NR_PREMUL_123(unsigned int c, unsigned int a) { return c * a; }
-static inline unsigned int NR_PREMUL_112(unsigned int c, unsigned int a) { return c * a; }
-static inline unsigned int NR_PREMUL_314(unsigned int c, unsigned int a) { return NR_PREMUL_134(c, a); }
-static inline unsigned int NR_PREMUL_213(unsigned int c, unsigned int a) { return NR_PREMUL_123(c, a); }
-static inline unsigned int NR_PREMUL_131(unsigned int c, unsigned int a) { return NR_NORMALIZE_41(NR_PREMUL_134(c, a)); }
-static inline unsigned int NR_PREMUL_221(unsigned int c, unsigned int a) { return NR_NORMALIZE_41(NR_PREMUL_224(c, a)); }
-static inline unsigned int NR_PREMUL_121(unsigned int c, unsigned int a) { return NR_NORMALIZE_31(NR_PREMUL_123(c, a)); }
-static inline unsigned int NR_PREMUL_111(unsigned int c, unsigned int a) { return NR_NORMALIZE_21(NR_PREMUL_112(c, a)); }
-static inline unsigned int NR_PREMUL_311(unsigned int c, unsigned int a) { return NR_NORMALIZE_41(NR_PREMUL_314(c, a)); }
-static inline unsigned int NR_PREMUL_211(unsigned int c, unsigned int a) { return NR_NORMALIZE_31(NR_PREMUL_213(c, a)); }
-
-// Demultiply using c/a
-static inline unsigned int NR_DEMUL_131(unsigned int c, unsigned int a) { return DIV_ROUND(255 * 255 * 255 * c, a); }
-static inline unsigned int NR_DEMUL_231(unsigned int c, unsigned int a) { return DIV_ROUND(255 * 255 * c, a); }
-static inline unsigned int NR_DEMUL_121(unsigned int c, unsigned int a) { return DIV_ROUND(255 * 255 * c, a); }
-static inline unsigned int NR_DEMUL_331(unsigned int c, unsigned int a) { return DIV_ROUND(255 * c, a); }
-static inline unsigned int NR_DEMUL_221(unsigned int c, unsigned int a) { return DIV_ROUND(255 * c, a); }
-static inline unsigned int NR_DEMUL_111(unsigned int c, unsigned int a) { return DIV_ROUND(255 * c, a); }
-static inline unsigned int NR_DEMUL_431(unsigned int c, unsigned int a) { return DIV_ROUND(c, a); }
-static inline unsigned int NR_DEMUL_321(unsigned int c, unsigned int a) { return DIV_ROUND(c, a); }
-static inline unsigned int NR_DEMUL_211(unsigned int c, unsigned int a) { return DIV_ROUND(c, a); }
-static inline unsigned int NR_DEMUL_421(unsigned int c, unsigned int a) { return DIV_ROUND(c, 255 * a); }
-static inline unsigned int NR_DEMUL_311(unsigned int c, unsigned int a) { return DIV_ROUND(c, 255 * a); }
-static inline unsigned int NR_DEMUL_411(unsigned int c, unsigned int a) { return DIV_ROUND(c, 255 * 255 * a); }
-
-
-#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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-point-matrix-ops.h b/src/libnr/nr-point-matrix-ops.h
deleted file mode 100644
index 7bed71587..000000000
--- a/src/libnr/nr-point-matrix-ops.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/** @file
- * @brief Operator functions over (NR::Point, NR::Matrix)
- */
-#ifndef SEEN_NR_POINT_MATRIX_OPS_H
-#define SEEN_NR_POINT_MATRIX_OPS_H
-
-#include "libnr/nr-point.h"
-#include "libnr/nr-matrix.h"
-
-namespace NR {
-
-inline Point operator*(Point const &v, Matrix const &m)
-{
-#if 1 /* Which code makes it easier to see what's happening? */
- NR::Point const xform_col0(m[0],
- m[2]);
- NR::Point const xform_col1(m[1],
- m[3]);
- NR::Point const xlate(m[4], m[5]);
- return ( Point(dot(v, xform_col0),
- dot(v, xform_col1))
- + xlate );
-#else
- return Point(v[X] * m[0] + v[Y] * m[2] + m[4],
- v[X] * m[1] + v[Y] * m[3] + m[5]);
-#endif
-}
-
-inline Point &Point::operator*=(Matrix const &m)
-{
- *this = *this * m;
- return *this;
-}
-
-} /* namespace NR */
-
-
-#endif /* !SEEN_NR_POINT_MATRIX_OPS_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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-rect.cpp b/src/libnr/nr-rect.cpp
index 1e1f36104..58e16e963 100644
--- a/src/libnr/nr-rect.cpp
+++ b/src/libnr/nr-rect.cpp
@@ -11,6 +11,7 @@
#include "nr-rect-l.h"
#include <algorithm>
+#include "nr-point-ops.h"
NRRect::NRRect(NR::Rect const &rect)
: x0(rect.min()[NR::X]), y0(rect.min()[NR::Y]),
@@ -220,6 +221,8 @@ nr_rect_d_union_xy (NRRect *d, NR::Coord x, NR::Coord y)
NRRect *
nr_rect_d_matrix_transform(NRRect *d, NRRect const *const s, NR::Matrix const &m)
{
+ // defunct
+ /*
using NR::X;
using NR::Y;
@@ -238,7 +241,7 @@ nr_rect_d_matrix_transform(NRRect *d, NRRect const *const s, NR::Matrix const &m
std::max(c10[X], c11[X]));
d->y1 = std::max(std::max(c00[Y], c01[Y]),
std::max(c10[Y], c11[Y]));
- }
+ }*/
return d;
}
diff --git a/src/libnr/nr-rect.h b/src/libnr/nr-rect.h
index ea656c8e1..aa5921309 100644
--- a/src/libnr/nr-rect.h
+++ b/src/libnr/nr-rect.h
@@ -16,19 +16,23 @@
#include <stdexcept>
#include <limits>
+#include <glib.h>
#include "libnr/nr-values.h"
#include <libnr/nr-coord.h>
#include <libnr/nr-i-coord.h>
#include <libnr/nr-dim2.h>
#include <libnr/nr-point.h>
+#include "libnr/nr-point-ops.h"
+#include "libnr/nr-macros.h"
#include <boost/optional.hpp>
-#include <libnr/nr-point-matrix-ops.h>
#include <libnr/nr-forward.h>
#include <2geom/rect.h>
namespace NR {
+class Matrix;
+
/** A rectangle is always aligned to the X and Y axis. This means it
* can be defined using only 4 coordinates, and determining
* intersection is very efficient. The points inside a rectangle are
@@ -136,11 +140,6 @@ public:
return Rect(s * min(), s * max());
}
- /** Transforms the rect by m. Note that it gives correct results only for scales and translates */
- inline Rect operator*(Matrix const m) const {
- return Rect(_min * m, _max * m);
- }
-
inline bool operator==(Rect const &in_rect) {
return ((this->min() == in_rect.min()) && (this->max() == in_rect.max()));
}
diff --git a/src/libnr/nr-rotate-fns-test.h b/src/libnr/nr-rotate-fns-test.h
deleted file mode 100644
index 9d85da097..000000000
--- a/src/libnr/nr-rotate-fns-test.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#include <cxxtest/TestSuite.h>
-
-#include <cmath>
-#include <glib/gmacros.h>
-
-#include <libnr/nr-rotate-fns.h>
-
-class NrRotateFnsTest : public CxxTest::TestSuite
-{
-public:
-
- NrRotateFnsTest()
- {
- }
- virtual ~NrRotateFnsTest() {}
-
-// createSuite and destroySuite get us per-suite setup and teardown
-// without us having to worry about static initialization order, etc.
- static NrRotateFnsTest *createSuite() { return new NrRotateFnsTest(); }
- static void destroySuite( NrRotateFnsTest *suite ) { delete suite; }
-
-
-
- void testRotateDegrees(void)
- {
- double const d[] = {
- 0, 90, 180, 270, 360, 45, 45.01, 44.99, 134, 135, 136, 314, 315, 317, 359, 361
- };
- for ( unsigned i = 0; i < G_N_ELEMENTS(d); ++i ) {
- double const degrees = d[i];
- NR::rotate const rot(rotate_degrees(degrees));
- NR::rotate const rot_approx( M_PI * ( degrees / 180. ) );
- TS_ASSERT( rotate_equalp(rot, rot_approx, 1e-12) );
-
- NR::rotate const rot_inv(rotate_degrees(-degrees));
- NR::rotate const rot_compl(rotate_degrees(360 - degrees));
- TS_ASSERT( rotate_equalp(rot_inv, rot_compl, 1e-12) );
-
- TS_ASSERT( !rotate_equalp(rot, rotate_degrees(degrees + 1), 1e-5) );
- }
- }
-
-};
-
-/*
- 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-rotate-fns.cpp b/src/libnr/nr-rotate-fns.cpp
deleted file mode 100644
index f2669c20c..000000000
--- a/src/libnr/nr-rotate-fns.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/** \file
- * Functions to/from NR::rotate.
- */
-#include <glib.h>
-#include "libnr/nr-rotate-ops.h"
-#include "libnr/nr-rotate-fns.h"
-
-/**
- * Returns a rotation matrix corresponding by the specified angle about the origin.
- *
- * Angle direction in Inkscape code: If you use the traditional mathematics convention that y
- * increases upwards, then positive angles are anticlockwise as per the mathematics convention. If
- * you take the common non-mathematical convention that y increases downwards, then positive angles
- * are clockwise, as is common outside of mathematics.
- */
-NR::rotate
-rotate_degrees(double degrees)
-{
- if (degrees < 0) {
- return rotate_degrees(-degrees).inverse();
- }
-
- double const degrees0 = degrees;
- if (degrees >= 360) {
- degrees = fmod(degrees, 360);
- }
-
- NR::rotate ret(1., 0.);
-
- if (degrees >= 180) {
- NR::rotate const rot180(-1., 0.);
- degrees -= 180;
- ret = rot180;
- }
-
- if (degrees >= 90) {
- NR::rotate const rot90(0., 1.);
- degrees -= 90;
- ret *= rot90;
- }
-
- if (degrees == 45) {
- NR::rotate const rot45(M_SQRT1_2, M_SQRT1_2);
- ret *= rot45;
- } else {
- double const radians = M_PI * ( degrees / 180 );
- ret *= NR::rotate(cos(radians), sin(radians));
- }
-
- NR::rotate const raw_ret( M_PI * ( degrees0 / 180 ) );
- g_return_val_if_fail(rotate_equalp(ret, raw_ret, 1e-8),
- raw_ret);
- return ret;
-}
-
-
-/*
- 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 :
diff --git a/src/libnr/nr-rotate-fns.h b/src/libnr/nr-rotate-fns.h
deleted file mode 100644
index bd075114c..000000000
--- a/src/libnr/nr-rotate-fns.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef SEEN_NR_ROTATE_FNS_H
-#define SEEN_NR_ROTATE_FNS_H
-
-/** \file
- * Declarations for rotation functions.
- */
-
-#include <libnr/nr-rotate.h>
-#include <libnr/nr-point-fns.h>
-
-inline bool rotate_equalp(NR::rotate const &a, NR::rotate const &b, double const eps)
-{
- return point_equalp(a.vec, b.vec, eps);
-}
-
-NR::rotate rotate_degrees(double degrees);
-
-#endif /* !SEEN_NR_ROTATE_FNS_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 :
diff --git a/src/libnr/nr-rotate-matrix-ops.cpp b/src/libnr/nr-rotate-matrix-ops.cpp
deleted file mode 100644
index a2dd44b43..000000000
--- a/src/libnr/nr-rotate-matrix-ops.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <libnr/nr-matrix-ops.h>
-
-NR::Matrix
-operator*(NR::rotate const &a, NR::Matrix const &b)
-{
- return NR::Matrix(a) * b;
-}
-
-
-/*
- 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-rotate-matrix-ops.h b/src/libnr/nr-rotate-matrix-ops.h
deleted file mode 100644
index e34cc623b..000000000
--- a/src/libnr/nr-rotate-matrix-ops.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef SEEN_LIBNR_NR_ROTATE_MATRIX_OPS_H
-#define SEEN_LIBNR_NR_ROTATE_MATRIX_OPS_H
-
-#include <libnr/nr-forward.h>
-
-
-NR::Matrix operator*(NR::rotate const &a, NR::Matrix const &b);
-
-
-#endif /* !SEEN_LIBNR_NR_ROTATE_MATRIX_OPS_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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-rotate-ops.h b/src/libnr/nr-rotate-ops.h
deleted file mode 100644
index 80eb57b9c..000000000
--- a/src/libnr/nr-rotate-ops.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef SEEN_NR_ROTATE_OPS_H
-#define SEEN_NR_ROTATE_OPS_H
-#include <libnr/nr-rotate.h>
-
-namespace NR {
-
-inline Point operator*(Point const &v, rotate const &r)
-{
- return Point(r.vec[X] * v[X] - r.vec[Y] * v[Y],
- r.vec[Y] * v[X] + r.vec[X] * v[Y]);
-}
-
-inline rotate operator*(rotate const &a, rotate const &b)
-{
- return rotate( a.vec * b );
-}
-
-inline rotate &rotate::operator*=(rotate const &b)
-{
- *this = *this * b;
- return *this;
-}
-
-inline rotate operator/(rotate const &numer, rotate const &denom)
-{
- return numer * denom.inverse();
-}
-
-} /* namespace NR */
-
-
-#endif /* !SEEN_NR_ROTATE_OPS_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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-rotate-test.h b/src/libnr/nr-rotate-test.h
deleted file mode 100644
index 4b3501113..000000000
--- a/src/libnr/nr-rotate-test.h
+++ /dev/null
@@ -1,110 +0,0 @@
-#include <cxxtest/TestSuite.h>
-
-#include <cmath>
-#include <libnr/nr-matrix.h>
-#include <libnr/nr-matrix-ops.h>
-#include <libnr/nr-matrix-fns.h> /* identity, matrix_equalp */
-#include <libnr/nr-point-fns.h>
-#include <libnr/nr-rotate.h>
-#include <libnr/nr-rotate-fns.h>
-#include <libnr/nr-rotate-ops.h>
-
-
-class NrRotateTest : public CxxTest::TestSuite
-{
-public:
-
- NrRotateTest() :
- m_id( NR::identity() ),
- r_id( 0.0 ),
- rot234( .234 ),
- b( -2.0, 3.0 ),
- rot180( NR::Point(-1.0, 0.0) )
- {
- }
- virtual ~NrRotateTest() {}
-
-// createSuite and destroySuite get us per-suite setup and teardown
-// without us having to worry about static initialization order, etc.
- static NrRotateTest *createSuite() { return new NrRotateTest(); }
- static void destroySuite( NrRotateTest *suite ) { delete suite; }
-
- NR::Matrix const m_id;
- NR::rotate const r_id;
- NR::rotate const rot234;
- NR::Point const b;
- NR::rotate const rot180;
-
-
-
-
- void testCtorsCompares(void)
- {
- TS_ASSERT_EQUALS( r_id, r_id );
- TS_ASSERT_EQUALS( rot234, rot234 );
- TS_ASSERT_DIFFERS( rot234, r_id );
- TS_ASSERT_EQUALS( r_id, NR::rotate(NR::Point(1.0, 0.0)) );
- TS_ASSERT_EQUALS( NR::Matrix(r_id), m_id );
- TS_ASSERT( NR::Matrix(r_id).test_identity() );
-
- TS_ASSERT(rotate_equalp(rot234, NR::rotate(NR::Point(cos(.234), sin(.234))), 1e-12));
- }
-
- void testAssignmentOp(void)
- {
- NR::rotate rot234_eq(r_id);
- rot234_eq = rot234;
- TS_ASSERT_EQUALS( rot234, rot234_eq );
- TS_ASSERT_DIFFERS( rot234_eq, r_id );
- }
-
- void testInverse(void)
- {
- TS_ASSERT_EQUALS( r_id.inverse(), r_id );
- TS_ASSERT_EQUALS( rot234.inverse(), NR::rotate(-.234) );
- }
-
- void testOpStarPointRotate(void)
- {
- TS_ASSERT_EQUALS( b * r_id, b );
- TS_ASSERT_EQUALS( b * rot180, -b );
- TS_ASSERT_EQUALS( b * rot234, b * NR::Matrix(rot234) );
- TS_ASSERT(point_equalp(b * NR::rotate(M_PI / 2),
- NR::rot90(b),
- 1e-14));
- TS_ASSERT_EQUALS( b * rotate_degrees(90.), NR::rot90(b) );
- }
-
- void testOpStarRotateRotate(void)
- {
- TS_ASSERT_EQUALS( r_id * r_id, r_id );
- TS_ASSERT_EQUALS( rot180 * rot180, r_id );
- TS_ASSERT_EQUALS( rot234 * r_id, rot234 );
- TS_ASSERT_EQUALS( r_id * rot234, rot234 );
- TS_ASSERT( rotate_equalp(rot234 * rot234.inverse(), r_id, 1e-14) );
- TS_ASSERT( rotate_equalp(rot234.inverse() * rot234, r_id, 1e-14) );
- TS_ASSERT( rotate_equalp(( NR::rotate(0.25) * NR::rotate(.5) ),
- NR::rotate(.75),
- 1e-10) );
- }
-
- void testOpDivRotateRotate(void)
- {
- TS_ASSERT_EQUALS( rot234 / r_id, rot234 );
- TS_ASSERT_EQUALS( rot234 / rot180, rot234 * rot180 );
- TS_ASSERT( rotate_equalp(rot234 / rot234, r_id, 1e-14) );
- TS_ASSERT( rotate_equalp(r_id / rot234, rot234.inverse(), 1e-14) );
- }
-
-};
-
-/*
- 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-rotate.h b/src/libnr/nr-rotate.h
deleted file mode 100644
index 6464983ab..000000000
--- a/src/libnr/nr-rotate.h
+++ /dev/null
@@ -1,66 +0,0 @@
-#ifndef SEEN_NR_ROTATE_H
-#define SEEN_NR_ROTATE_H
-
-/** \file
- * Rotation about the origin.
- */
-
-#include <libnr/nr-point.h>
-#include <libnr/nr-point-fns.h>
-#include <libnr/nr-point-ops.h>
-
-namespace NR {
-
-/** Notionally an NR::Matrix corresponding to rotation about the origin.
- Behaves like NR::Matrix for multiplication.
-**/
-class rotate {
-public:
- Point vec;
-
-private:
- rotate();
-
-public:
- explicit rotate(Coord theta);
- explicit rotate(Point const &p) : vec(p) {}
- explicit rotate(Coord const x, Coord const y) : vec(x, y) {}
-
- bool operator==(rotate const &o) const {
- return vec == o.vec;
- }
-
- bool operator!=(rotate const &o) const {
- return vec != o.vec;
- }
-
- inline rotate &operator*=(rotate const &b);
- /* Defined in nr-rotate-ops.h. */
-
- rotate inverse() const {
- /** \todo
- * In the usual case that vec is a unit vector (within rounding error),
- * dividing by len_sq is either a noop or numerically harmful.
- * Make a unit_rotate class (or the like) that knows its length is 1.
- */
- double const len_sq = dot(vec, vec);
- return rotate( Point(vec[X], -vec[Y])
- / len_sq );
- }
-};
-
-} /* namespace NR */
-
-
-#endif /* !SEEN_NR_ROTATE_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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-scale-matrix-ops.cpp b/src/libnr/nr-scale-matrix-ops.cpp
deleted file mode 100644
index 4bb90196e..000000000
--- a/src/libnr/nr-scale-matrix-ops.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-#include "libnr/nr-matrix-ops.h"
-
-NR::Matrix
-operator*(NR::scale const &s, NR::Matrix const &m)
-{
- using NR::X; using NR::Y;
- NR::Matrix ret(m);
- ret[0] *= s[X];
- ret[1] *= s[X];
- ret[2] *= s[Y];
- ret[3] *= s[Y];
- return ret;
-}
-
-
-/*
- 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-scale-matrix-ops.h b/src/libnr/nr-scale-matrix-ops.h
deleted file mode 100644
index bf1b498c9..000000000
--- a/src/libnr/nr-scale-matrix-ops.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef SEEN_LIBNR_NR_SCALE_MATRIX_OPS_H
-#define SEEN_LIBNR_NR_SCALE_MATRIX_OPS_H
-/** \file
- * Declarations (and definition if inline) of operator
- * blah (NR::scale, NR::Matrix).
- */
-
-#include "libnr/nr-forward.h"
-
-NR::Matrix operator*(NR::scale const &s, NR::Matrix const &m);
-
-
-#endif /* !SEEN_LIBNR_NR_SCALE_MATRIX_OPS_H */
diff --git a/src/libnr/nr-scale-ops.h b/src/libnr/nr-scale-ops.h
deleted file mode 100644
index 63bfe222a..000000000
--- a/src/libnr/nr-scale-ops.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef SEEN_NR_SCALE_OPS_H
-#define SEEN_NR_SCALE_OPS_H
-
-#include <libnr/nr-scale.h>
-
-namespace NR {
-
-inline Point operator*(Point const &p, scale const &s)
-{
- return Point(p[X] * s[X],
- p[Y] * s[Y]);
-}
-
-inline scale operator*(scale const &a, scale const &b)
-{
- return scale(a[X] * b[X],
- a[Y] * b[Y]);
-}
-
-inline scale operator/(scale const &numer, scale const &denom)
-{
- return scale(numer[X] / denom[X],
- numer[Y] / denom[Y]);
-}
-
-} /* namespace NR */
-
-
-#endif /* !SEEN_NR_SCALE_OPS_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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-scale-test.h b/src/libnr/nr-scale-test.h
deleted file mode 100644
index 55384c637..000000000
--- a/src/libnr/nr-scale-test.h
+++ /dev/null
@@ -1,90 +0,0 @@
-#include <cxxtest/TestSuite.h>
-
-#include <libnr/nr-scale.h>
-#include <libnr/nr-scale-ops.h>
-
-class NrScaleTest : public CxxTest::TestSuite
-{
-public:
-
- NrScaleTest() :
- sa( 1.5, 2.0 ),
- b( -2.0, 3.0 ),
- sb( b )
- {
- }
- virtual ~NrScaleTest() {}
-
-// createSuite and destroySuite get us per-suite setup and teardown
-// without us having to worry about static initialization order, etc.
- static NrScaleTest *createSuite() { return new NrScaleTest(); }
- static void destroySuite( NrScaleTest *suite ) { delete suite; }
-
- NR::scale const sa;
- NR::Point const b;
- NR::scale const sb;
-
-
-
- void testXY_CtorArrayOperator(void)
- {
- TS_ASSERT_EQUALS( sa[NR::X], 1.5 );
- TS_ASSERT_EQUALS( sa[NR::Y], 2.0 );
- TS_ASSERT_EQUALS( sa[0u], 1.5 );
- TS_ASSERT_EQUALS( sa[1u], 2.0 );
- }
-
-
- void testCopyCtor_AssignmentOp_NotEquals(void)
- {
- NR::scale const sa_copy(sa);
- TS_ASSERT_EQUALS( sa, sa_copy );
- TS_ASSERT(!( sa != sa_copy ));
- TS_ASSERT( sa != sb );
- }
-
- void testAssignmentOp(void)
- {
- NR::scale sa_eq(sb);
- sa_eq = sa;
- TS_ASSERT_EQUALS( sa, sa_eq );
- }
-
- void testPointCtor(void)
- {
- TS_ASSERT_EQUALS( sb[NR::X], b[NR::X] );
- TS_ASSERT_EQUALS( sb[NR::Y], b[NR::Y] );
- }
-
- void testOpStarPointScale(void)
- {
- NR::Point const ab( b * sa );
- TS_ASSERT_EQUALS( ab, NR::Point(-3.0, 6.0) );
- }
-
- void testOpStarScaleScale(void)
- {
- NR::scale const sab( sa * sb );
- TS_ASSERT_EQUALS( sab, NR::scale(-3.0, 6.0) );
- }
-
- void testOpDivScaleScale(void)
- {
- NR::scale const sa_b( sa / sb );
- NR::scale const exp_sa_b(-0.75, 2./3.);
- TS_ASSERT_EQUALS( sa_b[0], exp_sa_b[0] );
-// TS_ASSERT_EQUALS( fabs( sa_b[1] - exp_sa_b[1] ) < 1e-10 );
- TS_ASSERT_DELTA( sa_b[1], exp_sa_b[1], 1e-10 );
- }
-};
-
-/*
- 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-scale-translate-ops.cpp b/src/libnr/nr-scale-translate-ops.cpp
deleted file mode 100644
index 579d071d8..000000000
--- a/src/libnr/nr-scale-translate-ops.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-#include "libnr/nr-matrix-translate-ops.h"
-
-NR::Matrix
-operator*(NR::scale const &s, NR::translate const &t)
-{
- return NR::Matrix(s) * t;
-}
-
-
-/*
- 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-scale-translate-ops.h b/src/libnr/nr-scale-translate-ops.h
deleted file mode 100644
index 719b7b934..000000000
--- a/src/libnr/nr-scale-translate-ops.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef SEEN_LIBNR_NR_SCALE_TRANSLATE_OPS_H
-#define SEEN_LIBNR_NR_SCALE_TRANSLATE_OPS_H
-
-#include "libnr/nr-forward.h"
-
-NR::Matrix operator*(NR::scale const &s, NR::translate const &t);
-
-
-#endif /* !SEEN_LIBNR_NR_SCALE_TRANSLATE_OPS_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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-scale.h b/src/libnr/nr-scale.h
deleted file mode 100644
index fd59dc210..000000000
--- a/src/libnr/nr-scale.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef SEEN_NR_SCALE_H
-#define SEEN_NR_SCALE_H
-#include <libnr/nr-point.h>
-#include <libnr/nr-point-ops.h>
-
-namespace NR {
-
-class scale {
-private:
- Point _p;
-
-private:
- scale();
-
-public:
- explicit scale(Point const &p) : _p(p) {}
- scale(double const x, double const y) : _p(x, y) {}
- explicit scale(double const s) : _p(s, s) {}
- inline Coord operator[](Dim2 const d) const { return _p[d]; }
- inline Coord operator[](unsigned const d) const { return _p[d]; }
- inline Coord &operator[](Dim2 const d) { return _p[d]; }
- inline Coord &operator[](unsigned const d) { return _p[d]; }
-
- bool operator==(scale const &o) const {
- return _p == o._p;
- }
-
- bool operator!=(scale const &o) const {
- return _p != o._p;
- }
-
- scale inverse() const {
- return scale(1/_p[0], 1/_p[1]);
- }
-
- NR::Point point() const {
- return _p;
- }
-};
-
-} /* namespace NR */
-
-
-#endif /* !SEEN_NR_SCALE_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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-translate-matrix-ops.cpp b/src/libnr/nr-translate-matrix-ops.cpp
deleted file mode 100644
index 80d08afa8..000000000
--- a/src/libnr/nr-translate-matrix-ops.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "libnr/nr-matrix-ops.h"
-
-namespace NR {
-
-Matrix
-operator*(translate const &t, Matrix const &m)
-{
- Matrix ret(m);
- ret[4] += m[0] * t[X] + m[2] * t[Y];
- ret[5] += m[1] * t[X] + m[3] * t[Y];
- return ret;
-}
-
-} /* namespace NR */
-
-
-/*
- 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-translate-matrix-ops.h b/src/libnr/nr-translate-matrix-ops.h
deleted file mode 100644
index cb939d5cf..000000000
--- a/src/libnr/nr-translate-matrix-ops.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef SEEN_LIBNR_NR_TRANSLATE_MATRIX_OPS_H
-#define SEEN_LIBNR_NR_TRANSLATE_MATRIX_OPS_H
-
-#include "libnr/nr-forward.h"
-
-namespace NR {
-Matrix operator*(translate const &t, Matrix const &m);
-}
-
-
-#endif /* !SEEN_LIBNR_NR_TRANSLATE_MATRIX_OPS_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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-translate-ops.h b/src/libnr/nr-translate-ops.h
deleted file mode 100644
index 2812893fb..000000000
--- a/src/libnr/nr-translate-ops.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef SEEN_NR_TRANSLATE_OPS_H
-#define SEEN_NR_TRANSLATE_OPS_H
-
-#include <libnr/nr-translate.h>
-#include <libnr/nr-point-ops.h>
-
-namespace NR {
-
-inline bool operator==(translate const &a, translate const &b)
-{
- return a.offset == b.offset;
-}
-
-inline bool operator!=(translate const &a, translate const &b)
-{
- return !( a == b );
-}
-
-inline translate operator*(translate const &a, translate const &b)
-{
- return translate( a.offset + b.offset );
-}
-
-inline Point operator*(Point const &v, translate const &t)
-{
- return t.offset + v;
-}
-
-} /* namespace NR */
-
-
-#endif /* !SEEN_NR_TRANSLATE_OPS_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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-translate-rotate-ops.cpp b/src/libnr/nr-translate-rotate-ops.cpp
deleted file mode 100644
index 3dbe31211..000000000
--- a/src/libnr/nr-translate-rotate-ops.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <libnr/nr-matrix-translate-ops.h>
-#include <libnr/nr-rotate-ops.h>
-
-NR::Matrix
-operator*(NR::translate const &a, NR::rotate const &b)
-{
- return NR::Matrix(b) * NR::translate(a.offset * b);
-}
-
-
-/*
- 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-translate-rotate-ops.h b/src/libnr/nr-translate-rotate-ops.h
deleted file mode 100644
index 286e5caa7..000000000
--- a/src/libnr/nr-translate-rotate-ops.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef SEEN_LIBNR_NR_TRANSLATE_ROTATE_OPS_H
-#define SEEN_LIBNR_NR_TRANSLATE_ROTATE_OPS_H
-
-#include <libnr/nr-forward.h>
-
-
-NR::Matrix operator*(NR::translate const &a, NR::rotate const &b);
-
-
-#endif /* !SEEN_LIBNR_NR_TRANSLATE_ROTATE_OPS_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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-translate-scale-ops.cpp b/src/libnr/nr-translate-scale-ops.cpp
deleted file mode 100644
index 41e85c296..000000000
--- a/src/libnr/nr-translate-scale-ops.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "libnr/nr-matrix-ops.h"
-
-NR::Matrix
-operator*(NR::translate const &t, NR::scale const &s)
-{
- using NR::X; using NR::Y;
-
- NR::Matrix ret(s);
- ret[4] = t[X] * s[X];
- ret[5] = t[Y] * s[Y];
- return ret;
-}
-
-
-/*
- 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-translate-scale-ops.h b/src/libnr/nr-translate-scale-ops.h
deleted file mode 100644
index ad362a6a7..000000000
--- a/src/libnr/nr-translate-scale-ops.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef SEEN_LIBNR_NR_TRANSLATE_SCALE_OPS_H
-#define SEEN_LIBNR_NR_TRANSLATE_SCALE_OPS_H
-
-#include "libnr/nr-forward.h"
-
-NR::Matrix operator*(NR::translate const &t, NR::scale const &s);
-
-
-#endif /* !SEEN_LIBNR_NR_TRANSLATE_SCALE_OPS_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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-translate-test.h b/src/libnr/nr-translate-test.h
deleted file mode 100644
index 54d7c725f..000000000
--- a/src/libnr/nr-translate-test.h
+++ /dev/null
@@ -1,85 +0,0 @@
-#include <cxxtest/TestSuite.h>
-
-#include <libnr/nr-point-ops.h>
-#include <libnr/nr-matrix.h>
-#include <libnr/nr-matrix-fns.h>
-#include <libnr/nr-matrix-ops.h>
-#include <libnr/nr-point-matrix-ops.h>
-#include <libnr/nr-translate.h>
-#include <libnr/nr-translate-ops.h>
-
-class NrTranslateTest : public CxxTest::TestSuite
-{
-public:
-
- NrTranslateTest() :
- b( -2.0, 3.0 ),
- tb( b ),
- tc( -3.0, -2.0 ),
- tbc( tb * tc ),
- t_id( 0.0, 0.0 ),
- m_id( NR::identity() )
- {
- }
- virtual ~NrTranslateTest() {}
-
-// createSuite and destroySuite get us per-suite setup and teardown
-// without us having to worry about static initialization order, etc.
- static NrTranslateTest *createSuite() { return new NrTranslateTest(); }
- static void destroySuite( NrTranslateTest *suite ) { delete suite; }
-
- NR::Point const b;
- NR::translate const tb;
- NR::translate const tc;
- NR::translate const tbc;
- NR::translate const t_id;
- NR::Matrix const m_id;
-
-
- void testCtorsArrayOperator(void)
- {
- TS_ASSERT_EQUALS( tc[NR::X], -3.0 );
- TS_ASSERT_EQUALS( tc[NR::Y], -2.0 );
-
- TS_ASSERT_EQUALS( tb[0], b[NR::X] );
- TS_ASSERT_EQUALS( tb[1], b[NR::Y] );
- }
-
- void testAssignmentOperator(void)
- {
- NR::translate tb_eq(tc);
- tb_eq = tb;
- TS_ASSERT_EQUALS( tb, tb_eq );
- TS_ASSERT_DIFFERS( tb_eq, tc );
- }
-
- void testOpStarTranslateTranslate(void)
- {
- TS_ASSERT_EQUALS( tbc.offset, NR::Point(-5.0, 1.0) );
- TS_ASSERT_EQUALS( tbc.offset, ( tc * tb ).offset );
- TS_ASSERT_EQUALS( NR::Matrix(tbc), NR::Matrix(tb) * NR::Matrix(tc) );
- }
-
- void testOpStarPointTranslate(void)
- {
- TS_ASSERT_EQUALS( tbc.offset, b * tc );
- TS_ASSERT_EQUALS( b * tc, b * NR::Matrix(tc) );
- }
-
- void testIdentity(void)
- {
- TS_ASSERT_EQUALS( b * t_id, b );
- TS_ASSERT_EQUALS( NR::Matrix(t_id), m_id );
- }
-};
-
-/*
- 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-translate.h b/src/libnr/nr-translate.h
deleted file mode 100644
index 65660099c..000000000
--- a/src/libnr/nr-translate.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef SEEN_NR_TRANSLATE_H
-#define SEEN_NR_TRANSLATE_H
-
-#include <libnr/nr-point.h>
-
-namespace NR {
-
-class translate {
-public:
- Point offset;
-private:
- translate();
-public:
- explicit translate(Point const &p) : offset(p) {}
- explicit translate(Coord const x, Coord const y) : offset(x, y) {}
- Coord operator[](Dim2 const dim) const { return offset[dim]; }
- Coord operator[](unsigned const dim) const { return offset[dim]; }
-};
-
-} /* namespace NR */
-
-
-#endif /* !SEEN_NR_TRANSLATE_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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-types.h b/src/libnr/nr-types.h
index 8a1cb82cd..685c29342 100644
--- a/src/libnr/nr-types.h
+++ b/src/libnr/nr-types.h
@@ -18,7 +18,6 @@
#include <libnr/nr-coord.h>
#include <libnr/nr-dim2.h>
#include <libnr/nr-i-coord.h>
-#include <libnr/nr-matrix.h>
#include <libnr/nr-point.h>
#include <libnr/nr-point-l.h>
#include <libnr/nr-point-ops.h>
diff --git a/src/libnr/nr-values.cpp b/src/libnr/nr-values.cpp
index f828c1396..9193eff3b 100644
--- a/src/libnr/nr-values.cpp
+++ b/src/libnr/nr-values.cpp
@@ -1,14 +1,12 @@
#define __NR_VALUES_C__
#include <libnr/nr-rect-l.h>
-#include <libnr/nr-matrix-fns.h>
-
+#include "libnr/nr-rect.h"
/*
The following predefined objects are for reference
and comparison.
*/
-NR::Matrix NR_MATRIX_IDENTITY = NR::identity();
NRRect NR_RECT_EMPTY(NR_HUGE, NR_HUGE, -NR_HUGE, -NR_HUGE);
NRRectL NR_RECT_L_EMPTY =
{NR_HUGE_L, NR_HUGE_L, -NR_HUGE_L, -NR_HUGE_L};
diff --git a/src/libnr/nr-values.h b/src/libnr/nr-values.h
index 2a795e2c6..f85fca690 100644
--- a/src/libnr/nr-values.h
+++ b/src/libnr/nr-values.h
@@ -22,7 +22,6 @@
The following predefined objects are for reference
and comparison. They are defined in nr-values.cpp
*/
-extern NR::Matrix NR_MATRIX_IDENTITY;
extern NRRect NR_RECT_EMPTY;
extern NRRectL NR_RECT_L_EMPTY;
extern NRRectL NR_RECT_S_EMPTY;
diff --git a/src/libnr/testnr.cpp b/src/libnr/testnr.cpp
deleted file mode 100644
index 7ce01afab..000000000
--- a/src/libnr/testnr.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-#define __TESTNR_C__
-
-/*
- * Pixel buffer rendering library
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * This code is in public domain
- */
-
-#include <stdio.h>
-
-#if defined (_WIN32) || defined (__WIN32__)
-# include <windows.h>
-#include <glib.h>
-#endif
-
-
-#include "nr-blit.h"
-
-static double
-get_time (void)
-{
- GTimeVal tv;
- g_get_current_time (&tv);
- return tv.tv_sec + 1e-6 * tv.tv_usec;
-}
-
-static unsigned int
-rand_byte (void)
-{
- return (int) (256.0 * rand () / (RAND_MAX + 1.0));
-}
-
-int
-main (int argc, const char **argv)
-{
- double start, end;
- NRPixBlock d, m[16];
- int count, i;
-
- srand (time (NULL));
-
- printf ("Initializing buffers\n");
-
- /* Destination */
- nr_pixblock_setup_fast (&d, NR_PIXBLOCK_MODE_R8G8B8A8P, 0, 0, 64, 64, 1);
- d.empty = 0;
-
- /* Masks */
- for (i = 0; i < 16; i++) {
- int r, b, c;
- nr_pixblock_setup_fast (&m[i], NR_PIXBLOCK_MODE_A8, 0, 0, 64, 64, 0);
- for (r = 0; r < 64; r++) {
- unsigned int q;
- unsigned char *p;
- p = NR_PIXBLOCK_PX (&m[i]) + r * m[i].rs;
- for (b = 0; b < 8; b++) {
- q = rand_byte ();
- if (q < 120) {
- for (c = 0; c < 8; c++) *p++ = 0;
- } else if (q < 240) {
- for (c = 0; c < 8; c++) *p++ = 255;
- } else {
- for (c = 0; c < 8; c++) *p++ = rand_byte ();
- }
- }
- }
- m[i].empty = 0;
- }
-
- printf ("Random transparency\n");
- count = 0;
- start = end = get_time ();
- while ((end - start) < 5.0) {
- unsigned char r, g, b, a;
- r = rand_byte ();
- g = rand_byte ();
- b = rand_byte ();
- a = rand_byte ();
-
- for (i = 0; i < 16; i++) {
- nr_blit_pixblock_mask_rgba32 (&d, &m[i], (a << 24) | (g << 16) | (b << 8) | a);
- count += 1;
- }
- end = get_time ();
- }
- printf ("Did %d [64x64] random buffers in %f sec\n", count, end - start); // localizing ok
- printf ("%f buffers per second\n", count / (end - start)); // localizing ok
- printf ("%f pixels per second\n", count * (64 * 64) / (end - start)); // localizing ok
-
- return 0;
-}