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 b9b02ed950aa9b8c45aa065ef1e5175b6e7ea2e8 (commit)
via 76e72cf5507bca2ec0e6da9aff3b82a566543f89 (commit)
from 23a61ce77d10e1f69552bca123878f3c7602d363 (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/b9b02ed950aa9b8c45aa065ef1e5175b6e7e…
commit b9b02ed950aa9b8c45aa065ef1e5175b6e7ea2e8
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Dec 9 14:26:06 2012 +0100
gfx: Fix second special case of GP_Line().
diff --git a/libs/gfx/algo/Line.algo.h b/libs/gfx/algo/Line.algo.h
index c6ca4f8..a69d053 100644
--- a/libs/gfx/algo/Line.algo.h
+++ b/libs/gfx/algo/Line.algo.h
@@ -46,12 +46,11 @@ void FN_NAME(CONTEXT_T context, int x0, int y0, int x1, int y1, PUTPIXEL(context, x0, y0, pixval); return; } - int y = y0; - while (y != y1) { + if (y0 > y1) + GP_SWAP(y0, y1); + int y; + for (y = y0; y <= y1; y++) PUTPIXEL(context, x0, y, pixval); - if (y0 > y1) y--; - else y++; - } return; }
http://repo.or.cz/w/gfxprim.git/commit/76e72cf5507bca2ec0e6da9aff3b82a56654…
commit 76e72cf5507bca2ec0e6da9aff3b82a566543f89
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Dec 9 14:23:08 2012 +0100
gfx: Fix one special case for GP_Line().
diff --git a/libs/gfx/algo/Line.algo.h b/libs/gfx/algo/Line.algo.h
index afc37dc..c6ca4f8 100644
--- a/libs/gfx/algo/Line.algo.h
+++ b/libs/gfx/algo/Line.algo.h
@@ -42,6 +42,10 @@ void FN_NAME(CONTEXT_T context, int x0, int y0, int x1, int y1, PIXVAL_T pixval) { if (x0 == x1) { + if (y0 == y1) { + PUTPIXEL(context, x0, y0, pixval); + return; + } int y = y0; while (y != y1) { PUTPIXEL(context, x0, y, pixval);
-----------------------------------------------------------------------
Summary of changes:
libs/gfx/algo/Line.algo.h | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 ce13a7e7695f7264c8fe0047a912bcc1b9cf5126 (commit)
from 6c3a610f5c62bbcfbdabd7a538d97bc455fae1b4 (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/ce13a7e7695f7264c8fe0047a912bcc1b9cf…
commit ce13a7e7695f7264c8fe0047a912bcc1b9cf5126
Author: Jiri BlueBear Dluhos <jiri.bluebear.dluhos(a)gmail.com>
Date: Sat Dec 8 22:49:44 2012 +0100
Templatized GP_FillCircle.
diff --git a/libs/gfx/GP_Circle.c b/libs/gfx/GP_Circle.c
index 66e63c5..d8973e4 100644
--- a/libs/gfx/GP_Circle.c
+++ b/libs/gfx/GP_Circle.c
@@ -53,29 +53,10 @@ void GP_Circle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Circle_Raw(context, xcenter, ycenter, r, pixel);
}
-#include "algo/FillCircle.algo.h"
+/* #include "algo/FillCircle.algo.h" */
/* Generate drawing functions for various bit depths. */
-GP_DEF_FILL_FN_PER_BPP(GP_FillCircle_Raw, DEF_FILLCIRCLE_FN)
-
-void GP_FillCircle_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size r, GP_Pixel pixel)
-{
- GP_CHECK_CONTEXT(context);
-
- GP_FN_PER_BPP_CONTEXT(GP_FillCircle_Raw, context, context,
- xcenter, ycenter, r, pixel);
-}
-
-void GP_FillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size r, GP_Pixel pixel)
-{
- GP_CHECK_CONTEXT(context);
-
- GP_TRANSFORM_POINT(context, xcenter, ycenter);
-
- GP_FillCircle_Raw(context, xcenter, ycenter, r, pixel);
-}
+//GP_DEF_FILL_FN_PER_BPP(GP_FillCircle_Raw, DEF_FILLCIRCLE_FN)
void GP_Ring_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size r1, GP_Size r2, GP_Pixel pixel)
diff --git a/libs/gfx/GP_FillCircle.gen.c.t b/libs/gfx/GP_FillCircle.gen.c.t
new file mode 100644
index 0000000..db72768
--- /dev/null
+++ b/libs/gfx/GP_FillCircle.gen.c.t
@@ -0,0 +1,66 @@
+%% extends "base.c.t"
+
+{% block descr %}Circle filling algorithm{% endblock %}
+
+%% block body
+
+#include "core/GP_GetPutPixel.h"
+#include "core/GP_FnPerBpp.h"
+#include "gfx/GP_Circle.h"
+#include "gfx/GP_HLine.h"
+
+/*
+ * A filled circle drawing algorithm.
+ *
+ * A filled circle is drawn in the same way as an unfilled one,
+ * in a top-down, line per line manner, except that we don't need to draw
+ * four points in each X step. Instead, we just iterate X
+ * until we accumulate enough Y changes to reach the next line,
+ * and then draw the full line. The top and bottom half are mirrored.
+ */
+
+%% for ps in pixelsizes
+
+void GP_FillCircle_Raw_{{ ps.suffix }}(GP_Context *context,
+ GP_Coord xcenter, GP_Coord ycenter, GP_Size r, GP_Pixel pixel)
+{
+ /* for r == 0, circle degenerates to a point */
+ if (r == 0) {
+ GP_PutPixel_Raw_{{ ps.suffix }}(context, xcenter, ycenter, pixel);
+ return;
+ }
+
+ int x, y, error;
+ for (x = 0, error = -r, y = r; y >= 0; y--) {
+ while (error < 0) {
+ error += 2*x + 1;
+ x++;
+ }
+ error += -2*y + 1;
+ GP_HLine_Raw_{{ ps.suffix }}(context, xcenter-x+1, xcenter+x-1, ycenter-y, pixel);
+ GP_HLine_Raw_{{ ps.suffix }}(context, xcenter-x+1, xcenter+x-1, ycenter+y, pixel);
+ }
+}
+
+%% endfor
+
+void GP_FillCircle_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_FN_PER_BPP_CONTEXT(GP_FillCircle_Raw, context, context,
+ xcenter, ycenter, r, pixel);
+}
+
+void GP_FillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_TRANSFORM_POINT(context, xcenter, ycenter);
+
+ GP_FillCircle_Raw(context, xcenter, ycenter, r, pixel);
+}
+
+%% endblock body
diff --git a/libs/gfx/Makefile b/libs/gfx/Makefile
index dae754e..0641888 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_VLineAA.gen.c GP_FillCircle.gen.c
LIBNAME=gfx
include $(TOPDIR)/pre.mk
diff --git a/libs/gfx/algo/FillCircle.algo.h b/libs/gfx/algo/FillCircle.algo.h
deleted file mode 100644
index b3eeb6b..0000000
--- a/libs/gfx/algo/FillCircle.algo.h
+++ /dev/null
@@ -1,64 +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(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-/*
- * A filled circle drawing algorithm.
- *
- * A filled circle is drawn in the same way as an unfilled one,
- * in a top-down, line per line manner, except that we don't need to draw
- * four points in each X step. Instead, we just iterate X
- * until we accumulate enough Y changes to reach the next line,
- * and then draw the full line.
- */
-
-/*
- * This macro defines a filled circle drawing function.
- * Arguments:
- * CONTEXT_T - user-defined type of drawing context (passed to HLINE)
- * PIXVAL_T - user-defined pixel value type (passed to HLINE)
- * HLINE - horizontal line drawing function f(context, x0, x1, y, pixval)
- * FN_NAME - name of the function to be defined
- */
-#define DEF_FILLCIRCLE_FN(FN_NAME, CONTEXT_T, PIXVAL_T, HLINE) -void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, - unsigned int r, PIXVAL_T pixval) -{ - /* for r == 0, circle degenerates to a point */ - if (r == 0) { - HLINE(context, xcenter, xcenter, ycenter, pixval); - return; - } -- int x, y, error; - for (x = 0, error = -r, y = r; y >= 0; y--) { - while (error < 0) { - error += 2*x + 1; - x++; - } - error += -2*y + 1; - HLINE(context, xcenter-x+1, xcenter+x-1, ycenter-y, pixval); - HLINE(context, xcenter-x+1, xcenter+x-1, ycenter+y, pixval); - } -}
-----------------------------------------------------------------------
Summary of changes:
libs/gfx/GP_Circle.c | 23 +------------
libs/gfx/GP_FillCircle.gen.c.t | 66 +++++++++++++++++++++++++++++++++++++++
libs/gfx/Makefile | 2 +-
libs/gfx/algo/FillCircle.algo.h | 64 -------------------------------------
4 files changed, 69 insertions(+), 86 deletions(-)
create mode 100644 libs/gfx/GP_FillCircle.gen.c.t
delete mode 100644 libs/gfx/algo/FillCircle.algo.h
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 6c3a610f5c62bbcfbdabd7a538d97bc455fae1b4 (commit)
via bcd7731a0e0dec5884309cf6b920f8df0b3a3ca3 (commit)
from 14c24da39e8d293f98aae1e4ba72be6c4069417f (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/6c3a610f5c62bbcfbdabd7a538d97bc455fa…
commit 6c3a610f5c62bbcfbdabd7a538d97bc455fae1b4
Merge: bcd7731 14c24da
Author: Jiri BlueBear Dluhos <jiri.bluebear.dluhos(a)gmail.com>
Date: Sat Dec 8 21:36:54 2012 +0100
Merge branch 'master' of ssh://repo.or.cz/srv/git/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/bcd7731a0e0dec5884309cf6b920f8df0b3a…
commit bcd7731a0e0dec5884309cf6b920f8df0b3a3ca3
Author: Jiri BlueBear Dluhos <jiri.bluebear.dluhos(a)gmail.com>
Date: Sat Dec 8 21:36:34 2012 +0100
Added a special case for circle with r == 0.
diff --git a/libs/gfx/algo/FillCircle.algo.h b/libs/gfx/algo/FillCircle.algo.h
index c6a48d0..b3eeb6b 100644
--- a/libs/gfx/algo/FillCircle.algo.h
+++ b/libs/gfx/algo/FillCircle.algo.h
@@ -45,6 +45,12 @@
void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, unsigned int r, PIXVAL_T pixval) { + /* for r == 0, circle degenerates to a point */ + if (r == 0) { + HLINE(context, xcenter, xcenter, ycenter, pixval); + return; + } + int x, y, error; for (x = 0, error = -r, y = r; y >= 0; y--) { while (error < 0) {
-----------------------------------------------------------------------
Summary of changes:
libs/gfx/algo/FillCircle.algo.h | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 14c24da39e8d293f98aae1e4ba72be6c4069417f (commit)
from 8a0c954a8e79f88f06cfc99f7a29d3a1558b21d6 (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/14c24da39e8d293f98aae1e4ba72be6c4069…
commit 14c24da39e8d293f98aae1e4ba72be6c4069417f
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Dec 8 20:44:30 2012 +0100
core: GP_Common.h: Remove the C++ part.
The C++ implementation of common gfxprim
macros is not needed at all because these
problems have different solutions in C++.
Hide them only, which is sufficient for
using GP.h from C++ code.
diff --git a/include/core/GP_Common.h b/include/core/GP_Common.h
index ee5907c..a1e8d14 100644
--- a/include/core/GP_Common.h
+++ b/include/core/GP_Common.h
@@ -16,10 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2012 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -31,33 +31,7 @@
#include <stdlib.h>
#include <unistd.h>
-#ifdef __cplusplus
-
-/*-------------------------------------------------------------------------*/
-/* C++-specific code */
-/*-------------------------------------------------------------------------*/
-
-#include <algorithm>
-#include <cmath>
-
-/* use STL algorithms when we already have them */
-#define GP_MIN(a, b) std::min(a, b)
-#define GP_MAX(a, b) std::max(a, b)
-#define GP_SWAP(a, b) std::swap(a, b)
-#define GP_ABS(a) std::abs(a)
-
-/* C++ uses templates instead of typeof */
-template <typename t>
-int GP_SIGN(t x)
-{
- return (x > 0) ? 1 : ((x < 0) ? -1 : 0);
-}
-
-#else /* __cplusplus */
-
-/*-------------------------------------------------------------------------*/
-/* plain C-specific code */
-/*-------------------------------------------------------------------------*/
+#ifndef __cplusplus
/*
* Returns a minimum of the two numbers.
@@ -102,10 +76,6 @@ int GP_SIGN(t x)
(_a > 0) ? 1 : ((_a < 0) ? -1 : 0); })
-/*-------------------------------------------------------------------------*/
-/* end of C/C++-specific code */
-/*-------------------------------------------------------------------------*/
-
#endif /* __cplusplus */
/*
@@ -194,4 +164,4 @@ void SWIG_exception(const char *msg);
#define GP_CHECK(check_cond_, ...) GP_GENERAL_CHECK(check_cond_, "check failed: ", ##__VA_ARGS__);
-#endif /* CORE_GP_COMMON_H */
No newline at end of file
+#endif /* CORE_GP_COMMON_H */
-----------------------------------------------------------------------
Summary of changes:
include/core/GP_Common.h | 38 ++++----------------------------------
1 files changed, 4 insertions(+), 34 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 b77f76c2f45a7e07893d88d7edf9016d35411f95 (commit)
from 9e3d0f91aabd4b32abf770506e345424e39c4469 (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/b77f76c2f45a7e07893d88d7edf9016d3541…
commit b77f76c2f45a7e07893d88d7edf9016d35411f95
Author: Jiri BlueBear Dluhos <jiri.bluebear.dluhos(a)gmail.com>
Date: Sat Dec 8 15:47:22 2012 +0100
Suspicion of odd # of intersections; added assert.
diff --git a/libs/gfx/GP_Polygon.c b/libs/gfx/GP_Polygon.c
index fb4b03f..0901922 100644
--- a/libs/gfx/GP_Polygon.c
+++ b/libs/gfx/GP_Polygon.c
@@ -156,6 +156,9 @@ void GP_FillPolygon_Raw(GP_Context *context, unsigned int vertex_count,
int y;
for (y = (int) ymin; y <= (int) ymax; y++) {
int inter_count = GP_ComputeScanline(intersections, edges, vertex_count, y + 0.5f);
+
+ GP_ASSERT(inter_count % 2 == 0, "odd number of intersections!");
+
for (i = 0; i < inter_count; i+=2) {
GP_HLine_Raw(context, intersections[i], intersections[i + 1], y, pixel);
}
-----------------------------------------------------------------------
Summary of changes:
libs/gfx/GP_Polygon.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 9e3d0f91aabd4b32abf770506e345424e39c4469 (commit)
from f0c59afbe88bcd7157b727e6cc49f092730e5ab1 (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/9e3d0f91aabd4b32abf770506e345424e39c…
commit 9e3d0f91aabd4b32abf770506e345424e39c4469
Author: Jiri BlueBear Dluhos <jiri.bluebear.dluhos(a)gmail.com>
Date: Sat Dec 8 15:46:42 2012 +0100
Fixed a simple typo.
diff --git a/include/core/GP_Common.h b/include/core/GP_Common.h
index fff976e..ee5907c 100644
--- a/include/core/GP_Common.h
+++ b/include/core/GP_Common.h
@@ -181,7 +181,7 @@ void SWIG_exception(const char *msg);
* constants.
*/
#define GP_ASSERT(check_cond_, ...) - GP_GENERAL_CHECK(check_cond_, "asserion failed: ", ##__VA_ARGS__);
+ GP_GENERAL_CHECK(check_cond_, "assertion failed: ", ##__VA_ARGS__);
/*
* Perform a runtime check, on failure abort and print a message.
-----------------------------------------------------------------------
Summary of changes:
include/core/GP_Common.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 f0c59afbe88bcd7157b727e6cc49f092730e5ab1 (commit)
from 157e3c09faf8bc7f46b27c231e2fba9f4e409ff8 (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/f0c59afbe88bcd7157b727e6cc49f092730e…
commit f0c59afbe88bcd7157b727e6cc49f092730e5ab1
Author: Jiri BlueBear Dluhos <jiri.bluebear.dluhos(a)gmail.com>
Date: Sat Dec 8 13:57:46 2012 +0100
Made GP_Common.h compilable under C++
diff --git a/include/core/GP_Common.h b/include/core/GP_Common.h
index 9adc7de..fff976e 100644
--- a/include/core/GP_Common.h
+++ b/include/core/GP_Common.h
@@ -31,6 +31,34 @@
#include <stdlib.h>
#include <unistd.h>
+#ifdef __cplusplus
+
+/*-------------------------------------------------------------------------*/
+/* C++-specific code */
+/*-------------------------------------------------------------------------*/
+
+#include <algorithm>
+#include <cmath>
+
+/* use STL algorithms when we already have them */
+#define GP_MIN(a, b) std::min(a, b)
+#define GP_MAX(a, b) std::max(a, b)
+#define GP_SWAP(a, b) std::swap(a, b)
+#define GP_ABS(a) std::abs(a)
+
+/* C++ uses templates instead of typeof */
+template <typename t>
+int GP_SIGN(t x)
+{
+ return (x > 0) ? 1 : ((x < 0) ? -1 : 0);
+}
+
+#else /* __cplusplus */
+
+/*-------------------------------------------------------------------------*/
+/* plain C-specific code */
+/*-------------------------------------------------------------------------*/
+
/*
* Returns a minimum of the two numbers.
*/
@@ -58,6 +86,29 @@
})
/*
+ * Swap a and b using an intermediate variable
+ */
+#define GP_SWAP(a, b) do { + typeof(a) tmp = b; + b = a; + a = tmp; +} while (0)
+
+/* Determines the sign of the integer value; it is +1 if value is positive,
+ * -1 if negative, and 0 if it is zero.
+ */
+#define GP_SIGN(a) ({ + typeof(a) _a = a; + (_a > 0) ? 1 : ((_a < 0) ? -1 : 0); +})
+
+/*-------------------------------------------------------------------------*/
+/* end of C/C++-specific code */
+/*-------------------------------------------------------------------------*/
+
+#endif /* __cplusplus */
+
+/*
* The standard likely() and unlikely() used in Kernel
*/
#ifndef likely
@@ -75,7 +126,7 @@
/*
* Internal macros with common code for GP_ABORT, GP_ASSERT and GP_CHECK.
* GP_INTERNAL_ABORT takes a message that may contain % (e.g. assert condition)
- * and prints message and calls abort().
+ * and prints message and calls abort().
* GP_GENERAL_CHECK is a check with specified message prefix
* (for assert and check)
*
@@ -125,8 +176,8 @@ void SWIG_exception(const char *msg);
* printing the condition and location in the source.
* (Intended for checking for bugs within the library itself.)
*
- * Use as either GP_ASSERT(cond), GP_ASSERT(cond, msg) or
- * GP_ASSERT(cond, format, params...) where msg and format must be string
+ * Use as either GP_ASSERT(cond), GP_ASSERT(cond, msg) or
+ * GP_ASSERT(cond, format, params...) where msg and format must be string
* constants.
*/
#define GP_ASSERT(check_cond_, ...) @@ -136,29 +187,11 @@ void SWIG_exception(const char *msg);
* Perform a runtime check, on failure abort and print a message.
* (Intended for user-caused errors like invalid arguments.)
*
- * Use as either GP_CHECK(cond), GP_CHECK(cond, msg) or
- * GP_CHECK(cond, format, params...) where msg and format must be string
+ * Use as either GP_CHECK(cond), GP_CHECK(cond, msg) or
+ * GP_CHECK(cond, format, params...) where msg and format must be string
* constants.
*/
#define GP_CHECK(check_cond_, ...) GP_GENERAL_CHECK(check_cond_, "check failed: ", ##__VA_ARGS__);
-/*
- * Swap a and b using an intermediate variable
- */
-#define GP_SWAP(a, b) do { - typeof(a) tmp = b; - b = a; - a = tmp; -} while (0)
-
-
-/* Determines the sign of the integer value; it is +1 if value is positive,
- * -1 if negative, and 0 if it is zero.
- */
-#define GP_SIGN(a) ({ - typeof(a) _a = a; - (_a > 0) ? 1 : ((_a < 0) ? -1 : 0); -})
-
-#endif /* CORE_GP_COMMON_H */
+#endif /* CORE_GP_COMMON_H */
No newline at end of file
-----------------------------------------------------------------------
Summary of changes:
include/core/GP_Common.h | 81 ++++++++++++++++++++++++++++++++-------------
1 files changed, 57 insertions(+), 24 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 157e3c09faf8bc7f46b27c231e2fba9f4e409ff8 (commit)
via bcfc8e661f36485e4a0bd0ffbabc7eb54a6acb47 (commit)
from 725b6c106fdb6f78b7eb3dfef2192182b30233ff (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/157e3c09faf8bc7f46b27c231e2fba9f4e40…
commit 157e3c09faf8bc7f46b27c231e2fba9f4e409ff8
Merge: bcfc8e6 725b6c1
Author: Jiri BlueBear Dluhos <jiri.bluebear.dluhos(a)gmail.com>
Date: Fri Dec 7 23:00:37 2012 +0100
Merge branch 'master' of ssh://repo.or.cz/srv/git/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/bcfc8e661f36485e4a0bd0ffbabc7eb54a6a…
commit bcfc8e661f36485e4a0bd0ffbabc7eb54a6acb47
Author: Jiri BlueBear Dluhos <jiri.bluebear.dluhos(a)gmail.com>
Date: Fri Dec 7 22:58:26 2012 +0100
Fixed (maybe) off-by-half error in polygon vertices.
diff --git a/libs/gfx/GP_Polygon.c b/libs/gfx/GP_Polygon.c
index ed75a27..fb4b03f 100644
--- a/libs/gfx/GP_Polygon.c
+++ b/libs/gfx/GP_Polygon.c
@@ -128,22 +128,33 @@ void GP_FillPolygon_Raw(GP_Context *context, unsigned int vertex_count,
struct GP_PolygonEdge *edge;
struct GP_PolygonEdge edges[vertex_count];
+
+ /* Build edge structures for each vertex-vertex connection.
+ * NOTE: Each vertex is in fact in the middle of the pixel, so
+ * add 0.5 to both coordinates.
+ */
int i;
for (i = 0; i < (int)vertex_count - 1; i++) {
edge = edges + i;
- GP_InitEdge(edge, xy[2*i], xy[2*i + 1],
- xy[2*i + 2], xy[2*i + 3]);
+ GP_InitEdge(edge,
+ 0.5f + xy[2*i], 0.5f + xy[2*i + 1],
+ 0.5f + xy[2*i + 2], 0.5f + xy[2*i + 3]);
ymin = fminf(ymin, edge->ymin);
ymax = fmaxf(ymax, edge->ymax);
}
/* the last edge (from the last point to the first one) */
edge = edges + vertex_count - 1;
- GP_InitEdge(edge, xy[2*i], xy[2*i + 1], xy[0], xy[1]);
+ GP_InitEdge(edge,
+ 0.5f + xy[2*i], 0.5f + xy[2*i + 1],
+ 0.5f + xy[0], 0.5f + xy[1]);
+ /* For each scanline, compute intersections with all edges
+ * and draw a horizontal line segment between the intersections.
+ */
float intersections[vertex_count];
int y;
- for (y = (int) ymin; y < (int) ymax; y++) {
+ for (y = (int) ymin; y <= (int) ymax; y++) {
int inter_count = GP_ComputeScanline(intersections, edges, vertex_count, y + 0.5f);
for (i = 0; i < inter_count; i+=2) {
GP_HLine_Raw(context, intersections[i], intersections[i + 1], y, pixel);
@@ -176,10 +187,10 @@ void GP_Polygon_Raw(GP_Context *context, unsigned int vertex_count,
GP_Coord prev_x = xy[2 * vertex_count - 2];
GP_Coord prev_y = xy[2 * vertex_count - 1];
-
+
for (i = 0; i < vertex_count; i++) {
GP_Coord x = xy[2 * i];
- GP_Coord y = xy[2 * i + 1];
+ GP_Coord y = xy[2 * i + 1];
GP_Line_Raw(context, prev_x, prev_y, x, y, pixel);
@@ -196,12 +207,12 @@ void GP_Polygon(GP_Context *context, unsigned int vertex_count,
GP_Coord prev_x = xy[2 * vertex_count - 2];
GP_Coord prev_y = xy[2 * vertex_count - 1];
-
+
GP_TRANSFORM_POINT(context, prev_x, prev_y);
for (i = 0; i < vertex_count; i++) {
GP_Coord x = xy[2 * i];
- GP_Coord y = xy[2 * i + 1];
+ GP_Coord y = xy[2 * i + 1];
GP_TRANSFORM_POINT(context, x, y);
-----------------------------------------------------------------------
Summary of changes:
libs/gfx/GP_Polygon.c | 27 +++++++++++++++++++--------
1 files changed, 19 insertions(+), 8 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")