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 02901b7585b1265cedf68d019e7eb8ec5263c5a7 (commit) via d170475005b04f6e2a1d69283760c0bc03bc4d64 (commit) via 173957cead4c3099479976cfd3a5b62f3d2b0f56 (commit) from e659d64782d1f5d6c93fc1547c81d941b5ea45bc (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/02901b7585b1265cedf68d019e7eb8ec5263c...
commit 02901b7585b1265cedf68d019e7eb8ec5263c5a7 Author: Cyril Hrubis metan@ucw.cz Date: Sat Feb 11 18:40:33 2012 +0100
core: Cleanup Blit interface.
It's same old slow blit, this just cleans up the interface.
diff --git a/include/core/GP_Blit.h b/include/core/GP_Blit.h index f772ce0..152df72 100644 --- a/include/core/GP_Blit.h +++ b/include/core/GP_Blit.h @@ -21,36 +21,75 @@ * * *****************************************************************************/
+/* + + These blits automatically converts pixel types, that's good (and fast), but + there is a catch. This works rather well when the number of colors per + pixel/color channel is increased (the gamma correction is still on TODO). + However when the number of colors is decreased it's generally better to use + dithering, which will yield into far better (you can use Floyd Steinberg + filter for that). + + Also variants without the _Raw suffix do honor the rotation flags, that may + get a little tricky as the flags for rotation are put together but don't + worry althouth there is some algebra involved the result is quite intuitive. + + */ + #ifndef CORE_GP_BLIT_H #define CORE_GP_BLIT_H
/* Generated header */ #include "GP_Blit.gen.h"
-void GP_Blit(const GP_Context *c1, GP_Coord x1, GP_Coord y1, - GP_Size w, GP_Size h, GP_Context *c2, GP_Coord x2, GP_Coord y2); +/* + * Blits rectangle from src defined by x0, y0, x1, y1 (x1, y1 included) to dst + * starting on x2, y2. + */ +void GP_BlitXYXY(const GP_Context *src, + GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, + GP_Context *dst, GP_Coord x2, GP_Coord y2);
/* - * Doesn't respect rotations. Most of the time faster. + * Blits rectangle from src defined by x0, y0, w0, h0 (uses w0 x h0 pixels) to + * dst starting on x2, y2. */ -void GP_Blit_Raw(const GP_Context *c1, GP_Coord x1, GP_Coord y1, - GP_Size w, GP_Size h, GP_Context *c2, GP_Coord x2, GP_Coord y2); +void GP_BlitXYWH(const GP_Context *src, + GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0, + GP_Context *dst, GP_Coord x1, GP_Coord y1);
+/* The default is XYWH now, will be changed */ +static inline void GP_Blit(const GP_Context *src, + GP_Coord x0, GP_Coord y0, + GP_Size w0, GP_Size h0, + GP_Context *dst, GP_Coord x1, GP_Coord y1) +{ + GP_BlitXYWH(src, x0, y0, w0, h0, dst, x1, y1); +}
/* - * Very naive blit, no optimalizations whatsoever - keep it that way. - * Used as a reference for testing and such. Aaand ultimate fallback. - * GP_CHECKS for clipping and size (for testing) + * Same as GP_BlitXYXY but doesn't respect rotations. Faster (for now). */ -void GP_Blit_Naive(const GP_Context *c1, GP_Coord x1, GP_Coord y1, GP_Size w, GP_Size h, - GP_Context *c2, GP_Coord x2, GP_Coord y2); +void GP_BlitXYXY_Raw(const GP_Context *src, + GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, + GP_Context *dst, GP_Coord x2, GP_Coord y2);
-/* - * Similar in purpose to GP_Blit_Naive, but operates on raw coordinates. - * Does no range checking. +/* + * Same as GP_BlitXYWH but doesn't respect rotations. Faster (for now). */ +void GP_BlitXYWH_Raw(const GP_Context *src, + GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0, + GP_Context *dst, GP_Coord x2, GP_Coord y2); + /* -void GP_Blit_Naive_Raw(const GP_Context *c1, int x1, int y1, int w, int h, - GP_Context *c2, int x2, int y2); -*/ -#endif // CORE_GP_BLIT_H + * Same as GP_Blit but doesn't respect rotations. Faster (for now). + */ +static inline void GP_Blit_Raw(const GP_Context *src, + GP_Coord x0, GP_Coord y0, + GP_Size w0, GP_Size h0, + GP_Context *dst, GP_Coord x1, GP_Coord y1) +{ + GP_BlitXYWH_Raw(src, x0, y0, w0, h0, dst, x1, y1); +} + +#endif /* CORE_GP_BLIT_H */ diff --git a/libs/core/GP_Blit.c b/libs/core/GP_Blit.c index 9bcb80e..e7576d9 100644 --- a/libs/core/GP_Blit.c +++ b/libs/core/GP_Blit.c @@ -17,7 +17,7 @@ * Boston, MA 02110-1301 USA * * * * Copyright (C) 2011 Tomas Gavenciak gavento@ucw.cz * - * Copyright (C) 2011 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2011,2012 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -27,79 +27,106 @@ #include "GP_Convert.h" #include "GP_Blit.h"
-void GP_Blit(const GP_Context *c1, GP_Coord x1, GP_Coord y1, - GP_Size w, GP_Size h, GP_Context *c2, GP_Coord x2, GP_Coord y2) +void GP_BlitXYXY_Naive(const GP_Context *src, + GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, + GP_Context *dst, GP_Coord x2, GP_Coord y2) { - // Ultimate TODO: effective processing - GP_Blit_Naive(c1, x1, y1, w, h, c2, x2, y2); + /* Normalize source rectangle */ + if (x1 < x0) + GP_SWAP(x0, x1); + + if (y1 < y0) + GP_SWAP(y0, y1); + + /* All coordinates are inside of src the context */ + GP_CHECK(x0 < (GP_Coord)GP_ContextW(src)); + GP_CHECK(y0 < (GP_Coord)GP_ContextH(src)); + GP_CHECK(x1 < (GP_Coord)GP_ContextW(src)); + GP_CHECK(y1 < (GP_Coord)GP_ContextH(src)); + + /* Destination is big enough */ + GP_CHECK(x2 + (x1 - x0) < (GP_Coord)GP_ContextW(dst)); + GP_CHECK(y2 + (y1 - y0) < (GP_Coord)GP_ContextH(dst)); + + GP_Coord x, y; + + for (y = y0; y <= y1; y++) + for (x = x0; x <= x1; x++) { + GP_Pixel p = GP_GetPixel(src, x, y); + + if (src->pixel_type != dst->pixel_type) + p = GP_ConvertContextPixel(p, src, dst); + + GP_PutPixel(dst, x2 + (x - x0), y2 + (y - y0), p); + } }
-// 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_BlitXYXY(const GP_Context *src, + GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, + GP_Context *dst, GP_Coord x2, GP_Coord y2) +{ + //TODO + GP_BlitXYXY_Naive(src, x0, y0, x1, y1, dst, x2, y2); +}
-/* -void GP_Blit_Naive(const GP_Context *c1, int x1, int y1, int w, int h, - GP_Context *c2, int x2, int y2) +void GP_BlitXYWH(const GP_Context *src, + GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0, + GP_Context *dst, GP_Coord x1, GP_Coord y1) { - 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); + if (w0 == 0 || h0 == 0) + return; + + GP_BlitXYXY(src, x0, y0, x0 + w0 - 1, y0 + h0 - 1, dst, x1, y1); } -*/
-void GP_Blit_Naive_Raw(const GP_Context *c1, GP_Coord x1, GP_Coord y1, GP_Size w, GP_Size h, - GP_Context *c2, GP_Coord x2, GP_Coord y2) + +void GP_BlitXYXY_Naive_Raw(const GP_Context *src, + GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, + GP_Context *dst, GP_Coord x2, GP_Coord y2) { - GP_CHECK(x1 >= 0); - GP_CHECK(y1 >= 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)); - - GP_Size i, j; - - for (i = 0; i < w; i++) - for (j = 0; j < h; j++) { - GP_Pixel p = GP_GetPixel_Raw(c1, x1 + i, y1 + j); - if (c1->pixel_type != c2->pixel_type) - p = GP_ConvertContextPixel(p, c1, c2); - GP_PutPixel_Raw(c2, x2 + i, y2 + j, p); + /* Normalize source rectangle */ + if (x1 < x0) + GP_SWAP(x0, x1); + + if (y1 < y0) + GP_SWAP(y0, y1); + + /* All coordinates are inside of src the context */ + GP_CHECK(x0 < (GP_Coord)src->w); + GP_CHECK(y0 < (GP_Coord)src->h); + GP_CHECK(x1 < (GP_Coord)src->w); + GP_CHECK(y1 < (GP_Coord)src->h); + + /* Destination is big enough */ + GP_CHECK(x2 + (x1 - x0) < (GP_Coord)dst->w); + GP_CHECK(y2 + (y1 - y0) < (GP_Coord)dst->h); + + GP_Coord x, y; + + for (y = y0; y <= y1; y++) + for (x = x0; x <= x1; x++) { + GP_Pixel p = GP_GetPixel_Raw(src, x, y); + + if (src->pixel_type != dst->pixel_type) + p = GP_ConvertContextPixel(p, src, dst); + + GP_PutPixel_Raw(dst, x2 + (x - x0), y2 + (y - y0), p); } }
-void GP_Blit_Raw(const GP_Context *c1, GP_Coord x1, GP_Coord y1, - GP_Size w, GP_Size h, GP_Context *c2, GP_Coord x2, GP_Coord y2) +void GP_BlitXYXY_Raw(const GP_Context *src, + GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, + GP_Context *dst, GP_Coord x2, GP_Coord y2) { - // Ultimate TODO: effective processing - GP_Blit_Naive_Raw(c1, x1, y1, w, h, c2, x2, y2); + GP_BlitXYXY_Naive_Raw(src, x0, y0, x1, y1, dst, x2, y2); }
-void GP_Blit_Naive(const GP_Context *c1, GP_Coord x1, GP_Coord y1, GP_Size w, GP_Size h, - GP_Context *c2, GP_Coord x2, GP_Coord y2) +void GP_BlitXYWH_Raw(const GP_Context *src, + GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0, + GP_Context *dst, GP_Coord x2, GP_Coord y2) { - GP_CHECK(x1 >= 0); - GP_CHECK(y1 >= 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)); - - GP_Size i, j; - - for (i = 0; i < w; i++) - for (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); - GP_PutPixel(c2, x2 + i, y2 + j, p); - } + if (w0 == 0 || h0 == 0) + return; + + GP_BlitXYXY_Raw(src, x0, y0, x0 + w0 - 1, y0 + h0 - 1, dst, x2, y2); } diff --git a/libs/core/GP_Blit.gen.c.t b/libs/core/GP_Blit.gen.c.t index 2bc3f69..2259956 100644 --- a/libs/core/GP_Blit.gen.c.t +++ b/libs/core/GP_Blit.gen.c.t @@ -64,8 +64,8 @@ void GP_Blit_{{ ps.suffix }}(const GP_Context *c1, GP_Coord x1, GP_Coord y1, GP_ p2 += c2->bytes_per_row; end_p2 += c2->bytes_per_row; } - } else /* Different bit-alignment, can't use memcpy() */ - GP_Blit_Naive(c1, x1, y1, w, h, c2, x2, y2); + }// else /* Different bit-alignment, can't use memcpy() */ + // GP_Blit_Naive(c1, x1, y1, w, h, c2, x2, y2); %% endif }
http://repo.or.cz/w/gfxprim.git/commit/d170475005b04f6e2a1d69283760c0bc03bc4...
commit d170475005b04f6e2a1d69283760c0bc03bc4d64 Author: Cyril Hrubis metan@ucw.cz Date: Sat Feb 11 18:40:21 2012 +0100
core: Remove unused code from Fixed point.
diff --git a/include/core/GP_FixedPoint.h b/include/core/GP_FixedPoint.h index 33029ad..77e802f 100644 --- a/include/core/GP_FixedPoint.h +++ b/include/core/GP_FixedPoint.h @@ -34,8 +34,6 @@
#include <stdint.h>
-typedef uint8_t GP_FP_Frac; - /* * Number of bits used for fractional part. */
http://repo.or.cz/w/gfxprim.git/commit/173957cead4c3099479976cfd3a5b62f3d2b0...
commit 173957cead4c3099479976cfd3a5b62f3d2b0f56 Author: Cyril Hrubis metan@ucw.cz Date: Sat Feb 11 18:39:57 2012 +0100
tests: Add pause flag for linetest.
diff --git a/tests/SDL/linetest.c b/tests/SDL/linetest.c index 9e35f96..5a2e082 100644 --- a/tests/SDL/linetest.c +++ b/tests/SDL/linetest.c @@ -55,6 +55,7 @@ Uint32 timer_callback(__attribute__((unused)) Uint32 interval, double start_angle = 0.0;
static int aa_flag = 0; +static int pause_flag = 0;
void redraw_screen(void) { @@ -101,6 +102,10 @@ void event_loop(void) case SDL_USEREVENT: redraw_screen(); SDL_Flip(display); + + if (pause_flag) + continue; + start_angle += 0.01; if (start_angle > 2*M_PI) { start_angle = 0.0; @@ -111,6 +116,9 @@ void event_loop(void) case SDLK_a: aa_flag = !aa_flag; break; + case SDLK_p: + pause_flag = !pause_flag; + break; default: return; }
-----------------------------------------------------------------------
Summary of changes: include/core/GP_Blit.h | 73 ++++++++++++++++----- include/core/GP_FixedPoint.h | 2 - libs/core/GP_Blit.c | 149 +++++++++++++++++++++++++----------------- libs/core/GP_Blit.gen.c.t | 4 +- tests/SDL/linetest.c | 8 ++ 5 files changed, 154 insertions(+), 82 deletions(-)
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.