aboutsummaryrefslogtreecommitdiffhomepage
path: root/libs/graphics/sgl/SkSpriteBlitterTemplate.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/graphics/sgl/SkSpriteBlitterTemplate.h')
-rw-r--r--libs/graphics/sgl/SkSpriteBlitterTemplate.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/libs/graphics/sgl/SkSpriteBlitterTemplate.h b/libs/graphics/sgl/SkSpriteBlitterTemplate.h
new file mode 100644
index 0000000000..23d2fbf872
--- /dev/null
+++ b/libs/graphics/sgl/SkSpriteBlitterTemplate.h
@@ -0,0 +1,60 @@
+
+class SkSPRITE_CLASSNAME : public SkSpriteBlitter {
+public:
+ SkSPRITE_CLASSNAME(const SkBitmap& source SkSPRITE_ARGS)
+ : SkSpriteBlitter(source)
+ {
+ SkSPRITE_INIT
+ }
+ virtual void blitRect(int x, int y, int width, int height)
+ {
+ SkASSERT(width > 0 && height > 0);
+ int srcX = x - fLeft;
+ int srcY = y - fTop;
+ SkSPRITE_DST_TYPE* dst = fDevice->SkSPRITE_DST_GETADDR(x, y);
+ const SkSPRITE_SRC_TYPE* src = fSource->SkSPRITE_SRC_GETADDR(srcX, srcY);
+ unsigned dstRB = fDevice->rowBytes();
+ unsigned srcRB = fSource->rowBytes();
+
+ SkDEBUGCODE((void)fDevice->SkSPRITE_DST_GETADDR(x + width - 1, y + height - 1);)
+ SkDEBUGCODE((void)fSource->SkSPRITE_SRC_GETADDR(srcX + width - 1, srcY + height - 1);)
+
+ SkSPRITE_PREAMBLE((*fSource), srcX, srcY);
+
+ do {
+ SkSPRITE_DST_TYPE* d = dst;
+ const SkSPRITE_SRC_TYPE* s = src;
+#ifdef SkSPRITE_BEGIN_ROW
+ SkSPRITE_BEGIN_ROW
+#endif
+ int w = width;
+ do {
+ SkSPRITE_SRC_TYPE sc = *s++;
+ SkSPRITE_BLIT_PIXEL(d, sc);
+ d += 1;
+ } while (--w != 0);
+ dst = (SkSPRITE_DST_TYPE*)((char*)dst + dstRB);
+ src = (const SkSPRITE_SRC_TYPE*)((const char*)src + srcRB);
+ SkSPRITE_NEXT_ROW
+ } while (--height != 0);
+
+ SkSPRITE_POSTAMBLE((*fSource));
+ }
+private:
+ SkSPRITE_FIELDS
+};
+
+#undef SkSPRITE_BLIT_PIXEL
+#undef SkSPRITE_CLASSNAME
+#undef SkSPRITE_DST_TYPE
+#undef SkSPRITE_SRC_TYPE
+#undef SkSPRITE_DST_GETADDR
+#undef SkSPRITE_SRC_GETADDR
+#undef SkSPRITE_PREAMBLE
+#undef SkSPRITE_POSTAMBLE
+#undef SkSPRITE_ARGS
+#undef SkSPRITE_FIELDS
+#undef SkSPRITE_INIT
+#undef SkSPRITE_NEXT_ROW
+#undef SkSPRITE_BEGIN_ROW
+