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 07d8a923162114629fa898af720d16e41160285d (commit) via 567aafbadcf454ab32ea74f81d6dba8cd872e1d2 (commit) via e0d46203381e3dd146a17fe0078af68a1d2e8b40 (commit) via 923ee620ce7cc8acf847c29b9da82ba5899ae520 (commit) from 6b71d7fd13d9e9f9bd596d75e07d196c8042205c (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/07d8a923162114629fa898af720d16e411602...
commit 07d8a923162114629fa898af720d16e41160285d Author: Cyril Hrubis metan@ucw.cz Date: Mon Feb 13 17:18:33 2012 +0100
demos: Particle demo update.
diff --git a/demos/particle/particle_demo.c b/demos/particle/particle_demo.c index b8af396..b258956 100644 --- a/demos/particle/particle_demo.c +++ b/demos/particle/particle_demo.c @@ -106,7 +106,7 @@ int main(int argc, char *argv[]) GP_BackendFlip(backend);
struct space *space; - space = space_create(300, 10<<8, 10<<8, (context->w - 10)<<8, (context->h - 10)<<8); + space = space_create(160, 10<<8, 10<<8, (context->w - 10)<<8, (context->h - 10)<<8);
for (;;) { if (backend->Poll) @@ -148,7 +148,7 @@ int main(int argc, char *argv[]) } if (!pause_flag) { - space_time_tick(space, 3); + space_time_tick(space, 1); space_draw_particles(context, space); GP_BackendFlip(backend); } diff --git a/demos/particle/space.c b/demos/particle/space.c index c029b0b..030f2e4 100644 --- a/demos/particle/space.c +++ b/demos/particle/space.c @@ -20,6 +20,7 @@ * * *****************************************************************************/
+#include <time.h> #include "space.h"
struct space *space_create(unsigned int particle_count, int min_w, int min_h, @@ -73,9 +74,55 @@ void space_draw_particles(GP_Context *context, struct space *space) GP_Fill(context, 0x000000);
for (i = 0; i < space->particle_count; i++) { - GP_Pixel color = GP_RGBToContextPixel(0xff, 0xff, 0xff, context); + GP_Pixel color; - GP_PutPixelAA(context, space->particles[i].x, space->particles[i].y, color); + GP_Coord x = space->particles[i].x; + GP_Coord y = space->particles[i].y; + GP_Coord a1 = GP_FP_1 * 4; + GP_Coord a2 = GP_FP_1_2 * 2; + +/* + if (i == 0) { + x = GP_FP_1 * 10 + GP_FP_1_2; + y = GP_FP_1 * 10 + GP_FP_1_2; + } +*/ + + color = GP_RGBToContextPixel(0xee, 0xee, 0xee, context); + + GP_PutPixelAA(context, x, y, color); + + int val = SQUARE(space->particles[i].vx) + SQUARE(space->particles[i].vy); + + val = sqrt(val) + 0x40; + + if (val > 255) + val = 255; + + color = GP_RGBToContextPixel(val, val, 0x40, context); + + /* Hexagons */ + GP_LineAA(context, x - a2, y - a1, x + a2, y - a1, color); + // GP_LineAA(context, x + a2, y - a1, x + a1, y - a2, color); + GP_LineAA(context, x + a1, y - a2, x + a1, y + a2, color); + // GP_LineAA(context, x + a1, y + a2, x + a2, y + a1, color); + GP_LineAA(context, x + a2, y + a1, x - a2, y + a1, color); + // GP_LineAA(context, x - a2, y + a1, x - a1, y + a2, color); + GP_LineAA(context, x - a1, y + a2, x - a1, y - a2, color); + // GP_LineAA(context, x - a1, y - a2, x - a2, y - a1, color); +/* + GP_PutPixelAA(context, x + a2, y - a1, 0xffffff); + GP_PutPixelAA(context, x + a1, y - a2, 0xffffff); + + GP_PutPixelAA(context, x + a1, y + a2, 0xffffff); + GP_PutPixelAA(context, x + a2, y + a1, 0xffffff); + + GP_PutPixelAA(context, x - a2, y + a1, 0xffffff); + GP_PutPixelAA(context, x - a1, y + a2, 0xffffff); + + GP_PutPixelAA(context, x - a1, y - a2, 0xffffff); + GP_PutPixelAA(context, x - a2, y - a1, 0xffffff); +*/ } }
@@ -105,8 +152,11 @@ static void gravity_forces(struct space *space, int time) int dist_squared = (SQUARE((dist_x + (1<<7))>>8) + SQUARE((dist_y + (1<<7))>>8)) + (1<<8); int dist = ((int)sqrt(dist_squared))<<4;
- if (dist < (1<<9)) - dist = -dist; + if (dist < (2<<8)) + dist = -(dist>>1); + else if (dist < (8<<8)) + dist = dist>>1; +
int a = GP_FP_DIV(space->mass_kappa, dist_squared) * time;
http://repo.or.cz/w/gfxprim.git/commit/567aafbadcf454ab32ea74f81d6dba8cd872e...
commit 567aafbadcf454ab32ea74f81d6dba8cd872e1d2 Author: Cyril Hrubis metan@ucw.cz Date: Mon Feb 13 17:01:30 2012 +0100
gfx: Fix Anti Aliased primitives coordinate system
The middle of the pixel is now defined as integer coodinates + 0.5.
TODO: The general Anti Aliased Line doesn't work correctly with this change yet.
diff --git a/libs/gfx/GP_HLineAA.gen.c.t b/libs/gfx/GP_HLineAA.gen.c.t index 3b5d15b..c08f68b 100644 --- a/libs/gfx/GP_HLineAA.gen.c.t +++ b/libs/gfx/GP_HLineAA.gen.c.t @@ -17,6 +17,10 @@ void GP_HLineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1, if (x1 < x0) GP_SWAP(x1, x0); + x0 -= GP_FP_1_2; + x1 += GP_FP_1_2; + y -= GP_FP_1_2; + GP_Coord int_x0 = GP_FP_TO_INT(x0); GP_Coord int_x1 = GP_FP_TO_INT(x1); GP_Coord int_y = GP_FP_TO_INT(y); diff --git a/libs/gfx/GP_PutPixelAA.gen.c.t b/libs/gfx/GP_PutPixelAA.gen.c.t index 625af68..c7eeefe 100644 --- a/libs/gfx/GP_PutPixelAA.gen.c.t +++ b/libs/gfx/GP_PutPixelAA.gen.c.t @@ -17,6 +17,8 @@ void GP_PutPixelAA_Raw(GP_Context *context, GP_Coord x, GP_Coord y, GP_Pixel pixel) { + x -= GP_FP_1_2; + y -= GP_FP_1_2; GP_Coord int_x = GP_FP_TO_INT(x); GP_Coord int_y = GP_FP_TO_INT(y); GP_Coord frac_x = GP_FP_FRAC(x); diff --git a/libs/gfx/GP_VLineAA.gen.c.t b/libs/gfx/GP_VLineAA.gen.c.t index 6a9663a..e754d3e 100644 --- a/libs/gfx/GP_VLineAA.gen.c.t +++ b/libs/gfx/GP_VLineAA.gen.c.t @@ -16,7 +16,11 @@ void GP_VLineAA_Raw(GP_Context *context, GP_Coord x, GP_Coord y0, { if (y1 < y0) GP_SWAP(y1, y0); - + + y0 -= GP_FP_1_2; + y1 += GP_FP_1_2; + x -= GP_FP_1_2; + GP_Coord int_y0 = GP_FP_TO_INT(y0); GP_Coord int_y1 = GP_FP_TO_INT(y1); GP_Coord int_x = GP_FP_TO_INT(x);
http://repo.or.cz/w/gfxprim.git/commit/e0d46203381e3dd146a17fe0078af68a1d2e8...
commit e0d46203381e3dd146a17fe0078af68a1d2e8b40 Author: Cyril Hrubis metan@ucw.cz Date: Mon Feb 13 15:38:20 2012 +0100
gfx: Add Anti Aliased HLine and VLine.
(Needed for correct Anti Aliased Line)
diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_Gfx.h index 6c2b8f6..df86280 100644 --- a/include/gfx/GP_Gfx.h +++ b/include/gfx/GP_Gfx.h @@ -53,6 +53,8 @@ #include "GP_Symbol.h"
#include "GP_PutPixelAA.h" +#include "GP_VLineAA.h" +#include "GP_HLineAA.h" #include "GP_LineAA.h" #include "GP_RectAA.h"
diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_HLineAA.h similarity index 64% copy from include/gfx/GP_Gfx.h copy to include/gfx/GP_HLineAA.h index 6c2b8f6..6889840 100644 --- a/include/gfx/GP_Gfx.h +++ b/include/gfx/GP_HLineAA.h @@ -16,44 +16,37 @@ * 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-2011 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
/* + + Anti Aliased Horizontal line.
- This is a main header for gfx part. + The coordinates are in XX.8 fixed point format, see core/GP_FixedPoint.h + for helper macros. + + For RGB contexts gamma correction tables are used to generate correct + intensity for pixels.
*/
-#ifndef GP_GFX_H -#define GP_GFX_H +#ifndef GFX_GP_HLINE_AA_H +#define GFX_GP_HLINE_AA_H
-/* basic definitions and structures */ #include "core/GP_Context.h" -#include "core/GP_GetPutPixel.h" -#include "core/GP_WritePixel.h" - -/* public drawing API */ -#include "GP_Fill.h" -#include "GP_HLine.h" -#include "GP_VLine.h" -#include "GP_Line.h" -#include "GP_Rect.h" -#include "GP_Triangle.h" -#include "GP_Tetragon.h" -#include "GP_Circle.h" -#include "GP_CircleSeg.h" -#include "GP_Ellipse.h" -#include "GP_Arc.h" -#include "GP_Polygon.h" -#include "GP_Symbol.h" - -#include "GP_PutPixelAA.h" -#include "GP_LineAA.h" -#include "GP_RectAA.h" - -#endif /* GP_GFX_H */ + +/* + * Anti Aliased Horizontal Line respecting context rotation flags and with clipping. + */ +void GP_HLineAA(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y, + GP_Pixel pixel); + +/* + * Horizontal Line without contect rotation flags. + */ +void GP_HLineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); + +#endif /* GFX_GP_HLINE_AA_H */ diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_VLineAA.h similarity index 64% copy from include/gfx/GP_Gfx.h copy to include/gfx/GP_VLineAA.h index 6c2b8f6..4bbce5a 100644 --- a/include/gfx/GP_Gfx.h +++ b/include/gfx/GP_VLineAA.h @@ -16,44 +16,37 @@ * 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-2011 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
/* + + Anti Aliased Vertical line.
- This is a main header for gfx part. + The coordinates are in XX.8 fixed point format, see core/GP_FixedPoint.h + for helper macros. + + For RGB contexts gamma correction tables are used to generate correct + intensity for pixels.
*/
-#ifndef GP_GFX_H -#define GP_GFX_H +#ifndef GFX_GP_VLINE_AA_H +#define GFX_GP_VLINE_AA_H
-/* basic definitions and structures */ #include "core/GP_Context.h" -#include "core/GP_GetPutPixel.h" -#include "core/GP_WritePixel.h" - -/* public drawing API */ -#include "GP_Fill.h" -#include "GP_HLine.h" -#include "GP_VLine.h" -#include "GP_Line.h" -#include "GP_Rect.h" -#include "GP_Triangle.h" -#include "GP_Tetragon.h" -#include "GP_Circle.h" -#include "GP_CircleSeg.h" -#include "GP_Ellipse.h" -#include "GP_Arc.h" -#include "GP_Polygon.h" -#include "GP_Symbol.h" - -#include "GP_PutPixelAA.h" -#include "GP_LineAA.h" -#include "GP_RectAA.h" - -#endif /* GP_GFX_H */ + +/* + * Anti Aliased Horizontal Line respecting context rotation flags and with clipping. + */ +void GP_VLineAA(GP_Context *context, GP_Coord x, GP_Coord y0, GP_Coord y1, + GP_Pixel pixel); + +/* + * Horizontal Line without contect rotation flags. + */ +void GP_VLineAA_Raw(GP_Context *context, GP_Coord x, + GP_Coord y0, GP_Coord y1, GP_Pixel pixel); + +#endif /* GFX_GP_VLINE_AA_H */ diff --git a/include/gfx/GP_Gfx.h b/libs/gfx/GP_HLineAA.c similarity index 63% copy from include/gfx/GP_Gfx.h copy to libs/gfx/GP_HLineAA.c index 6c2b8f6..01770f4 100644 --- a/include/gfx/GP_Gfx.h +++ b/libs/gfx/GP_HLineAA.c @@ -16,44 +16,41 @@ * 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-2011 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
-/* - - This is a main header for gfx part. - - */ +#include "core/GP_FnPerBpp.h" +#include "core/GP_Transform.h"
-#ifndef GP_GFX_H -#define GP_GFX_H +#include "gfx/GP_HLineAA.h" +#include "gfx/GP_VLineAA.h"
-/* basic definitions and structures */ -#include "core/GP_Context.h" -#include "core/GP_GetPutPixel.h" -#include "core/GP_WritePixel.h" - -/* public drawing API */ -#include "GP_Fill.h" -#include "GP_HLine.h" -#include "GP_VLine.h" -#include "GP_Line.h" -#include "GP_Rect.h" -#include "GP_Triangle.h" -#include "GP_Tetragon.h" -#include "GP_Circle.h" -#include "GP_CircleSeg.h" -#include "GP_Ellipse.h" -#include "GP_Arc.h" -#include "GP_Polygon.h" -#include "GP_Symbol.h" - -#include "GP_PutPixelAA.h" -#include "GP_LineAA.h" -#include "GP_RectAA.h" - -#endif /* GP_GFX_H */ +/* +void GP_HLineXXYAA_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_HLineAA(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_FP(context, x0); + GP_TRANSFORM_Y_FP(context, x1); + GP_TRANSFORM_X_FP(context, y); + GP_VLineAA_Raw(context, y, x0, x1, pixel); + } else { + GP_TRANSFORM_X_FP(context, x0); + GP_TRANSFORM_X_FP(context, x1); + GP_TRANSFORM_Y_FP(context, y); + GP_HLineAA_Raw(context, x0, x1, y, pixel); + } +} diff --git a/libs/gfx/GP_HLineAA.gen.c.t b/libs/gfx/GP_HLineAA.gen.c.t new file mode 100644 index 0000000..3b5d15b --- /dev/null +++ b/libs/gfx/GP_HLineAA.gen.c.t @@ -0,0 +1,58 @@ +%% extends "base.c.t" + +{% block descr %}Anti Aliased Horizontal Line{% endblock %} + +%% block body + +#include "core/GP_Context.h" +#include "core/GP_MixPixels.h" +#include "core/GP_FixedPoint.h" +#include "core/GP_GammaCorrection.h" + +#define FP_TO_PERC(a) (GP_FP_ROUND_TO_INT((a) * 255)) + +void GP_HLineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel) +{ + if (x1 < x0) + GP_SWAP(x1, x0); + + GP_Coord int_x0 = GP_FP_TO_INT(x0); + GP_Coord int_x1 = GP_FP_TO_INT(x1); + GP_Coord int_y = GP_FP_TO_INT(y); + + /* Line is shorter than two pixels */ + if (int_x0 == int_x1) { + //TODO + return; + } + + /* Draw the starting and ending pixel */ + uint8_t perc; + + perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(y), GP_FP_RFRAC(x0))); + GP_MixPixel_Raw_Clipped(context, int_x0, int_y, pixel, perc); + + perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(y), GP_FP_RFRAC(x0))); + GP_MixPixel_Raw_Clipped(context, int_x0, int_y+1, pixel, perc); + + + perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(y), GP_FP_FRAC(x1))); + GP_MixPixel_Raw_Clipped(context, int_x1, int_y, pixel, perc); + + perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(y), GP_FP_FRAC(x1))); + GP_MixPixel_Raw_Clipped(context, int_x1, int_y+1, pixel, perc); + + /* Draw the middle pixels */ + uint8_t up = FP_TO_PERC(GP_FP_RFRAC(y)); + uint8_t lp = FP_TO_PERC(GP_FP_FRAC(y)); + + GP_Coord x; + + for (x = int_x0 + 1; x < int_x1; x++) { + GP_MixPixel_Raw_Clipped(context, x, int_y, pixel, up); + GP_MixPixel_Raw_Clipped(context, x, int_y+1, pixel, lp); + } +} + +%% endblock body diff --git a/libs/gfx/GP_LineAA.gen.c.t b/libs/gfx/GP_LineAA.gen.c.t index 2bf413f..c5796d5 100644 --- a/libs/gfx/GP_LineAA.gen.c.t +++ b/libs/gfx/GP_LineAA.gen.c.t @@ -9,8 +9,8 @@ #include "core/GP_FixedPoint.h" #include "core/GP_GammaCorrection.h"
-#include "gfx/GP_HLine.h" -#include "gfx/GP_VLine.h" +#include "gfx/GP_HLineAA.h" +#include "gfx/GP_VLineAA.h"
#define FP_TO_PERC(a) (GP_FP_ROUND_TO_INT((a) * 255))
@@ -121,16 +121,12 @@ void GP_LineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, int64_t dy = y1 - y0;
if (dy == 0) { - //TODO!!! - GP_HLine_Raw(context, GP_FP_ROUND_TO_INT(x0), GP_FP_ROUND_TO_INT(x1), - GP_FP_ROUND_TO_INT(y0), pixel); + GP_HLineAA_Raw(context, x0, x1, y0, pixel); return; }
if (dx == 0) { - //TODO!!! - GP_VLine(context, GP_FP_ROUND_TO_INT(x0), GP_FP_ROUND_TO_INT(y0), - GP_FP_ROUND_TO_INT(y1), pixel); + GP_VLineAA_Raw(context, x0, y0, y1, pixel); return; }
diff --git a/include/gfx/GP_Gfx.h b/libs/gfx/GP_VLineAA.c similarity index 64% copy from include/gfx/GP_Gfx.h copy to libs/gfx/GP_VLineAA.c index 6c2b8f6..6b5b1d4 100644 --- a/include/gfx/GP_Gfx.h +++ b/libs/gfx/GP_VLineAA.c @@ -16,44 +16,40 @@ * 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-2011 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
-/* - - This is a main header for gfx part. - - */ - -#ifndef GP_GFX_H -#define GP_GFX_H - -/* basic definitions and structures */ -#include "core/GP_Context.h" #include "core/GP_GetPutPixel.h" -#include "core/GP_WritePixel.h" +#include "core/GP_FnPerBpp.h"
-/* public drawing API */ -#include "GP_Fill.h" -#include "GP_HLine.h" -#include "GP_VLine.h" -#include "GP_Line.h" -#include "GP_Rect.h" -#include "GP_Triangle.h" -#include "GP_Tetragon.h" -#include "GP_Circle.h" -#include "GP_CircleSeg.h" -#include "GP_Ellipse.h" -#include "GP_Arc.h" -#include "GP_Polygon.h" -#include "GP_Symbol.h" +#include "gfx/GP_VLineAA.h" +#include "gfx/GP_HLineAA.h"
-#include "GP_PutPixelAA.h" -#include "GP_LineAA.h" -#include "GP_RectAA.h" - -#endif /* GP_GFX_H */ +/* +void GP_VLineXYY_Raw(GP_Context *context, GP_Coord x, GP_Coord y0, + GP_Coord y1, GP_Pixel pixel) +{ + GP_CHECK_CONTEXT(context); + + GP_FN_PER_BPP_CONTEXT(GP_VLine, context, context, x, y0, y1, pixel); +} +*/ + +void GP_VLineAA(GP_Context *context, GP_Coord x, GP_Coord y0, + GP_Coord y1, GP_Pixel pixel) +{ + GP_CHECK_CONTEXT(context); + + if (context->axes_swap) { + GP_TRANSFORM_Y_FP(context, x); + GP_TRANSFORM_X_FP(context, y0); + GP_TRANSFORM_X_FP(context, y1); + GP_HLineAA_Raw(context, y0, y1, x, pixel); + } else { + GP_TRANSFORM_X_FP(context, x); + GP_TRANSFORM_Y_FP(context, y0); + GP_TRANSFORM_Y_FP(context, y1); + GP_VLineAA_Raw(context, x, y0, y1, pixel); + } +} diff --git a/libs/gfx/GP_VLineAA.gen.c.t b/libs/gfx/GP_VLineAA.gen.c.t new file mode 100644 index 0000000..6a9663a --- /dev/null +++ b/libs/gfx/GP_VLineAA.gen.c.t @@ -0,0 +1,58 @@ +%% extends "base.c.t" + +{% block descr %}Anti Aliased Vertical Line{% endblock %} + +%% block body + +#include "core/GP_Context.h" +#include "core/GP_MixPixels.h" +#include "core/GP_FixedPoint.h" +#include "core/GP_GammaCorrection.h" + +#define FP_TO_PERC(a) (GP_FP_ROUND_TO_INT((a) * 255)) + +void GP_VLineAA_Raw(GP_Context *context, GP_Coord x, GP_Coord y0, + GP_Coord y1, GP_Pixel pixel) +{ + if (y1 < y0) + GP_SWAP(y1, y0); + + GP_Coord int_y0 = GP_FP_TO_INT(y0); + GP_Coord int_y1 = GP_FP_TO_INT(y1); + GP_Coord int_x = GP_FP_TO_INT(x); + + /* Line is shorter than two pixels */ + if (int_y0 == int_y1) { + //TODO + return; + } + + /* Draw the starting and ending pixel */ + uint8_t perc; + + perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(x), GP_FP_RFRAC(y0))); + GP_MixPixel_Raw_Clipped(context, int_x, int_y0, pixel, perc); + + perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(x), GP_FP_RFRAC(y0))); + GP_MixPixel_Raw_Clipped(context, int_x+1, int_y0, pixel, perc); + + + perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(x), GP_FP_FRAC(y1))); + GP_MixPixel_Raw_Clipped(context, int_x, int_y1, pixel, perc); + + perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(x), GP_FP_FRAC(y1))); + GP_MixPixel_Raw_Clipped(context, int_x+1, int_y1, pixel, perc); + + /* Draw the middle pixels */ + uint8_t up = FP_TO_PERC(GP_FP_RFRAC(x)); + uint8_t lp = FP_TO_PERC(GP_FP_FRAC(x)); + + GP_Coord y; + + for (y = int_y0 + 1; y < int_y1; y++) { + GP_MixPixel_Raw_Clipped(context, int_x, y, pixel, up); + GP_MixPixel_Raw_Clipped(context, int_x+1, y, pixel, lp); + } +} + +%% endblock body diff --git a/libs/gfx/Makefile b/libs/gfx/Makefile index 3e7cb28..60a485b 100644 --- a/libs/gfx/Makefile +++ b/libs/gfx/Makefile @@ -1,6 +1,7 @@ TOPDIR=../.. CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c)) -GENSOURCES=GP_LineAA.gen.c GP_PutPixelAA.gen.c +GENSOURCES=GP_LineAA.gen.c GP_PutPixelAA.gen.c GP_HLineAA.gen.c + GP_VLineAA.gen.c LIBNAME=gfx
include $(TOPDIR)/gen.mk
http://repo.or.cz/w/gfxprim.git/commit/923ee620ce7cc8acf847c29b9da82ba5899ae...
commit 923ee620ce7cc8acf847c29b9da82ba5899ae520 Author: Cyril Hrubis metan@ucw.cz Date: Mon Feb 13 14:44:05 2012 +0100
gfx: Added header for Anti Aliased line, finally.
diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_Gfx.h index acc5fd2..6c2b8f6 100644 --- a/include/gfx/GP_Gfx.h +++ b/include/gfx/GP_Gfx.h @@ -52,7 +52,8 @@ #include "GP_Polygon.h" #include "GP_Symbol.h"
-#include "GP_RectAA.h" #include "GP_PutPixelAA.h" +#include "GP_LineAA.h" +#include "GP_RectAA.h"
#endif /* GP_GFX_H */ diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_LineAA.h similarity index 65% copy from include/gfx/GP_Gfx.h copy to include/gfx/GP_LineAA.h index acc5fd2..34ec028 100644 --- a/include/gfx/GP_Gfx.h +++ b/include/gfx/GP_LineAA.h @@ -16,43 +16,37 @@ * 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-2011 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2012 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
/* + + Anti Aliased line.
- This is a main header for gfx part. + The coordinates are in XX.8 fixed point format, see core/GP_FixedPoint.h + for helper macros. + + For RGB contexts gamma correction tables are used to generate correct + intensity for pixels.
*/
-#ifndef GP_GFX_H -#define GP_GFX_H +#ifndef GFX_GP_LINE_AA_H +#define GFX_GP_LINE_AA_H
-/* basic definitions and structures */ #include "core/GP_Context.h" -#include "core/GP_GetPutPixel.h" -#include "core/GP_WritePixel.h" - -/* public drawing API */ -#include "GP_Fill.h" -#include "GP_HLine.h" -#include "GP_VLine.h" -#include "GP_Line.h" -#include "GP_Rect.h" -#include "GP_Triangle.h" -#include "GP_Tetragon.h" -#include "GP_Circle.h" -#include "GP_CircleSeg.h" -#include "GP_Ellipse.h" -#include "GP_Arc.h" -#include "GP_Polygon.h" -#include "GP_Symbol.h" - -#include "GP_RectAA.h" -#include "GP_PutPixelAA.h" - -#endif /* GP_GFX_H */ + +/* + * Anti Aliased Line respecting context rotation flags and with clipping. + */ +void GP_LineAA(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel); + +/* + * Line without contect rotation flags. + */ +void GP_LineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel); + +#endif /* GFX_GP_LINE_AA_H */ diff --git a/include/gfx/GP_Gfx.h b/libs/gfx/GP_LineAA.c similarity index 72% copy from include/gfx/GP_Gfx.h copy to libs/gfx/GP_LineAA.c index acc5fd2..6d30df0 100644 --- a/include/gfx/GP_Gfx.h +++ b/libs/gfx/GP_LineAA.c @@ -19,40 +19,33 @@ * Copyright (C) 2009-2010 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 * * * *****************************************************************************/
-/* - - This is a main header for gfx part. - - */ - -#ifndef GP_GFX_H -#define GP_GFX_H +#include "core/GP_Transform.h" +#include "core/GP_FnPerBpp.h"
-/* basic definitions and structures */ -#include "core/GP_Context.h" -#include "core/GP_GetPutPixel.h" -#include "core/GP_WritePixel.h" +#include "gfx/GP_LineAA.h"
-/* public drawing API */ -#include "GP_Fill.h" -#include "GP_HLine.h" -#include "GP_VLine.h" -#include "GP_Line.h" -#include "GP_Rect.h" -#include "GP_Triangle.h" -#include "GP_Tetragon.h" -#include "GP_Circle.h" -#include "GP_CircleSeg.h" -#include "GP_Ellipse.h" -#include "GP_Arc.h" -#include "GP_Polygon.h" -#include "GP_Symbol.h" - -#include "GP_RectAA.h" -#include "GP_PutPixelAA.h" - -#endif /* GP_GFX_H */ +/* +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_LineAA(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_FP(context, x0, y0); + GP_TRANSFORM_POINT_FP(context, x1, y1); + + GP_LineAA_Raw(context, x0, y0, x1, y1, pixel); +}
-----------------------------------------------------------------------
Summary of changes: demos/particle/particle_demo.c | 4 +- demos/particle/space.c | 58 +++++++++++++++++++++-- include/gfx/GP_Gfx.h | 5 ++- include/gfx/{GP_PutPixelAA.h => GP_HLineAA.h} | 29 +++++------- include/gfx/{GP_PutPixelAA.h => GP_LineAA.h} | 25 ++++------ include/gfx/{GP_PutPixelAA.h => GP_VLineAA.h} | 29 +++++------- libs/gfx/{GP_Line.c => GP_HLineAA.c} | 42 +++++++++-------- libs/gfx/GP_HLineAA.gen.c.t | 62 +++++++++++++++++++++++++ libs/gfx/{GP_Line.c => GP_LineAA.c} | 21 ++++----- libs/gfx/GP_LineAA.gen.c.t | 12 ++--- libs/gfx/GP_PutPixelAA.gen.c.t | 2 + libs/{text/GP_Font.c => gfx/GP_VLineAA.c} | 61 ++++++++++--------------- libs/gfx/GP_VLineAA.gen.c.t | 62 +++++++++++++++++++++++++ libs/gfx/Makefile | 3 +- 14 files changed, 281 insertions(+), 134 deletions(-) copy include/gfx/{GP_PutPixelAA.h => GP_HLineAA.h} (73%) copy include/gfx/{GP_PutPixelAA.h => GP_LineAA.h} (76%) copy include/gfx/{GP_PutPixelAA.h => GP_VLineAA.h} (73%) copy libs/gfx/{GP_Line.c => GP_HLineAA.c} (67%) create mode 100644 libs/gfx/GP_HLineAA.gen.c.t copy libs/gfx/{GP_Line.c => GP_LineAA.c} (83%) copy libs/{text/GP_Font.c => gfx/GP_VLineAA.c} (68%) create mode 100644 libs/gfx/GP_VLineAA.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.