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 46a94e8b7af27012503eca96f3d5a1395d75bb10 (commit) via af8413c459e1427af1690769d44dd38eec968016 (commit) via d82e10f8c5711640d32a614c043d75c9b49808e1 (commit) via 3ac85f2f55d88631e43794d67e93663b73bd1f9d (commit) via 4920417b0a6d627b8d44d50a79ffe53419cd50d5 (commit) via ae4159f55d95af964981f666c129693281aade0e (commit) via 2ef01b5df8f4d6c6fe1e3a4f45096399b5629752 (commit) from c8a27730e311669696166d376863941b73e5e552 (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/46a94e8b7af27012503eca96f3d5a1395d75b...
commit 46a94e8b7af27012503eca96f3d5a1395d75bb10 Author: Tomas Gavenciak gavento@ucw.cz Date: Mon May 30 01:10:48 2011 +0200
Add TRANSFORM_BLIT for blit pre-transformation
+ edit doc string
diff --git a/include/core/GP_Transform.h b/include/core/GP_Transform.h index 152253d..9ea5eec 100644 --- a/include/core/GP_Transform.h +++ b/include/core/GP_Transform.h @@ -63,16 +63,29 @@ * Transform "user"-coordinates to "real"-coordinates of a rectangle corner * according to context transformation. Corner with min-coordinates is * transformed to (different) corner with min-coordinates etc. + * Arguments x, y, w, h are modified. */ -#define GP_TRANSFORM_RECT(context, x, y, rw, rh) do { - GP_TRANSFORM_SWAP(context, x, y); - GP_TRANSFORM_SWAP(context, w, h); - if ((context)->x_swap) { - x = (context)->w - x - rw; - } - if ((context)->y_swap) { - y = (context)->h - y - rh; - } +#define GP_TRANSFORM_RECT(context, x, y, w, h) do { + GP_TRANSFORM_SWAP(context, x, y); + GP_TRANSFORM_SWAP(context, w, h); + if ((context)->x_swap) { + x = (context)->w - x - w; + } + if ((context)->y_swap) { + y = (context)->h - y - h; + } +} while (0) + +/* + * Transform "user"-coordinates to "real"-coordinates for a blit + * called as GP_Blit(c1, x1, y1, w, h, c2, x2, y2). + * All x1, y1, x2, y2, w, h are adjusted. + */ +#define GP_TRANSFORM_BLIT(c1, x1, y1, w, h, c2, x2, y2) do { + GP_TRANSFORM_RECT(c1, x1, y1, w, h); + int w2 = w, h2 = h; + GP_TRANSFORM_SWAP(c2, w2, h2); + GP_TRANSFORM_RECT(c2, x2, y2, w2, h2); } while (0)
/*
http://repo.or.cz/w/gfxprim.git/commit/af8413c459e1427af1690769d44dd38eec968...
commit af8413c459e1427af1690769d44dd38eec968016 Author: Tomas Gavenciak gavento@ucw.cz Date: Mon May 30 01:09:50 2011 +0200
Add one generated header
diff --git a/include/core/GP_Pixel.h b/include/core/GP_Pixel.h index feb7eac..a1469e8 100644 --- a/include/core/GP_Pixel.h +++ b/include/core/GP_Pixel.h @@ -52,8 +52,9 @@ struct GP_Context;
typedef uint32_t GP_Pixel;
-/* Generated header */ +/* Generated headers */ #include "GP_Pixel.gen.h" +#include "GP_Pixel_Scale.gen.h"
/* * Information about ordering of pixels in byte for 1, 2 and 4 bpp
http://repo.or.cz/w/gfxprim.git/commit/d82e10f8c5711640d32a614c043d75c9b4980...
commit d82e10f8c5711640d32a614c043d75c9b49808e1 Author: Tomas Gavenciak gavento@ucw.cz Date: Mon May 30 01:07:32 2011 +0200
Reimplemented Get/PutPixel with generated code
Minor shuffling generators and includes around Common file GP_Pixel_Access.h (ugly name, huh)
diff --git a/include/core/GP_Core.h b/include/core/GP_Core.h index dd70700..a00f1d7 100644 --- a/include/core/GP_Core.h +++ b/include/core/GP_Core.h @@ -41,8 +41,10 @@ /* ... and it's trasformations */ #include "core/GP_Transform.h"
-/* Pixels */ -#include "GP_GetPixel.h" -#include "GP_PutPixel.h" +/* Pixeltypes */ +#include "core/GP_Pixel.h" + +/* Individual pixel access */ +#include "core/GP_Pixel_Access.h"
#endif /* GP_CORE_H */ diff --git a/include/core/GP_GetPixel.h b/include/core/GP_GetPixel.h deleted file mode 100644 index f611a1a..0000000 --- a/include/core/GP_GetPixel.h +++ /dev/null @@ -1,78 +0,0 @@ -/***************************************************************************** - * This file is part of gfxprim library. * - * * - * Gfxprim is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * Gfxprim is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with gfxprim; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02110-1301 USA * - * * - * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * - * * - *****************************************************************************/ - -#ifndef GP_GETPIXEL_H -#define GP_GETPIXEL_H - -#include "GP_Context.h" - -#define GP_GETPIXEL_1BPP(context, x, y) ({ - uint8_t *gp_pix_addr = GP_PIXEL_ADDR(context, x, y); - (0x80>>(x%8) & *gp_pix_addr) ? 1 : 0; -}) - -#define GP_GETPIXEL_2BPP(context, x, y) ({ - uint8_t *gp_pix_addr = GP_PIXEL_ADDR(context, x, y); - (*gp_pix_addr & (0xc0 >> (2*(x%4)))) >> (2*(3 - x%4)); -}) - -#define GP_GETPIXEL_4BPP(context, x, y) ({ - uint8_t *gp_pix_addr = GP_PIXEL_ADDR(context, x, y); - (*gp_pix_addr & (0xf0 >> (4*(x%2)))) >> (4*(1 - x%2)); -}) - -#define GP_GETPIXEL_8BPP(context, x, y) ({ - uint8_t *gp_pix_addr = GP_PIXEL_ADDR(context, x, y); - gp_pix_addr[0]; -}) - -#define GP_GETPIXEL_16BPP(context, x, y) ({ - uint8_t *gp_pix_addr = GP_PIXEL_ADDR(context, x, y); - gp_pix_addr[0]<<8 | gp_pix_addr[1]; -}) - -#define GP_GETPIXEL_24BPP(context, x, y) ({ - uint8_t *gp_pix_addr = GP_PIXEL_ADDR(context, x, y); - gp_pix_addr[0]<<16 | gp_pix_addr[1] << 8 | - gp_pix_addr[2]; -}) - -#define GP_GETPIXEL_32BPP(context, x, y) ({ - uint8_t *gp_pix_addr = GP_PIXEL_ADDR(context, x, y); - gp_pix_addr[0]<<24 | gp_pix_addr[1] << 16 | - gp_pix_addr[2] << 8 | gp_pix_addr[3]; -}) - -/* - * General getpixel. - */ -GP_Pixel GP_GetPixel(GP_Context *context, int x, int y); - -/* - * General rotated getpixel. - */ -GP_Pixel GP_TGetPixel(GP_Context *context, int x, int y); - -#endif /* GP_GETPIXEL_H */ diff --git a/libs/core/GP_PutPixel.c b/include/core/GP_Pixel_Access.h similarity index 60% rename from libs/core/GP_PutPixel.c rename to include/core/GP_Pixel_Access.h index 40a8363..3513d61 100644 --- a/libs/core/GP_PutPixel.c +++ b/include/core/GP_Pixel_Access.h @@ -16,50 +16,50 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2011 Tomas Gavenciak gavento@ucw.cz * * * *****************************************************************************/
-#include "GP_Core.h" +#ifndef GP_PIXEL_ACCESS_H +#define GP_PIXEL_ACCESS_H
+#include "GP_Context.h" #include "GP_FnPerBpp.h" +#include "GP_Pixel.h"
-#define DO_PUTPIXEL(bits) -void GP_PutPixel##bits##bpp(GP_Context *context, int x, int y, GP_Pixel pixel) -{ - if (GP_PIXEL_IS_CLIPPED(context, x, y)) - return; -- GP_PUTPIXEL_##bits##BPP(context, x, y, pixel); -} +/* + * Generated header + */ +#include "GP_Pixel_Access.gen.h"
-DO_PUTPIXEL(1) -DO_PUTPIXEL(2) -DO_PUTPIXEL(4) -DO_PUTPIXEL(8) -DO_PUTPIXEL(16) -DO_PUTPIXEL(24) -DO_PUTPIXEL(32) +/* + * GetPixel with context transformations and clipping. + * Returns 0 for clipped pixels or pixels outside bitmap. + */ +GP_Pixel GP_GetPixel_(GP_Context *context, int x, int y);
/* - * A generic PutPixel call that automatically determines the number of - * bits per pixel. + * Version of GetPixel without transformations nor border checking. */ -void GP_PutPixel(GP_Context *context, int x, int y, GP_Pixel pixel) +static inline GP_Pixel GP_GetPixel_Raw(GP_Context *context, int x, int y) { - GP_CHECK_CONTEXT(context); - - GP_FN_PER_BPP(GP_PutPixel, context->bpp, context, x, y, pixel); + GP_FN_RET_PER_BPP(GP_GetPixel_Raw, context->bpp, context->bit_endian, + context, x, y); }
-void GP_TPutPixel(GP_Context *context, int x, int y, GP_Pixel pixel) -{ - GP_CHECK_CONTEXT(context); - - GP_TRANSFORM_POINT(context, x, y); +/* + * PutPixel with context transformations and clipping. + * NOP for clipped pixels or pixels outside bitmap. + */ +void GP_PutPixel_(GP_Context *context, int x, int y, GP_Pixel p);
- GP_PutPixel(context, x, y, pixel); +/* + * Version of PutPixel without transformations nor border checking. + */ +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); } + +#endif /* GP_PIXEL_ACCESS_H */ diff --git a/include/core/GP_PutPixel.h b/include/core/GP_PutPixel.h deleted file mode 100644 index fe5b219..0000000 --- a/include/core/GP_PutPixel.h +++ /dev/null @@ -1,109 +0,0 @@ -/***************************************************************************** - * This file is part of gfxprim library. * - * * - * Gfxprim is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * Gfxprim is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with gfxprim; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02110-1301 USA * - * * - * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * - * * - *****************************************************************************/ - -#ifndef GP_PUTPIXEL_H -#define GP_PUTPIXEL_H - -#include "GP_Context.h" - -/* - * Putpixel macros. - */ -#define GP_PUTPIXEL_1BPP(context, x, y, pixel) do { - uint8_t *gp_pix_addr = GP_PIXEL_ADDR(context, x, y); -- if (pixel) - *gp_pix_addr |= (0x80>>(x%8)); - else - *gp_pix_addr &= ~(0x80>>(x%8)); -} while (0) - -#define GP_PUTPIXEL_2BPP(context, x, y, pixel) do { - uint8_t *gp_pix_addr = GP_PIXEL_ADDR(context, x, y); -- *gp_pix_addr = (*gp_pix_addr & ~(0xc0 >> (2*(x%4)))) | - (pixel << (2*(3 - x%4))); --} while (0) - -#define GP_PUTPIXEL_4BPP(context, x, y, pixel) do { - uint8_t *gp_pix_addr = GP_PIXEL_ADDR(context, x, y); -- *gp_pix_addr = (*gp_pix_addr & (0xf0 >> (4*(x%2)))) | - (pixel << (4*(1 - x%2))); -} while (0) - -#define GP_PUTPIXEL_8BPP(context, x, y, pixel) do { - uint8_t *gp_pix_addr = GP_PIXEL_ADDR(context, x, y); -- *gp_pix_addr = (pixel) & 0xff; -} while (0) - -#define GP_PUTPIXEL_16BPP(context, x, y, pixel) do { - uint8_t *gp_pix_addr = GP_PIXEL_ADDR(context, x, y); -- gp_pix_addr[0] = pixel & 0xff; - gp_pix_addr[1] = (pixel>>8) & 0xff; -} while (0) - -#define GP_PUTPIXEL_24BPP(context, x, y, pixel) do { - uint8_t *gp_pix_addr = GP_PIXEL_ADDR(context, x, y); -- gp_pix_addr[0] = pixel & 0xff; - gp_pix_addr[1] = (pixel>>8) & 0xff; - gp_pix_addr[2] = (pixel>>16) & 0xff; -} while (0) - -#define GP_PUTPIXEL_32BPP(context, x, y, pixel) do { - uint8_t *gp_pix_addr = GP_PIXEL_ADDR(context, x, y); -- gp_pix_addr[0] = pixel & 0xff; - gp_pix_addr[1] = (pixel>>8) & 0xff; - gp_pix_addr[2] = (pixel>>16) & 0xff; - gp_pix_addr[3] = (pixel>>24) & 0xff; -} while (0) - -/* - * Safe functions, that checks clipping. - */ -void GP_PutPixel1bpp(GP_Context *context, int x, int y, GP_Pixel pixel); -void GP_PutPixel2bpp(GP_Context *context, int x, int y, GP_Pixel pixel); -void GP_PutPixel4bpp(GP_Context *context, int x, int y, GP_Pixel pixel); -void GP_PutPixel8bpp(GP_Context *context, int x, int y, GP_Pixel pixel); -void GP_PutPixel16bpp(GP_Context *context, int x, int y, GP_Pixel pixel); -void GP_PutPixel24bpp(GP_Context *context, int x, int y, GP_Pixel pixel); -void GP_PutPixel32bpp(GP_Context *context, int x, int y, GP_Pixel pixel); - -/* - * General putpixel. - */ -void GP_PutPixel(GP_Context *context, int x, int y, GP_Pixel pixel); - -/* - * General rotated putpixel. - */ -void GP_TPutPixel(GP_Context *context, int x, int y, GP_Pixel pixel); - -#endif /* GP_PUTPIXEL_H */ diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_Gfx.h index 19bad4e..2f42cb1 100644 --- a/include/gfx/GP_Gfx.h +++ b/include/gfx/GP_Gfx.h @@ -37,8 +37,7 @@ #include "core/GP_Transform.h" #include "core/GP_Context.h" #include "core/GP_WritePixel.h" -#include "core/GP_GetPixel.h" -#include "core/GP_PutPixel.h" +#include "core/GP_Pixel_Access.h" #include "core/GP_Color.h"
/* public drawing API */ diff --git a/libs/core/GP_GetPixel.c b/libs/core/GP_Pixel_Access.c similarity index 64% rename from libs/core/GP_GetPixel.c rename to libs/core/GP_Pixel_Access.c index 76013b4..4f9b579 100644 --- a/libs/core/GP_GetPixel.c +++ b/libs/core/GP_Pixel_Access.c @@ -16,44 +16,24 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2011 Tomas Gavenciak gavento@ucw.cz * * * *****************************************************************************/
-#include "GP_Core.h" -#include "GP_FnPerBpp.h" - -#define DO_GETPIXEL(bits) -GP_RetCode GP_GetPixel##bits##bpp(GP_Context *context, int x, int y) -{ - if (GP_PIXEL_IS_CLIPPED(context, x, y)) - return 0; -- return GP_GETPIXEL_##bits##BPP(context, x, y); -} - -DO_GETPIXEL(1) -DO_GETPIXEL(2) -DO_GETPIXEL(4) -DO_GETPIXEL(8) -DO_GETPIXEL(16) -DO_GETPIXEL(24) -DO_GETPIXEL(32) +#include "GP_Pixel_Access.h" +#include "GP_Transform.h"
-GP_Pixel GP_GetPixel(GP_Context *context, int x, int y) +GP_Pixel GP_GetPixel_(GP_Context *context, int x, int y) { - GP_CHECK_CONTEXT(context); - - GP_FN_RET_PER_BPP(GP_GetPixel, context->bpp, context, x, y); - - return 0; + GP_TRANSFORM_POINT(context, x, y); + if (GP_PIXEL_IS_CLIPPED(context, x, y)) + return 0; + return GP_GetPixel_Raw(context, x, y); }
-GP_Pixel GP_TGetPixel(GP_Context *context, int x, int y) +void GP_PutPixel_(GP_Context *context, int x, int y, GP_Pixel p) { GP_TRANSFORM_POINT(context, x, y); - return GP_GetPixel(context, x, y); + if (! GP_PIXEL_IS_CLIPPED(context, x, y)) + GP_PutPixel_Raw(context, x, y, p); } diff --git a/libs/core/Makefile b/libs/core/Makefile index 8126e00..0b9fb55 100644 --- a/libs/core/Makefile +++ b/libs/core/Makefile @@ -1,6 +1,6 @@ TOPDIR=../.. GENSOURCES=GP_Pixel.gen.c GP_Blit.gen.c -GENHEADERS=GP_Pixel_Scale.gen.h GP_Blit.gen.h GP_Pixel.gen.h +GENHEADERS=GP_Pixel_Scale.gen.h GP_Blit.gen.h GP_Pixel.gen.h GP_Pixel_Access.gen.h CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c)) LIBNAME=core
diff --git a/pylib/gfxprim/generators/core/gen_pixel_access.py b/pylib/gfxprim/generators/core/gen_pixel_access.py new file mode 100644 index 0000000..6b96fc3 --- /dev/null +++ b/pylib/gfxprim/generators/core/gen_pixel_access.py @@ -0,0 +1,51 @@ +# Module generating C source and headers for get/putpixel +# 2011 - Tomas Gavenciak gavento@ucw.cz + +from gfxprim.generators.utils import * + +def gen_get_pixel_addr_bpp(size, size_suffix, header): + "Generate GP_PIXEL_ADDR_<size_suffix> and _OFFSET_<size_suffix> macros" + bit_endian = size_suffix[-2:] + if size < 8: + assert bit_endian in ['LE', 'BE'] + header.rbody( + "/* macro to get address of pixel in a {{ size_suffix }} context */n" + "#define GP_PIXEL_ADDR_{{ size_suffix }}(context, x, y) " + " ((context)->pixels + (context)->bytes_per_row * (y) + {{ size//8 }} * (x))n" + "/* macro to get bit-offset of pixel in {{ size_suffix }} context */n" + "{% if size >= 8 %}" + "#define GP_PIXEL_ADDR_OFFSET_{{ size_suffix }}(x) (0)n" + "{% else %}" # bit_endian matters + "{% if bit_endian=='LE' %}" + "#define GP_PIXEL_ADDR_OFFSET_{{ size_suffix }}(x) " + " (((x) % {{ 8//size }}) * {{ size }})n" + "{% else %}" + "#define GP_PIXEL_ADDR_OFFSET_{{ size_suffix }}(x) " + " ({{ 8-size }} - ((x) % {{ 8//size }}) * {{ size }})n" + "{% endif %}" + "{% endif %}", + size=size, size_suffix=size_suffix, bit_endian=bit_endian) + +def gen_getpixel_bpp(size, size_suffix, header): + "Generate code for GetPixel_Raw_xBPP, no clipping or transform. " + "Only depends on bpp (bit size), size_suffix must be " + "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" + "{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) + +def gen_putpixel_bpp(size, size_suffix, header): + "Generate code for PutPixel_Raw_xBPP, no clipping or transform. " + "Only depends on bpp (bit size), size_suffix must be " + "of form 8BPP, 2BPP_LE and the like." + header.rbody( + "n/*** GP_PutPixel for {{ size_suffix }} ***/n" + "static inline void GP_PutPixel_Raw_{{ size_suffix }}(GP_Context *c, int x, int y, GP_Pixel p)n" + "{n" + " GP_SET_BITS(GP_PIXEL_ADDR_OFFSET_{{ size_suffix }}(x) , {{ size }},n" + " *(GP_PIXEL_ADDR_{{ size_suffix}}(c, x, y)), p);n" + "}nn", size=size, size_suffix=size_suffix) diff --git a/pylib/gfxprim/generators/core/gen_pixeltype.py b/pylib/gfxprim/generators/core/gen_pixeltype.py index b46d3dd..ea3ae20 100644 --- a/pylib/gfxprim/generators/core/gen_pixeltype.py +++ b/pylib/gfxprim/generators/core/gen_pixeltype.py @@ -154,25 +154,3 @@ def gen_get_pixel_addr(ptype, header, code): " GP_PIXEL_ADDR_OFFSET_{{ f.size_suffix }}(x)n", f=ptype)
-def gen_get_pixel_addr_bpp(size, size_suffix, header, code): - "Generate GP_PIXEL_ADDR_<size_suffix> and _OFFSET_<size_suffix> macros" - bit_endian = size_suffix[-2:] - if size < 8: - assert bit_endian in ['LE', 'BE'] - header.rbody( - "/* macro to get address of pixel in a {{ size_suffix }} context */n" - "#define GP_PIXEL_ADDR_{{ size_suffix }}(context, x, y) " - " ((context)->pixels + (context)->bytes_per_row * (y) + {{ size//8 }} * (x))n" - "/* macro to get bit-offset of pixel in {{ size_suffix }} context */n" - "{% if size >= 8 %}" - "#define GP_PIXEL_ADDR_OFFSET_{{ size_suffix }}(x) (0)n" - "{% else %}" # bit_endian matters - "{% if bit_endian=='LE' %}" - "#define GP_PIXEL_ADDR_OFFSET_{{ size_suffix }}(x) " - " (((x) % {{ 8//size }}) * {{ size }})n" - "{% else %}" - "#define GP_PIXEL_ADDR_OFFSET_{{ size_suffix }}(x) " - " ({{ 8-size }} - ((x) % {{ 8//size }}) * {{ size }})n" - "{% endif %}" - "{% endif %}", - size=size, size_suffix=size_suffix, bit_endian=bit_endian) diff --git a/pylib/gfxprim/generators/core/make_GP_Pixel.py b/pylib/gfxprim/generators/core/make_GP_Pixel.py index f383f98..0a1ff3b 100644 --- a/pylib/gfxprim/generators/core/make_GP_Pixel.py +++ b/pylib/gfxprim/generators/core/make_GP_Pixel.py @@ -1,6 +1,10 @@ #!/usr/bin/python # -# Script generating GP_Pixel.gen.c and GP_Pixel.gen.h +# Script generating: +# +# GP_Pixel.gen.c, GP_Pixel.gen.h +# GP_Pixel_Scale.gen.h +# GP_Pixel_Access.gen.h # # 2011 - Tomas Gavenciak gavento@ucw.cz # @@ -8,9 +12,10 @@ from gfxprim.generators.generator import * from gfxprim.generators.pixeltype import * from gfxprim.generators.core.gen_pixeltype import * +from gfxprim.generators.core.gen_pixel_access import *
@generator(CHeaderGenerator(name = 'GP_Pixel_Scale.gen.h'), - descr = 'fast value scaling macros', + descr = 'Fast value scaling macrosnDo not include directly, use GP_Pixel.h', authors = ["2011 - Tomas Gavenciak gavento@ucw.cz"]) def core_GP_Pixel_Scale_gen(h): h.rhead( @@ -31,13 +36,12 @@ def core_GP_Pixel_Scale_gen(h):
@generator(CHeaderGenerator(name='GP_Pixel.gen.h'), CSourceGenerator(name='GP_Pixel.gen.c'), - descr = 'pixel type definitions and functions', + descr = 'Pixel type definitions and functionsnDo not include directly, use GP_Pixel.h', authors = ["2011 - Tomas Gavenciak gavento@ucw.cz"]) def core_GP_Pixel_gen(h, c): c.rhead( '#include <stdio.h>n' - '#include <GP.h>n' - '#include "GP_Pixel.h"n') + '#include "GP_Pixel.h"nn')
## Enum of types gen_GP_PixelType(h, c) @@ -57,14 +61,28 @@ def core_GP_Pixel_gen(h, c): gen_get_chs(t, h, c) gen_get_pixel_addr(t, h, c)
- # Per-bpp macros - for bpp in bitsizes: - for bit_endian in bit_endians: - if (bpp < 8) or (bit_endian == bit_endians[0]): - gen_get_pixel_addr_bpp(bpp, get_size_suffix(bpp, bit_endian), h, c) - ## Conversion macros gen_convert_to(pixeltypes['RGB565'], pixeltypes['RGBA8888'], h, c) gen_convert_to(pixeltypes['RGBA8888'], pixeltypes['V2'], h, c) gen_convert_to(pixeltypes['VA12'], pixeltypes['RGBA8888'], h, c)
+ +@generator(CHeaderGenerator(name = 'GP_Pixel_Access.gen.h'), + descr = 'Access pixel bytes, Put and GetPixelnDo not include directly, use GP_Pixel.h', + authors = ["2011 - Tomas Gavenciak gavento@ucw.cz"]) +def core_GP_Pixel_Scale_gen(h): + h.rhead('#include "GP_Common.h"nn'); + h.rhead('struct GP_Context;nn'); + # Per-bpp adress/offset macros + for bpp in bitsizes: + for bit_endian in bit_endians: + if (bpp < 8) or (bit_endian == bit_endians[0]): + gen_get_pixel_addr_bpp(bpp, get_size_suffix(bpp, bit_endian), h) + + # Per-bpp adress/offset macros + for bpp in bitsizes: + for bit_endian in bit_endians: + if (bpp < 8) or (bit_endian == bit_endians[0]): + gen_getpixel_bpp(bpp, get_size_suffix(bpp, bit_endian), h) + gen_putpixel_bpp(bpp, get_size_suffix(bpp, bit_endian), h) +
http://repo.or.cz/w/gfxprim.git/commit/3ac85f2f55d88631e43794d67e93663b73bd1...
commit 3ac85f2f55d88631e43794d67e93663b73bd1f9d Author: Tomas Gavenciak gavento@ucw.cz Date: Mon May 30 01:03:59 2011 +0200
Add includes to GP_Blit.c
diff --git a/libs/core/GP_Blit.c b/libs/core/GP_Blit.c index 20c13ba..a316597 100644 --- a/libs/core/GP_Blit.c +++ b/libs/core/GP_Blit.c @@ -21,6 +21,8 @@ *****************************************************************************/
#include "GP_Pixel.h" +#include "GP_Pixel_Access.h" +#include "GP_Context.h"
/* void GP_Blit(const GP_Context *c1, int x1, int y1, int w, int h,
http://repo.or.cz/w/gfxprim.git/commit/4920417b0a6d627b8d44d50a79ffe53419cd5...
commit 4920417b0a6d627b8d44d50a79ffe53419cd50d5 Author: Tomas Gavenciak gavento@ucw.cz Date: Mon May 30 01:03:16 2011 +0200
Make FnPerBPP depend on bit-endian
diff --git a/include/core/GP_FnPerBpp.h b/include/core/GP_FnPerBpp.h index 7cd5889..ed2356d 100644 --- a/include/core/GP_FnPerBpp.h +++ b/include/core/GP_FnPerBpp.h @@ -29,79 +29,79 @@ * Extra arguments are arguments to be passed to the function. * Returns GP_ENOIMPL if the bit depth is unknown. */ -#define GP_FN_PER_BPP(FN_NAME, bpp, ...) +#define GP_FN_PER_BPP(FN_NAME, bpp, bit_endian, ...) switch (bpp) { case 1: {- if (context->bit_endian==GP_BIT_ENDIAN_LE)- FN_NAME##1bpp_LE(__VA_ARGS__);+ if (bit_endian==GP_BIT_ENDIAN_LE)+ FN_NAME##_1BPP_LE(__VA_ARGS__); else - FN_NAME##1bpp_BE(__VA_ARGS__);+ FN_NAME##_1BPP_BE(__VA_ARGS__); } break; case 2: {- if (context->bit_endian==GP_BIT_ENDIAN_LE)- FN_NAME##2bpp_LE(__VA_ARGS__);+ if (bit_endian==GP_BIT_ENDIAN_LE)+ FN_NAME##_2BPP_LE(__VA_ARGS__); else - FN_NAME##2bpp_BE(__VA_ARGS__);+ FN_NAME##_2BPP_BE(__VA_ARGS__); } break; case 4: {- if (context->bit_endian==GP_BIT_ENDIAN_LE)- FN_NAME##4bpp_LE(__VA_ARGS__);+ if (bit_endian==GP_BIT_ENDIAN_LE)+ FN_NAME##_4BPP_LE(__VA_ARGS__); else - FN_NAME##4bpp_BE(__VA_ARGS__);+ FN_NAME##_4BPP_BE(__VA_ARGS__); } break; case 8: - FN_NAME##8bpp(__VA_ARGS__); + FN_NAME##_8BPP(__VA_ARGS__); break; case 16: - FN_NAME##16bpp( __VA_ARGS__); + FN_NAME##_16BPP(__VA_ARGS__); break; case 24: - FN_NAME##24bpp(__VA_ARGS__); + FN_NAME##_24BPP(__VA_ARGS__); break; case 32: - FN_NAME##32bpp(__VA_ARGS__); + FN_NAME##_32BPP(__VA_ARGS__); break; default: break; } -#define GP_FN_RET_PER_BPP(FN_NAME, bpp, ...) +#define GP_FN_RET_PER_BPP(FN_NAME, bpp, bit_endian, ...) switch (bpp) { case 1: {- if (context->bit_endian==GP_BIT_ENDIAN_LE)- return FN_NAME##1bpp_LE(__VA_ARGS__);+ if (bit_endian==GP_BIT_ENDIAN_LE)+ return FN_NAME##_1BPP_LE(__VA_ARGS__); else - return FN_NAME##1bpp_BE(__VA_ARGS__);+ return FN_NAME##_1BPP_BE(__VA_ARGS__); } case 2: {- if (context->bit_endian==GP_BIT_ENDIAN_LE)- return FN_NAME##2bpp_LE(__VA_ARGS__);+ if (bit_endian==GP_BIT_ENDIAN_LE)+ return FN_NAME##_2BPP_LE(__VA_ARGS__); else - return FN_NAME##2bpp_BE(__VA_ARGS__);+ return FN_NAME##_2BPP_BE(__VA_ARGS__); } case 4: {- if (context->bit_endian==GP_BIT_ENDIAN_LE)- return FN_NAME##4bpp_LE(__VA_ARGS__);+ if (bit_endian==GP_BIT_ENDIAN_LE)+ return FN_NAME##_4BPP_LE(__VA_ARGS__); else - return FN_NAME##4bpp_BE(__VA_ARGS__);+ return FN_NAME##_4BPP_BE(__VA_ARGS__); } case 8: - return FN_NAME##8bpp(__VA_ARGS__) ; + return FN_NAME##_8BPP(__VA_ARGS__); case 16: - return FN_NAME##16bpp(__VA_ARGS__); + return FN_NAME##_16BPP(__VA_ARGS__); case 24: - return FN_NAME##24bpp(__VA_ARGS__); + return FN_NAME##_24BPP(__VA_ARGS__); case 32: - return FN_NAME##32bpp(__VA_ARGS__); + return FN_NAME##_32BPP(__VA_ARGS__); }
http://repo.or.cz/w/gfxprim.git/commit/ae4159f55d95af964981f666c129693281aad...
commit ae4159f55d95af964981f666c129693281aade0e Author: Tomas Gavenciak gavento@ucw.cz Date: Mon May 30 00:55:18 2011 +0200
Added 'const' to GP_ContextW/H
diff --git a/include/core/GP_Context.h b/include/core/GP_Context.h index a8b04db..da344f3 100644 --- a/include/core/GP_Context.h +++ b/include/core/GP_Context.h @@ -141,7 +141,7 @@ void GP_ContextFlagsRotateCCW(GP_Context *context); /* * Returns context width and height. */ -static inline uint32_t GP_ContextW(GP_Context *context) +static inline uint32_t GP_ContextW(const GP_Context *context) { if (context->axes_swap) return context->h; @@ -149,7 +149,7 @@ static inline uint32_t GP_ContextW(GP_Context *context) return context->w; }
-static inline uint32_t GP_ContextH(GP_Context *context) +static inline uint32_t GP_ContextH(const GP_Context *context) { if (context->axes_swap) return context->w;
http://repo.or.cz/w/gfxprim.git/commit/2ef01b5df8f4d6c6fe1e3a4f45096399b5629...
commit 2ef01b5df8f4d6c6fe1e3a4f45096399b5629752 Author: Tomas Gavenciak gavento@ucw.cz Date: Mon May 30 00:14:43 2011 +0200
Naive blit implementation (testing reference)
After losing my older, much more complete version ...
diff --git a/libs/core/GP_Blit.c b/libs/core/GP_Blit.c new file mode 100644 index 0000000..20c13ba --- /dev/null +++ b/libs/core/GP_Blit.c @@ -0,0 +1,74 @@ +/***************************************************************************** + * 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) 2011 Tomas Gavenciak gavento@ucw.cz * + * * + *****************************************************************************/ + +#include "GP_Pixel.h" + +/* +void GP_Blit(const GP_Context *c1, int x1, int y1, int w, int h, + GP_Context *c2, int x2, int y2) +{ + // Ultimate TODO: effective processing + GP_Blit_Naive(c1, x1, y1, w, h, c2, x2, y2); +} +*/ + +// TODO(gavento, czech) Plan: +// GP_Blit_Naive - Zadne rotovani a tak, jen Get/PutPixel a konverze A->RGBA8888->B +// GP_Blit_Simple - S rotovanim, makrovy Get/PutPixel, mozna optimalizace na radky, chytrejsi konverze (ale porad univ.) +// GP_Blit_Simple_xBPP - S rotovanim, makrovy Get/PutPixel +// GP_Blit_xBPP - Optimalizovane, muze volat GP_Blit_Simple_xBPP pro divne pripady +// GP_Blit - Vola GP_Blit_xBPP (stejny typ) nebo GP_Blit_Simple (jine typy), pripadne optimalizovat + +/* +void GP_Blit_Naive(const GP_Context *c1, int x1, int y1, int w, int h, + GP_Context *c2, int x2, int y2) +{ + GP_TRANSFORM_BLIT(c1, x1, y1, w, h, c2, x2, y2); + // TODO: Cipping? + GP_Blit_Naive_Raw(c1, x1, y1, w, h, c2, x2, y2); +} +*/ + +/* + * Very naive blit, no optimalizations whatsoever - keep it that way. + * Used as a reference for testing and such. Aaand ultimate fallback. + */ +void GP_Blit_Naive(const GP_Context *c1, int x1, int y1, int w, int h, + GP_Context *c2, int x2, int y2) +{ + 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); + GP_CHECK(y2 >= 0); + 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++) { + GP_Pixel p = GP_GetPixel(c1, x1 + i, y1 + j); + GP_PutPixel(c2, x2 + i, y2 + j); + } +}
-----------------------------------------------------------------------
Summary of changes: include/core/GP_Context.h | 4 +- include/core/GP_Core.h | 8 +- include/core/GP_FnPerBpp.h | 56 +++++----- include/core/GP_GetPixel.h | 78 -------------- include/core/GP_Pixel.h | 3 +- .../core/GP_Pixel_Access.h | 64 ++++++------ include/core/GP_PutPixel.h | 109 -------------------- include/core/GP_Transform.h | 31 ++++-- include/gfx/GP_Gfx.h | 3 +- libs/core/GP_Blit.c | 76 ++++++++++++++ libs/core/GP_GetPixel.c | 59 ----------- .../GP_Filters.h => libs/core/GP_Pixel_Access.c | 30 +++--- libs/core/Makefile | 2 +- pylib/gfxprim/generators/core/gen_pixel_access.py | 51 +++++++++ pylib/gfxprim/generators/core/gen_pixeltype.py | 22 ---- pylib/gfxprim/generators/core/make_GP_Pixel.py | 40 +++++-- 16 files changed, 265 insertions(+), 371 deletions(-) delete mode 100644 include/core/GP_GetPixel.h rename libs/core/GP_PutPixel.c => include/core/GP_Pixel_Access.h (60%) delete mode 100644 include/core/GP_PutPixel.h create mode 100644 libs/core/GP_Blit.c delete mode 100644 libs/core/GP_GetPixel.c copy include/filters/GP_Filters.h => libs/core/GP_Pixel_Access.c (76%) create mode 100644 pylib/gfxprim/generators/core/gen_pixel_access.py
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.