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 f80c7c799ea3cc54e9858863dc4a0e8461c6aeb8 (commit) from 8aec3f568b4b7301f82a9ece1344a0aec93dc746 (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/f80c7c799ea3cc54e9858863dc4a0e8461c6a...
commit f80c7c799ea3cc54e9858863dc4a0e8461c6aeb8 Author: Jiri BlueBear Dluhos jiri.bluebear.dluhos@gmail.com Date: Mon Dec 17 17:16:54 2012 +0100
Templatized GP_Line().
diff --git a/include/gfx/GP_VLine.h b/include/gfx/GP_VLine.h index f4c5d1e..a070f53 100644 --- a/include/gfx/GP_VLine.h +++ b/include/gfx/GP_VLine.h @@ -28,6 +28,41 @@
#include "core/GP_Context.h"
+/* Raw per BPP HLines */ + +void GP_VLine_Raw_1BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); + +void GP_VLine_Raw_1BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); + +void GP_VLine_Raw_2BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); + +void GP_VLine_Raw_2BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); + +void GP_VLine_Raw_4BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); + +void GP_VLine_Raw_4BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); + +void GP_VLine_Raw_8BPP(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); + +void GP_VLine_Raw_18BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); + +void GP_VLine_Raw_16BPP(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); + +void GP_VLine_Raw_24BPP(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); + +void GP_VLine_Raw_32BPP(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); + void GP_VLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0, GP_Coord y1, GP_Pixel pixel);
diff --git a/libs/gfx/GP_Line.c b/libs/gfx/GP_Line.c deleted file mode 100644 index 62db8a7..0000000 --- a/libs/gfx/GP_Line.c +++ /dev/null @@ -1,54 +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-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * - * * - *****************************************************************************/ - -#include "core/GP_GetPutPixel.h" -#include "core/GP_FnPerBpp.h" - -#include "gfx/GP_Line.h" - -#include "algo/Line.algo.h" - -/* Generate drawing functions for various bit depths. */ -GP_DEF_DRAW_FN_PER_BPP(GP_Line_Raw, DEF_LINE_FN) - -void GP_Line_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, - GP_Coord x1, GP_Coord y1, GP_Pixel pixel) -{ - GP_CHECK_CONTEXT(context); - - GP_FN_PER_BPP_CONTEXT(GP_Line_Raw, context, context, x0, y0, x1, y1, - pixel); -} - -void GP_Line(GP_Context *context, GP_Coord x0, GP_Coord y0, - GP_Coord x1, GP_Coord y1, GP_Pixel pixel) -{ - GP_CHECK_CONTEXT(context); - - GP_TRANSFORM_POINT(context, x0, y0); - GP_TRANSFORM_POINT(context, x1, y1); - - GP_Line_Raw(context, x0, y0, x1, y1, pixel); -} diff --git a/libs/gfx/GP_Line.gen.c.t b/libs/gfx/GP_Line.gen.c.t new file mode 100644 index 0000000..42b9167 --- /dev/null +++ b/libs/gfx/GP_Line.gen.c.t @@ -0,0 +1,130 @@ +/***************************************************************************** + * 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-2010 Jiri "BlueBear" Dluhos * + * jiri.bluebear.dluhos@gmail.com * + * * + * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +%% extends "base.c.t" + +{% block descr %}Line drawing algorithm{% endblock %} + +%% block body + +#include "core/GP_Common.h" +#include "core/GP_GetPutPixel.h" +#include "core/GP_FnPerBpp.h" + +#include "gfx/GP_VLine.h" +#include "gfx/GP_HLine.h" +#include "gfx/GP_Line.h" + +/* + * The classical Bresenham line drawing algorithm. + * Please see http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm + * for a nice and understandable description. + */ + +%% for ps in pixelsizes + +void GP_Line_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int y0, + int x1, int y1, GP_Pixel pixval) +{ + /* special cases: vertical line, horizontal line, single point */ + if (x0 == x1) { + if (y0 == y1) { + GP_PutPixel_Raw_{{ ps.suffix }}(context, x0, y0, + pixval); + return; + } + GP_VLine_Raw(context, x0, y0, y1, pixval); + return; + } + if (y0 == y1) { + GP_HLine_Raw(context, x0, x1, y0, pixval); + return; + } + + /* + * Which axis is longer? Swap the coordinates if necessary so + * that the X axis is always the longer one and Y is shorter. + */ + int steep = abs(y1 - y0) / abs(x1 - x0); + if (steep) { + GP_SWAP(x0, y0); + GP_SWAP(x1, y1); + } + if (x0 > x1) { + GP_SWAP(x0, x1); + GP_SWAP(y0, y1); + } + + /* iterate over the longer axis, calculate values on the shorter */ + int deltax = x1 - x0; + int deltay = abs(y1 - y0); + + /* + * start with error of 0.5 (multiplied by deltax for integer-only math), + * this reflects the fact that ideally, the coordinate should be + * in the middle of the pixel + */ + int error = deltax / 2; + + int y = y0, x; + int ystep = (y0 < y1) ? 1 : -1; + for (x = x0; x <= x1; x++) { + + if (steep) + GP_PutPixel_Raw_{{ ps.suffix }}(context, y, x, pixval); + else + GP_PutPixel_Raw_{{ ps.suffix }}(context, x, y, pixval); + + error -= deltay; + if (error < 0) { + y += ystep; /* next step on the shorter axis */ + error += deltax; + } + } +} + +%% endfor + +void GP_Line_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel) +{ + GP_CHECK_CONTEXT(context); + + GP_FN_PER_BPP_CONTEXT(GP_Line_Raw, context, context, x0, y0, x1, y1, + pixel); +} + +void GP_Line(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel) +{ + GP_CHECK_CONTEXT(context); + + GP_TRANSFORM_POINT(context, x0, y0); + GP_TRANSFORM_POINT(context, x1, y1); + + GP_Line_Raw(context, x0, y0, x1, y1, pixel); +} + +%% endblock body diff --git a/libs/gfx/Makefile b/libs/gfx/Makefile index 0641888..145827b 100644 --- a/libs/gfx/Makefile +++ b/libs/gfx/Makefile @@ -1,7 +1,7 @@ TOPDIR=../.. CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c)) -GENSOURCES=GP_LineAA.gen.c GP_PutPixelAA.gen.c GP_HLineAA.gen.c - GP_VLineAA.gen.c GP_FillCircle.gen.c +GENSOURCES=GP_Line.gen.c GP_LineAA.gen.c GP_PutPixelAA.gen.c + GP_HLineAA.gen.c GP_VLineAA.gen.c GP_FillCircle.gen.c LIBNAME=gfx
include $(TOPDIR)/pre.mk
-----------------------------------------------------------------------
Summary of changes: include/gfx/GP_VLine.h | 35 ++++++++++++ libs/gfx/GP_Line.c | 54 ------------------- libs/gfx/GP_Line.gen.c.t | 130 ++++++++++++++++++++++++++++++++++++++++++++++ libs/gfx/Makefile | 4 +- 4 files changed, 167 insertions(+), 56 deletions(-) delete mode 100644 libs/gfx/GP_Line.c create mode 100644 libs/gfx/GP_Line.gen.c.t
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.