ucw.cz
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
List overview
Download
Gfxprim
July 2011
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
gfxprim@ucw.cz
3 participants
17 discussions
Start a n
N
ew thread
[repo.or.cz] gfxprim.git branch master updated: b3779d6def780f74dc0dbaed7ed5f5172a9faa7c
by bluebear
17 Jul '11
17 Jul '11
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 b3779d6def780f74dc0dbaed7ed5f5172a9faa7c (commit) from 9d50a7192a8d4620a221c571092015891182f63a (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/b3779d6def780f74dc0dbaed7ed5f5172a9f…
commit b3779d6def780f74dc0dbaed7ed5f5172a9faa7c Author: BlueBear <jiri.bluebear.dluhos(a)gmail.com> Date: Sun Jul 17 20:23:31 2011 +0200 Initial attempt on rings (only circular for now). diff --git a/include/gfx/GP_Circle.h b/include/gfx/GP_Circle.h index 6360e72..57b5a0a 100644 --- a/include/gfx/GP_Circle.h +++ b/include/gfx/GP_Circle.h @@ -40,4 +40,10 @@ void GP_FillCircle(GP_Context *context, int xcenter, int ycenter, void GP_TFillCircle(GP_Context *context, int xcenter, int ycenter, unsigned int r, GP_Pixel pixel); +void GP_FillRing(GP_Context *context, int xcenter, int ycenter, + unsigned int outer_r, unsigned int inner_r, GP_Pixel pixel); + +void GP_TFillRing(GP_Context *context, int xcenter, int ycenter, + unsigned int outer_r, unsigned int inner_r, GP_Pixel pixel); + #endif /* GP_CIRCLE_H */ diff --git a/libs/gfx/GP_Circle.c b/libs/gfx/GP_Circle.c index 4e92243..427a9ad 100644 --- a/libs/gfx/GP_Circle.c +++ b/libs/gfx/GP_Circle.c @@ -84,3 +84,33 @@ void GP_TFillCircle(GP_Context *context, int xcenter, int ycenter, GP_FillCircle(context, xcenter, ycenter, r, pixel); } + +#include "algo/FillRing.algo.h" + +/* Generate drawing functions for various bit depths. */ +DEF_FILLRING_FN(GP_FillRing1bpp, GP_Context *, GP_Pixel, GP_HLine1bpp) +DEF_FILLRING_FN(GP_FillRing2bpp, GP_Context *, GP_Pixel, GP_HLine2bpp) +DEF_FILLRING_FN(GP_FillRing4bpp, GP_Context *, GP_Pixel, GP_HLine4bpp) +DEF_FILLRING_FN(GP_FillRing8bpp, GP_Context *, GP_Pixel, GP_HLine8bpp) +DEF_FILLRING_FN(GP_FillRing16bpp, GP_Context *, GP_Pixel, GP_HLine16bpp) +DEF_FILLRING_FN(GP_FillRing24bpp, GP_Context *, GP_Pixel, GP_HLine24bpp) +DEF_FILLRING_FN(GP_FillRing32bpp, GP_Context *, GP_Pixel, GP_HLine32bpp) + +void GP_FillRing(GP_Context *context, int xcenter, int ycenter, + unsigned int outer_r, unsigned int inner_r, GP_Pixel pixel) +{ + GP_CHECK_CONTEXT(context); + + GP_FN_PER_BPP(GP_FillRing, context->bpp, context, + xcenter, ycenter, outer_r, inner_r, pixel); +} + +void GP_TFillRing(GP_Context *context, int xcenter, int ycenter, + unsigned int outer_r, unsigned int inner_r, GP_Pixel pixel) +{ + GP_CHECK_CONTEXT(context); + + GP_TRANSFORM_POINT(context, xcenter, ycenter); + + GP_FillRing(context, xcenter, ycenter, outer_r, inner_r, pixel); +} diff --git a/include/gfx/GP_Circle.h b/libs/gfx/algo/FillRing.algo.h similarity index 53% copy from include/gfx/GP_Circle.h copy to libs/gfx/algo/FillRing.algo.h index 6360e72..4458bec 100644 --- a/include/gfx/GP_Circle.h +++ b/libs/gfx/algo/FillRing.algo.h @@ -23,21 +23,51 @@ * * *****************************************************************************/ -#ifndef GP_CIRCLE_H -#define GP_CIRCLE_H +/* + * A filled ring drawing algorithm. + */ -#include "core/GP_Context.h" - -void GP_Circle(GP_Context *context, int xcenter, int ycenter, - unsigned int r, GP_Pixel pixel); - -void GP_TCircle(GP_Context *context, int xcenter, int ycenter, - unsigned int r, GP_Pixel pixel); - -void GP_FillCircle(GP_Context *context, int xcenter, int ycenter, - unsigned int r, GP_Pixel pixel); - -void GP_TFillCircle(GP_Context *context, int xcenter, int ycenter, - unsigned int r, GP_Pixel pixel); - -#endif /* GP_CIRCLE_H */ +/* + * 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_FILLRING_FN(FN_NAME, CONTEXT_T, PIXVAL_T, HLINE) +void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, + unsigned int outer_r, unsigned int inner_r, PIXVAL_T pixval) +{ + if (inner_r >= outer_r) return; ++ int outer_x = 0; + int inner_x = 0; + int y; + int outer_error = -outer_r; + int inner_error = -inner_r; + for (y = outer_r; y >= 0; y--) { ++ while (outer_error < 0) { + outer_error += 2*outer_x + 1; + outer_x++; + } + outer_error += -2*y + 1; ++ if (y < (int) inner_r && y > -((int) inner_r)) { + while (inner_error < 0) { + inner_error += 2*inner_x + 1; + inner_x++; + } + inner_error += -2*y + 1; ++ HLINE(context, xcenter - outer_x + 1, xcenter - inner_x - 1, ycenter - y, pixval); + HLINE(context, xcenter + inner_x + 1, xcenter + outer_x - 1, ycenter - y, pixval); + HLINE(context, xcenter - outer_x + 1, xcenter - inner_x - 1, ycenter + y, pixval); + HLINE(context, xcenter + inner_x + 1, xcenter + outer_x - 1, ycenter + y, pixva l); + } else { + HLINE(context, xcenter - outer_x + 1, xcenter + outer_x - 1, ycenter-y, pixval); + HLINE(context, xcenter - outer_x + 1, xcenter + outer_x - 1, ycenter+y, pixval); + } + } +} diff --git a/tests/SDL/shapetest.c b/tests/SDL/shapetest.c index fb85b2e..d1009d9 100644 --- a/tests/SDL/shapetest.c +++ b/tests/SDL/shapetest.c @@ -68,9 +68,10 @@ static int show_axes = 1; #define SHAPE_FIRST 1 #define SHAPE_TRIANGLE 1 #define SHAPE_CIRCLE 2 -#define SHAPE_ELLIPSE 3 -#define SHAPE_RECTANGLE 4 -#define SHAPE_LAST 4 +#define SHAPE_RING 3 +#define SHAPE_ELLIPSE 4 +#define SHAPE_RECTANGLE 5 +#define SHAPE_LAST 5 static int shape = SHAPE_FIRST; /* Variants in coordinates, if applicable */ @@ -157,6 +158,25 @@ void draw_testing_circle(int x, int y, int xradius, GP_TCircle(&context, x, y, xradius, white); } +void draw_testing_ring(int x, int y, int xradius, + __attribute__((unused)) int yradius) +{ + if (outline == 1) + GP_TCircle(&context, x, y, xradius, yellow); + + if (fill) { + if (xradius == yradius) { + GP_TFillRing(&context, x, y, xradius, xradius/2, red); + } else { + GP_TFillRing(&context, x, y, GP_MAX(xradius, yradius), + GP_MIN(xradius, yradius), red); + } + } + + if (outline == 2) + GP_TCircle(&context, x, y, xradius, white); +} + void draw_testing_ellipse(int x, int y, int xradius, int yradius) { if (outline == 1) @@ -217,6 +237,10 @@ void redraw_screen(void) draw_testing_circle(center_x, center_y, xradius, yradius); title = "CIRCLE"; break; + case SHAPE_RING: + draw_testing_ring(center_x, center_y, xradius, yradius); + title = "RING"; + break; case SHAPE_ELLIPSE: draw_testing_ellipse(center_x, center_y, xradius, yradius); title = "ELLIPSE"; ----------------------------------------------------------------------- Summary of changes: include/gfx/GP_Circle.h | 6 ++ libs/gfx/GP_Circle.c | 30 ++++++++++++ .../algo/{FillCircle.algo.h => FillRing.algo.h} | 49 +++++++++++++------- tests/SDL/shapetest.c | 30 +++++++++++- 4 files changed, 95 insertions(+), 20 deletions(-) copy libs/gfx/algo/{FillCircle.algo.h => FillRing.algo.h} (66%) 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.")
1
0
0
0
[repo.or.cz] gfxprim.git branch generate updated: f7289bd299e2a2414ab8b69f692f6e36f701a2e3
by metan
17 Jul '11
17 Jul '11
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, generate has been updated via f7289bd299e2a2414ab8b69f692f6e36f701a2e3 (commit) via d200a400aa94a961bec59b76e73979dfd6f22709 (commit) via 16295ba207ab7fc7e05031ff3319b87a07884f5d (commit) from f4f99af5bd7efbf8214eaf84a95dab162f763179 (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/f7289bd299e2a2414ab8b69f692f6e36f701…
commit f7289bd299e2a2414ab8b69f692f6e36f701a2e3 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Sun Jul 17 15:53:42 2011 +0200 Fixed GP_Color and Pixel so that SDL demos compile. diff --git a/include/core/GP_Color.h b/include/core/GP_Color.h index 3f13f95..1fddae9 100644 --- a/include/core/GP_Color.h +++ b/include/core/GP_Color.h @@ -19,13 +19,16 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * <jiri.bluebear.dluhos(a)gmail.com> * * * - * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> * + * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> * * * *****************************************************************************/ #ifndef GP_COLOR_H #define GP_COLOR_H +#include "GP_Context.h" +#include "GP_Pixel.h" + typedef enum GP_ColorName { GP_COL_BLACK, GP_COL_RED, @@ -41,4 +44,6 @@ typedef enum GP_ColorName { GP_COL_MAX, } GP_ColorName; +GP_Pixel GP_ColorNameToPixel(GP_Context *context, GP_ColorName name); + #endif /* GP_COLOR_H */ diff --git a/include/core/GP_Core.h b/include/core/GP_Core.h index 6d45291..f4d8e46 100644 --- a/include/core/GP_Core.h +++ b/include/core/GP_Core.h @@ -44,6 +44,9 @@ /* Pixeltypes */ #include "core/GP_Pixel.h" +/* Pixel conversions */ +#include "core/GP_Convert.h" + /* Individual pixel access */ #include "core/GP_GetPutPixel.h" diff --git a/include/core/GP_GetPutPixel.h b/include/core/GP_GetPutPixel.h index 4f7a146..12e9af4 100644 --- a/include/core/GP_GetPutPixel.h +++ b/include/core/GP_GetPutPixel.h @@ -25,6 +25,7 @@ #define CORE_GP_GETPUTPIXEL_H #include "GP_Context.h" +#include "GP_Transform.h" #include "GP_FnPerBpp.h" #include "GP_Pixel.h" @@ -56,6 +57,14 @@ static inline GP_Pixel GP_GetPixel_Raw(const GP_Context *context, int x, int y) */ void GP_PutPixel(GP_Context *context, int x, int y, GP_Pixel p); +static inline void GP_TPutPixel(GP_Context *context, GP_Coord x, GP_Coord y, + GP_Pixel p) +{ + GP_TRANSFORM_POINT(context, x, y); + + GP_PutPixel(context, x, y, p); +} + /* * Version of PutPixel without transformations nor border checking. */ diff --git a/include/core/GP_Pixel.h b/include/core/GP_Pixel.h index 6282bf1..de2b4a5 100644 --- a/include/core/GP_Pixel.h +++ b/include/core/GP_Pixel.h @@ -31,7 +31,6 @@ #include <stdbool.h> #include <stdint.h> -#include "GP_Color.h" #include "GP_Common.h" #include "GP_RetCode.h" #include "GP_FnPerBpp.h" @@ -158,12 +157,13 @@ static inline void GP_PixelPrint(GP_Pixel pixel, GP_PixelType type) } /* - * Match pixel type to known pixel types. + * Match pixel type to known pixel types, pixel_size is in bits. * * Returns either valid PixelType or GP_PIXEL_UNKNOWN */ GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask, - GP_Pixel bmask, GP_Pixel amask); + GP_Pixel bmask, GP_Pixel amask, + uint8_t pixel_size); #endif /* GP_PIXEL_H */ diff --git a/libs/SDL/GP_SDL_Context.c b/libs/SDL/GP_SDL_Context.c index 021b6e6..e8b7500 100644 --- a/libs/SDL/GP_SDL_Context.c +++ b/libs/SDL/GP_SDL_Context.c @@ -38,7 +38,8 @@ GP_RetCode GP_SDL_ContextFromSurface(GP_Context *context, SDL_Surface *surf) enum GP_PixelType pixeltype = GP_PixelRGBMatch(surf->format->Rmask, surf->format->Gmask, surf->format->Bmask, - surf->format->Ashift); + surf->format->Ashift, + surf->format->BitsPerPixel); if (pixeltype == GP_PIXEL_UNKNOWN) return GP_ENOIMPL; diff --git a/libs/backends/GP_Backend_SDL.c b/libs/backends/GP_Backend_SDL.c index aac4a32..c3fd9ac 100644 --- a/libs/backends/GP_Backend_SDL.c +++ b/libs/backends/GP_Backend_SDL.c @@ -58,7 +58,8 @@ inline GP_RetCode GP_SDL_ContextFromSurface( enum GP_PixelType pixeltype = GP_PixelRGBMatch(surf->format->Rmask, surf->format->Gmask, surf->format->Bmask, - surf->format->Ashift); + surf->format->Ashift, + surf->format->BitsPerPixel); if (pixeltype == GP_PIXEL_UNKNOWN) return GP_ENOIMPL; diff --git a/libs/core/GP_Color.c b/libs/core/GP_Color.c index e6f2c53..19906e3 100644 --- a/libs/core/GP_Color.c +++ b/libs/core/GP_Color.c @@ -23,6 +23,10 @@ * * *****************************************************************************/ +#include "GP_Convert.h" + +#include "GP_Color.h" + #include <stdint.h> static char *color_names[] = { @@ -53,3 +57,11 @@ static uint8_t rgb888_colors[][3] = { {0xff, 0xff, 0xff}, /* white */ }; +GP_Pixel GP_ColorNameToPixel(GP_Context *context, GP_ColorName name) +{ + GP_ASSERT(name < GP_COL_MAX); + + return GP_RGBToPixel(rgb888_colors[name][0], + rgb888_colors[name][1], + rgb888_colors[name][2], context->pixel_type); +} diff --git a/libs/core/GP_Pixel.c b/libs/core/GP_Pixel.c index d6553b1..0132c7a 100644 --- a/libs/core/GP_Pixel.c +++ b/libs/core/GP_Pixel.c @@ -41,19 +41,24 @@ static const GP_PixelTypeChannel *get_channel(const GP_PixelTypeDescription *des static int match(const GP_PixelTypeChannel *channel, GP_Pixel mask) { - if (channel == NULL) + if (channel == NULL) { + printf("%s gen %08x pass %08xn", channel->name, 0, mask); return !mask; + } GP_Pixel chmask = ~0; chmask >>= (GP_PIXEL_BITS - channel->size); chmask <<= channel->offset; + + printf("%s gen %08x pass %08xn", channel->name, chmask, mask); return (chmask == mask); } GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask, - GP_Pixel bmask, GP_Pixel amask) + GP_Pixel bmask, GP_Pixel amask, + uint8_t pixel_size) { unsigned int i; @@ -62,10 +67,27 @@ GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask, const GP_PixelTypeChannel *r, *g, *b, *a; + if (GP_PixelTypes[i].size != pixel_size) + continue; + r = get_channel(&GP_PixelTypes[i], "R"); g = get_channel(&GP_PixelTypes[i], "G"); b = get_channel(&GP_PixelTypes[i], "B"); a = get_channel(&GP_PixelTypes[i], "A"); + + printf("------------------------ %s %un", GP_PixelTypes[i].name, pixel_size); + + if (r) + printf("Matching R %i %in", r->size, r->offset); + + if (g) + printf("Matching G %i %in", g->size, g->offset); + + if (b) + printf("Matching B %i %in", b->size, b->offset); + + if (a) + printf("Matching A %i %in", a->size, a->offset); res = match(r, rmask) && match(g, gmask) && match(b, bmask) && match(a, amask); diff --git a/tests/Makefile b/tests/Makefile index 83de916..e002663 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,3 +1,3 @@ TOPDIR=.. -SUBDIRS=filters core SDL #loaders +SUBDIRS=core SDL #loaders filters include $(TOPDIR)/include.mk diff --git a/tests/SDL/fileview.c b/tests/SDL/fileview.c index c1660a0..d7eead9 100644 --- a/tests/SDL/fileview.c +++ b/tests/SDL/fileview.c @@ -237,12 +237,12 @@ int main(int argc, char *argv[]) GP_SDL_ContextFromSurface(&context, display); /* Load colors suitable for the display */ - GP_ColorNameToPixel(&context, GP_COL_WHITE, &white_pixel); - GP_ColorNameToPixel(&context, GP_COL_GRAY_LIGHT, &gray_pixel); - GP_ColorNameToPixel(&context, GP_COL_GRAY_DARK, &dark_gray_pixel); - GP_ColorNameToPixel(&context, GP_COL_BLACK, &black_pixel); - GP_ColorNameToPixel(&context, GP_COL_RED, &red_pixel); - GP_ColorNameToPixel(&context, GP_COL_BLUE, &blue_pixel); + white_pixel = GP_ColorNameToPixel(&context, GP_COL_WHITE); + gray_pixel = GP_ColorNameToPixel(&context, GP_COL_GRAY_LIGHT); + dark_gray_pixel = GP_ColorNameToPixel(&context, GP_COL_GRAY_DARK); + black_pixel = GP_ColorNameToPixel(&context, GP_COL_BLACK); + red_pixel = GP_ColorNameToPixel(&context, GP_COL_RED); + blue_pixel = GP_ColorNameToPixel(&context, GP_COL_BLUE); redraw_screen(); SDL_Flip(display); diff --git a/tests/SDL/fonttest.c b/tests/SDL/fonttest.c index 756f01d..788f652 100644 --- a/tests/SDL/fonttest.c +++ b/tests/SDL/fonttest.c @@ -231,12 +231,12 @@ int main(int argc, char *argv[]) GP_SDL_ContextFromSurface(&context, display); /* Load colors suitable for the display */ - GP_ColorNameToPixel(&context, GP_COL_WHITE, &white_pixel); - GP_ColorNameToPixel(&context, GP_COL_GRAY_LIGHT, &gray_pixel); - GP_ColorNameToPixel(&context, GP_COL_GRAY_DARK, &dark_gray_pixel); - GP_ColorNameToPixel(&context, GP_COL_BLACK, &black_pixel); - GP_ColorNameToPixel(&context, GP_COL_RED, &red_pixel); - GP_ColorNameToPixel(&context, GP_COL_BLUE, &blue_pixel); + white_pixel = GP_ColorNameToPixel(&context, GP_COL_WHITE); + gray_pixel = GP_ColorNameToPixel(&context, GP_COL_GRAY_LIGHT); + dark_gray_pixel = GP_ColorNameToPixel(&context, GP_COL_GRAY_DARK); + black_pixel = GP_ColorNameToPixel(&context, GP_COL_BLACK); + red_pixel = GP_ColorNameToPixel(&context, GP_COL_RED); + blue_pixel = GP_ColorNameToPixel(&context, GP_COL_BLUE); redraw_screen(); SDL_Flip(display); diff --git a/tests/SDL/linetest.c b/tests/SDL/linetest.c index d9925c8..7012804 100644 --- a/tests/SDL/linetest.c +++ b/tests/SDL/linetest.c @@ -72,7 +72,7 @@ void redraw_screen(void) Uint8 b = 127.0 + 127.0 * sin(start_angle + angle); GP_Pixel pixel; - GP_RGBToPixel(&context, r, 0, b, &pixel); + pixel = GP_RGBToPixel(r, 0, b, context.pixel_type); /* * Draw the line forth and back to detect any pixel change @@ -124,8 +124,8 @@ int main(int argc, char **argv) GP_SDL_ContextFromSurface(&context, display); /* Load colors in display format */ - GP_ColorNameToPixel(&context, GP_COL_BLACK, &black); - GP_ColorNameToPixel(&context, GP_COL_WHITE, &white); + black = GP_ColorNameToPixel(&context, GP_COL_BLACK); + white = GP_ColorNameToPixel(&context, GP_COL_WHITE); /* Set up the refresh timer */ timer = SDL_AddTimer(30, timer_callback, NULL); diff --git a/tests/SDL/pixeltest.c b/tests/SDL/pixeltest.c index 7b3ffe5..5ea47a1 100644 --- a/tests/SDL/pixeltest.c +++ b/tests/SDL/pixeltest.c @@ -53,7 +53,7 @@ Uint32 timer_callback(__attribute__((unused)) Uint32 interval, void draw_pixel(void) { - GP_Color pixel, conv; +// GP_Color pixel, conv; int x = random() % 320; int y = random() % 240; @@ -156,10 +156,10 @@ int main(int argc, char **argv) GP_SDL_ContextFromSurface(&context, display); /* Load pixel values compatible with the display. */ - GP_ColorNameToPixel(&context, GP_COL_RED, &red_pixel); - GP_ColorNameToPixel(&context, GP_COL_GREEN, &green_pixel); - GP_ColorNameToPixel(&context, GP_COL_BLUE, &blue_pixel); - GP_ColorNameToPixel(&context, GP_COL_WHITE, &white_pixel); + red_pixel = GP_ColorNameToPixel(&context, GP_COL_RED); + green_pixel = GP_ColorNameToPixel(&context, GP_COL_GREEN); + blue_pixel = GP_ColorNameToPixel(&context, GP_COL_BLUE); + white_pixel = GP_ColorNameToPixel(&context, GP_COL_WHITE); /* Set up the refresh timer */ timer = SDL_AddTimer(30, timer_callback, NULL); diff --git a/tests/SDL/randomshapetest.c b/tests/SDL/randomshapetest.c index b46125d..61c9f6f 100644 --- a/tests/SDL/randomshapetest.c +++ b/tests/SDL/randomshapetest.c @@ -178,7 +178,7 @@ void redraw_screen(void) /* Pick a random color for drawing. */ GP_Pixel pixel; - GP_RGBToPixel(&context, random() % 256, random() % 256, random() % 256, &pixel); + pixel = GP_RGBToPixel(&context, random() % 256, random() % 256, random() % 256); switch (shape) { case SHAPE_CIRCLE: @@ -309,8 +309,8 @@ int main(int argc, char *argv[]) GP_SDL_ContextFromSurface(&context, display); - GP_ColorNameToPixel(&context, GP_COL_WHITE, &white); - GP_ColorNameToPixel(&context, GP_COL_BLACK, &black); + white = GP_ColorNameToPixel(&context, GP_COL_WHITE); + black = GP_ColorNameToPixel(&context, GP_COL_BLACK); /* Set up the refresh timer */ timer = SDL_AddTimer(60, timer_callback, NULL); diff --git a/tests/SDL/shapetest.c b/tests/SDL/shapetest.c index fb85b2e..44f04cf 100644 --- a/tests/SDL/shapetest.c +++ b/tests/SDL/shapetest.c @@ -463,13 +463,13 @@ int main(int argc, char ** argv) GP_SDL_ContextFromSurface(&context, display); /* Load colors compatible with the display */ - GP_ColorNameToPixel(&context, GP_COL_BLACK, &black); - GP_ColorNameToPixel(&context, GP_COL_WHITE, &white); - GP_ColorNameToPixel(&context, GP_COL_YELLOW, &yellow); - GP_ColorNameToPixel(&context, GP_COL_GREEN, &green); - GP_ColorNameToPixel(&context, GP_COL_RED, &red); - GP_ColorNameToPixel(&context, GP_COL_GRAY_LIGHT, &gray); - GP_ColorNameToPixel(&context, GP_COL_GRAY_DARK, &darkgray); + black = GP_ColorNameToPixel(&context, GP_COL_BLACK); + white = GP_ColorNameToPixel(&context, GP_COL_WHITE); + yellow = GP_ColorNameToPixel(&context, GP_COL_YELLOW); + green = GP_ColorNameToPixel(&context, GP_COL_GREEN); + red = GP_ColorNameToPixel(&context, GP_COL_RED); + gray = GP_ColorNameToPixel(&context, GP_COL_GRAY_LIGHT); + darkgray = GP_ColorNameToPixel(&context, GP_COL_GRAY_DARK); /* Set up the refresh timer */ timer = SDL_AddTimer(60, timer_callback, NULL); diff --git a/tests/SDL/sierpinsky.c b/tests/SDL/sierpinsky.c index 1136a45..333107f 100644 --- a/tests/SDL/sierpinsky.c +++ b/tests/SDL/sierpinsky.c @@ -55,7 +55,7 @@ static void sierpinsky(double x1, double y1, double x4, double y4, int iter) { double x2, y2, x3, y3, x5, y5; GP_Pixel pixel; - GP_RGBToPixel(context, 0, 0, 255-16*iter, &pixel); + pixel = GP_RGBToPixel(context, 0, 0, 255-16*iter); if (iter <= 0) { if (draw_edge) @@ -162,10 +162,10 @@ int main(void) display = SDL_GetVideoSurface(); context = GP_GetBackendVideoContext(); - GP_ColorNameToPixel(context, GP_COL_BLACK, &black); - GP_ColorNameToPixel(context, GP_COL_BLUE, &blue); - GP_ColorNameToPixel(context, GP_COL_GRAY_LIGHT, &gray); - GP_ColorNameToPixel(context, GP_COL_RED, &red); + black = GP_ColorNameToPixel(context, GP_COL_BLACK); + blue = GP_ColorNameToPixel(context, GP_COL_BLUE); + gray = GP_ColorNameToPixel(context, GP_COL_GRAY_LIGHT); + red = GP_ColorNameToPixel(context, GP_COL_RED); iter = 0; draw(display->w/2, display->h/2, l, iter); diff --git a/tests/SDL/symbolstest.c b/tests/SDL/symbolstest.c index 57a9722..532c13a 100644 --- a/tests/SDL/symbolstest.c +++ b/tests/SDL/symbolstest.c @@ -29,6 +29,8 @@ #include "GP_SDL.h" +static GP_Pixel black; + /* The surface used as a display (in fact it is a software surface). */ SDL_Surface *display = NULL; GP_Context context; @@ -39,9 +41,6 @@ SDL_TimerID timer; /* An event used for signaling that the timer was triggered. */ SDL_UserEvent timer_event; -/* Globally used colors. */ -GP_Pixel white, black; - static int pause_flag = 0; static int fill_flag = 0; @@ -85,18 +84,14 @@ void clear_screen(void) void redraw_screen(void) { - /* Random color. */ - GP_Color color = GP_RGB888_PACK(random() % 256, - random() % 256, - random() % 256); - if (pause_flag) return; SDL_LockSurface(display); GP_Pixel pixel; - GP_ColorToPixel(&context, color, &pixel); + pixel = GP_RGBToPixel(random() % 256, random() % 256, + random() % 256, context.pixel_type); draw_random_symbol(pixel); @@ -177,9 +172,8 @@ int main(int argc, char *argv[]) GP_SDL_ContextFromSurface(&context, display); - GP_ColorNameToPixel(&context, GP_COL_WHITE, &white); - GP_ColorNameToPixel(&context, GP_COL_BLACK, &black); - + black = GP_ColorNameToPixel(&context, GP_COL_BLACK); + /* Set up the refresh timer */ timer = SDL_AddTimer(60, timer_callback, NULL); if (timer == 0) { diff --git a/tests/SDL/textaligntest.c b/tests/SDL/textaligntest.c index 7731860..348eab7 100644 --- a/tests/SDL/textaligntest.c +++ b/tests/SDL/textaligntest.c @@ -159,12 +159,9 @@ int main(void) GP_SDL_ContextFromSurface(&context, display); /* Load colors suitable for the display */ - GP_ColorNameToPixel(&context, GP_COL_YELLOW, &yellow_pixel); - GP_ColorNameToPixel(&context, GP_COL_BLUE, &blue_pixel); - GP_ColorNameToPixel(&context, GP_COL_RED, &red_pixel); - GP_ColorNameToPixel(&context, GP_COL_GREEN, &green_pixel); - GP_ColorNameToPixel(&context, GP_COL_BLACK, &black_pixel); - GP_ColorNameToPixel(&context, GP_COL_GRAY_DARK, &darkgray_pixel); + black_pixel = GP_ColorNameToPixel(&context, GP_COL_BLACK); + red_pixel = GP_ColorNameToPixel(&context, GP_COL_RED); + blue_pixel = GP_ColorNameToPixel(&context, GP_COL_BLUE); redraw_screen(); SDL_Flip(display); diff --git a/tests/SDL/trianglefps.c b/tests/SDL/trianglefps.c index 8204521..17c0604 100644 --- a/tests/SDL/trianglefps.c +++ b/tests/SDL/trianglefps.c @@ -70,16 +70,15 @@ void draw_frame(void) int y1 = random() % display->h; int x2 = display->w/2; int y2 = random() % display->h; - GP_Color color = GP_RGB888_PACK(random() % 255, random() % 255, random() % 255); GP_Pixel pixel; - GP_ColorToPixel(&context, color, &pixel); - - if (filled) { + pixel = GP_RGBToPixel(random() % 255, random() % 255, + random() % 255, context.pixel_type); + + if (filled) GP_FillTriangle(&context, x0, y0, x1, y1, x2, y2, pixel); - } else { + else GP_Triangle(&context, x0, y0, x1, y1, x2, y2, pixel); - } } void event_loop(void) @@ -160,8 +159,8 @@ int main(int argc, char ** argv) GP_SDL_ContextFromSurface(&context, display); - GP_ColorNameToPixel(&context, GP_COL_WHITE, &white); - GP_ColorNameToPixel(&context, GP_COL_BLACK, &black); + white = GP_ColorNameToPixel(&context, GP_COL_WHITE); + black = GP_ColorNameToPixel(&context, GP_COL_BLACK); /* Set up the timer */ timer = SDL_AddTimer(1000, timer_callback, NULL);
http://repo.or.cz/w/gfxprim.git/commit/d200a400aa94a961bec59b76e73979dfd6f2…
commit d200a400aa94a961bec59b76e73979dfd6f22709 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Sun Jul 17 15:41:30 2011 +0200 Fix the default types, offsets was backwards. diff --git a/pylib/pixeltypes.py b/pylib/pixeltypes.py index 4762255..b035b6a 100644 --- a/pylib/pixeltypes.py +++ b/pylib/pixeltypes.py @@ -4,6 +4,7 @@ # # 2011 - Tomas Gavenciak <gavento(a)ucw.cz> +# 2011 - Cyril Hrubis <metan(a)ucw.cz> # # Every call to PixelType defines one new GP_PixelType, order defines # the numbering. Undefined type is defined automatically. @@ -19,28 +20,28 @@ # PixelType(name='RGBx8888', size=32, chanslist=[ - ('R', 0, 8), + ('R', 16, 8), ('G', 8, 8), - ('B', 16, 8)]) + ('B', 0, 8)]) PixelType(name='RGBA8888', size=32, chanslist=[ - ('R', 0, 8), - ('G', 8, 8), - ('B', 16, 8), - ('A', 24, 8)]) + ('R', 24, 8), + ('G', 16, 8), + ('B', 8, 8), + ('A', 0, 8)]) PixelType(name='RGB888', size=24, chanslist=[ - ('R', 0, 8), + ('R', 16, 8), ('G', 8, 8), - ('B', 16, 8)]) + ('B', 0, 8)]) PixelType(name='RGB565', size=16, chanslist=[ - ('R', 0, 5), + ('R', 11, 5), ('G', 5, 6), - ('B', 11, 5)]) + ('B', 0, 5)]) # # Palette types
http://repo.or.cz/w/gfxprim.git/commit/16295ba207ab7fc7e05031ff3319b87a0788…
commit 16295ba207ab7fc7e05031ff3319b87a07884f5d Author: Cyril Hrubis <metan(a)ucw.cz> Date: Sun Jul 17 15:37:45 2011 +0200 Delete debug lines. diff --git a/pylib/Makefile b/pylib/Makefile index af75868..2d01e96 100644 --- a/pylib/Makefile +++ b/pylib/Makefile @@ -8,7 +8,4 @@ CLEAN+=$(patsubst %.py, %.pyc, ${PYTHON_FILES}) include $(TOPDIR)/include.mk all: - ls $(PYLIBSDIR) - echo $(PYTHON_FILES) - echo $(CLEAN) @true ----------------------------------------------------------------------- Summary of changes: include/core/GP_Color.h | 7 ++++++- include/core/GP_Core.h | 3 +++ include/core/GP_GetPutPixel.h | 9 +++++++++ include/core/GP_Pixel.h | 6 +++--- libs/SDL/GP_SDL_Context.c | 3 ++- libs/backends/GP_Backend_SDL.c | 3 ++- libs/core/GP_Color.c | 12 ++++++++++++ libs/core/GP_Pixel.c | 26 ++++++++++++++++++++++++-- pylib/Makefile | 3 --- pylib/pixeltypes.py | 21 +++++++++++---------- tests/Makefile | 2 +- tests/SDL/fileview.c | 12 ++++++------ tests/SDL/fonttest.c | 12 ++++++------ tests/SDL/linetest.c | 6 +++--- tests/SDL/pixeltest.c | 10 +++++----- tests/SDL/randomshapetest.c | 6 +++--- tests/SDL/shapetest.c | 14 +++++++------- tests/SDL/sierpinsky.c | 10 +++++----- tests/SDL/symbolstest.c | 18 ++++++------------ tests/SDL/textaligntest.c | 9 +++------ tests/SDL/trianglefps.c | 15 +++++++-------- 21 files changed, 124 insertions(+), 83 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.")
1
0
0
0
[repo.or.cz] gfxprim.git branch generate updated: f4f99af5bd7efbf8214eaf84a95dab162f763179
by metan
17 Jul '11
17 Jul '11
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, generate has been updated via f4f99af5bd7efbf8214eaf84a95dab162f763179 (commit) from 80e05d567a9526b7bfb21cd458572c364502e4a0 (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/f4f99af5bd7efbf8214eaf84a95dab162f76…
commit f4f99af5bd7efbf8214eaf84a95dab162f763179 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Sun Jul 17 14:41:01 2011 +0200 Fixed Filters to work with generated code. diff --git a/include/core/GP_DefFnPerBpp.h b/include/core/GP_DefFnPerBpp.h index 6da6754..534a451 100644 --- a/include/core/GP_DefFnPerBpp.h +++ b/include/core/GP_DefFnPerBpp.h @@ -51,4 +51,25 @@ GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 24BPP) GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 32BPP) +/* + * 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) + +#define GP_DEF_FFN_PER_BPP(fname, MACRO_NAME) + GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, 1BPP_LE) + GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, 1BPP_BE) + GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, 2BPP_LE) + GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, 2BPP_BE) + GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, 4BPP_LE) + GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, 4BPP_BE) + GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, 8BPP) + GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, 16BPP) + GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, 24BPP) + GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, 32BPP) + #endif /* GP_DEF_FN_PER_BPP_H */ diff --git a/libs/filters/GP_Rotate.c b/libs/filters/GP_Rotate.c index e73c106..adb0ce2 100644 --- a/libs/filters/GP_Rotate.c +++ b/libs/filters/GP_Rotate.c @@ -25,14 +25,14 @@ #include "core/GP_Core.h" #include "core/GP_FnPerBpp.h" +#include "core/GP_DefFnPerBpp.h" #include "GP_Rotate.h" -#include "algo/GP_MirrorV.algo.h" -#include "algo/GP_Rotate.algo.h" - #include <string.h> +#include "algo/GP_MirrorV.algo.h" + GP_RetCode GP_MirrorH(GP_Context *context) { uint32_t bpr = context->bytes_per_row; @@ -56,63 +56,43 @@ GP_RetCode GP_MirrorH(GP_Context *context) return GP_ESUCCESS; } -DEF_MIRRORV_FN(GP_MirrorV1bpp, GP_Context *, GP_Pixel, - GP_PUTPIXEL_1BPP, GP_GETPIXEL_1BPP) -DEF_MIRRORV_FN(GP_MirrorV2bpp, GP_Context *, GP_Pixel, - GP_PUTPIXEL_2BPP, GP_GETPIXEL_2BPP) -DEF_MIRRORV_FN(GP_MirrorV4bpp, GP_Context *, GP_Pixel, - GP_PUTPIXEL_4BPP, GP_GETPIXEL_4BPP) -DEF_MIRRORV_FN(GP_MirrorV8bpp, GP_Context *, GP_Pixel, - GP_PUTPIXEL_8BPP, GP_GETPIXEL_8BPP) -DEF_MIRRORV_FN(GP_MirrorV16bpp, GP_Context *, GP_Pixel, - GP_PUTPIXEL_16BPP, GP_GETPIXEL_16BPP) -DEF_MIRRORV_FN(GP_MirrorV24bpp, GP_Context *, GP_Pixel, - GP_PUTPIXEL_24BPP, GP_GETPIXEL_24BPP) -DEF_MIRRORV_FN(GP_MirrorV32bpp, GP_Context *, GP_Pixel, - GP_PUTPIXEL_32BPP, GP_GETPIXEL_32BPP) +/* Generate mirror functions per BPP */ +GP_DEF_FFN_PER_BPP(GP_MirrorV, DEF_MIRRORV_FN) GP_RetCode GP_MirrorV(GP_Context *context) { if (context == NULL) return GP_ENULLPTR; - GP_FN_PER_BPP(GP_MirrorV, context->bpp, context); + GP_FN_PER_BPP_CONTEXT(GP_MirrorV, context, context); return GP_ESUCCESS; } -DEF_ROTATECW_FN(GP_RotateCW1bpp, GP_Context *, GP_PUTPIXEL_1BPP, GP_GETPIXEL_1BPP) -DEF_ROTATECW_FN(GP_RotateCW2bpp, GP_Context *, GP_PUTPIXEL_2BPP, GP_GETPIXEL_2BPP) -DEF_ROTATECW_FN(GP_RotateCW4bpp, GP_Context *, GP_PUTPIXEL_4BPP, GP_GETPIXEL_4BPP) -DEF_ROTATECW_FN(GP_RotateCW8bpp, GP_Context *, GP_PUTPIXEL_8BPP, GP_GETPIXEL_8BPP) -DEF_ROTATECW_FN(GP_RotateCW16bpp, GP_Context *, GP_PUTPIXEL_16BPP, GP_GETPIXEL_16BPP) -DEF_ROTATECW_FN(GP_RotateCW24bpp, GP_Context *, GP_PUTPIXEL_24BPP, GP_GETPIXEL_24BPP) -DEF_ROTATECW_FN(GP_RotateCW32bpp, GP_Context *, GP_PUTPIXEL_32BPP, GP_GETPIXEL_32BPP) +#include "algo/GP_Rotate.algo.h" + +/* Generate Rotate functions per BPP */ +GP_DEF_FFN_PER_BPP(GP_RotateCW, DEF_ROTATECW_FN) GP_RetCode GP_RotateCW(GP_Context *context) { if (context == NULL) return GP_ENULLPTR; - GP_FN_RET_PER_BPP(GP_RotateCW, context->bpp, context); + GP_FN_RET_PER_BPP_CONTEXT(GP_RotateCW, context, context); return GP_ENOIMPL; } -DEF_ROTATECCW_FN(GP_RotateCCW1bpp, GP_Context *, GP_PUTPIXEL_1BPP, GP_GETPIXEL_1BPP) -DEF_ROTATECCW_FN(GP_RotateCCW2bpp, GP_Context *, GP_PUTPIXEL_2BPP, GP_GETPIXEL_2BPP) -DEF_ROTATECCW_FN(GP_RotateCCW4bpp, GP_Context *, GP_PUTPIXEL_4BPP, GP_GETPIXEL_4BPP) -DEF_ROTATECCW_FN(GP_RotateCCW8bpp, GP_Context *, GP_PUTPIXEL_8BPP, GP_GETPIXEL_8BPP) -DEF_ROTATECCW_FN(GP_RotateCCW16bpp, GP_Context *, GP_PUTPIXEL_16BPP, GP_GETPIXEL_16BPP) -DEF_ROTATECCW_FN(GP_RotateCCW24bpp, GP_Context *, GP_PUTPIXEL_24BPP, GP_GETPIXEL_24BPP) -DEF_ROTATECCW_FN(GP_RotateCCW32bpp, GP_Context *, GP_PUTPIXEL_32BPP, GP_GETPIXEL_32BPP) +/* Generate Rotate functions per BPP */ +GP_DEF_FFN_PER_BPP(GP_RotateCCW, DEF_ROTATECCW_FN) GP_RetCode GP_RotateCCW(GP_Context *context) { if (context == NULL) return GP_ENULLPTR; - GP_FN_RET_PER_BPP(GP_RotateCCW, context->bpp, context); + GP_FN_RET_PER_BPP_CONTEXT(GP_RotateCCW, context, context); return GP_ENOIMPL; } diff --git a/libs/filters/algo/GP_Rotate.algo.h b/libs/filters/algo/GP_Rotate.algo.h index 2d5cf28..e6ea14d 100644 --- a/libs/filters/algo/GP_Rotate.algo.h +++ b/libs/filters/algo/GP_Rotate.algo.h @@ -27,7 +27,7 @@ #include "core/GP_Common.h" #include "core/GP_Context.h" -#define DEF_ROTATECW_FN(FN_NAME, CONTEXT_T, PUTPIXEL, GETPIXEL) +#define DEF_ROTATECW_FN(FN_NAME, CONTEXT_T, PIXEL_T, PUTPIXEL, GETPIXEL) GP_RetCode FN_NAME(CONTEXT_T context) { uint32_t x, y; @@ -58,7 +58,7 @@ GP_RetCode FN_NAME(CONTEXT_T context) return GP_ESUCCESS; } -#define DEF_ROTATECCW_FN(FN_NAME, CONTEXT_T, PUTPIXEL, GETPIXEL) +#define DEF_ROTATECCW_FN(FN_NAME, CONTEXT_T, PIXEL_T, PUTPIXEL, GETPIXEL) GP_RetCode FN_NAME(CONTEXT_T context) { uint32_t x, y; diff --git a/tests/Makefile b/tests/Makefile index 71029bb..83de916 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,3 +1,3 @@ TOPDIR=.. -SUBDIRS=loaders filters core SDL +SUBDIRS=filters core SDL #loaders include $(TOPDIR)/include.mk ----------------------------------------------------------------------- Summary of changes: include/core/GP_DefFnPerBpp.h | 21 +++++++++++++++ libs/filters/GP_Rotate.c | 48 ++++++++++------------------------- libs/filters/algo/GP_Rotate.algo.h | 4 +- tests/Makefile | 2 +- 4 files changed, 38 insertions(+), 37 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.")
1
0
0
0
[repo.or.cz] gfxprim.git branch generate updated: 80e05d567a9526b7bfb21cd458572c364502e4a0
by metan
17 Jul '11
17 Jul '11
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, generate has been updated via 80e05d567a9526b7bfb21cd458572c364502e4a0 (commit) from cfc6c022b5368c44e60c7f494865c651066fb117 (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/80e05d567a9526b7bfb21cd458572c364502…
commit 80e05d567a9526b7bfb21cd458572c364502e4a0 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Sun Jul 17 14:21:10 2011 +0200 Fixed Text library compilation. diff --git a/libs/text/GP_Text.c b/libs/text/GP_Text.c index af11a48..4ffae23 100644 --- a/libs/text/GP_Text.c +++ b/libs/text/GP_Text.c @@ -19,25 +19,21 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * <jiri.bluebear.dluhos(a)gmail.com> * * * - * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> * + * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> * * * *****************************************************************************/ #include "algo/Text.algo.h" #include "gfx/GP_Gfx.h" #include "core/GP_FnPerBpp.h" +#include "core/GP_DefFnPerBpp.h" #include "GP_Text.h" static GP_TextStyle DefaultStyle = GP_DEFAULT_TEXT_STYLE; /* Generate drawing functions for various bit depths. */ -DEF_TEXT_FN(GP_Text1bpp, GP_Context *, GP_Pixel, GP_HLine1bpp) -DEF_TEXT_FN(GP_Text2bpp, GP_Context *, GP_Pixel, GP_HLine2bpp) -DEF_TEXT_FN(GP_Text4bpp, GP_Context *, GP_Pixel, GP_HLine4bpp) -DEF_TEXT_FN(GP_Text8bpp, GP_Context *, GP_Pixel, GP_HLine8bpp) -DEF_TEXT_FN(GP_Text16bpp, GP_Context *, GP_Pixel, GP_HLine16bpp) -DEF_TEXT_FN(GP_Text24bpp, GP_Context *, GP_Pixel, GP_HLine24bpp) -DEF_TEXT_FN(GP_Text32bpp, GP_Context *, GP_Pixel, GP_HLine32bpp) +GP_DEF_FILL_FN_PER_BPP(GP_Text, DEF_TEXT_FN) + DEF_TEXT_FN(GP_TText_internal, GP_Context *, GP_Pixel, GP_THLine) GP_RetCode GP_Text(GP_Context *context, const GP_TextStyle *style, @@ -87,7 +83,7 @@ GP_RetCode GP_Text(GP_Context *context, const GP_TextStyle *style, return GP_EINVAL; } - GP_FN_PER_BPP(GP_Text, context->bpp, context, + GP_FN_PER_BPP_CONTEXT(GP_Text, context, context, style, topleft_x, topleft_y, str, pixel); return GP_ESUCCESS; ----------------------------------------------------------------------- Summary of changes: libs/text/GP_Text.c | 14 +++++--------- 1 files changed, 5 insertions(+), 9 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.")
1
0
0
0
[repo.or.cz] gfxprim.git branch generate updated: cfc6c022b5368c44e60c7f494865c651066fb117
by metan
17 Jul '11
17 Jul '11
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, generate has been updated via cfc6c022b5368c44e60c7f494865c651066fb117 (commit) from ecca5686f36c35b12f2bd72dd5ef16165da1ec8c (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/cfc6c022b5368c44e60c7f494865c651066f…
commit cfc6c022b5368c44e60c7f494865c651066fb117 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Sun Jul 17 14:13:32 2011 +0200 Made the gfx library work with the generated code. diff --git a/include/core/GP_Context.h b/include/core/GP_Context.h index ce85f65..35b8ae7 100644 --- a/include/core/GP_Context.h +++ b/include/core/GP_Context.h @@ -30,13 +30,9 @@ #include <unistd.h> #include "GP_Common.h" +#include "GP_Types.h" #include "GP_Pixel.h" -/* Integer type for coordinates: x, y, width, height, ... - * Should be signed to hold negative values as well. */ -typedef int GP_Coord; -typedef unsigned int GP_Size; - /* This structure holds all information needed for drawing into an image. */ typedef struct GP_Context { uint8_t *pixels; /* pointer to image pixels */ diff --git a/include/gfx/GP_Gfx.h b/include/core/GP_DefFnPerBpp.h similarity index 54% copy from include/gfx/GP_Gfx.h copy to include/core/GP_DefFnPerBpp.h index aa578b4..6da6754 100644 --- a/include/gfx/GP_Gfx.h +++ b/include/core/GP_DefFnPerBpp.h @@ -16,41 +16,39 @@ * 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> * + * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> * * * *****************************************************************************/ /* - - This is a main header for gfx part. - + * Macros that gets MACRO template for drawing function and generates drawing + * functions for each BPP. + * + * This functions are later used by GP_FN_PER_BPP_CONTEXT() to generate one + * drawing function for all BPP Yay! */ +#ifndef GP_DEF_FN_PER_BPP_H +#define GP_DEF_FN_PER_BPP_H + +#define GP_DEF_DRAW_FN_PER_BPP(fname, MACRO_NAME) + GP_DEF_FN_PER_BPP(fname, MACRO_NAME, GP_PutPixel_Raw_) -#ifndef GP_GFX_H -#define GP_GFX_H +#define GP_DEF_FILL_FN_PER_BPP(fname, MACRO_NAME) + GP_DEF_FN_PER_BPP(fname, MACRO_NAME, GP_HLine_) -/* basic definitions and structures */ -#include "core/GP_Common.h" -#include "core/GP_Transform.h" -#include "core/GP_Context.h" -#include "core/GP_WritePixel.h" -#include "core/GP_GetPutPixel.h" -#include "core/GP_Color.h" +#define GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, bpp) + MACRO_NAME(fname##_##bpp, GP_Context *, GP_Pixel, fdraw##bpp) -/* 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_Polygon.h" -#include "GP_Symbol.h" +#define GP_DEF_FN_PER_BPP(fname, MACRO_NAME, fdraw) + GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 1BPP_LE) + GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 1BPP_BE) + GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 2BPP_LE) + GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 2BPP_BE) + GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 4BPP_LE) + GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 4BPP_BE) + GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 8BPP) + GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 16BPP) + GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 24BPP) + GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 32BPP) -#endif /* GP_GFX_H */ +#endif /* GP_DEF_FN_PER_BPP_H */ diff --git a/include/gfx/GP_Polygon.h b/include/core/GP_Types.h similarity index 75% copy from include/gfx/GP_Polygon.h copy to include/core/GP_Types.h index dc4a6e1..e3d0f55 100644 --- a/include/gfx/GP_Polygon.h +++ b/include/core/GP_Types.h @@ -16,19 +16,20 @@ * 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> * + * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> * * * *****************************************************************************/ -#ifndef GP_FILL_POLYGON_H -#define GP_FILL_POLYGON_H +#ifndef GP_TYPES_H +#define GP_TYPES_H -#include "core/GP_Context.h" +#include <stdint.h> -void GP_FillPolygon(GP_Context *context, int vertex_count, const int *xy, - GP_Pixel pixel); +/* + * Integer type for coordinates: x, y, width, height, ... + * Should be signed to hold negative values as well. + */ +typedef int GP_Coord; +typedef unsigned int GP_Size; -#endif /* GP_FILL_POLYGON_H */ +#endif /* GP_TYPES_H */ diff --git a/include/gfx/GP_Circle.h b/include/gfx/GP_Circle.h index 6360e72..aaab27a 100644 --- a/include/gfx/GP_Circle.h +++ b/include/gfx/GP_Circle.h @@ -28,16 +28,16 @@ #include "core/GP_Context.h" -void GP_Circle(GP_Context *context, int xcenter, int ycenter, - unsigned int r, GP_Pixel pixel); +void GP_Circle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, + GP_Size r, GP_Pixel pixel); -void GP_TCircle(GP_Context *context, int xcenter, int ycenter, - unsigned int r, GP_Pixel pixel); +void GP_TCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, + GP_Size r, GP_Pixel pixel); -void GP_FillCircle(GP_Context *context, int xcenter, int ycenter, - unsigned int r, GP_Pixel pixel); +void GP_FillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, + GP_Size r, GP_Pixel pixel); -void GP_TFillCircle(GP_Context *context, int xcenter, int ycenter, - unsigned int r, GP_Pixel pixel); +void GP_TFillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, + GP_Size r, GP_Pixel pixel); #endif /* GP_CIRCLE_H */ diff --git a/include/gfx/GP_Ellipse.h b/include/gfx/GP_Ellipse.h index eeb6d5a..ef10808 100644 --- a/include/gfx/GP_Ellipse.h +++ b/include/gfx/GP_Ellipse.h @@ -28,17 +28,17 @@ #include "core/GP_Context.h" -void GP_Ellipse(GP_Context *context, int xcenter, int ycenter, - unsigned int a, unsigned int b, GP_Pixel pixel); +void GP_Ellipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, + GP_Size a, GP_Size b, GP_Pixel pixel); -void GP_TEllipse(GP_Context *context, int xcenter, int ycenter, - unsigned int a, unsigned int b, GP_Pixel pixel); +void GP_TEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, + GP_Size a, GP_Size b, GP_Pixel pixel); -void GP_FillEllipse(GP_Context *context, int xcenter, int ycenter, - unsigned int a, unsigned int b, GP_Pixel pixel); +void GP_FillEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, + GP_Size a, GP_Size b, GP_Pixel pixel); -void GP_TFillEllipse(GP_Context *context, int xcenter, int ycenter, - unsigned int a, unsigned int b, GP_Pixel pixel); +void GP_TFillEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, + GP_Size a, GP_Size b, GP_Pixel pixel); #endif /* GP_ELLIPSE_H */ diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_Gfx.h index aa578b4..4639b1f 100644 --- a/include/gfx/GP_Gfx.h +++ b/include/gfx/GP_Gfx.h @@ -34,6 +34,7 @@ /* basic definitions and structures */ #include "core/GP_Common.h" +#include "core/GP_Types.h" #include "core/GP_Transform.h" #include "core/GP_Context.h" #include "core/GP_WritePixel.h" diff --git a/include/gfx/GP_HLine.h b/include/gfx/GP_HLine.h index ee3c674..66e2b79 100644 --- a/include/gfx/GP_HLine.h +++ b/include/gfx/GP_HLine.h @@ -28,26 +28,59 @@ #include "core/GP_Context.h" -void GP_HLine1bpp(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel); -void GP_HLine2bpp(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel); -void GP_HLine8bpp(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel); -void GP_HLine4bpp(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel); -void GP_HLine16bpp(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel); -void GP_HLine24bpp(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel); -void GP_HLine32bpp(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel); +void GP_HLine_1BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); -void GP_HLineXXY(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel); +void GP_HLine_1BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); -void GP_HLineXYW(GP_Context *context, int x, int y, unsigned int w, +void GP_HLine_2BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); + +void GP_HLine_2BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); + +void GP_HLine_4BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); + +void GP_HLine_4BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); + +void GP_HLine_8BPP(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); + +void GP_HLine_16BPP(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); + +void GP_HLine_24BPP(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); + +void GP_HLine_32BPP(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); + +void GP_HLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); + +void GP_HLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w, GP_Pixel pixel); -void GP_THLineXXY(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel); +void GP_THLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel); -void GP_THLineXYW(GP_Context *context, int x, int y, unsigned int w, +void GP_THLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w, GP_Pixel pixel); /* default argument set is XXY */ -#define GP_HLine GP_HLineXXY -#define GP_THLine GP_THLineXXY +static inline void GP_HLine(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel p) +{ + GP_HLineXXY(context, x0, x1, y, p); +} + +static inline void GP_THLine(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel p) +{ + GP_THLineXXY(context, x0, x1, y, p); +} #endif /* GP_HLINE_H */ diff --git a/include/gfx/GP_Line.h b/include/gfx/GP_Line.h index b5587bd..be0b67f 100644 --- a/include/gfx/GP_Line.h +++ b/include/gfx/GP_Line.h @@ -28,19 +28,22 @@ #include "core/GP_Context.h" -void GP_Line8bpp(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel); -void GP_Line16bpp(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel); -void GP_Line24bpp(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel); -void GP_Line32bpp(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel); - -void GP_Line(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel); - -void GP_TLine(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel); +void GP_Line8bpp(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel); + +void GP_Line16bpp(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel); + +void GP_Line24bpp(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel); + +void GP_Line32bpp(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel); + +void GP_Line(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel); + +void GP_TLine(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel); #endif /* GP_LINE_H */ diff --git a/include/gfx/GP_Polygon.h b/include/gfx/GP_Polygon.h index dc4a6e1..eee3bcc 100644 --- a/include/gfx/GP_Polygon.h +++ b/include/gfx/GP_Polygon.h @@ -23,12 +23,12 @@ * * *****************************************************************************/ -#ifndef GP_FILL_POLYGON_H -#define GP_FILL_POLYGON_H +#ifndef GP_POLYGON_H +#define GP_POLYGON_H #include "core/GP_Context.h" -void GP_FillPolygon(GP_Context *context, int vertex_count, const int *xy, - GP_Pixel pixel); +void GP_FillPolygon(GP_Context *context, int vertex_count, const GP_Coord *xy, + GP_Pixel pixel); -#endif /* GP_FILL_POLYGON_H */ +#endif /* GP_POLYGON_H */ diff --git a/include/gfx/GP_Rect.h b/include/gfx/GP_Rect.h index a0085e8..984e0ee 100644 --- a/include/gfx/GP_Rect.h +++ b/include/gfx/GP_Rect.h @@ -28,33 +28,33 @@ #include "core/GP_Context.h" -void GP_RectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel); +void GP_RectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel); -void GP_RectXYWH(GP_Context *context, int x, int y, - unsigned int w, unsigned int h, GP_Pixel pixel); +void GP_RectXYWH(GP_Context *context, GP_Coord x, GP_Coord y, + GP_Size w, GP_Size h, GP_Pixel pixel); -void GP_TRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel); +void GP_TRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel); -void GP_TRectXYWH(GP_Context *context, int x, int y, - unsigned int w, unsigned int h, GP_Pixel pixel); +void GP_TRectXYWH(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 */ #define GP_Rect GP_RectXYXY #define GP_TRect GP_TRectXYXY -void GP_FillRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel); +void GP_FillRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel); -void GP_FillRectXYWH(GP_Context *context, int x, int y, - unsigned int w, unsigned int h, GP_Pixel pixel); +void GP_FillRectXYWH(GP_Context *context, GP_Coord x, GP_Coord y, + GP_Size w, GP_Size h, GP_Pixel pixel); -void GP_TFillRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel); +void GP_TFillRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel); -void GP_TFillRectXYWH(GP_Context *context, int x, int y, - unsigned int w, unsigned int h, GP_Pixel pixel); +void GP_TFillRectXYWH(GP_Context *context, GP_Coord x, GP_Coord y, + GP_Size w, GP_Size h, GP_Pixel pixel); #define GP_FillRect GP_FillRectXYXY #define GP_TFillRect GP_TFillRectXYXY diff --git a/include/gfx/GP_Symbol.h b/include/gfx/GP_Symbol.h index 5aa3f2c..648a11e 100644 --- a/include/gfx/GP_Symbol.h +++ b/include/gfx/GP_Symbol.h @@ -30,7 +30,7 @@ #ifndef GP_SYMBOL_H #define GP_SYMBOL_H -#include "core/GP_Context.h" +#include "core/GP_Types.h" typedef enum GP_SymbolType { GP_SYM_TRIANGLE_UP, @@ -41,15 +41,19 @@ typedef enum GP_SymbolType { } GP_SymbolType; void GP_Symbol(GP_Context *context, GP_SymbolType sym, - int x, int y, int w, int h, GP_Pixel pixel); + GP_Coord x, GP_Coord y, + GP_Size w, GP_Size h, GP_Pixel pixel); void GP_TSymbol(GP_Context *context, GP_SymbolType sym, - int x, int y, int w, int h, GP_Pixel pixel); + GP_Coord x, GP_Coord y, + GP_Size w, GP_Size h, GP_Pixel pixel); void GP_FillSymbol(GP_Context *context, GP_SymbolType sym, - int x, int y, int w, int h, GP_Pixel pixel); + GP_Coord x, GP_Coord y, + GP_Size w, GP_Size h, GP_Pixel pixel); void GP_TFillSymbol(GP_Context *context, GP_SymbolType sym, - int x, int y, int w, int h, GP_Pixel pixel); + GP_Coord x, GP_Coord y, + GP_Size w, GP_Size h, GP_Pixel pixel); #endif /* GP_SYMBOL_H */ diff --git a/include/gfx/GP_Tetragon.h b/include/gfx/GP_Tetragon.h index 3f9d027..687ed7e 100644 --- a/include/gfx/GP_Tetragon.h +++ b/include/gfx/GP_Tetragon.h @@ -28,16 +28,20 @@ #include "core/GP_Context.h" -void GP_Tetragon(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, int x3, int y3, GP_Pixel pixel); +void GP_Tetragon(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, + GP_Coord x3, GP_Coord y3, GP_Pixel pixel); -void GP_TTetragon(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, int x3, int y3, GP_Pixel pixel); +void GP_TTetragon(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, + GP_Coord x3, GP_Coord y3, GP_Pixel pixel); -void GP_FillTetragon(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, int x3, int y3, GP_Pixel pixel); +void GP_FillTetragon(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, + GP_Coord x3, GP_Coord y3, GP_Pixel pixel); -void GP_TFillTetragon(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, int x3, int y3, GP_Pixel pixel); +void GP_TFillTetragon(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, + GP_Coord x3, GP_Coord y3, GP_Pixel pixel); #endif /* GP_TETRAGON_H */ diff --git a/include/gfx/GP_Triangle.h b/include/gfx/GP_Triangle.h index 128a721..7703a5f 100644 --- a/include/gfx/GP_Triangle.h +++ b/include/gfx/GP_Triangle.h @@ -28,16 +28,20 @@ #include "core/GP_Context.h" -void GP_Triangle(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, GP_Pixel pixel); +void GP_Triangle(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, + GP_Coord x2, GP_Coord y2, GP_Pixel pixel); -void GP_TTriangle(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, GP_Pixel pixel); +void GP_TTriangle(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, + GP_Coord x2, GP_Coord y2, GP_Pixel pixel); -void GP_FillTriangle(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, GP_Pixel pixel); +void GP_FillTriangle(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, + GP_Coord x2, GP_Coord y2, GP_Pixel pixel); -void GP_TFillTriangle(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, GP_Pixel pixel); +void GP_TFillTriangle(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, + GP_Coord x2, GP_Coord y2, GP_Pixel pixel); #endif /* GP_TRIANGLE_H */ diff --git a/include/gfx/GP_VLine.h b/include/gfx/GP_VLine.h index 9e857b4..3cf6085 100644 --- a/include/gfx/GP_VLine.h +++ b/include/gfx/GP_VLine.h @@ -28,15 +28,17 @@ #include "core/GP_Context.h" -void GP_VLineXYY(GP_Context *context, int x, int y0, int y1, GP_Pixel pixel); +void GP_VLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0, + GP_Coord y1, GP_Pixel pixel); -void GP_VLineXYH(GP_Context *context, int x, int y, - unsigned int height, GP_Pixel pixel); +void GP_VLineXYH(GP_Context *context, GP_Coord x, GP_Coord y, + GP_Size height, GP_Pixel pixel); -void GP_TVLineXYY(GP_Context *context, int x, int y0, int y1, GP_Pixel pixel); +void GP_TVLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0, + GP_Coord y1, GP_Pixel pixel); -void GP_TVLineXYH(GP_Context *context, int x, int y, - unsigned int height, GP_Pixel pixel); +void GP_TVLineXYH(GP_Context *context, GP_Coord x, GP_Coord y, + GP_Size height, GP_Pixel pixel); /* default argument set is XYY */ #define GP_VLine GP_VLineXYY diff --git a/libs/gfx/GP_Circle.c b/libs/gfx/GP_Circle.c index 4e92243..e92d8cc 100644 --- a/libs/gfx/GP_Circle.c +++ b/libs/gfx/GP_Circle.c @@ -24,32 +24,28 @@ *****************************************************************************/ #include "GP_Gfx.h" -#include "algo/Circle.algo.h" #include "core/GP_FnPerBpp.h" +#include "core/GP_DefFnPerBpp.h" + +#include "algo/Circle.algo.h" /* Generate drawing functions for various bit depths. */ -DEF_CIRCLE_FN(GP_Circle1bpp, GP_Context *, GP_Pixel, GP_PutPixel1bpp) -DEF_CIRCLE_FN(GP_Circle2bpp, GP_Context *, GP_Pixel, GP_PutPixel2bpp) -DEF_CIRCLE_FN(GP_Circle4bpp, GP_Context *, GP_Pixel, GP_PutPixel4bpp) -DEF_CIRCLE_FN(GP_Circle8bpp, GP_Context *, GP_Pixel, GP_PutPixel8bpp) -DEF_CIRCLE_FN(GP_Circle16bpp, GP_Context *, GP_Pixel, GP_PutPixel16bpp) -DEF_CIRCLE_FN(GP_Circle24bpp, GP_Context *, GP_Pixel, GP_PutPixel24bpp) -DEF_CIRCLE_FN(GP_Circle32bpp, GP_Context *, GP_Pixel, GP_PutPixel32bpp) +GP_DEF_DRAW_FN_PER_BPP(GP_Circle, DEF_CIRCLE_FN) -void GP_Circle(GP_Context *context, int xcenter, int ycenter, - unsigned int r, GP_Pixel pixel) +void GP_Circle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, + GP_Size r, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - GP_FN_PER_BPP(GP_Circle, context->bpp, context, - xcenter, ycenter, r, pixel); + GP_FN_PER_BPP_CONTEXT(GP_Circle, context, context, + xcenter, ycenter, r, pixel); } -void GP_TCircle(GP_Context *context, int xcenter, int ycenter, - unsigned int r, GP_Pixel pixel) +void GP_TCircle(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_Circle(context, xcenter, ycenter, r, pixel); @@ -58,25 +54,19 @@ void GP_TCircle(GP_Context *context, int xcenter, int ycenter, #include "algo/FillCircle.algo.h" /* Generate drawing functions for various bit depths. */ -DEF_FILLCIRCLE_FN(GP_FillCircle1bpp, GP_Context *, GP_Pixel, GP_HLine1bpp) -DEF_FILLCIRCLE_FN(GP_FillCircle2bpp, GP_Context *, GP_Pixel, GP_HLine2bpp) -DEF_FILLCIRCLE_FN(GP_FillCircle4bpp, GP_Context *, GP_Pixel, GP_HLine4bpp) -DEF_FILLCIRCLE_FN(GP_FillCircle8bpp, GP_Context *, GP_Pixel, GP_HLine8bpp) -DEF_FILLCIRCLE_FN(GP_FillCircle16bpp, GP_Context *, GP_Pixel, GP_HLine16bpp) -DEF_FILLCIRCLE_FN(GP_FillCircle24bpp, GP_Context *, GP_Pixel, GP_HLine24bpp) -DEF_FILLCIRCLE_FN(GP_FillCircle32bpp, GP_Context *, GP_Pixel, GP_HLine32bpp) +GP_DEF_FILL_FN_PER_BPP(GP_FillCircle, DEF_FILLCIRCLE_FN) -void GP_FillCircle(GP_Context *context, int xcenter, int ycenter, - unsigned int r, GP_Pixel pixel) +void GP_FillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, + GP_Size r, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - GP_FN_PER_BPP(GP_FillCircle, context->bpp, context, - xcenter, ycenter, r, pixel); + GP_FN_PER_BPP_CONTEXT(GP_FillCircle, context, context, + xcenter, ycenter, r, pixel); } -void GP_TFillCircle(GP_Context *context, int xcenter, int ycenter, - unsigned int r, GP_Pixel pixel) +void GP_TFillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, + GP_Size r, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); diff --git a/libs/gfx/GP_Ellipse.c b/libs/gfx/GP_Ellipse.c index 701f9bb..bbd3bdf 100644 --- a/libs/gfx/GP_Ellipse.c +++ b/libs/gfx/GP_Ellipse.c @@ -24,33 +24,29 @@ *****************************************************************************/ #include "GP_Gfx.h" -#include "algo/Ellipse.algo.h" #include "core/GP_FnPerBpp.h" +#include "core/GP_DefFnPerBpp.h" + +#include "algo/Ellipse.algo.h" /* Generate drawing functions for various bit depths. */ -DEF_ELLIPSE_FN(GP_Ellipse1bpp, GP_Context *, GP_Pixel, GP_PutPixel1bpp); -DEF_ELLIPSE_FN(GP_Ellipse2bpp, GP_Context *, GP_Pixel, GP_PutPixel2bpp); -DEF_ELLIPSE_FN(GP_Ellipse4bpp, GP_Context *, GP_Pixel, GP_PutPixel4bpp); -DEF_ELLIPSE_FN(GP_Ellipse8bpp, GP_Context *, GP_Pixel, GP_PutPixel8bpp); -DEF_ELLIPSE_FN(GP_Ellipse16bpp, GP_Context *, GP_Pixel, GP_PutPixel16bpp); -DEF_ELLIPSE_FN(GP_Ellipse24bpp, GP_Context *, GP_Pixel, GP_PutPixel24bpp); -DEF_ELLIPSE_FN(GP_Ellipse32bpp, GP_Context *, GP_Pixel, GP_PutPixel32bpp); +GP_DEF_DRAW_FN_PER_BPP(GP_Ellipse, DEF_ELLIPSE_FN) -void GP_Ellipse(GP_Context *context, int xcenter, int ycenter, - unsigned int a, unsigned int b, GP_Pixel pixel) +void GP_Ellipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, + GP_Size a, GP_Size b, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - GP_FN_PER_BPP(GP_Ellipse, context->bpp, context, - xcenter, ycenter, a, b, pixel); + GP_FN_PER_BPP_CONTEXT(GP_Ellipse, context, context, + xcenter, ycenter, a, b, pixel); } -void GP_TEllipse(GP_Context *context, int xcenter, int ycenter, - unsigned int a, unsigned int b, GP_Pixel pixel) +void GP_TEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, + GP_Size a, GP_Size b, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - /* recalculate center point and swap a and b when axes are swapped */ + /* recalculate center poGP_Coord and swap a and b when axes are swapped */ GP_TRANSFORM_POINT(context, xcenter, ycenter); GP_TRANSFORM_SWAP(context, a, b); @@ -60,25 +56,19 @@ void GP_TEllipse(GP_Context *context, int xcenter, int ycenter, #include "algo/FillEllipse.algo.h" /* Generate drawing functions for various bit depths. */ -DEF_FILLELLIPSE_FN(GP_FillEllipse1bpp, GP_Context *, GP_Pixel, GP_HLine1bpp) -DEF_FILLELLIPSE_FN(GP_FillEllipse2bpp, GP_Context *, GP_Pixel, GP_HLine2bpp) -DEF_FILLELLIPSE_FN(GP_FillEllipse4bpp, GP_Context *, GP_Pixel, GP_HLine4bpp) -DEF_FILLELLIPSE_FN(GP_FillEllipse8bpp, GP_Context *, GP_Pixel, GP_HLine8bpp) -DEF_FILLELLIPSE_FN(GP_FillEllipse16bpp, GP_Context *, GP_Pixel, GP_HLine16bpp) -DEF_FILLELLIPSE_FN(GP_FillEllipse24bpp, GP_Context *, GP_Pixel, GP_HLine24bpp) -DEF_FILLELLIPSE_FN(GP_FillEllipse32bpp, GP_Context *, GP_Pixel, GP_HLine32bpp) +GP_DEF_FILL_FN_PER_BPP(GP_FillEllipse, DEF_FILLELLIPSE_FN) -void GP_FillEllipse(GP_Context *context, int xcenter, int ycenter, - unsigned int a, unsigned int b, GP_Pixel pixel) +void GP_FillEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, + GP_Size a, GP_Size b, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - GP_FN_PER_BPP(GP_FillEllipse, context->bpp, context, - xcenter, ycenter, a, b, pixel); + GP_FN_PER_BPP_CONTEXT(GP_FillEllipse, context, context, + xcenter, ycenter, a, b, pixel); } -void GP_TFillEllipse(GP_Context *context, int xcenter, int ycenter, - unsigned int a, unsigned int b, GP_Pixel pixel) +void GP_TFillEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, + GP_Size a, GP_Size b, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); diff --git a/libs/gfx/GP_HLine.c b/libs/gfx/GP_HLine.c index ede37ef..3d51cc4 100644 --- a/libs/gfx/GP_HLine.c +++ b/libs/gfx/GP_HLine.c @@ -28,22 +28,29 @@ #include "core/GP_FnPerBpp.h" /* Generate drawing functions for various bit depths. */ -DEF_HLINE_BU_FN(GP_HLine1bpp, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels1bpp) -DEF_HLINE_BU_FN(GP_HLine2bpp, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp) -DEF_HLINE_BU_FN(GP_HLine4bpp, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels4bpp) -DEF_HLINE_FN(GP_HLine8bpp, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels8bpp) -DEF_HLINE_FN(GP_HLine16bpp, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels16bpp) -DEF_HLINE_FN(GP_HLine24bpp, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels24bpp) -DEF_HLINE_FN(GP_HLine32bpp, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels32bpp) -void GP_HLineXXY(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel) +//TODO: BIT ENDIANESS +DEF_HLINE_BU_FN(GP_HLine_1BPP_LE, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels1bpp) +DEF_HLINE_BU_FN(GP_HLine_1BPP_BE, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels1bpp) +DEF_HLINE_BU_FN(GP_HLine_2BPP_LE, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp) +DEF_HLINE_BU_FN(GP_HLine_2BPP_BE, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp) +DEF_HLINE_BU_FN(GP_HLine_4BPP_LE, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp) +DEF_HLINE_BU_FN(GP_HLine_4BPP_BE, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp) + +DEF_HLINE_FN(GP_HLine_8BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels8bpp) +DEF_HLINE_FN(GP_HLine_16BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels16bpp) +DEF_HLINE_FN(GP_HLine_24BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels24bpp) +DEF_HLINE_FN(GP_HLine_32BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels32bpp) + +void GP_HLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - GP_FN_PER_BPP(GP_HLine, context->bpp, context, x0, x1, y, pixel); + GP_FN_PER_BPP_CONTEXT(GP_HLine, context, context, x0, x1, y, pixel); } -void GP_HLineXYW(GP_Context *context, int x, int y, unsigned int w, +void GP_HLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w, GP_Pixel pixel) { /* zero width: do not draw anything */ @@ -53,7 +60,8 @@ void GP_HLineXYW(GP_Context *context, int x, int y, unsigned int w, GP_HLineXXY(context, x, x + w - 1, y, pixel); } -void GP_THLineXXY(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel) +void GP_THLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1, + GP_Coord y, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); @@ -70,7 +78,7 @@ void GP_THLineXXY(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel) } } -void GP_THLineXYW(GP_Context *context, int x, int y, unsigned int w, +void GP_THLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w, GP_Pixel pixel) { /* zero width: do not draw anything */ diff --git a/libs/gfx/GP_Line.c b/libs/gfx/GP_Line.c index 21066b1..d5dda97 100644 --- a/libs/gfx/GP_Line.c +++ b/libs/gfx/GP_Line.c @@ -24,31 +24,24 @@ *****************************************************************************/ #include "GP_Gfx.h" -#include "algo/Line.algo.h" #include "core/GP_FnPerBpp.h" +#include "core/GP_DefFnPerBpp.h" + +#include "algo/Line.algo.h" /* Generate drawing functions for various bit depths. */ -DEF_LINE_FN(GP_Line1bpp_LE, GP_Context *, GP_Pixel, GP_PutPixel1bpp_LE) -DEF_LINE_FN(GP_Line2bpp_LE, GP_Context *, GP_Pixel, GP_PutPixel2bpp_LE) -DEF_LINE_FN(GP_Line4bpp_LE, GP_Context *, GP_Pixel, GP_PutPixel4bpp_LE) -DEF_LINE_FN(GP_Line1bpp_BE, GP_Context *, GP_Pixel, GP_PutPixel1bpp_BE) -DEF_LINE_FN(GP_Line2bpp_BE, GP_Context *, GP_Pixel, GP_PutPixel2bpp_BE) -DEF_LINE_FN(GP_Line4bpp_BE, GP_Context *, GP_Pixel, GP_PutPixel4bpp_BE) -DEF_LINE_FN(GP_Line8bpp, GP_Context *, GP_Pixel, GP_PutPixel8bpp) -DEF_LINE_FN(GP_Line16bpp, GP_Context *, GP_Pixel, GP_PutPixel16bpp) -DEF_LINE_FN(GP_Line24bpp, GP_Context *, GP_Pixel, GP_PutPixel24bpp) -DEF_LINE_FN(GP_Line32bpp, GP_Context *, GP_Pixel, GP_PutPixel32bpp) +GP_DEF_DRAW_FN_PER_BPP(GP_Line, DEF_LINE_FN) -void GP_Line(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel 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_FN_PER_BPP(GP_Line, context->bpp, context, x0, y0, x1, y1, pixel); + GP_FN_PER_BPP_CONTEXT(GP_Line, context, context, x0, y0, x1, y1, pixel); } -void GP_TLine(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel) +void GP_TLine(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); diff --git a/libs/gfx/GP_Polygon.c b/libs/gfx/GP_Polygon.c index bf47baf..1bf5dc7 100644 --- a/libs/gfx/GP_Polygon.c +++ b/libs/gfx/GP_Polygon.c @@ -29,15 +29,15 @@ #include <stdlib.h> struct GP_PolygonEdge { - int startx, starty; - int endx, endy; - int dx, dy; + GP_Coord startx, starty; + GP_Coord endx, endy; + GP_Coord dx, dy; }; struct GP_Polygon { struct GP_PolygonEdge *edges; - int edge_count; - int ymin, ymax; + GP_Coord edge_count; + GP_Coord ymin, ymax; }; #define GP_POLYGON_INITIALIZER { @@ -48,7 +48,7 @@ struct GP_Polygon { } static void GP_InitEdge(struct GP_PolygonEdge *edge, - int x1, int y1, int x2, int y2) + GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2) { if (y1 < y2) { /* coords are top-down, correct */ edge->startx = x1; @@ -66,7 +66,8 @@ static void GP_InitEdge(struct GP_PolygonEdge *edge, edge->dy = edge->endy - edge->starty; } -static void GP_AddEdge(struct GP_Polygon *poly, int x1, int y1, int x2, int y2) +static void GP_AddEdge(struct GP_Polygon *poly, GP_Coord x1, GP_Coord y1, + GP_Coord x2, GP_Coord y2) { struct GP_PolygonEdge *edge = poly->edges + poly->edge_count; @@ -78,7 +79,7 @@ static void GP_AddEdge(struct GP_Polygon *poly, int x1, int y1, int x2, int y2) poly->ymax = GP_MAX(poly->ymax, edge->endy); } -static int GP_CompareEdges(const void *edge1, const void *edge2) +static GP_Coord GP_CompareEdges(const void *edge1, const void *edge2) { struct GP_PolygonEdge *e1 = (struct GP_PolygonEdge *) edge1; struct GP_PolygonEdge *e2 = (struct GP_PolygonEdge *) edge2; @@ -96,15 +97,15 @@ static int GP_CompareEdges(const void *edge1, const void *edge2) return 0; } -static void GP_LoadPolygon(struct GP_Polygon *poly, int vertex_count, - const int *xy) +static void GP_LoadPolygon(struct GP_Polygon *poly, GP_Coord vertex_count, + const GP_Coord *xy) { poly->edge_count = 0; poly->edges = calloc(sizeof(struct GP_PolygonEdge), vertex_count); - int i; - int coord_count = 2*vertex_count - 2; + GP_Coord i; + GP_Coord coord_count = 2*vertex_count - 2; for (i = 0; i < coord_count; i+=2) { /* add the edge, unless it is horizontal */ @@ -133,13 +134,13 @@ static void GP_ResetPolygon(struct GP_Polygon *poly) } /* - * Finds an X coordinate of an intersection of the edge + * Finds an X coordinate of an GP_Coordersection of the edge * with the given Y line. */ -static inline int GP_FindIntersection(int y, const struct GP_PolygonEdge *edge) +static inline GP_Coord GP_FindIntersection(GP_Coord y, const struct GP_PolygonEdge *edge) { - int edge_y = y - edge->starty; /* Y relative to the edge */ - int x = edge->startx; + GP_Coord edge_y = y - edge->starty; /* Y relative to the edge */ + GP_Coord x = edge->startx; if (edge->dx > 0) { while (edge->startx*edge->dy + edge_y*edge->dx > x*edge->dy) @@ -152,37 +153,37 @@ static inline int GP_FindIntersection(int y, const struct GP_PolygonEdge *edge) return x; } -void GP_FillPolygon(GP_Context *context, int vertex_count, const int *xy, +void GP_FillPolygon(GP_Context *context, GP_Coord vertex_count, const GP_Coord *xy, GP_Pixel pixel) { struct GP_Polygon poly = GP_POLYGON_INITIALIZER; GP_LoadPolygon(&poly, vertex_count, xy); - int y, startx, endx; - int startx_prev = -INT_MAX; - int endx_prev = INT_MAX; + GP_Coord y, startx, endx; + GP_Coord startx_prev = -INT_MAX; + GP_Coord endx_prev = INT_MAX; for (y = poly.ymin; y <= poly.ymax; y++) { startx = INT_MAX; endx = 0; - int i; + GP_Coord i; for (i = 0; i < poly.edge_count; i++) { struct GP_PolygonEdge *edge = poly.edges + i; if (y < edge->starty || y > edge->endy) continue; - int inter = GP_FindIntersection(y, edge); + GP_Coord GP_Coorder = GP_FindIntersection(y, edge); - startx = GP_MIN(startx, inter); - endx = GP_MAX(endx, inter); + startx = GP_MIN(startx, GP_Coorder); + endx = GP_MAX(endx, GP_Coorder); if (y != edge->endy) { - inter = GP_FindIntersection(y + 1, edge); - startx = GP_MIN(startx, inter); - endx = GP_MAX(endx, inter); + GP_Coorder = GP_FindIntersection(y + 1, edge); + startx = GP_MIN(startx, GP_Coorder); + endx = GP_MAX(endx, GP_Coorder); } } diff --git a/libs/gfx/GP_Rect.c b/libs/gfx/GP_Rect.c index 52e3a36..9f1fabe 100644 --- a/libs/gfx/GP_Rect.c +++ b/libs/gfx/GP_Rect.c @@ -25,8 +25,8 @@ #include "GP_Gfx.h" -void GP_RectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel) +void GP_RectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); @@ -36,8 +36,8 @@ void GP_RectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, GP_VLine(context, x1, y0, y1, pixel); } -void GP_RectXYWH(GP_Context *context, int x, int y, - unsigned int w, unsigned int h, GP_Pixel pixel) +void GP_RectXYWH(GP_Context *context, GP_Coord x, GP_Coord y, + GP_Size w, GP_Size h, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); @@ -47,8 +47,8 @@ void GP_RectXYWH(GP_Context *context, int x, int y, GP_VLine(context, x + w, y, y + h, pixel); } -void GP_TRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel) +void GP_TRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); @@ -58,27 +58,27 @@ void GP_TRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, GP_RectXYXY(context, x0, y0, x1, y1, pixel); } -void GP_TRectXYWH(GP_Context *context, int x, int y, - unsigned int w, unsigned int h, GP_Pixel pixel) +void GP_TRectXYWH(GP_Context *context, GP_Coord x, GP_Coord y, + GP_Size w, GP_Size h, GP_Pixel pixel) { GP_TRectXYXY(context, x, y, x + w, y + h, pixel); } -void GP_FillRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel) +void GP_FillRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); if (y0 > y1) GP_SWAP(y0, y1); - int y; + GP_Coord y; for (y = y0; y <= y1; y++) GP_HLine(context, x0, x1, y, pixel); } -void GP_FillRectXYWH(GP_Context *context, int x, int y, - unsigned int w, unsigned int h, GP_Pixel pixel) +void GP_FillRectXYWH(GP_Context *context, GP_Coord x, GP_Coord y, + GP_Size w, GP_Size h, GP_Pixel pixel) { /* zero width/height: draw nothing */ if (w == 0 || h == 0) @@ -87,8 +87,8 @@ void GP_FillRectXYWH(GP_Context *context, int x, int y, return GP_FillRectXYXY(context, x, y, x + w - 1, y + h - 1, pixel); } -void GP_TFillRectXYXY(GP_Context *context, int x0, int y0, - int x1, int y1, GP_Pixel pixel) +void GP_TFillRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); @@ -98,8 +98,8 @@ void GP_TFillRectXYXY(GP_Context *context, int x0, int y0, GP_FillRect(context, x0, y0, x1, y1, pixel); } -void GP_TFillRectXYWH(GP_Context *context, int x, int y, - unsigned int w, unsigned int h, GP_Pixel pixel) +void GP_TFillRectXYWH(GP_Context *context, GP_Coord x, GP_Coord y, + GP_Size w, GP_Size h, GP_Pixel pixel) { /* zero width/height: draw nothing */ if (w == 0 || h == 0) diff --git a/libs/gfx/GP_Symbol.c b/libs/gfx/GP_Symbol.c index 1103673..7a7b44e 100644 --- a/libs/gfx/GP_Symbol.c +++ b/libs/gfx/GP_Symbol.c @@ -69,7 +69,7 @@ } while (0) void GP_Symbol(GP_Context *context, GP_SymbolType sym, - int x, int y, int w, int h, GP_Pixel pixel) + GP_Coord x, GP_Coord y, GP_Size w, GP_Size h, GP_Pixel pixel) { DO_DECREMENT(w); DO_DECREMENT(h); @@ -97,7 +97,7 @@ void GP_Symbol(GP_Context *context, GP_SymbolType sym, } void GP_FillSymbol(GP_Context *context, GP_SymbolType sym, - int x, int y, int w, int h, GP_Pixel pixel) + GP_Coord x, GP_Coord y, GP_Size w, GP_Size h, GP_Pixel pixel) { DO_DECREMENT(w); DO_DECREMENT(h); @@ -125,7 +125,7 @@ void GP_FillSymbol(GP_Context *context, GP_SymbolType sym, } void GP_TSymbol(GP_Context *context, GP_SymbolType sym, - int x, int y, int w, int h, GP_Pixel pixel) + GP_Coord x, GP_Coord y, GP_Size w, GP_Size h, GP_Pixel pixel) { DO_DECREMENT(w); DO_DECREMENT(h); @@ -153,7 +153,8 @@ void GP_TSymbol(GP_Context *context, GP_SymbolType sym, } void GP_TFillSymbol(GP_Context *context, GP_SymbolType sym, - int x, int y, int w, int h, GP_Pixel pixel) + GP_Coord x, GP_Coord y, + GP_Size w, GP_Size h, GP_Pixel pixel) { DO_DECREMENT(w); DO_DECREMENT(h); diff --git a/libs/gfx/GP_Tetragon.c b/libs/gfx/GP_Tetragon.c index ff9100e..f5f924a 100644 --- a/libs/gfx/GP_Tetragon.c +++ b/libs/gfx/GP_Tetragon.c @@ -25,8 +25,9 @@ #include "GP_Gfx.h" -void GP_Tetragon(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, int x3, int y3, GP_Pixel pixel) +void GP_Tetragon(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, + GP_Coord x3, GP_Coord y3, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); @@ -36,8 +37,9 @@ void GP_Tetragon(GP_Context *context, int x0, int y0, int x1, int y1, GP_Line(context, x3, y3, x0, y0, pixel); } -void GP_TTetragon(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, int x3, int y3, GP_Pixel pixel) +void GP_TTetragon(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, + GP_Coord x3, GP_Coord y3, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); @@ -49,17 +51,19 @@ void GP_TTetragon(GP_Context *context, int x0, int y0, int x1, int y1, GP_Tetragon(context, x0, y0, x1, y1, x2, y2, x3, y3, pixel); } -void GP_FillTetragon(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, int x3, int y3, GP_Pixel pixel) +void GP_FillTetragon(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, + GP_Coord x3, GP_Coord y3, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - int xy[8] = { x0, y0, x1, y1, x2, y2, x3, y3 }; - GP_FillPolygon(context, 4, (const int *) xy, pixel); + const GP_Coord xy[8] = { x0, y0, x1, y1, x2, y2, x3, y3 }; + GP_FillPolygon(context, 4, xy, pixel); } -void GP_TFillTetragon(GP_Context* context, int x0, int y0, int x1, int y1, - int x2, int y2, int x3, int y3, GP_Pixel pixel) +void GP_TFillTetragon(GP_Context* context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, + GP_Coord x3, GP_Coord y3, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); @@ -68,6 +72,6 @@ void GP_TFillTetragon(GP_Context* context, int x0, int y0, int x1, int y1, GP_TRANSFORM_POINT(context, x2, y2); GP_TRANSFORM_POINT(context, x3, y3); - int xy[8] = { x0, y0, x1, y1, x2, y2, x3, y3 }; - GP_FillPolygon(context, 4, (const int *) xy, pixel); + const GP_Coord xy[8] = { x0, y0, x1, y1, x2, y2, x3, y3 }; + GP_FillPolygon(context, 4, xy, pixel); } diff --git a/libs/gfx/GP_Triangle.c b/libs/gfx/GP_Triangle.c index 46f6939..10725ec 100644 --- a/libs/gfx/GP_Triangle.c +++ b/libs/gfx/GP_Triangle.c @@ -25,8 +25,9 @@ #include "GP_Gfx.h" -void GP_Triangle(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, GP_Pixel pixel) +void GP_Triangle(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, + GP_Coord x2, GP_Coord y2, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); @@ -35,8 +36,9 @@ void GP_Triangle(GP_Context *context, int x0, int y0, int x1, int y1, GP_Line(context, x1, y1, x2, y2, pixel); } -void GP_TTriangle(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, GP_Pixel pixel) +void GP_TTriangle(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, + GP_Coord x2, GP_Coord y2, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); @@ -47,17 +49,19 @@ void GP_TTriangle(GP_Context *context, int x0, int y0, int x1, int y1, GP_Triangle(context, x0, y0, x1, y1, x2, y2, pixel); } -void GP_FillTriangle(GP_Context * context, int x0, int y0, int x1, int y1, - int x2, int y2, GP_Pixel pixel) +void GP_FillTriangle(GP_Context *context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, + GP_Coord x2, GP_Coord y2, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - int coords[6] = { x0, y0, x1, y1, x2, y2 }; + const GP_Coord coords[6] = { x0, y0, x1, y1, x2, y2 }; GP_FillPolygon(context, 3, coords, pixel); } -void GP_TFillTriangle(GP_Context* context, int x0, int y0, int x1, int y1, - int x2, int y2, GP_Pixel pixel) +void GP_TFillTriangle(GP_Context* context, GP_Coord x0, GP_Coord y0, + GP_Coord x1, GP_Coord y1, + GP_Coord x2, GP_Coord y2, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); @@ -65,6 +69,6 @@ void GP_TFillTriangle(GP_Context* context, int x0, int y0, int x1, int y1, GP_TRANSFORM_POINT(context, x1, y1); GP_TRANSFORM_POINT(context, x2, y2); - int coords[6] = { x0, y0, x1, y1, x2, y2 }; + const GP_Coord coords[6] = { x0, y0, x1, y1, x2, y2 }; GP_FillPolygon(context, 3, coords, pixel); } diff --git a/libs/gfx/GP_VLine.c b/libs/gfx/GP_VLine.c index 7a27768..91d26da 100644 --- a/libs/gfx/GP_VLine.c +++ b/libs/gfx/GP_VLine.c @@ -24,27 +24,24 @@ *****************************************************************************/ #include "GP_Gfx.h" -#include "algo/VLine.algo.h" #include "core/GP_FnPerBpp.h" +#include "core/GP_DefFnPerBpp.h" + +#include "algo/VLine.algo.h" /* Generate drawing functions for various bit depths. */ -DEF_VLINE_FN(GP_VLine1bpp, GP_Context *, GP_Pixel, GP_PutPixel1bpp) -DEF_VLINE_FN(GP_VLine2bpp, GP_Context *, GP_Pixel, GP_PutPixel2bpp) -DEF_VLINE_FN(GP_VLine4bpp, GP_Context *, GP_Pixel, GP_PutPixel4bpp) -DEF_VLINE_FN(GP_VLine8bpp, GP_Context *, GP_Pixel, GP_PutPixel8bpp) -DEF_VLINE_FN(GP_VLine16bpp, GP_Context *, GP_Pixel, GP_PutPixel16bpp) -DEF_VLINE_FN(GP_VLine24bpp, GP_Context *, GP_Pixel, GP_PutPixel24bpp) -DEF_VLINE_FN(GP_VLine32bpp, GP_Context *, GP_Pixel, GP_PutPixel32bpp) +GP_DEF_DRAW_FN_PER_BPP(GP_VLine, DEF_VLINE_FN) -void GP_VLineXYY(GP_Context *context, int x, int y0, int y1, GP_Pixel pixel) +void GP_VLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0, + GP_Coord y1, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - GP_FN_PER_BPP(GP_VLine, context->bpp, context, x, y0, y1, pixel); + GP_FN_PER_BPP_CONTEXT(GP_VLine, context, context, x, y0, y1, pixel); } -void GP_VLineXYH(GP_Context *context, int x, int y, unsigned int height, - GP_Pixel pixel) +void GP_VLineXYH(GP_Context *context, GP_Coord x, GP_Coord y, + GP_Size height, GP_Pixel pixel) { /* zero height: do not draw anything */ if (height == 0) @@ -53,7 +50,8 @@ void GP_VLineXYH(GP_Context *context, int x, int y, unsigned int height, GP_VLineXYY(context, x, y, y + height - 1, pixel); } -void GP_TVLineXYY(GP_Context *context, int x, int y0, int y1, GP_Pixel pixel) +void GP_TVLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0, + GP_Coord y1, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); @@ -70,8 +68,8 @@ void GP_TVLineXYY(GP_Context *context, int x, int y0, int y1, GP_Pixel pixel) } } -void GP_TVLineXYH(GP_Context *context, int x, int y, unsigned int height, - GP_Pixel pixel) +void GP_TVLineXYH(GP_Context *context, GP_Coord x, GP_Coord y, + GP_Size height, GP_Pixel pixel) { /* zero height: do not draw anything */ if (height == 0) ----------------------------------------------------------------------- Summary of changes: include/core/GP_Context.h | 6 +-- .../core/GP_DefFnPerBpp.h | 62 ++++++++++---------- LICENSE => include/core/GP_Types.h | 19 +++++- include/gfx/GP_Circle.h | 16 +++--- include/gfx/GP_Ellipse.h | 16 +++--- include/gfx/GP_Gfx.h | 1 + include/gfx/GP_HLine.h | 59 +++++++++++++++---- include/gfx/GP_Line.h | 31 +++++----- include/gfx/GP_Polygon.h | 10 ++-- include/gfx/GP_Rect.h | 32 +++++----- include/gfx/GP_Symbol.h | 14 +++-- include/gfx/GP_Tetragon.h | 20 ++++--- include/gfx/GP_Triangle.h | 20 ++++--- include/gfx/GP_VLine.h | 14 +++-- libs/gfx/GP_Circle.c | 46 ++++++--------- libs/gfx/GP_Ellipse.c | 46 ++++++--------- libs/gfx/GP_HLine.c | 32 ++++++---- libs/gfx/GP_Line.c | 25 +++----- libs/gfx/GP_Polygon.c | 55 +++++++++--------- libs/gfx/GP_Rect.c | 34 +++++----- libs/gfx/GP_Symbol.c | 9 ++- libs/gfx/GP_Tetragon.c | 28 +++++---- libs/gfx/GP_Triangle.c | 24 +++++--- libs/gfx/GP_VLine.c | 28 ++++----- 24 files changed, 346 insertions(+), 301 deletions(-) copy libs/loaders/GP_PXMCommon.h => include/core/GP_DefFnPerBpp.h (55%) copy LICENSE => include/core/GP_Types.h (83%) 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.")
1
0
0
0
[repo.or.cz] gfxprim.git branch generate updated: ecca5686f36c35b12f2bd72dd5ef16165da1ec8c
by metan
13 Jul '11
13 Jul '11
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, generate has been updated via ecca5686f36c35b12f2bd72dd5ef16165da1ec8c (commit) from 7d798834242fb298acd49b2c444843eaad852a93 (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/ecca5686f36c35b12f2bd72dd5ef16165da1…
commit ecca5686f36c35b12f2bd72dd5ef16165da1ec8c Author: Cyril Hrubis <metan(a)ucw.cz> Date: Wed Jul 13 21:40:12 2011 +0200 Fix some typos and warnings. diff --git a/include/core/GP_GetPutPixel.h b/include/core/GP_GetPutPixel.h index 7151a36..4f7a146 100644 --- a/include/core/GP_GetPutPixel.h +++ b/include/core/GP_GetPutPixel.h @@ -17,6 +17,7 @@ * Boston, MA 02110-1301 USA * * * * Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz> * + * Copyright (C) 2011 Cyril Hrubis <metan(a)ucw.cz> * * * *****************************************************************************/ @@ -41,10 +42,12 @@ GP_Pixel GP_GetPixel(const GP_Context *context, int x, int y); /* * Version of GetPixel without transformations nor border checking. */ -static inline GP_Pixel GP_GetPixel_Raw(GP_Context *context, int x, int y) +static inline GP_Pixel GP_GetPixel_Raw(const GP_Context *context, int x, int y) { GP_FN_RET_PER_BPP(GP_GetPixel_Raw, context->bpp, context->bit_endian, context, x, y); + + GP_ABORT("Invalid context pixel type"); } /* @@ -56,7 +59,8 @@ void GP_PutPixel(GP_Context *context, int x, int y, GP_Pixel p); /* * Version of PutPixel without transformations nor border checking. */ -static inline void GP_PutPixel_Raw(GP_Context *context, int x, int y, GP_Pixel p) +static inline void GP_PutPixel_Raw(GP_Context *context, int x, int y, + GP_Pixel p) { GP_FN_PER_BPP(GP_PutPixel_Raw, context->bpp, context->bit_endian, context, x, y, p); diff --git a/libs/core/GP_Blit.c b/libs/core/GP_Blit.c index 251272d..a43c16f 100644 --- a/libs/core/GP_Blit.c +++ b/libs/core/GP_Blit.c @@ -57,8 +57,6 @@ void GP_Blit_Naive(const GP_Context *c1, GP_Coord x1, GP_Coord y1, GP_Size w, GP { GP_CHECK(x1 >= 0); GP_CHECK(y1 >= 0); - GP_CHECK(w >= 0); - GP_CHECK(h >= 0); GP_CHECK(x1 + w <= GP_ContextW(c1)); GP_CHECK(y1 + h <= GP_ContextH(c1)); GP_CHECK(x2 >= 0); @@ -66,8 +64,8 @@ void GP_Blit_Naive(const GP_Context *c1, GP_Coord x1, GP_Coord y1, GP_Size w, GP GP_CHECK(x2 + w <= GP_ContextW(c2)); GP_CHECK(y2 + h <= GP_ContextH(c2)); - for (int i = 0; i < w; i++) - for (int j = 0; j < h; j++) { + for (GP_Size i = 0; i < w; i++) + for (GP_Size j = 0; j < h; j++) { GP_Pixel p = GP_GetPixel(c1, x1 + i, y1 + j); if (c1->pixel_type != c2->pixel_type) p = GP_ConvertContextPixel(p, c1, c2); diff --git a/libs/core/GP_WritePixel.c b/libs/core/GP_WritePixel.c index 534094e..182a42e 100644 --- a/libs/core/GP_WritePixel.c +++ b/libs/core/GP_WritePixel.c @@ -23,6 +23,8 @@ * * *****************************************************************************/ +#include <string.h> + #include "GP_Core.h" #include "GP_WritePixel.h" diff --git a/pylib/gfxprim/generators/core/gen_getputpixel.py b/pylib/gfxprim/generators/core/gen_getputpixel.py index 6b96fc3..f360ec0 100644 --- a/pylib/gfxprim/generators/core/gen_getputpixel.py +++ b/pylib/gfxprim/generators/core/gen_getputpixel.py @@ -1,5 +1,6 @@ # Module generating C source and headers for get/putpixel # 2011 - Tomas Gavenciak <gavento(a)ucw.cz> +# 2011 - Cyril Hrubis <metan(a)ucw.cz> from gfxprim.generators.utils import * @@ -32,9 +33,9 @@ def gen_getpixel_bpp(size, size_suffix, header): "of form 8BPP, 2BPP_LE and the like." header.rbody( "n/*** GP_GetPixel for {{ size_suffix }} ***/n" - "static inline GP_Pixel GP_GetPixel_Raw_{{ size_suffix }}(GP_Context *c, int x, int y)n" + "static inline GP_Pixel GP_GetPixel_Raw_{{ size_suffix }}(const GP_Context *c, int x, int y)n" "{n" - " return GP_GET_BITS(GP_PIXEL_ADDR_OFFSET_{{ size_suffix }}(x) , {{ size }},n" + " return GP_GET_BITS(GP_PIXEL_ADDR_OFFSET_{{ size_suffix }}(x), {{ size }},n" " *(GP_PIXEL_ADDR_{{ size_suffix}}(c, x, y)));n" "}nn", size=size, size_suffix=size_suffix) ----------------------------------------------------------------------- Summary of changes: include/core/GP_GetPutPixel.h | 8 ++++++-- libs/core/GP_Blit.c | 6 ++---- libs/core/GP_WritePixel.c | 2 ++ pylib/gfxprim/generators/core/gen_getputpixel.py | 5 +++-- 4 files changed, 13 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.")
1
0
0
0
[repo.or.cz] gfxprim.git branch generate updated: 7d798834242fb298acd49b2c444843eaad852a93
by metan
09 Jul '11
09 Jul '11
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, generate has been updated via 7d798834242fb298acd49b2c444843eaad852a93 (commit) from b7f10b82d579dfb7878335336b0d016f5343f793 (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/7d798834242fb298acd49b2c444843eaad85…
commit 7d798834242fb298acd49b2c444843eaad852a93 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Sat Jul 9 22:44:00 2011 +0200 Started to fix surrounding library code. Started to fix the library code to play well with generated code. BEWARE UNTESTED. diff --git a/include/core/GP_Pixel.h b/include/core/GP_Pixel.h index 7250179..6282bf1 100644 --- a/include/core/GP_Pixel.h +++ b/include/core/GP_Pixel.h @@ -41,7 +41,7 @@ struct GP_Context; /* * GP_PixelType is typedef enum of PixelTypes, * - * each named GP_PIXEL_<TYPENAME>, such as GP_PIXEL_GRB888 + * each named GP_PIXEL_<TYPENAME>, such as GP_PIXEL_RGB888 * see the beginning of GP_Pixel.gen.h for a complete list * * The type always contains GP_PIXEL_UNKNOWN = 0 and @@ -52,8 +52,8 @@ struct GP_Context; /* * GP_Pixel is just uint32_t */ - typedef uint32_t GP_Pixel; +#define GP_PIXEL_BITS 32 /* Generated header */ #include "GP_Pixel.gen.h" @@ -123,8 +123,8 @@ extern const GP_PixelTypeDescription const GP_PixelTypes[]; static inline const char *GP_PixelTypeName(GP_PixelType type) { - GP_CHECK(type < GP_PIXEL_MAX); - return GP_PixelTypes[type].name; + GP_CHECK(type < GP_PIXEL_MAX); + return GP_PixelTypes[type].name; } /* @@ -133,15 +133,16 @@ static inline const char *GP_PixelTypeName(GP_PixelType type) static inline uint32_t GP_PixelSize(GP_PixelType type) { - GP_CHECK(type < GP_PIXEL_MAX); - return GP_PixelTypes[type].size; + GP_CHECK(type < GP_PIXEL_MAX); + return GP_PixelTypes[type].size; } /* * Print a human-readable representation of a pixel value to a string. * Arguments as for snprintf(). */ -static inline void GP_PixelSNPrint(char *buf, size_t len, GP_Pixel pixel, GP_PixelType type) +static inline void GP_PixelSNPrint(char *buf, size_t len, GP_Pixel pixel, + GP_PixelType type) { GP_FN_PER_PIXELTYPE(GP_PixelSNPrint, type, buf, len, pixel); } @@ -156,4 +157,13 @@ static inline void GP_PixelPrint(GP_Pixel pixel, GP_PixelType type) printf("%s", buf); } +/* + * Match pixel type to known pixel types. + * + * Returns either valid PixelType or GP_PIXEL_UNKNOWN + */ +GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask, + GP_Pixel bmask, GP_Pixel amask); + + #endif /* GP_PIXEL_H */ diff --git a/libs/SDL/GP_SDL_Context.c b/libs/SDL/GP_SDL_Context.c index 487476b..021b6e6 100644 --- a/libs/SDL/GP_SDL_Context.c +++ b/libs/SDL/GP_SDL_Context.c @@ -26,91 +26,22 @@ #include "GP.h" #include "GP_SDL.h" -/* Checks whether pixel color component masks in the given surface are equal - * to specified. Returns nonzero if they match, zero otherwise. - */ -static int check_pixel_masks(SDL_Surface *surf, unsigned int rmask, - unsigned int gmask, unsigned int bmask, unsigned int amask) -{ - return (surf->format->Rmask == rmask - && surf->format->Gmask == gmask - && surf->format->Bmask == bmask - && surf->format->Ashift == amask); -} - -/* Detects the pixel type of the SDL surface. - * Returns the pixel type, or GP_PIXEL_UNKNOWN if the type was not recognized. - */ -static enum GP_PixelType find_surface_pixel_type(SDL_Surface *surf) -{ - switch (surf->format->BytesPerPixel) { - case 1: - if (check_pixel_masks(surf, 0, 0, 0, 0)) { - return GP_PIXEL_PAL8; - } - break; - case 2: - if (check_pixel_masks(surf, 0x7c00, 0x03e0, 0x001f, 0)) { - return GP_PIXEL_RGB555; - } - if (check_pixel_masks(surf, 0xf800, 0x07e0, 0x001f, 0)) { - return GP_PIXEL_RGB565; - } - break; - case 3: - if (check_pixel_masks(surf, 0xff0000, 0xff00, 0xff, 0)) { - return GP_PIXEL_RGB888; - } - if (check_pixel_masks(surf, 0xff, 0xff00, 0xff0000, 0)) { - return GP_PIXEL_BGR888; - } - break; - case 4: - if (check_pixel_masks(surf, 0xff0000, 0xff00, 0xff, 0)) { - return GP_PIXEL_XRGB8888; - } - if (check_pixel_masks(surf, 0xff, 0xff00, 0xff0000, 0)) { - return GP_PIXEL_XBGR8888; - } - if (check_pixel_masks(surf, 0xff000000, 0xff0000, 0xff00, 0)) { - return GP_PIXEL_RGBX8888; - } - if (check_pixel_masks(surf, 0xff00, 0xff0000, 0xff000000, 0)) { - return GP_PIXEL_BGRX8888; - } - if (check_pixel_masks(surf, 0xff0000, 0xff00, 0xff, 0xff000000)) { - return GP_PIXEL_ARGB8888; - } - if (check_pixel_masks(surf, 0xff, 0xff00, 0xff0000, 0xff000000)) { - return GP_PIXEL_ABGR8888; - } - if (check_pixel_masks(surf, 0xff000000, 0xff0000, 0xff00, 0xff)) { - return GP_PIXEL_RGBA8888; - } - if (check_pixel_masks(surf, 0xff00, 0xff0000, 0xff000000, 0xff)) { - return GP_PIXEL_BGRA8888; - } - break; - - } - return GP_PIXEL_UNKNOWN; - -} - GP_RetCode GP_SDL_ContextFromSurface(GP_Context *context, SDL_Surface *surf) { - if (surf == NULL || surf->pixels == NULL || context == NULL) { + if (surf == NULL || surf->pixels == NULL || context == NULL) return GP_ENULLPTR; - } /* sanity checks on the SDL surface */ - if (surf->format->BytesPerPixel == 0 || surf->format->BytesPerPixel > 4) { + if (surf->format->BytesPerPixel == 0 || surf->format->BytesPerPixel > 4) return GP_ENOIMPL; - } - enum GP_PixelType pixeltype = find_surface_pixel_type(surf); - if (pixeltype == GP_PIXEL_UNKNOWN) { + + enum GP_PixelType pixeltype = GP_PixelRGBMatch(surf->format->Rmask, + surf->format->Gmask, + surf->format->Bmask, + surf->format->Ashift); + + if (pixeltype == GP_PIXEL_UNKNOWN) return GP_ENOIMPL; - } /* basic structure and size */ context->pixels = surf->pixels; diff --git a/libs/backends/GP_Backend_SDL.c b/libs/backends/GP_Backend_SDL.c index 2cf4fe4..aac4a32 100644 --- a/libs/backends/GP_Backend_SDL.c +++ b/libs/backends/GP_Backend_SDL.c @@ -45,78 +45,6 @@ static int (*dyn_SDL_WaitEvent)(SDL_Event *); /* User callbacks. */ static void (*GP_SDL_update_video_callback)(void) = NULL; -/* - * Checks whether pixel color component masks in the given surface are equal - * to specified. Returns nonzero if they match, zero otherwise. - */ -static int GP_SDL_CheckPixelMasks(SDL_Surface *surf, unsigned int rmask, - unsigned int gmask, unsigned int bmask, unsigned int amask) -{ - return (surf->format->Rmask == rmask - && surf->format->Gmask == gmask - && surf->format->Bmask == bmask - && surf->format->Ashift == amask); -} - -/* - * Detects the pixel type of the SDL surface. - * Returns the pixel type, or GP_PIXEL_UNKNOWN if the type was not recognized. - */ -static enum GP_PixelType GP_SDL_FindSurfacePixelType(SDL_Surface *surf) -{ - switch (surf->format->BytesPerPixel) { - case 1: - if (GP_SDL_CheckPixelMasks(surf, 0, 0, 0, 0)) { - return GP_PIXEL_PAL8; - } - break; - case 2: - if (GP_SDL_CheckPixelMasks(surf, 0x7c00, 0x03e0, 0x001f, 0)) { - return GP_PIXEL_RGB555; - } - if (GP_SDL_CheckPixelMasks(surf, 0xf800, 0x07e0, 0x001f, 0)) { - return GP_PIXEL_RGB565; - } - break; - case 3: - if (GP_SDL_CheckPixelMasks(surf, 0xff0000, 0xff00, 0xff, 0)) { - return GP_PIXEL_RGB888; - } - if (GP_SDL_CheckPixelMasks(surf, 0xff, 0xff00, 0xff0000, 0)) { - return GP_PIXEL_BGR888; - } - break; - case 4: - if (GP_SDL_CheckPixelMasks(surf, 0xff0000, 0xff00, 0xff, 0)) { - return GP_PIXEL_XRGB8888; - } - if (GP_SDL_CheckPixelMasks(surf, 0xff, 0xff00, 0xff0000, 0)) { - return GP_PIXEL_XBGR8888; - } - if (GP_SDL_CheckPixelMasks(surf, 0xff000000, 0xff0000, 0xff00, 0)) { - return GP_PIXEL_RGBX8888; - } - if (GP_SDL_CheckPixelMasks(surf, 0xff00, 0xff0000, 0xff000000, 0)) { - return GP_PIXEL_BGRX8888; - } - if (GP_SDL_CheckPixelMasks(surf, 0xff0000, 0xff00, 0xff, 0xff000000)) { - return GP_PIXEL_ARGB8888; - } - if (GP_SDL_CheckPixelMasks(surf, 0xff, 0xff00, 0xff0000, 0xff000000)) { - return GP_PIXEL_ABGR8888; - } - if (GP_SDL_CheckPixelMasks(surf, 0xff000000, 0xff0000, 0xff00, 0xff)) { - return GP_PIXEL_RGBA8888; - } - if (GP_SDL_CheckPixelMasks(surf, 0xff00, 0xff0000, 0xff000000, 0xff)) { - return GP_PIXEL_BGRA8888; - } - break; - - } - return GP_PIXEL_UNKNOWN; -} - inline GP_RetCode GP_SDL_ContextFromSurface( GP_Context *context, SDL_Surface *surf) { @@ -124,13 +52,16 @@ inline GP_RetCode GP_SDL_ContextFromSurface( GP_CHECK(surf, "surface is NULL"); /* sanity checks on the SDL surface */ - if (surf->format->BytesPerPixel == 0 || surf->format->BytesPerPixel > 4) { + if (surf->format->BytesPerPixel == 0 || surf->format->BytesPerPixel > 4) return GP_ENOIMPL; - } - enum GP_PixelType pixeltype = GP_SDL_FindSurfacePixelType(surf); - if (pixeltype == GP_PIXEL_UNKNOWN) { + + enum GP_PixelType pixeltype = GP_PixelRGBMatch(surf->format->Rmask, + surf->format->Gmask, + surf->format->Bmask, + surf->format->Ashift); + + if (pixeltype == GP_PIXEL_UNKNOWN) return GP_ENOIMPL; - } /* basic structure and size */ context->pixels = surf->pixels; diff --git a/libs/core/GP_Pixel.c b/libs/core/GP_Pixel.c new file mode 100644 index 0000000..d6553b1 --- /dev/null +++ b/libs/core/GP_Pixel.c @@ -0,0 +1,78 @@ +/***************************************************************************** + * 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> * + * * + *****************************************************************************/ + +#include <string.h> + +#include "GP_Pixel.h" + +static const GP_PixelTypeChannel *get_channel(const GP_PixelTypeDescription *desc, + const char *name) +{ + unsigned int i; + + for (i = 0; i < desc->numchannels; i++) + if (!strcmp(desc->channels[i].name, name)) + return &desc->channels[i]; + + return NULL; +} + +static int match(const GP_PixelTypeChannel *channel, GP_Pixel mask) +{ + if (channel == NULL) + return !mask; + + GP_Pixel chmask = ~0; + + chmask >>= (GP_PIXEL_BITS - channel->size); + chmask <<= channel->offset; + + return (chmask == mask); +} + +GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask, + GP_Pixel bmask, GP_Pixel amask) +{ + unsigned int i; + + for (i = 0; i < GP_PIXEL_MAX; i++) { + int res; + + const GP_PixelTypeChannel *r, *g, *b, *a; + + r = get_channel(&GP_PixelTypes[i], "R"); + g = get_channel(&GP_PixelTypes[i], "G"); + b = get_channel(&GP_PixelTypes[i], "B"); + a = get_channel(&GP_PixelTypes[i], "A"); + + res = match(r, rmask) && match(g, gmask) && + match(b, bmask) && match(a, amask); + + if (res) + return GP_PixelTypes[i].type; + } + + return GP_PIXEL_UNKNOWN; +} diff --git a/libs/loaders/Makefile b/libs/loaders/Makefile index 1e88e78..e753f5c 100644 --- a/libs/loaders/Makefile +++ b/libs/loaders/Makefile @@ -1,5 +1,5 @@ TOPDIR=../.. -CSOURCES=$(shell ls *.c) +#CSOURCES=$(shell ls *.c) LIBNAME=loaders include $(TOPDIR)/include.mk include $(TOPDIR)/lib.mk diff --git a/pylib/gfxprim/generators/core/make_GP_Convert.py b/pylib/gfxprim/generators/core/make_GP_Convert.py index dfd23dd..03b682c 100644 --- a/pylib/gfxprim/generators/core/make_GP_Convert.py +++ b/pylib/gfxprim/generators/core/make_GP_Convert.py @@ -20,7 +20,7 @@ def core_GP_Pixel_Scale_gen(h): h.rhead( "/* helper macros to transfer s1-bit value to s2-bit valuen" " * NOTE: efficient and accurate for both up- and downscaling,n" - " * WARNING: GP_SCALE_VAL requires constants numebrs as first two parametersn" + " * WARNING: GP_SCALE_VAL requires constants numbers as first two parametersn" " */n" "#define GP_SCALE_VAL(s1, s2, val) ( GP_SCALE_VAL_##s1##_##s2(val) )nn" ----------------------------------------------------------------------- Summary of changes: include/core/GP_Pixel.h | 24 ++++-- libs/SDL/GP_SDL_Context.c | 87 ++------------------- libs/backends/GP_Backend_SDL.c | 85 ++------------------- libs/{backends/GP_Backend.c => core/GP_Pixel.c} | 79 +++++++++----------- libs/loaders/Makefile | 2 +- pylib/gfxprim/generators/core/make_GP_Convert.py | 2 +- 6 files changed, 71 insertions(+), 208 deletions(-) copy libs/{backends/GP_Backend.c => core/GP_Pixel.c} (64%) 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.")
1
0
0
0
← Newer
1
2
Older →
Jump to page:
1
2
Results per page:
10
25
50
100
200