This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via d15c6dd78c9e1605830aec10a58dad1dd4e7c39a (commit) via 8f11a42580586ca3fd0c71f3de3c6017ec9f50f0 (commit) via 15218977e283fb9d7f61db2f336b662350bfecd7 (commit) via 66288dc8cf7dc3f0e2308a5913820f49814181af (commit) via 3b0b817ad655b1c5a7172d41d971793fafd4e033 (commit) via f65e8ed5951cb097f67d212da67b48604c47bd66 (commit) via 785fcafc3003d9af67c6d17a1451efc00d3544d1 (commit) via afe7e710ea1a940e90b80a511ba05b598491b16c (commit) from ee2a7bf0f846b6283b0c3cab6acb7c5afb4ca93b (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/d15c6dd78c9e1605830aec10a58dad1dd4e7c...
commit d15c6dd78c9e1605830aec10a58dad1dd4e7c39a Author: Cyril Hrubis metan@ucw.cz Date: Sun Dec 30 20:56:06 2012 +0100
core: GP_ContextEqual: Minor coding style fix.
diff --git a/libs/core/GP_Context.c b/libs/core/GP_Context.c index c749fcc..c082c53 100644 --- a/libs/core/GP_Context.c +++ b/libs/core/GP_Context.c @@ -348,10 +348,15 @@ void GP_ContextRotateCCW(GP_Context *context)
int GP_ContextEqual(const GP_Context *ctx1, const GP_Context *ctx2) { - if (ctx1->pixel_type != ctx2->pixel_type) return 0; - if (GP_ContextW(ctx1) != GP_ContextW(ctx2)) return 0; - if (GP_ContextH(ctx1) != GP_ContextH(ctx2)) return 0; + if (ctx1->pixel_type != ctx2->pixel_type) + return 0;
+ if (GP_ContextW(ctx1) != GP_ContextW(ctx2)) + return 0; + + if (GP_ContextH(ctx1) != GP_ContextH(ctx2)) + return 0; + GP_Coord x, y, w = GP_ContextW(ctx1), h = GP_ContextH(ctx1);
for (x = 0; x < w; x++)
http://repo.or.cz/w/gfxprim.git/commit/8f11a42580586ca3fd0c71f3de3c6017ec9f5...
commit 8f11a42580586ca3fd0c71f3de3c6017ec9f50f0 Merge: f65e8ed 1521897 Author: Cyril Hrubis metan@ucw.cz Date: Sun Dec 30 20:52:41 2012 +0100
Merge gfxprim
http://repo.or.cz/w/gfxprim.git/commit/15218977e283fb9d7f61db2f336b662350bfe...
commit 15218977e283fb9d7f61db2f336b662350bfecd7 Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Dec 30 16:38:43 2012 +0100
core: pylib: Tests for Context equality
diff --git a/tests/pylib/test_core.py b/tests/pylib/test_core.py index 2752c64..f1703a5 100644 --- a/tests/pylib/test_core.py +++ b/tests/pylib/test_core.py @@ -1,3 +1,4 @@ +"core.Context"
### Helper imports and decorators # TODO: separate (nose plugin?) @@ -25,15 +26,19 @@ def test_basic_types_exist(): assert core.C.PIXEL_RGBA8888 > 0 assert core.C.PIXEL_G8 > 0
-def test_create_context(): - c = Context.Create(7, 9, core.C.PIXEL_RGB888) - assert c.w == 7 - assert c.h == 9 +@alltypes() +def test_create_by_pixeltype(t): + "Allocate Context by pixeltype" + c = Context.Create(13, 15, t.type)
+@alltypes() +def test_create_by_number(t): + "Allocation by pixeltype number" + c = Context.Create(3, 5, t)
@alltypes() -def test_create_context_and_check_sanity(t): - "Allocate Context by pixeltype and check basic invariants" +def test_check_attributes(t): + "Context attributes" c = Context.Create(13, 15, t.type) assert c.w == 13 assert c.h == 15 @@ -42,13 +47,8 @@ def test_create_context_and_check_sanity(t): assert c._free_pixels
@alltypes() -def test_create_by_number(t): - "Allocation by pixeltype number" - c = Context.Create(3, 5, t) - -@alltypes() def test_context_convert_from_RGB888(t): - "Test conversion from RGB888" + "Conversion from RGB888" if 'P' in t.name: raise SkipTest("Palette conversion os TODO") c = Context.Create(17, 19, core.C.PIXEL_RGB888) @@ -59,10 +59,32 @@ def test_context_convert_from_RGB888(t): assert c3.pixel_type == t.type
@alltypes() -def test_context_convert_to_RGB888(t): - "Test conversion to RGB888" +def test_convert_to_RGB888(t): + "Conversion to RGB888" if 'P' in t.name: raise SkipTest("Palette conversion os TODO") c = Context.Create(1, 1, t) c2 = c.Convert(core.C.PIXEL_RGB888) assert c2.pixel_type == core.C.PIXEL_RGB888 + +@alltypes() +def test_equality_same_type(t): + "Basics of equality" + c1 = Context.Create(2, 1, t) + assert c1 == c1 + c2 = Context.Create(1, 2, t) + assert c2 == c2 + assert c1 != c2 + assert c2 != c1 + +@alltypes() +def test_equality_data(t): + "Equality of data" + c1 = Context.Create(1, 1, t) + c1.PutPixel(0, 0, 1) + c2 = Context.Create(1, 1, t) + c2.PutPixel(0, 0, 1) + assert c1 == c2 + c2.PutPixel(0, 0, 0) + assert c1 != c2 +
http://repo.or.cz/w/gfxprim.git/commit/66288dc8cf7dc3f0e2308a5913820f4981418...
commit 66288dc8cf7dc3f0e2308a5913820f49814181af Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Dec 30 16:37:31 2012 +0100
core: pylib: Context equality
diff --git a/pylib/gfxprim/core/__init__.py b/pylib/gfxprim/core/__init__.py index 27c32e3..1b082f5 100644 --- a/pylib/gfxprim/core/__init__.py +++ b/pylib/gfxprim/core/__init__.py @@ -24,16 +24,22 @@ def _init(module): import re from ..utils import extend, extend_direct, add_swig_getmethod, add_swig_setmethod from ..utils import import_members - _context = module['Context'] + + ### PixelTypeDescription + _ptdescr = c_core.GP_PixelTypeDescription
- # String representation + # String representation of
@extend(_ptdescr, name='__str__') @extend(_ptdescr, name='__repr__') def ptdescr_str(self): return "<PixelTypeDescription %s>" % (self.name, )
+ ### Context + + _context = module['Context'] + # String representation
@extend(_context, name='__str__') @@ -44,6 +50,15 @@ def _init(module): "" if self.thisown else "not ", "with" if self.parent else "no")
+ # Equality + + @extend(_context, name='__eq__') + def ContextEqual(self, other): + "Compare Contexts - pixel types, sizes and data must match (gamma ignored)." + if not isinstance(other, _context): + raise TypeError("Can only compare two Contexts.") + return bool(c_core.GP_ContextEqual(self, other)) + # Creation
def pixeltype_no(pixeltype):
http://repo.or.cz/w/gfxprim.git/commit/3b0b817ad655b1c5a7172d41d971793fafd4e...
commit 3b0b817ad655b1c5a7172d41d971793fafd4e033 Author: Tomas Gavenciak gavento@ucw.cz Date: Sun Dec 30 15:19:41 2012 +0100
core: Added GP_COntextEqual (naive version)
diff --git a/include/core/GP_Context.h b/include/core/GP_Context.h index 9de8572..0977a27 100644 --- a/include/core/GP_Context.h +++ b/include/core/GP_Context.h @@ -252,4 +252,17 @@ static inline GP_Size GP_ContextH(const GP_Context *context) return context->h; }
+/* + * Compare two contexts. Returns true only if all of types, sizes and + * bitmap data match. Takes transformations into account. + * + * For now ignores gamma tables. + * + * Currently rather slow (getpixel). + * TODO: speed up for same rotation and same bit-offset data (per-row memcpy). + */ + +int GP_ContextEqual(const GP_Context *ctx1, const GP_Context *ctx2); + #endif /* CORE_GP_CONTEXT_H */ + diff --git a/libs/core/GP_Context.c b/libs/core/GP_Context.c index 8b66a3b..c749fcc 100644 --- a/libs/core/GP_Context.c +++ b/libs/core/GP_Context.c @@ -345,3 +345,20 @@ void GP_ContextRotateCCW(GP_Context *context)
context->x_swap = 1; } + +int GP_ContextEqual(const GP_Context *ctx1, const GP_Context *ctx2) +{ + if (ctx1->pixel_type != ctx2->pixel_type) return 0; + if (GP_ContextW(ctx1) != GP_ContextW(ctx2)) return 0; + if (GP_ContextH(ctx1) != GP_ContextH(ctx2)) return 0; + + GP_Coord x, y, w = GP_ContextW(ctx1), h = GP_ContextH(ctx1); + + for (x = 0; x < w; x++) + for (y = 0; y < h; y++) + if (GP_GetPixel(ctx1, x, y) != GP_GetPixel(ctx2, x, y)) + return 0; + + return 1; +} +
http://repo.or.cz/w/gfxprim.git/commit/f65e8ed5951cb097f67d212da67b48604c47b...
commit f65e8ed5951cb097f67d212da67b48604c47bd66 Author: Cyril Hrubis metan@ucw.cz Date: Sun Dec 30 12:29:49 2012 +0100
gfx: HLine: Split HLine && cleanup.
This commit splits HLine implementation and remove unused files.
diff --git a/libs/gfx/GP_HLine.c b/libs/gfx/GP_HLine.c new file mode 100644 index 0000000..2255660 --- /dev/null +++ b/libs/gfx/GP_HLine.c @@ -0,0 +1,74 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos * + * jiri.bluebear.dluhos@gmail.com * + * * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#include "core/GP_Transform.h" + +#include "gfx/GP_HLine.h" +#include "gfx/GP_VLine.h" + +void GP_HLineXXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel) +{ + GP_CHECK_CONTEXT(context); + + GP_FN_PER_BPP_CONTEXT(GP_HLine_Raw, context, context, x0, x1, y, + pixel); +} + +void GP_HLineXYW_Raw(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w, + GP_Pixel pixel) +{ + if (w == 0) + return; + + GP_HLineXXY_Raw(context, x, x + w - 1, y, pixel); +} + +void GP_HLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y, + GP_Pixel pixel) +{ + GP_CHECK_CONTEXT(context); + + if (context->axes_swap) { + GP_TRANSFORM_Y(context, x0); + GP_TRANSFORM_Y(context, x1); + GP_TRANSFORM_X(context, y); + GP_VLine_Raw(context, y, x0, x1, pixel); + } else { + GP_TRANSFORM_X(context, x0); + GP_TRANSFORM_X(context, x1); + GP_TRANSFORM_Y(context, y); + GP_HLine_Raw(context, x0, x1, y, pixel); + } +} + +void GP_HLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w, + GP_Pixel pixel) +{ + if (w == 0) + return; + + GP_HLineXXY(context, x, x + w - 1, y, pixel); +} diff --git a/libs/gfx/GP_HLine.gen.c.t b/libs/gfx/GP_HLine.gen.c.t index 8fe9169..5e0a761 100644 --- a/libs/gfx/GP_HLine.gen.c.t +++ b/libs/gfx/GP_HLine.gen.c.t @@ -29,14 +29,9 @@
%% block body
-#include "core/GP_FnPerBpp.h" #include "core/GP_WritePixel.h" -#include "core/GP_Transform.h" - -/* #include "algo/HLine.algo.h" */
#include "gfx/GP_HLine.h" -#include "gfx/GP_VLine.h"
%% for ps in pixelsizes
@@ -48,8 +43,7 @@ void GP_HLine_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int x1, int y, GP_SWAP(x0, x1);
/* return immediately if the line is completely out of surface */ - if (y < 0 || y >= (int) context->h || - x1 < 0 || x0 >= (int) context->w) + if (y < 0 || y >= (int) context->h || x1 < 0 || x0 >= (int) context->w) return;
/* clip the line against surface boundaries */ @@ -68,68 +62,4 @@ void GP_HLine_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int x1, int y, }
%% endfor - -/* Generate drawing functions for various bit depths. */ - -//TODO: BIT ENDIANESS -/* -DEF_HLINE_BU_FN(GP_HLine_Raw_1BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels_1BPP_LE) -DEF_HLINE_BU_FN(GP_HLine_Raw_1BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels1bpp) -DEF_HLINE_BU_FN(GP_HLine_Raw_2BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels_2BPP_LE) -DEF_HLINE_BU_FN(GP_HLine_Raw_2BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp) -DEF_HLINE_BU_FN(GP_HLine_Raw_4BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels_4BPP_LE) -DEF_HLINE_BU_FN(GP_HLine_Raw_4BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels4bpp) -DEF_HLINE_BU_FN(GP_HLine_Raw_18BPP_LE, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels18bpp) - -DEF_HLINE_FN(GP_HLine_Raw_8BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels8bpp) -DEF_HLINE_FN(GP_HLine_Raw_16BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels16bpp) -DEF_HLINE_FN(GP_HLine_Raw_24BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels24bpp) -DEF_HLINE_FN(GP_HLine_Raw_32BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels32bpp) -*/ - -void GP_HLineXXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1, - GP_Coord y, GP_Pixel pixel) -{ - GP_CHECK_CONTEXT(context); - - GP_FN_PER_BPP_CONTEXT(GP_HLine_Raw, context, context, x0, x1, y, - pixel); -} - -void GP_HLineXYW_Raw(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w, - GP_Pixel pixel) -{ - if (w == 0) - return; - - GP_HLineXXY_Raw(context, x, x + w - 1, y, pixel); -} - -void GP_HLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y, - GP_Pixel pixel) -{ - GP_CHECK_CONTEXT(context); - - if (context->axes_swap) { - GP_TRANSFORM_Y(context, x0); - GP_TRANSFORM_Y(context, x1); - GP_TRANSFORM_X(context, y); - GP_VLine_Raw(context, y, x0, x1, pixel); - } else { - GP_TRANSFORM_X(context, x0); - GP_TRANSFORM_X(context, x1); - GP_TRANSFORM_Y(context, y); - GP_HLine_Raw(context, x0, x1, y, pixel); - } -} - -void GP_HLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w, - GP_Pixel pixel) -{ - if (w == 0) - return; - - GP_HLineXXY(context, x, x + w - 1, y, pixel); -} - %% endblock body diff --git a/libs/gfx/algo/HLine.algo.h b/libs/gfx/algo/HLine.algo.h deleted file mode 100644 index 91dd35f..0000000 --- a/libs/gfx/algo/HLine.algo.h +++ /dev/null @@ -1,75 +0,0 @@ -/***************************************************************************** - * This file is part of gfxprim library. * - * * - * Gfxprim is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * Gfxprim is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with gfxprim; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02110-1301 USA * - * * - * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * - * * - *****************************************************************************/ - -/* A horizontal line drawing algorithm. */ - -/* Ensures that coordinates are in correct order, and clips them. - * Exits immediately if the line is completely clipped out. - */ -#define ORDER_AND_CLIP_COORDS do { - if (x0 > x1) - GP_SWAP(x0, x1); - if (y < 0 || y >= (int) context->h || - x1 < 0 || x0 >= (int) context->w) - return; - x0 = GP_MAX(x0, 0); - x1 = GP_MIN(x1, (int) context->w - 1); -} while (0) - -/* - * This macro defines a horizontal line drawing function. - * Arguments: - * CONTEXT_T - user-defined type of drawing context (passed to PUTPIXEL) - * PIXVAL_T - user-defined pixel value type (passed to PUTPIXEL) - * PIXEL_ADDRESS - a function that returns a pointer to a pixel in memory, - * in form f(context, x, y) - * WRITE_PIXELS - a function that fills a linear block with pixel value, - * in form f(start, length, pixel) - * FN_NAME - name of the function to be defined - */ -#define DEF_HLINE_FN(FN_NAME, CONTEXT_T, PIXEL_T, PIXEL_ADDRESS, WRITE_PIXELS) -void FN_NAME(CONTEXT_T context, int x0, int x1, int y, PIXEL_T pixel) -{ - ORDER_AND_CLIP_COORDS; -- size_t length = 1 + x1 - x0; - void *start = PIXEL_ADDRESS(context, x0, y); -- WRITE_PIXELS(start, length, pixel); -} - -/* - * Not byte aligned pixels. The number of bits per pixel must be power of two. - */ -#define DEF_HLINE_BU_FN(FN_NAME, CONTEXT_T, PIXEL_T, PIXEL_ADDRESS, WRITE_PIXELS) -void FN_NAME(CONTEXT_T context, int x0, int x1, int y, PIXEL_T pixel) -{ - ORDER_AND_CLIP_COORDS; -- size_t length = 1 + x1 - x0; - void *start = PIXEL_ADDRESS(context, x0, y); -- WRITE_PIXELS(start, x0 % (8 / context->bpp), length, pixel); -}
http://repo.or.cz/w/gfxprim.git/commit/785fcafc3003d9af67c6d17a1451efc00d354...
commit 785fcafc3003d9af67c6d17a1451efc00d3544d1 Author: Cyril Hrubis metan@ucw.cz Date: Sun Dec 30 11:50:11 2012 +0100
tests: gfx: Add very basic HLine testsuite.
diff --git a/tests/gfx/HLine.c b/tests/gfx/HLine.c new file mode 100644 index 0000000..ddab1c7 --- /dev/null +++ b/tests/gfx/HLine.c @@ -0,0 +1,292 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#include <string.h> +#include <errno.h> + +#include <core/GP_Context.h> +#include <gfx/GP_HLine.h> + +#include "tst_test.h" + +#include "common.h" + +struct testcase { + /* HLine description */ + GP_Coord x0; + GP_Coord x1; + GP_Coord y; + + GP_Coord x; + GP_Size lw; + + int flag; + + /* expected result */ + GP_Size w, h; + const char pixmap[]; +}; + +static int test_hline(struct testcase *t) +{ + GP_Context *c; + int err; + + c = GP_ContextAlloc(t->w, t->h, GP_PIXEL_G8); + + if (c == NULL) { + tst_err("Failed to allocate context"); + return TST_UNTESTED; + } + + /* zero the pixels buffer */ + memset(c->pixels, 0, c->w * c->h); + + if (t->flag) + GP_HLineXYW(c, t->x, t->y, t->lw, 1); + else + GP_HLine(c, t->x0, t->x1, t->y, 1); + + err = compare_buffers(t->pixmap, c); + + if (err) { + tst_msg("Patterns are different"); + return TST_FAILED; + } + + return TST_SUCCESS; +} + +static struct testcase testcase_1_px = { + .x0 = 1, + .x1 = 1, + .y = 1, + + .w = 3, + .h = 3, + .pixmap = { + 0, 0, 0, + 0, 1, 0, + 0, 0, 0, + } +}; + +static struct testcase testcase_3_px_1 = { + .x0 = 1, + .x1 = 3, + .y = 1, + + .w = 5, + .h = 3, + .pixmap = { + 0, 0, 0, 0, 0, + 0, 1, 1, 1, 0, + 0, 0, 0, 0, 0, + } +}; + +static struct testcase testcase_3_px_2 = { + .x0 = 3, + .x1 = 1, + .y = 1, + + .w = 5, + .h = 3, + .pixmap = { + 0, 0, 0, 0, 0, + 0, 1, 1, 1, 0, + 0, 0, 0, 0, 0, + } +}; + +static struct testcase testcase_clipping_1 = { + .x0 = -10000, + .x1 = 10000, + .y = 1, + + .w = 5, + .h = 3, + .pixmap = { + 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, + } +}; + +static struct testcase testcase_clipping_2 = { + .x0 = -10000, + .x1 = 10000, + .y = 4, + + .w = 5, + .h = 3, + .pixmap = { + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + } +}; + +static struct testcase testcase_clipping_3 = { + .x0 = -100000, + .x1 = 100000, + .y = -4, + + .w = 5, + .h = 3, + .pixmap = { + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + } +}; + +static struct testcase testcase_xyw_1 = { + .x = 1, + .y = 1, + .lw = 0, + + .flag = 1, + + .w = 3, + .h = 3, + .pixmap = { + 0, 0, 0, + 0, 1, 0, + 0, 0, 0, + } +}; + +static struct testcase testcase_xyw_2 = { + .x = 1, + .y = 1, + .lw = 1, + + .flag = 1, + + .w = 4, + .h = 3, + .pixmap = { + 0, 0, 0, 0, + 0, 1, 1, 0, + 0, 0, 0, 0, + } +}; + +static struct testcase testcase_xyw_clipp_1 = { + .x = -10000, + .y = 1, + .lw = 20000, + + .flag = 1, + + .w = 3, + .h = 3, + .pixmap = { + 0, 0, 0, + 1, 1, 1, + 0, 0, 0, + } +}; + +static struct testcase testcase_xyw_clipp_2 = { + .x = 1, + .y = 1, + .lw = 200000, + + .flag = 1, + + .w = 3, + .h = 3, + .pixmap = { + 0, 0, 0, + 0, 1, 1, + 0, 0, 0, + } +}; + +static struct testcase testcase_xyw_clipp_3 = { + .x = -10000, + .y = -10000, + .lw = -1, + + .flag = 1, + + .w = 3, + .h = 3, + .pixmap = { + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + } +}; + +const struct tst_suite tst_suite = { + .suite_name = "HLine Testsuite", + .tests = { + {.name = "HLine 1px", + .tst_fn = test_hline, + .data = &testcase_1_px}, + + {.name = "HLine 3px 1", + .tst_fn = test_hline, + .data = &testcase_3_px_1}, + + {.name = "HLine 3px 2", + .tst_fn = test_hline, + .data = &testcase_3_px_2}, + + {.name = "HLine clipping 1", + .tst_fn = test_hline, + .data = &testcase_clipping_1}, + + {.name = "HLine clipping 2", + .tst_fn = test_hline, + .data = &testcase_clipping_2}, + + {.name = "HLine clipping 3", + .tst_fn = test_hline, + .data = &testcase_clipping_3}, + + {.name = "HLineXYW 1", + .tst_fn = test_hline, + .data = &testcase_xyw_1}, + + {.name = "HLineXYW 2", + .tst_fn = test_hline, + .data = &testcase_xyw_2}, + + {.name = "HLineXYW clipping 1", + .tst_fn = test_hline, + .data = &testcase_xyw_clipp_1}, + + {.name = "HLineXYW clipping 2", + .tst_fn = test_hline, + .data = &testcase_xyw_clipp_2}, + + {.name = "HLineXYW clipping 3", + .tst_fn = test_hline, + .data = &testcase_xyw_clipp_3}, + + {.name = NULL} + } +}; diff --git a/tests/gfx/Makefile b/tests/gfx/Makefile index d8090a9..1edbb99 100644 --- a/tests/gfx/Makefile +++ b/tests/gfx/Makefile @@ -3,7 +3,7 @@ include $(TOPDIR)/pre.mk
CSOURCES=$(shell echo *.c)
-APPS=gfx_benchmark Circle FillCircle Line CircleSeg Polygon Ellipse +APPS=gfx_benchmark Circle FillCircle Line CircleSeg Polygon Ellipse HLine
Circle: common.o FillCircle: common.o @@ -11,6 +11,7 @@ Ellipse: common.o Line: common.o CircleSeg: common.o Polygon: common.o +HLine: common.o
include ../tests.mk
diff --git a/tests/gfx/runtest.sh b/tests/gfx/runtest.sh index 2edd6b4..c890920 100755 --- a/tests/gfx/runtest.sh +++ b/tests/gfx/runtest.sh @@ -10,6 +10,7 @@ export LIBC_FATAL_STDERR_=1
#LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./gfx_benchmark "$@" +LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./HLine "$@" LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Line "$@" LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Circle "$@" LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./FillCircle "$@"
http://repo.or.cz/w/gfxprim.git/commit/afe7e710ea1a940e90b80a511ba05b598491b...
commit afe7e710ea1a940e90b80a511ba05b598491b16c Author: Cyril Hrubis metan@ucw.cz Date: Sun Dec 30 11:28:26 2012 +0100
gfx: HLine: Generate HLine per BPP header too.
diff --git a/include/gfx/GP_HLine.gen.h.t b/include/gfx/GP_HLine.gen.h.t new file mode 100644 index 0000000..873f727 --- /dev/null +++ b/include/gfx/GP_HLine.gen.h.t @@ -0,0 +1,35 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +%% extends 'base.h.t' + +{% block description %}HLine generated header{% endblock %} + +{% block body %} + +%% for ps in pixelsizes +void GP_HLine_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord x0, + GP_Coord x1, GP_Coord y, GP_Pixel pixel); + +%% endfor + +{% endblock body %} diff --git a/include/gfx/GP_HLine.h b/include/gfx/GP_HLine.h index 0737f66..50f9a12 100644 --- a/include/gfx/GP_HLine.h +++ b/include/gfx/GP_HLine.h @@ -19,52 +19,19 @@ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
-#ifndef GP_HLINE_H -#define GP_HLINE_H +#ifndef GFX_GP_HLINE_H +#define GFX_GP_HLINE_H
#include "core/GP_Context.h"
/* Raw per BPP HLines */ - -void GP_HLine_Raw_1BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1, - GP_Coord y, GP_Pixel pixel); - -void GP_HLine_Raw_1BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1, - GP_Coord y, GP_Pixel pixel); - -void GP_HLine_Raw_2BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1, - GP_Coord y, GP_Pixel pixel); - -void GP_HLine_Raw_2BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1, - GP_Coord y, GP_Pixel pixel); - -void GP_HLine_Raw_4BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1, - GP_Coord y, GP_Pixel pixel); - -void GP_HLine_Raw_4BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1, - GP_Coord y, GP_Pixel pixel); - -void GP_HLine_Raw_8BPP(GP_Context *context, GP_Coord x0, GP_Coord x1, - GP_Coord y, GP_Pixel pixel); - -void GP_HLine_Raw_18BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1, - GP_Coord y, GP_Pixel pixel); - -void GP_HLine_Raw_16BPP(GP_Context *context, GP_Coord x0, GP_Coord x1, - GP_Coord y, GP_Pixel pixel); - -void GP_HLine_Raw_24BPP(GP_Context *context, GP_Coord x0, GP_Coord x1, - GP_Coord y, GP_Pixel pixel); - -void GP_HLine_Raw_32BPP(GP_Context *context, GP_Coord x0, GP_Coord x1, - GP_Coord y, GP_Pixel pixel); +#include "gfx/GP_HLine.gen.h"
/* Generic HLines */ - void GP_HLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y, GP_Pixel pixel);
@@ -90,4 +57,4 @@ static inline void GP_HLine(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_HLineXXY(context, x0, x1, y, p); }
-#endif /* GP_HLINE_H */ +#endif /* GFX_GP_HLINE_H */ diff --git a/include/gfx/Makefile b/include/gfx/Makefile index 7548d55..894b898 100644 --- a/include/gfx/Makefile +++ b/include/gfx/Makefile @@ -2,7 +2,7 @@ TOPDIR=../..
include $(TOPDIR)/pre.mk
-GENHEADERS=GP_VLine.gen.h +GENHEADERS=GP_VLine.gen.h GP_HLine.gen.h
include $(TOPDIR)/gen.mk include $(TOPDIR)/post.mk
-----------------------------------------------------------------------
Summary of changes: include/core/GP_Context.h | 13 + include/gfx/{GP_VLine.gen.h.t => GP_HLine.gen.h.t} | 6 +- include/gfx/GP_HLine.h | 43 +--- include/gfx/Makefile | 2 +- libs/core/GP_Context.c | 22 ++ libs/gfx/{GP_Arc.c => GP_HLine.c} | 63 +++-- libs/gfx/GP_HLine.gen.c.t | 72 +----- libs/gfx/algo/HLine.algo.h | 75 ----- pylib/gfxprim/core/__init__.py | 19 ++- tests/gfx/HLine.c | 292 ++++++++++++++++++++ tests/gfx/Makefile | 3 +- tests/gfx/runtest.sh | 1 + tests/pylib/test_core.py | 50 +++- 13 files changed, 431 insertions(+), 230 deletions(-) copy include/gfx/{GP_VLine.gen.h.t => GP_HLine.gen.h.t} (91%) copy libs/gfx/{GP_Arc.c => GP_HLine.c} (64%) delete mode 100644 libs/gfx/algo/HLine.algo.h create mode 100644 tests/gfx/HLine.c
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.