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 5f214b37219110e2e9051b3bfffbbd65498002b7 (commit)
from 910d31f9711c5e518189c5e5f47761125ef06207 (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/5f214b37219110e2e9051b3bfffbbd654980…
commit 5f214b37219110e2e9051b3bfffbbd65498002b7
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Tue Dec 18 14:33:22 2012 +0100
Grammar fix
diff --git a/doc/input.txt b/doc/input.txt
index 44da370..6a85ebf 100644
--- a/doc/input.txt
+++ b/doc/input.txt
@@ -38,7 +38,7 @@ typedef struct GP_Event {
struct timeval time;
/*
- * Cursor possition, possition on screen accumulated
+ * Cursor position, possition on screen accumulated
* from all pointer devices
*/
uint32_t cursor_x;
diff --git a/include/input/GP_Event.h b/include/input/GP_Event.h
index de5d93e..162a5d2 100644
--- a/include/input/GP_Event.h
+++ b/include/input/GP_Event.h
@@ -271,7 +271,7 @@ typedef struct GP_Event {
struct timeval time;
/*
- * Cursor possition, possition on screen accumulated
+ * Cursor position, position on screen accumulated
* from all pointer devices
*/
uint32_t cursor_x;
@@ -290,7 +290,7 @@ typedef struct GP_Event {
void GP_EventSetScreenSize(uint32_t w, uint32_t h);
/*
- * Sets global cursor possition, doesn't generate event.
+ * Sets global cursor position, doesn't generate an event.
*
* Use for initial cursor placement.
*/
diff --git a/include/loaders/GP_JPG.h b/include/loaders/GP_JPG.h
index 5906b11..5ee57ce 100644
--- a/include/loaders/GP_JPG.h
+++ b/include/loaders/GP_JPG.h
@@ -40,7 +40,7 @@
int GP_OpenJPG(const char *src_path, FILE **f);
/*
- * Reads JPG from an open FILE. Expects the file possition set after the eight
+ * Reads JPG from an open FILE. Expects the file position set after the eight
* bytes JPG signature.
*/
GP_Context *GP_ReadJPG(FILE *f, GP_ProgressCallback *callback);
diff --git a/include/loaders/GP_PNG.h b/include/loaders/GP_PNG.h
index 4b6e3bb..cbb4b70 100644
--- a/include/loaders/GP_PNG.h
+++ b/include/loaders/GP_PNG.h
@@ -47,13 +47,13 @@
/*
* Opens up file and checks signature. Upon successful return (zero is
- * returned) the file possition would be set to eight bytes (exactly after the
+ * returned) the file position would be set to eight bytes (exactly after the
* PNG signature).
*/
int GP_OpenPNG(const char *src_path, FILE **f);
/*
- * Reads PNG from an open FILE. Expects the file possition set after the eight
+ * Reads PNG from an open FILE. Expects the file position set after the eight
* bytes PNG signature.
*
* Upon succesfull return pointer to newly allocated context is returned.
diff --git a/libs/input/GP_Event.c b/libs/input/GP_Event.c
index cb66c4f..efd82c9 100644
--- a/libs/input/GP_Event.c
+++ b/libs/input/GP_Event.c
@@ -29,7 +29,7 @@
#include "GP_Event.h"
-/* Screen size for clipping the cursor possition */
+/* Screen size for clipping the cursor position */
static uint32_t screen_w = 0, screen_h = 0;
/* Event queue */
diff --git a/libs/loaders/GP_PNM.h b/libs/loaders/GP_PNM.h
index af59319..2ce48a3 100644
--- a/libs/loaders/GP_PNM.h
+++ b/libs/loaders/GP_PNM.h
@@ -32,7 +32,7 @@
#include <stdint.h>
/*
- * Loads image header, returns pointer to FILE* (with file possition pointing
+ * Loads image header, returns pointer to FILE* (with file position pointing
* to the start of the data stream) on success, fills image metadata into
* arguments.
*/
-----------------------------------------------------------------------
Summary of changes:
doc/input.txt | 2 +-
include/input/GP_Event.h | 4 ++--
include/loaders/GP_JPG.h | 2 +-
include/loaders/GP_PNG.h | 4 ++--
libs/input/GP_Event.c | 2 +-
libs/loaders/GP_PNM.h | 2 +-
6 files changed, 8 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.")
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 23a690342a49f0f96aad7ce26eb0d7290349d4f3 (commit)
from f80c7c799ea3cc54e9858863dc4a0e8461c6aeb8 (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/23a690342a49f0f96aad7ce26eb0d7290349…
commit 23a690342a49f0f96aad7ce26eb0d7290349d4f3
Author: Jiri BlueBear Dluhos <jiri.bluebear.dluhos(a)gmail.com>
Date: Mon Dec 17 23:53:04 2012 +0100
Use clipped putpixel in line drawing for now (slower but does not crash).
diff --git a/libs/gfx/GP_Line.gen.c.t b/libs/gfx/GP_Line.gen.c.t
index 42b9167..edc5382 100644
--- a/libs/gfx/GP_Line.gen.c.t
+++ b/libs/gfx/GP_Line.gen.c.t
@@ -51,8 +51,8 @@ void GP_Line_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int y0,
/* special cases: vertical line, horizontal line, single point */
if (x0 == x1) {
if (y0 == y1) {
- GP_PutPixel_Raw_{{ ps.suffix }}(context, x0, y0,
- pixval);
+ GP_PutPixel_Raw_Clipped_{{ ps.suffix }}(context,
+ x0, y0, pixval);
return;
}
GP_VLine_Raw(context, x0, y0, y1, pixval);
@@ -93,9 +93,11 @@ void GP_Line_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int y0,
for (x = x0; x <= x1; x++) {
if (steep)
- GP_PutPixel_Raw_{{ ps.suffix }}(context, y, x, pixval);
+ GP_PutPixel_Raw_Clipped_{{ ps.suffix }}(context, y, x,
+ pixval);
else
- GP_PutPixel_Raw_{{ ps.suffix }}(context, x, y, pixval);
+ GP_PutPixel_Raw_Clipped_{{ ps.suffix }}(context, x, y,
+ pixval);
error -= deltay;
if (error < 0) {
-----------------------------------------------------------------------
Summary of changes:
libs/gfx/GP_Line.gen.c.t | 10 ++++++----
1 files changed, 6 insertions(+), 4 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 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/f80c7c799ea3cc54e9858863dc4a0e8461c6…
commit f80c7c799ea3cc54e9858863dc4a0e8461c6aeb8
Author: Jiri BlueBear Dluhos <jiri.bluebear.dluhos(a)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(a)gmail.com> *
- * *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)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(a)gmail.com> *
+ * *
+ * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)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(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 8aec3f568b4b7301f82a9ece1344a0aec93dc746 (commit)
from 13f50596531c7c69961d1625a6be2550c3565634 (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/8aec3f568b4b7301f82a9ece1344a0aec93d…
commit 8aec3f568b4b7301f82a9ece1344a0aec93dc746
Author: Jiri BlueBear Dluhos <jiri.bluebear.dluhos(a)gmail.com>
Date: Mon Dec 17 02:25:58 2012 +0100
Finally understood how to handle horizontal lines.
diff --git a/libs/gfx/GP_Polygon.c b/libs/gfx/GP_Polygon.c
index 4bd0297..e76babe 100644
--- a/libs/gfx/GP_Polygon.c
+++ b/libs/gfx/GP_Polygon.c
@@ -41,20 +41,20 @@ typedef struct {
} GP_Point;
/* "almost equality" for float coordinates */
-#define GP_COORDS_ALMOST_EQUAL(a,b) (fabsf(a-b) < 0.00001f)
+#define GP_COORDS_ALMOST_EQUAL(a,b) (fabsf((a)-(b)) < 0.0001f)
/*
* Edge state. Every edge proceeds from READY to ACTIVE and then FINISHED.
- * Numeric values reflect sorting priority (ACTIVE < READY < FINISHED).
+ * HORIZONTAL is special (horizontal edges are handled separately).
+ * Numeric values reflect sorting priority (ACTIVE is foremost).
*/
+#define EDGE_HORIZONTAL 3
#define EDGE_FINISHED 2
#define EDGE_READY 1
#define EDGE_ACTIVE 0
/* Working record about an edge. */
struct GP_Edge {
- GP_Point start; /* starting point as specified by user */
- GP_Point end; /* ending point as specified by user */
int state; /* edge state */
float x; /* X coordinate of the working point */
int y; /* Y coordinate of the working point */
@@ -65,8 +65,15 @@ struct GP_Edge {
/* Initializes the edge structure. */
static void GP_InitEdge(struct GP_Edge *e, GP_Point start, GP_Point end)
{
- e->start = start;
- e->end = end;
+ /* horizontal edges are a special case */
+ if (start.y == end.y) {
+ e->dy = 0;
+ e->x = start.x;
+ e->y = start.y;
+ e->dxy = end.x - start.x;
+ e->state = EDGE_HORIZONTAL;
+ return;
+ }
/* initialize the working point to the top point of the edge */
if (start.y < end.y) {
@@ -77,17 +84,17 @@ static void GP_InitEdge(struct GP_Edge *e, GP_Point start, GP_Point end)
e->y = end.y;
}
- e->dy = GP_ABS(end.y - start.y) - 1;
+ e->dy = GP_ABS(end.y - start.y);
- if (e->dy < 0) {
+ e->dxy = (float)(end.x - start.x)/(end.y - start.y);
+ e->state = EDGE_READY;
- /* horizontal edge */
- e->dxy = (start.x < end.x) ? INFINITY : -INFINITY;
- e->state = EDGE_FINISHED; /* these are skipped */
- } else {
- e->dxy = (float)(end.x - start.x)/(end.y - start.y);
- e->state = EDGE_READY;
- }
+ /* Shorten each edge by one pixel at the bottom. This prevents
+ * every vertex point to be reported as two intersections.
+ * This also means causes all horizontal edges cut by one pixel,
+ * but we will fix this at the end by drawing them separately.
+ */
+ e->dy--;
}
/* Type of a callback function to be passed to qsort(). */
@@ -140,7 +147,7 @@ void GP_FillPolygon_Raw(GP_Context *context, unsigned int nvert,
if (nvert < 3)
return; /* not enough vertices */
-
+
GP_Point const *vert = (GP_Point const *) xy;
/* find first and last scanline */
@@ -149,7 +156,7 @@ void GP_FillPolygon_Raw(GP_Context *context, unsigned int nvert,
ymax = GP_MAX(ymax, vert[i].y);
ymin = GP_MIN(ymin, vert[i].y);
}
-
+
/* build a list of edges */
struct GP_Edge edges[nvert];
unsigned int nedges = 0; /* number of edges in list */
@@ -161,9 +168,9 @@ void GP_FillPolygon_Raw(GP_Context *context, unsigned int nvert,
*/
unsigned int nexti = (i+1) % nvert;
- GP_InitEdge(edges + nedges, vert[i], vert[nexti]);
-
- nedges++;
+ /* add new edge record */
+ e = edges + nedges++;
+ GP_InitEdge(e, vert[i], vert[nexti]);
}
if (nedges < 2)
@@ -172,7 +179,7 @@ void GP_FillPolygon_Raw(GP_Context *context, unsigned int nvert,
/* initially sort edges by Y, then X */
qsort(edges, nedges, sizeof(struct GP_Edge),
(GP_SortCallback) GP_CompareEdgesInitial);
-
+
/*
* for each scanline, compute intersections with all edges
* and draw a horizontal line segment between the intersections.
@@ -191,7 +198,7 @@ void GP_FillPolygon_Raw(GP_Context *context, unsigned int nvert,
}
qsort(edges, nedges, sizeof(struct GP_Edge),
(GP_SortCallback) GP_CompareEdgesRuntime);
-
+
/* record intersections with active edges */
ninter = 0;
for (i = 0; i < nedges; i++) {
@@ -200,7 +207,7 @@ void GP_FillPolygon_Raw(GP_Context *context, unsigned int nvert,
inter[ninter++] = e->x;
}
}
-
+
/* draw each even range between intersections */
for (i = 0; i < ninter; i += 2) {
float start = inter[i];
@@ -212,7 +219,7 @@ void GP_FillPolygon_Raw(GP_Context *context, unsigned int nvert,
float end = inter[i+1];
GP_HLine_Raw(context, start, end, y, pixel);
}
-
+
/* update active edges for next step */
for (i = 0; i < nedges; i++) {
e = edges + i;
@@ -226,6 +233,17 @@ void GP_FillPolygon_Raw(GP_Context *context, unsigned int nvert,
}
}
}
+
+ /* finishing touch: draw all horizontal edges that were skipped
+ * in the main loop
+ */
+ for (i = 0; i < nedges; i++) {
+ e = edges + i;
+ if (e->state == EDGE_HORIZONTAL) {
+ GP_HLine_Raw(context, e->x, e->x + e->dxy, e->y,
+ pixel);
+ }
+ }
}
void GP_FillPolygon(GP_Context *context, unsigned int vertex_count,
-----------------------------------------------------------------------
Summary of changes:
libs/gfx/GP_Polygon.c | 66 +++++++++++++++++++++++++++++++-----------------
1 files changed, 42 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 561ae54e3e8468a4368622344e5a90187d15da48 (commit)
from 47ecc1b6fbfe01c1b21089b596deb39955ebddfd (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/561ae54e3e8468a4368622344e5a90187d15…
commit 561ae54e3e8468a4368622344e5a90187d15da48
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Dec 15 10:53:00 2012 +0100
pywrap: loaders.i: Add a few %newobject directives.
diff --git a/pylib/gfxprim/loaders/loaders.i b/pylib/gfxprim/loaders/loaders.i
index 9561176..7c9d903 100644
--- a/pylib/gfxprim/loaders/loaders.i
+++ b/pylib/gfxprim/loaders/loaders.i
@@ -12,6 +12,8 @@ ERROR_ON_NULL(GP_LoadImage);
ERROR_ON_NONZERO(GP_LoadMetaData);
ERROR_ON_NONZERO(GP_SaveImage);
+%newobject GP_LoadImage;
+
%include "GP_Loaders.h"
ERROR_ON_NONZERO(GP_OpenJPG);
@@ -21,18 +23,24 @@ ERROR_ON_NONZERO(GP_ReadJPGMetaData);
ERROR_ON_NONZERO(GP_LoadJPGMetaData);
ERROR_ON_NONZERO(GP_SaveJPG);
+%newobject GP_LoadJPG;
+
%include "GP_JPG.h"
ERROR_ON_NONZERO(GP_OpenBMP);
ERROR_ON_NULL(GP_ReadBMP);
ERROR_ON_NULL(GP_LoadBMP);
+%newobject GP_LoadBMP;
+
%include "GP_BMP.h"
ERROR_ON_NONZERO(GP_OpenGIF);
ERROR_ON_NULL(GP_ReadGIF);
ERROR_ON_NULL(GP_LoadGIF);
+%newobject GP_LoadGIF;
+
%include "GP_GIF.h"
ERROR_ON_NONZERO(GP_OpenPNG);
@@ -42,6 +50,8 @@ ERROR_ON_NONZERO(GP_ReadPNGMetaData);
ERROR_ON_NONZERO(GP_LoadPNGMetaData);
ERROR_ON_NONZERO(GP_SavePNG);
+%newobject GP_LoadPNG;
+
%include "GP_PNG.h"
ERROR_ON_NULL(GP_LoadPBM);
@@ -54,4 +64,3 @@ ERROR_ON_NONZERO(GP_SavePPM);
%include "GP_PBM.h"
%include "GP_PGM.h"
%include "GP_PPM.h"
-
-----------------------------------------------------------------------
Summary of changes:
pylib/gfxprim/loaders/loaders.i | 11 ++++++++++-
1 files changed, 10 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 47ecc1b6fbfe01c1b21089b596deb39955ebddfd (commit)
from a69e12cc1918ea0b302e668fbcc378e95e9bda7e (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/47ecc1b6fbfe01c1b21089b596deb39955eb…
commit 47ecc1b6fbfe01c1b21089b596deb39955ebddfd
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Dec 14 23:23:53 2012 +0100
pywrap: Comment out the PyBuffer_FromMemory.
Now at least some of the python examples runs.
diff --git a/pylib/gfxprim/core/core.i b/pylib/gfxprim/core/core.i
index 6ddfc29..c679c4b 100644
--- a/pylib/gfxprim/core/core.i
+++ b/pylib/gfxprim/core/core.i
@@ -77,10 +77,12 @@ and self.thisown.") GP_Context;
$self->w, $self->h, $self->bpp, $self->free_pixels);
GP_ContextFree($self);
}
+ /*
PyObject *_hacky_hacky_pixels_buffer() {
GP_DEBUG(0, "Evil and dangerous _hacky_hacky_pixels_buffer() used!");
return PyBuffer_FromMemory($self->pixels, $self->bytes_per_row * $self->h);
}
+ */
};
/* Error handling */
-----------------------------------------------------------------------
Summary of changes:
pylib/gfxprim/core/core.i | 2 ++
1 files changed, 2 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.")