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 83d2379331b535cc28f96ac11c27ef3565cfebb3 (commit) via 347598ceea691da3a252b3f119f33e0ee188c6ac (commit) from f36ba9ddb07263d7922546bbe4b823a029572702 (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/83d2379331b535cc28f96ac11c27ef3565cfe...
commit 83d2379331b535cc28f96ac11c27ef3565cfebb3 Author: Cyril Hrubis metan@ucw.cz Date: Tue May 1 20:55:12 2012 +0200
core: Fix stupid bug in special case blit.
diff --git a/libs/core/GP_Blit.gen.c.t b/libs/core/GP_Blit.gen.c.t index 50496e6..988223e 100644 --- a/libs/core/GP_Blit.gen.c.t +++ b/libs/core/GP_Blit.gen.c.t @@ -59,7 +59,7 @@ void blitXYXY_Raw_{{ ps.suffix }}(const GP_Context *src, /* General case - memcpy() each horizontal line */ GP_Coord y;
- for (y = y0; y <= y1; y++) + for (y = 0; y <= (y1 - y0); y++) memcpy(GP_PIXEL_ADDR_{{ ps.suffix }}(dst, x2, y2 + y), GP_PIXEL_ADDR_{{ ps.suffix }}(src, x0, y0 + y), {{ int(ps.size/8) }} * (x1 - x0 + 1));
http://repo.or.cz/w/gfxprim.git/commit/347598ceea691da3a252b3f119f33e0ee188c...
commit 347598ceea691da3a252b3f119f33e0ee188c6ac Author: Cyril Hrubis metan@ucw.cz Date: Tue May 1 18:56:39 2012 +0200
core: Make the Clipped blit more versatile.
diff --git a/include/core/GP_Blit.h b/include/core/GP_Blit.h index 46d478b..cacfa8b 100644 --- a/include/core/GP_Blit.h +++ b/include/core/GP_Blit.h @@ -48,9 +48,9 @@ void GP_BlitXYXY(const GP_Context *src, GP_Context *dst, GP_Coord x2, GP_Coord y2);
/* - * Clipped variant, if destination context size (from x2, y2 to the end of the - * context) is not big enough the source rectangle is clipped, eg. only initial - * part of the source (starting on x0, y0) will be blitted. + * Clipped variant. Could handle destination coordinates outside of the + * destination rectangle (both possitive and negative). Source larger than + * destination and so. */ void GP_BlitXYXY_Clipped(const GP_Context *src, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, @@ -65,9 +65,9 @@ void GP_BlitXYWH(const GP_Context *src, GP_Context *dst, GP_Coord x1, GP_Coord y1);
/* - * Clipped variant, if destination context size (from x1, y1 to the end of the - * context) is not big enough the source rectangle is clipped, eg. only initial - * part of the source (starting on x0, y0) will be blitted. + * Clipped variant. Could handle destination coordinates outside of the + * destination rectangle (both possitive and negative). Source larger than + * destination and so. */ void GP_BlitXYWH_Clipped(const GP_Context *src, GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0, diff --git a/libs/core/GP_Blit.c b/libs/core/GP_Blit.c index 13acb22..3b9f88a 100644 --- a/libs/core/GP_Blit.c +++ b/libs/core/GP_Blit.c @@ -76,12 +76,10 @@ void GP_BlitXYXY(const GP_Context *src, GP_CHECK(x2 + (x1 - x0) < (GP_Coord)GP_ContextW(dst)); GP_CHECK(y2 + (y1 - y0) < (GP_Coord)GP_ContextH(dst));
- if (GP_CONTEXT_ROTATION_EQUAL(src, dst)) { + if (GP_CONTEXT_ROTATION_EQUAL(src, dst)) GP_BlitXYXY_Raw_Fast(src, x0, y0, x1, y1, dst, x2, y2); - return; - } - - GP_BlitXYXY_Fast(src, x0, y0, x1, y1, dst, x2, y2); + else + GP_BlitXYXY_Fast(src, x0, y0, x1, y1, dst, x2, y2); }
void GP_BlitXYXY_Clipped(const GP_Context *src, @@ -95,14 +93,31 @@ void GP_BlitXYXY_Clipped(const GP_Context *src, if (y1 < y0) GP_SWAP(y0, y1); - /* All coordinates are inside of src and dst 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)); - GP_CHECK(x2 < (GP_Coord)GP_ContextW(dst)); - GP_CHECK(y2 < (GP_Coord)GP_ContextH(dst)); + /* Noting to blit return now */ + if (x2 >= (GP_Coord)GP_ContextW(dst) || + y2 >= (GP_Coord)GP_ContextH(dst)) + return; + + /* We need to shift source rectangle */ + if (x2 < 0) { + x0 -= x2; + x1 -= x2; + x2 = 0; + } + + if (y2 < 0) { + y0 -= y2; + y1 -= y2; + y2 = 0; + } + + /* Make sure souce coordinates are inside of the src */ + x0 = GP_MAX(x0, 0); + y0 = GP_MAX(y0, 0); + x1 = GP_MIN(x1, (GP_Coord)GP_ContextW(src) - 1); + y1 = GP_MIN(y1, (GP_Coord)GP_ContextH(src) - 1);
+ /* And source rectangle fits inside of the destination */ GP_Coord src_w = x1 - x0; GP_Coord src_h = y1 - y0;
@@ -118,15 +133,14 @@ void GP_BlitXYXY_Clipped(const GP_Context *src, if (src_h > dst_h) y1 -= src_h - dst_h + 1;
- GP_DEBUG(2, "Blitting %ix%i->%ix%i in %ux%u", - x0, y0, x1, y1, GP_ContextW(src), GP_ContextH(src)); + GP_DEBUG(2, "Blitting %ix%i->%ix%i in %ux%u to %ix%i in %ux%u", + x0, y0, x1, y1, GP_ContextW(src), GP_ContextH(src), + x2, y2, GP_ContextW(dst), GP_ContextH(dst));
- if (GP_CONTEXT_ROTATION_EQUAL(src, dst)) { + if (GP_CONTEXT_ROTATION_EQUAL(src, dst)) GP_BlitXYXY_Raw_Fast(src, x0, y0, x1, y1, dst, x2, y2); - return; - } - - GP_BlitXYXY_Fast(src, x0, y0, x1, y1, dst, x2, y2); + else + GP_BlitXYXY_Fast(src, x0, y0, x1, y1, dst, x2, y2); }
void GP_BlitXYWH(const GP_Context *src,
-----------------------------------------------------------------------
Summary of changes: include/core/GP_Blit.h | 12 +++++----- libs/core/GP_Blit.c | 52 ++++++++++++++++++++++++++++---------------- libs/core/GP_Blit.gen.c.t | 2 +- 3 files changed, 40 insertions(+), 26 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.