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 89909d1774eb1b3ac35e2e643401bab3b79c9dc2 (commit) from 23a690342a49f0f96aad7ce26eb0d7290349d4f3 (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/89909d1774eb1b3ac35e2e643401bab3b79c9...
commit 89909d1774eb1b3ac35e2e643401bab3b79c9dc2 Author: Jiri BlueBear Dluhos jiri.bluebear.dluhos@gmail.com Date: Mon Dec 17 23:55:01 2012 +0100
Templatized HLine, modernized WritePixel slightly.
diff --git a/include/core/GP_WritePixel.h b/include/core/GP_WritePixel.h index 0d1a875..d9530f9 100644 --- a/include/core/GP_WritePixel.h +++ b/include/core/GP_WritePixel.h @@ -50,16 +50,27 @@ void GP_WritePixels_4BPP_LE(uint8_t *start, uint8_t off, size_t cnt, uint8_t val);
/* - * These calls are not byte aligned, thuss needs start offset. + * These calls are not byte aligned, thus need start offset. */ -void GP_WritePixels1bpp(uint8_t *start, uint8_t off, size_t cnt, uint8_t val); -void GP_WritePixels2bpp(uint8_t *start, uint8_t off, size_t cnt, uint8_t val); -void GP_WritePixels4bpp(uint8_t *start, uint8_t off, size_t cnt, uint8_t val); -void GP_WritePixels18bpp(void *start, uint8_t off, size_t count, uint32_t value); +void GP_WritePixels_1BPP_BE(uint8_t *start, uint8_t off, size_t cnt, uint8_t val); +void GP_WritePixels_2BPP_BE(uint8_t *start, uint8_t off, size_t cnt, uint8_t val); +void GP_WritePixels_4BPP_BE(uint8_t *start, uint8_t off, size_t cnt, uint8_t val); +void GP_WritePixels_18BPP_BE(void *start, uint8_t off, size_t count, uint32_t value);
-void GP_WritePixels8bpp(void *start, size_t count, uint8_t value); -void GP_WritePixels16bpp(void *start, size_t count, uint16_t value); -void GP_WritePixels24bpp(void *start, size_t count, uint32_t value); -void GP_WritePixels32bpp(void *start, size_t count, uint32_t value); +/* Byte-aligned calls. */ +void GP_WritePixels_8BPP(void *start, size_t count, uint8_t value); +void GP_WritePixels_16BPP(void *start, size_t count, uint16_t value); +void GP_WritePixels_24BPP(void *start, size_t count, uint32_t value); +void GP_WritePixels_32BPP(void *start, size_t count, uint32_t value); + +/* aliases for older names */ +#define GP_WritePixels1bpp GP_WritePixels_1BPP_BE +#define GP_WritePixels2bpp GP_WritePixels_2BPP_BE +#define GP_WritePixels4bpp GP_WritePixels_4BPP_BE +#define GP_WritePixels18bpp GP_WritePixels_18BPP_BE +#define GP_WritePixels8bpp GP_WritePixels_8BPP +#define GP_WritePixels16bpp GP_WritePixels_16BPP +#define GP_WritePixels24bpp GP_WritePixels_24BPP +#define GP_WritePixels32bpp GP_WritePixels_32BPP
#endif /* GP_WRITEPIXEL_H */ diff --git a/libs/core/GP_WritePixel.c b/libs/core/GP_WritePixel.c index bc57ea1..a6829b0 100644 --- a/libs/core/GP_WritePixel.c +++ b/libs/core/GP_WritePixel.c @@ -41,40 +41,40 @@ void GP_WritePixels_1BPP_LE(uint8_t *start, uint8_t off, break; case 1: GP_SET_BITS1_ALIGNED(1, 1, start, val); - + if (--len == 0) return; case 2: GP_SET_BITS1_ALIGNED(2, 1, start, val); - + if (--len == 0) return; case 3: GP_SET_BITS1_ALIGNED(3, 1, start, val); - + if (--len == 0) return; case 4: GP_SET_BITS1_ALIGNED(4, 1, start, val); - + if (--len == 0) return; case 5: GP_SET_BITS1_ALIGNED(5, 1, start, val); - + if (--len == 0) return; case 6: GP_SET_BITS1_ALIGNED(6, 1, start, val); - + if (--len == 0) return; case 7: GP_SET_BITS1_ALIGNED(7, 1, start, val); - + if (--len == 0) return; - + start++; break; } @@ -117,27 +117,27 @@ void GP_WritePixels_2BPP_LE(uint8_t *start, uint8_t off, break; case 1: GP_SET_BITS1_ALIGNED(2, 2, start, val); - + if (--len == 0) return; case 2: GP_SET_BITS1_ALIGNED(4, 2, start, val); - + if (--len == 0) return; case 3: GP_SET_BITS1_ALIGNED(6, 2, start, val); - + if (--len == 0) return; - + start++; - break; + break; } - + /* Write as many bytes as possible */ memset(start, bytes_2BPP[val & 0x03], len/4); - + start+=len/4;
/* And the rest */ @@ -168,17 +168,17 @@ void GP_WritePixels_4BPP_LE(uint8_t *start, uint8_t off, break; case 1: GP_SET_BITS1_ALIGNED(4, 4, start, val); - + if (--len == 0) return; - + start++; - break; + break; }
/* Write as many bytes as possible */ memset(start, bytes_4BPP[val & 0x0f], len/2); - + start+=len/2;
/* And the rest */ @@ -193,7 +193,7 @@ static const uint8_t chunks_1bpp[8] = { 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, };
-void GP_WritePixels1bpp(uint8_t *start, uint8_t off, size_t cnt, uint8_t val) +void GP_WritePixels_1BPP_BE(uint8_t *start, uint8_t off, size_t cnt, uint8_t val) { uint8_t s_off = off % 8; uint8_t e_off = (cnt + s_off) % 8; @@ -218,7 +218,7 @@ void GP_WritePixels1bpp(uint8_t *start, uint8_t off, size_t cnt, uint8_t val)
/* write len - 2 bytes */ if (len > 1) - GP_WritePixels8bpp(start + 1, len - 2, col); + GP_WritePixels_8BPP(start + 1, len - 2, col);
/* deal with the start and end */ if (val) { @@ -236,7 +236,7 @@ static const uint8_t colors_2bpp[4] = {
#define PUT_PIXEL_2BPP(p, off, pix) *(p) = (*(p) & ~(0xc0>>(off))) | (pix<<(6 - off))
-void GP_WritePixels2bpp(uint8_t *start, uint8_t off, size_t cnt, uint8_t val) +void GP_WritePixels_2BPP_BE(uint8_t *start, uint8_t off, size_t cnt, uint8_t val) { uint8_t s_off = off % 4; uint8_t e_off = 2 * ((cnt + s_off) % 4); @@ -252,7 +252,7 @@ void GP_WritePixels2bpp(uint8_t *start, uint8_t off, size_t cnt, uint8_t val)
for (off = s_off; off < max; off+=2) PUT_PIXEL_2BPP(start, off, val); - + if (len <= 8) return;
@@ -264,7 +264,7 @@ void GP_WritePixels2bpp(uint8_t *start, uint8_t off, size_t cnt, uint8_t val)
/* write len - 2 bytes */ if (len > 1) - GP_WritePixels8bpp(start + 1, len - 2, colors_2bpp[val]); + GP_WritePixels_8BPP(start + 1, len - 2, colors_2bpp[val]);
/* handle start and end */ start[0] = (start[0] & (0xff << (8 - s_off))) | @@ -275,7 +275,7 @@ void GP_WritePixels2bpp(uint8_t *start, uint8_t off, size_t cnt, uint8_t val) }
-void GP_WritePixels4bpp(uint8_t *start, uint8_t off, size_t cnt, uint8_t val) +void GP_WritePixels_4BPP_BE(uint8_t *start, uint8_t off, size_t cnt, uint8_t val) { uint8_t s_off = off % 2; uint8_t e_off = (cnt + s_off) % 2; @@ -285,20 +285,20 @@ void GP_WritePixels4bpp(uint8_t *start, uint8_t off, size_t cnt, uint8_t val) uint8_t col = (val << 4)& val;
if (len > 0) - GP_WritePixels8bpp(start + s_off, len, val); + GP_WritePixels_8BPP(start + s_off, len, val);
/* handle start and end */ if (s_off) GP_SET_BITS(4, 4, start[0], col); if (e_off) GP_SET_BITS(0, 4, start[len+s_off], val); }
-void GP_WritePixels8bpp(void *start, size_t count, uint8_t value) +void GP_WritePixels_8BPP(void *start, size_t count, uint8_t value) { - + memset(start, value, count); }
-void GP_WritePixels16bpp(void *start, size_t count, uint16_t value) +void GP_WritePixels_16BPP(void *start, size_t count, uint16_t value) { uint16_t *p = (uint16_t *) start; size_t i; @@ -323,12 +323,17 @@ void GP_WritePixels16bpp(void *start, size_t count, uint16_t value) } }
-void GP_WritePixels18bpp(void *start, uint8_t off, size_t count, uint32_t value) +void GP_WritePixels_18BPP_LE(void *start, uint8_t off, size_t count, uint32_t value) +{ + #warning TODO +} + +void GP_WritePixels_18BPP_BE(void *start, uint8_t off, size_t count, uint32_t value) { #warning TODO }
-void GP_WritePixels24bpp(void *start, size_t count, uint32_t value) +void GP_WritePixels_24BPP(void *start, size_t count, uint32_t value) { uint8_t *bytep = (uint8_t *) start;
@@ -406,7 +411,7 @@ void GP_WritePixels24bpp(void *start, size_t count, uint32_t value) break; }
- /* + /* * Write as much of the line as possible as * triplets of 32-bit numbers; hopefully the compiler can * put some wide write instructions in. @@ -448,11 +453,11 @@ void GP_WritePixels24bpp(void *start, size_t count, uint32_t value) } }
-void GP_WritePixels32bpp(void *start, size_t count, uint32_t value) +void GP_WritePixels_32BPP(void *start, size_t count, uint32_t value) { /* * Inspired by GNU libc's wmemset() (by Ulrich Drepper, licensed under LGPL). - * + * * Write the pixels in groups of four, allowing the compiler to use * MMX/SSE/similar instructions if available. The last few pixels are * copied normally one-by-one. (Speed gain is about 15% over a naive loop diff --git a/libs/gfx/GP_HLine.c b/libs/gfx/GP_HLine.gen.c.t similarity index 82% rename from libs/gfx/GP_HLine.c rename to libs/gfx/GP_HLine.gen.c.t index 35e3e36..8fe9169 100644 --- a/libs/gfx/GP_HLine.c +++ b/libs/gfx/GP_HLine.gen.c.t @@ -23,18 +23,56 @@ * * *****************************************************************************/
+%% extends "base.c.t" + +{% block descr %}Horizontal line drawing{% endblock %} + +%% block body + #include "core/GP_FnPerBpp.h" #include "core/GP_WritePixel.h" #include "core/GP_Transform.h"
-#include "algo/HLine.algo.h" +/* #include "algo/HLine.algo.h" */
#include "gfx/GP_HLine.h" #include "gfx/GP_VLine.h"
+%% for ps in pixelsizes + +void GP_HLine_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int x1, int y, + GP_Pixel pixel) +{ + /* draw always from left to right, swap coords if necessary */ + if (x0 > x1) + GP_SWAP(x0, x1); + + /* return immediately if the line is completely out of surface */ + if (y < 0 || y >= (int) context->h || + x1 < 0 || x0 >= (int) context->w) + return; + + /* clip the line against surface boundaries */ + x0 = GP_MAX(x0, 0); + x1 = GP_MIN(x1, (int) context->w - 1); + + size_t length = 1 + x1 - x0; + void *start = GP_PIXEL_ADDR(context, x0, y); + +%% if ps.needs_bit_endian() + GP_WritePixels_{{ ps.suffix }}(start, x0 % (8 / context->bpp), length, pixel); +%% else + GP_WritePixels_{{ ps.suffix }}(start, length, pixel); +%% endif + +} + +%% endfor + /* Generate drawing functions for various bit depths. */
//TODO: BIT ENDIANESS +/* DEF_HLINE_BU_FN(GP_HLine_Raw_1BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels_1BPP_LE) DEF_HLINE_BU_FN(GP_HLine_Raw_1BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels1bpp) DEF_HLINE_BU_FN(GP_HLine_Raw_2BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels_2BPP_LE) @@ -47,12 +85,13 @@ DEF_HLINE_FN(GP_HLine_Raw_8BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_Write DEF_HLINE_FN(GP_HLine_Raw_16BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels16bpp) DEF_HLINE_FN(GP_HLine_Raw_24BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels24bpp) DEF_HLINE_FN(GP_HLine_Raw_32BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels32bpp) +*/
void GP_HLineXXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - + GP_FN_PER_BPP_CONTEXT(GP_HLine_Raw, context, context, x0, x1, y, pixel); } @@ -70,7 +109,7 @@ void GP_HLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - + if (context->axes_swap) { GP_TRANSFORM_Y(context, x0); GP_TRANSFORM_Y(context, x1); @@ -92,3 +131,5 @@ void GP_HLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w,
GP_HLineXXY(context, x, x + w - 1, y, pixel); } + +%% endblock body diff --git a/libs/gfx/Makefile b/libs/gfx/Makefile index 145827b..d80e49a 100644 --- a/libs/gfx/Makefile +++ b/libs/gfx/Makefile @@ -1,6 +1,6 @@ TOPDIR=../.. CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c)) -GENSOURCES=GP_Line.gen.c GP_LineAA.gen.c GP_PutPixelAA.gen.c +GENSOURCES=GP_Line.gen.c GP_HLine.gen.c GP_LineAA.gen.c GP_PutPixelAA.gen.c GP_HLineAA.gen.c GP_VLineAA.gen.c GP_FillCircle.gen.c LIBNAME=gfx
-----------------------------------------------------------------------
Summary of changes: include/core/GP_WritePixel.h | 29 ++++++++---- libs/core/GP_WritePixel.c | 73 +++++++++++++++------------- libs/gfx/{GP_HLine.c => GP_HLine.gen.c.t} | 47 +++++++++++++++++- libs/gfx/Makefile | 2 +- 4 files changed, 104 insertions(+), 47 deletions(-) rename libs/gfx/{GP_HLine.c => GP_HLine.gen.c.t} (82%)
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.