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 f36ba9ddb07263d7922546bbe4b823a029572702 (commit) from 3447cc05da97de60400ac7cfbf0325e4ac84e1ad (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/f36ba9ddb07263d7922546bbe4b823a029572...
commit f36ba9ddb07263d7922546bbe4b823a029572702 Author: Cyril Hrubis metan@ucw.cz Date: Tue May 1 18:23:26 2012 +0200
core: Add clipped blit.
diff --git a/include/core/GP_Blit.h b/include/core/GP_Blit.h index adae66b..46d478b 100644 --- a/include/core/GP_Blit.h +++ b/include/core/GP_Blit.h @@ -48,6 +48,15 @@ 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. + */ +void GP_BlitXYXY_Clipped(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); + +/* * Blits rectangle from src defined by x0, y0, w0, h0 (uses w0 x h0 pixels) to * dst starting on x2, y2. */ @@ -55,7 +64,16 @@ 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 */ +/* + * 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. + */ +void GP_BlitXYWH_Clipped(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 */ static inline void GP_Blit(const GP_Context *src, GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0, @@ -64,6 +82,14 @@ static inline void GP_Blit(const GP_Context *src, GP_BlitXYWH(src, x0, y0, w0, h0, dst, x1, y1); }
+static inline void GP_Blit_Clipped(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_Clipped(src, x0, y0, w0, h0, dst, x1, y1); +} + /* * Same as GP_BlitXYXY but doesn't respect rotations. Faster (for now). */ diff --git a/libs/core/GP_Blit.c b/libs/core/GP_Blit.c index e69d7da..13acb22 100644 --- a/libs/core/GP_Blit.c +++ b/libs/core/GP_Blit.c @@ -25,6 +25,7 @@ #include "GP_GetPutPixel.h" #include "GP_Context.h" #include "GP_Convert.h" +#include "GP_Debug.h" #include "GP_Blit.h"
/* Generated functions */ @@ -83,6 +84,51 @@ void GP_BlitXYXY(const GP_Context *src, GP_BlitXYXY_Fast(src, x0, y0, x1, y1, dst, x2, y2); }
+void GP_BlitXYXY_Clipped(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) +{ + /* Normalize source rectangle */ + if (x1 < x0) + GP_SWAP(x0, x1); + + 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)); + + GP_Coord src_w = x1 - x0; + GP_Coord src_h = y1 - y0; + + GP_Coord dst_w = GP_ContextW(dst) - x2; + GP_Coord dst_h = GP_ContextH(dst) - y2; + + GP_DEBUG(2, "Blitting %ix%i, available %ix%i", + src_w, src_h, dst_w, dst_h); + + if (src_w > dst_w) + x1 -= src_w - dst_w + 1; + + 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)); + + 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); +} + 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) @@ -93,6 +139,16 @@ void GP_BlitXYWH(const GP_Context *src, GP_BlitXYXY(src, x0, y0, x0 + w0 - 1, y0 + h0 - 1, dst, x1, y1); }
+void GP_BlitXYWH_Clipped(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) +{ + if (w0 == 0 || h0 == 0) + return; + + GP_BlitXYXY_Clipped(src, x0, y0, x0 + w0 - 1, y0 + h0 - 1, dst, x1, y1); +} + 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)
-----------------------------------------------------------------------
Summary of changes: include/core/GP_Blit.h | 28 +++++++++++++++++++++++- libs/core/GP_Blit.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 1 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.