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 0850c45f543489686dc6a2984cf104ed2e89b4aa (commit) via 39de4836f42404f669d76cf0ebd759a0a32f41b9 (commit) via 261533840975611674984ee1e3a8ea2b83085dae (commit) from 1bac6fdd5618b074d38c9f7d4da6e867b302ba16 (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/0850c45f543489686dc6a2984cf104ed2e89b...
commit 0850c45f543489686dc6a2984cf104ed2e89b4aa Author: Cyril Hrubis metan@ucw.cz Date: Tue Jan 3 01:30:31 2012 +0100
gfx: First attempt on Anti Aliased rectangle.
diff --git a/include/gfx/GP_Gfx.h b/include/core/GP_GammaCorrection.h similarity index 66% copy from include/gfx/GP_Gfx.h copy to include/core/GP_GammaCorrection.h index 5e54131..d36b1a9 100644 --- a/include/gfx/GP_Gfx.h +++ b/include/core/GP_GammaCorrection.h @@ -16,39 +16,32 @@ * 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. + Gamma correction. + + */ + +#ifndef CORE_GP_GAMMA_CORRECTION_H +#define CORE_GP_GAMMA_CORRECTION_H
+#include <stdint.h> +#include <math.h> + +#define GP_GAMMA 2.2 + +/* + * Coverts linear 0 255 value into 0 255 gama value. + * + * (this is used for Anti Aliased gfx primitives. */ +static inline uint8_t GP_GammaToLinear(uint8_t val) +{ + return pow(1.00 * val/255, 1/GP_GAMMA) * 255 + 0.5; +}
-#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" - -/* 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_Ellipse.h" -#include "GP_Arc.h" -#include "GP_Polygon.h" -#include "GP_Symbol.h" - -#endif /* GP_GFX_H */ +#endif /* CORE_GP_GAMMA_CORRECTION_H */ diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_Gfx.h index 5e54131..6503952 100644 --- a/include/gfx/GP_Gfx.h +++ b/include/gfx/GP_Gfx.h @@ -51,4 +51,6 @@ #include "GP_Polygon.h" #include "GP_Symbol.h"
+#include "GP_RectAA.h" + #endif /* GP_GFX_H */ diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_RectAA.h similarity index 56% copy from include/gfx/GP_Gfx.h copy to include/gfx/GP_RectAA.h index 5e54131..fc6d9e9 100644 --- a/include/gfx/GP_Gfx.h +++ b/include/gfx/GP_RectAA.h @@ -16,39 +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 * * * *****************************************************************************/
-/* +#ifndef GFX_GP_RECT_AA_H +#define GFX_GP_RECT_AA_H + +#include "core/GP_Context.h"
- This is a main header for gfx part. +/* Filled Rectangle */
- */ +void GP_FillRectXYXY_AA(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
-#ifndef GP_GFX_H -#define GP_GFX_H +void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
-/* 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_Ellipse.h" -#include "GP_Arc.h" -#include "GP_Polygon.h" -#include "GP_Symbol.h" - -#endif /* GP_GFX_H */ +void GP_FillRectXYWH_AA(GP_Context *context, GP_Coord x, GP_Coord y, + GP_Size w, GP_Size h, GP_Pixel pixel); + +void GP_FillRectXYWH_AA_Raw(GP_Context *context, GP_Coord x, GP_Coord y, + GP_Size w, GP_Size h, GP_Pixel pixel); + +/* The XYXY argument set is the default */ +static inline void GP_FillRect_AA(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel) +{ + GP_FillRectXYXY_AA(context, x0, y0, x1, y1, pixel); +} + +static inline void GP_FillRect_AA_Raw(GP_Context *context, + GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel) +{ + GP_FillRectXYXY_AA_Raw(context, x0, y0, x1, y1, pixel); +} + +#endif /* GFX_GP_RECT_AA_H */ diff --git a/libs/gfx/GP_RectAA.c b/libs/gfx/GP_RectAA.c new file mode 100644 index 0000000..0939a7f --- /dev/null +++ b/libs/gfx/GP_RectAA.c @@ -0,0 +1,129 @@ +/***************************************************************************** + * 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 "core/GP_Transform.h" +#include "core/GP_GetPutPixel.h" +#include "core/GP_MixPixels.h" +#include "core/GP_GammaCorrection.h" +#include "GP_Rect.h" +#include "GP_RectAA.h" + +void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel) +{ + GP_CHECK_CONTEXT(context); + + if (x0 > x1) + GP_SWAP(x0, x1); + + if (y0 > y1) + GP_SWAP(y0, y1); + + /* Draw the full part of the rect */ + GP_FillRect(context, x0>>8, y0>>8, x1>>8, y1>>8, pixel); + + /* Draw the "frame" around */ + GP_Coord i; + + uint8_t u_perc; + uint8_t d_perc; + + d_perc = GP_GammaToLinear(x0%8); + u_perc = GP_GammaToLinear(x1%8); + + for (i = x0>>8; i <= x1>>8; i++) { + GP_Pixel u = GP_GetPixel(context, i, (y0>>8) - 1); + GP_Pixel d = GP_GetPixel(context, i, (y1>>8) + 1); + + u = GP_MixPixels(pixel, u, u_perc, context->pixel_type); + d = GP_MixPixels(pixel, d, d_perc, context->pixel_type); + + GP_PutPixel(context, i, (y0>>8) - 1, u); + GP_PutPixel(context, i, (y1>>8) + 1, d); + } + + d_perc = GP_GammaToLinear(y0%8); + u_perc = GP_GammaToLinear(y1%8); + + for (i = y0>>8; i <= y1>>8; i++) { + GP_Pixel u = GP_GetPixel(context, (x0>>8) - 1, i); + GP_Pixel d = GP_GetPixel(context, (x1>>8) + 1, i); + + u = GP_MixPixels(pixel, u, u_perc, context->pixel_type); + d = GP_MixPixels(pixel, d, d_perc, context->pixel_type); + + GP_PutPixel(context, (x0>>8) - 1, i, u); + GP_PutPixel(context, (x1>>8) + 1, i, d); + } + + uint8_t perc; + GP_Pixel p; + + perc = GP_GammaToLinear((x0%8+y0%8)/2); + p = GP_GetPixel(context, (x0>>8) - 1, (y0>>8) - 1); + p = GP_MixPixels(pixel, p, perc, context->pixel_type); + GP_PutPixel(context, (x0>>8) - 1, (y0>>8) - 1, p); + + perc = GP_GammaToLinear((x1%8+y0%8)/2); + p = GP_GetPixel(context, (x1>>8) + 1, (y0>>8) - 1); + p = GP_MixPixels(pixel, p, perc, context->pixel_type); + GP_PutPixel(context, (x1>>8) + 1, (y0>>8) - 1, p); + + perc = GP_GammaToLinear((x0%8+y1%8)/2); + p = GP_GetPixel(context, (x0>>8) - 1, (y1>>8) + 1); + p = GP_MixPixels(pixel, p, perc, context->pixel_type); + GP_PutPixel(context, (x0>>8) - 1, (y1>>8) + 1, p); + + perc = GP_GammaToLinear((x1%8+y1%8)/2); + p = GP_GetPixel(context, (x1>>8) + 1, (y1>>8) + 1); + p = GP_MixPixels(pixel, p, perc, context->pixel_type); + GP_PutPixel(context, (x1>>8) + 1, (y1>>8) + 1, p); +} + +void GP_FillRectXYWH_AA_Raw(GP_Context *context, GP_Coord x, GP_Coord y, + GP_Size w, GP_Size h, GP_Pixel pixel) +{ + if (w == 0 || h == 0) + return; + + GP_FillRectXYXY_AA_Raw(context, x, y, x + w - 1, y + h - 1, pixel); +} + +void GP_FillRectXYXY_AA(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_FillRect_AA_Raw(context, x0, y0, x1, y1, pixel); +} + +void GP_FillRectXYWH_AA(GP_Context *context, GP_Coord x, GP_Coord y, + GP_Size w, GP_Size h, GP_Pixel pixel) +{ + if (w == 0 || h == 0) + return; + + GP_FillRectXYXY_AA(context, x, y, x + w - 1, y + h - 1, pixel); +} diff --git a/tests/SDL/randomshapetest.c b/tests/SDL/randomshapetest.c index edc8554..f7c8939 100644 --- a/tests/SDL/randomshapetest.c +++ b/tests/SDL/randomshapetest.c @@ -60,7 +60,8 @@ Uint32 timer_callback(__attribute__((unused)) Uint32 interval, #define SHAPE_TRIANGLE 3 #define SHAPE_RECTANGLE 4 #define SHAPE_TETRAGON 5 -#define SHAPE_LAST 5 +#define SHAPE_RECTANGLE_AA 6 +#define SHAPE_LAST 6 static int shape = SHAPE_FIRST;
/* Draw outlines? */ @@ -83,6 +84,12 @@ void random_point(SDL_Surface *surf, int *x, int *y) } }
+void random_point_AA(SDL_Surface *surf, int *x, int *y) +{ + *x = random() % (surf->w<<8); + *y = random() % (surf->h<<8); +} + void draw_random_circle(GP_Pixel pixel) { int x, y; @@ -152,6 +159,20 @@ void draw_random_tetragon(GP_Pixel pixel) GP_Tetragon(&context, x0, y0, x1, y1, x2, y2, x3, y3, pixel); }
+void draw_random_rectangle_AA(GP_Pixel pixel) +{ + int x0, y0, x1, y1; + random_point_AA(display, &x0, &y0); + random_point_AA(display, &x1, &y1); + +// if (fill_flag) + GP_FillRect_AA(&context, x0, y0, x1, y1, pixel); + +// if (outline_flag) +// GP_Rect(&context, x0, y0, x1, y1, white); +} + + void clear_screen(void) { SDL_LockSurface(display); @@ -174,23 +195,22 @@ void redraw_screen(void) switch (shape) { case SHAPE_CIRCLE: draw_random_circle(pixel); - break; - + break; case SHAPE_ELLIPSE: draw_random_ellipse(pixel); - break; - + break; case SHAPE_TRIANGLE: draw_random_triangle(pixel); - break; - + break; case SHAPE_RECTANGLE: draw_random_rectangle(pixel); - break; - + break; case SHAPE_TETRAGON: draw_random_tetragon(pixel); - break; + break; + case SHAPE_RECTANGLE_AA: + draw_random_rectangle_AA(pixel); + break; }
SDL_UnlockSurface(display);
http://repo.or.cz/w/gfxprim.git/commit/39de4836f42404f669d76cf0ebd759a0a32f4...
commit 39de4836f42404f669d76cf0ebd759a0a32f41b9 Author: Cyril Hrubis metan@ucw.cz Date: Tue Jan 3 00:16:41 2012 +0100
core: Remove now unused DEF_FFN_PER_BPP macros.
diff --git a/include/core/GP_FnPerBpp.gen.h.t b/include/core/GP_FnPerBpp.gen.h.t index 02238a1..13a1f84 100644 --- a/include/core/GP_FnPerBpp.gen.h.t +++ b/include/core/GP_FnPerBpp.gen.h.t @@ -12,11 +12,6 @@ GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, {{ ps.suffix }}) {% endfor %}
-#define GP_DEF_FFN_PER_BPP(fname, MACRO_NAME) -%% for ps in pixelsizes - GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, {{ ps.suffix }}) -{% endfor %} - {% macro bpp_suffix(suffix) %}{% if suffix == "LE" or suffix == "BE" %}_{{ suffix }}{% endif %}{% endmacro %}
/* diff --git a/include/core/GP_FnPerBpp.h b/include/core/GP_FnPerBpp.h index daf21c9..11d12a3 100644 --- a/include/core/GP_FnPerBpp.h +++ b/include/core/GP_FnPerBpp.h @@ -85,13 +85,4 @@ #define GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, bpp) MACRO_NAME(fname##_##bpp, GP_Context *, GP_Pixel, fdraw##bpp)
-/* - * Dtto for filters. - * - * Filter is functions that works on Context per pixel. - */ -#define GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, bpp) - MACRO_NAME(fname##_##bpp, GP_Context *, GP_Pixel, - GP_PutPixel_Raw_##bpp, GP_GetPixel_Raw_##bpp) - #endif /* GP_FN_PER_BPP_H */
http://repo.or.cz/w/gfxprim.git/commit/261533840975611674984ee1e3a8ea2b83085...
commit 261533840975611674984ee1e3a8ea2b83085dae Author: Cyril Hrubis metan@ucw.cz Date: Tue Jan 3 00:06:19 2012 +0100
core: Add GP_MixPixels() function.
diff --git a/include/core/GP_MixPixels.gen.h.t b/include/core/GP_MixPixels.gen.h.t index 2ad33a8..deb6912 100644 --- a/include/core/GP_MixPixels.gen.h.t +++ b/include/core/GP_MixPixels.gen.h.t @@ -32,4 +32,19 @@ Macros to mix two pixels accordingly to percentage. %% endif %% endfor
+static inline GP_Pixel GP_MixPixels(GP_Pixel pix1, GP_Pixel pix2, + uint8_t perc, GP_PixelType pixel_type) +{ + switch (pixel_type) { +%% for pt in pixeltypes +%% if not pt.is_unknown() + case GP_PIXEL_{{ pt.name }}: + return GP_MIX_PIXELS_{{ pt.name }}(pix1, pix2, perc); +%% endif +%% endfor + default: + GP_ABORT("Unknown pixeltype"); + } +} + %% endblock body diff --git a/include/core/GP_MixPixels.h b/include/core/GP_MixPixels.h new file mode 100644 index 0000000..bd9006e --- /dev/null +++ b/include/core/GP_MixPixels.h @@ -0,0 +1,29 @@ +/***************************************************************************** + * 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) 2012 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#ifndef CORE_GP_MIXPIXELS_H +#define CORE_GP_MIXPIXELS_H + +/* Generated header */ +#include "GP_MixPixels.gen.h" + +#endif /* CORE_GP_MIXPIXELS_H */
-----------------------------------------------------------------------
Summary of changes: include/core/GP_FnPerBpp.gen.h.t | 5 - include/core/GP_FnPerBpp.h | 9 -- .../GP_GammaCorrection.h} | 22 +++- include/core/GP_MixPixels.gen.h.t | 15 +++ .../GP_Blit.test.c => include/core/GP_MixPixels.h | 11 +- include/gfx/GP_Gfx.h | 2 + libs/text/GP_Font.c => include/gfx/GP_RectAA.h | 58 ++++------ libs/gfx/GP_RectAA.c | 129 ++++++++++++++++++++ tests/SDL/randomshapetest.c | 40 +++++-- 9 files changed, 220 insertions(+), 71 deletions(-) copy include/{input/GP_InputDriverSDL.h => core/GP_GammaCorrection.h} (78%) copy tests/core/GP_Blit.test.c => include/core/GP_MixPixels.h (88%) copy libs/text/GP_Font.c => include/gfx/GP_RectAA.h (58%) create mode 100644 libs/gfx/GP_RectAA.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.