From 30884b9e814d7baaa2299803e8cb76cf203ca084 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 4 Aug 2010 05:45:58 +0200 Subject: Wholesale cruft removal part 1 (bzr r9508.1.44) --- src/libnr/Makefile_insert | 9 - src/libnr/nr-convex-hull-ops.h | 29 --- src/libnr/nr-convex-hull.h | 59 ----- src/libnr/nr-gradient.cpp | 554 ---------------------------------------- src/libnr/nr-gradient.h | 81 ------ src/libnr/nr-matrix-div.cpp | 22 -- src/libnr/nr-matrix-div.h | 21 -- src/libnr/nr-pixblock-line.cpp | 92 ------- src/libnr/nr-pixblock-line.h | 28 -- src/libnr/nr-pixblock-pixel.cpp | 230 ----------------- src/libnr/nr-pixblock-pixel.h | 28 -- 11 files changed, 1153 deletions(-) delete mode 100644 src/libnr/nr-convex-hull-ops.h delete mode 100644 src/libnr/nr-convex-hull.h delete mode 100644 src/libnr/nr-gradient.cpp delete mode 100644 src/libnr/nr-gradient.h delete mode 100644 src/libnr/nr-matrix-div.cpp delete mode 100644 src/libnr/nr-matrix-div.h delete mode 100644 src/libnr/nr-pixblock-line.cpp delete mode 100644 src/libnr/nr-pixblock-line.h delete mode 100644 src/libnr/nr-pixblock-pixel.cpp delete mode 100644 src/libnr/nr-pixblock-pixel.h (limited to 'src/libnr') diff --git a/src/libnr/Makefile_insert b/src/libnr/Makefile_insert index 8dd3c46e3..dc329c351 100644 --- a/src/libnr/Makefile_insert +++ b/src/libnr/Makefile_insert @@ -10,16 +10,11 @@ ink_common_sources += \ 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 \ @@ -33,12 +28,8 @@ ink_common_sources += \ 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 \ 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 - * - * This code is licensed under the GNU GPL; see COPYING for more information. - */ - -#include -#include - -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 - * - * This code is licensed under the GNU GPL; see COPYING for more information. - */ - -#include - -namespace NR { - -class ConvexHull { -public: - ConvexHull() : _bounds() {} - explicit ConvexHull(Point const &p) : _bounds(Rect(p, p)) {} - - boost::optional midpoint() const { - if (_bounds) { - return _bounds->midpoint(); - } else { - return boost::optional(); - } - } - - 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 const &bounds() const { - return _bounds; - } - -private: - boost::optional _bounds; -}; - -} /* namespace NR */ - -#endif diff --git a/src/libnr/nr-gradient.cpp b/src/libnr/nr-gradient.cpp deleted file mode 100644 index e6eb9b79c..000000000 --- a/src/libnr/nr-gradient.cpp +++ /dev/null @@ -1,554 +0,0 @@ -#define __NR_GRADIENT_C__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * MenTaLguY - *...Jasper van de Gronde - * - * 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 -#include -#include -#include -#include -#include -#include -#include - -/* 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 struct Spread; - -template <> -struct Spread { -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 { -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 { -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 struct ModeTraits; - -template <> -struct ModeTraits { -static const unsigned bpp=4; -}; - -template <> -struct ModeTraits { -static const unsigned bpp=4; -}; - -template <> -struct ModeTraits { -static const unsigned bpp=3; -}; - -template <> -struct ModeTraits { -static const unsigned bpp=1; -}; - -template -struct Compose { -static const unsigned bpp=ModeTraits::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 { -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 { -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 { -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 { -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 { -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 { -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 { -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 -static void -render_spread(NRGradientRenderer *gr, NRPixBlock *pb) -{ - switch (pb->mode) { - case NR_PIXBLOCK_MODE_R8G8B8A8N: - if (pb->empty) { - typedef Compose compose; - Subtype::template render(gr, pb); - } else { - typedef Compose compose; - Subtype::template render(gr, pb); - } - break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: - if (pb->empty) { - typedef Compose compose; - Subtype::template render(gr, pb); - } else { - typedef Compose compose; - Subtype::template render(gr, pb); - } - break; - case NR_PIXBLOCK_MODE_R8G8B8: - if (pb->empty) { - typedef Compose compose; - Subtype::template render(gr, pb); - } else { - typedef Compose compose; - Subtype::template render(gr, pb); - } - break; - case NR_PIXBLOCK_MODE_A8: - if (pb->empty) { - typedef Compose compose; - Subtype::template render(gr, pb); - } else { - typedef Compose compose; - Subtype::template render(gr, pb); - } - break; - } -} - -template -static void -render(NRRenderer *r, NRPixBlock *pb, NRPixBlock */*m*/) -{ - NRGradientRenderer *gr = static_cast(r); - - switch (gr->spread) { - case NR_GRADIENT_SPREAD_REPEAT: - render_spread >(gr, pb); - break; - case NR_GRADIENT_SPREAD_REFLECT: - render_spread >(gr, pb); - break; - case NR_GRADIENT_SPREAD_PAD: - default: - render_spread >(gr, pb); - } -} -} - -/* Linear */ - -namespace { - -struct Linear { -template -static void render(NRGradientRenderer *gr, NRPixBlock *pb) { - NRLGradientRenderer *lgr = static_cast(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; - - 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 -static void render(NRGradientRenderer *gr, NRPixBlock *pb) -{ - NRRGradientRenderer *rgr = static_cast(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 -static void render(NRGradientRenderer *gr, NRPixBlock *pb) -{ - NRRGradientRenderer *rgr = static_cast(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; - - 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; - - 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:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-gradient.h b/src/libnr/nr-gradient.h deleted file mode 100644 index 1073f36ae..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 - * - * 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 -#include - -#define NR_GRADIENT_VECTOR_BITS 10 -#define NR_GRADIENT_VECTOR_LENGTH (1< - * - * This code is in public domain - */ - -#include -#include - -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 7fd58a0ab..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 - * - * This code is in public domain - */ - -#include - -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:encoding=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 - * - * 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 d989f53cf..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 - * - * This code is in public domain - */ - -#include - -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:encoding=utf-8:textwidth=99 : -- cgit v1.2.3