1 /*
2  * Copyright 2006 The Android Open Source Project
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 class SkSPRITE_CLASSNAME : public SkSpriteBlitter {
9 public:
SkSPRITE_CLASSNAME(const SkPixmap & source SkSPRITE_ARGS)10     SkSPRITE_CLASSNAME(const SkPixmap& source SkSPRITE_ARGS) : SkSpriteBlitter(source) {
11         SkSPRITE_INIT
12     }
13 
blitRect(int x,int y,int width,int height)14     virtual void blitRect(int x, int y, int width, int height) {
15         SkASSERT(width > 0 && height > 0);
16         int srcX = x - fLeft;
17         int srcY = y - fTop;
18         SkSPRITE_DST_TYPE* SK_RESTRICT dst =fDst.SkSPRITE_DST_GETADDR(x, y);
19         const SkSPRITE_SRC_TYPE* SK_RESTRICT src = fSource.SkSPRITE_SRC_GETADDR(srcX, srcY);
20         size_t dstRB = fDst.rowBytes();
21         size_t srcRB = fSource.rowBytes();
22 
23         SkDEBUGCODE((void)fDst.SkSPRITE_DST_GETADDR(x + width - 1, y + height - 1);)
24         SkDEBUGCODE((void)fSource.SkSPRITE_SRC_GETADDR(srcX + width  - 1, srcY + height - 1);)
25 
26         SkSPRITE_PREAMBLE(fSource, srcX, srcY);
27 
28         do {
29             SkSPRITE_DST_TYPE* d = dst;
30             const SkSPRITE_SRC_TYPE* s = src;
31 #ifdef SkSPRITE_BEGIN_ROW
32             SkSPRITE_BEGIN_ROW
33 #endif
34 
35 #ifdef SkSPRITE_ROW_PROC
36             SkSPRITE_ROW_PROC(d, s, width, x, y);
37 #else
38             int w = width;
39             do {
40                 SkSPRITE_SRC_TYPE sc = *s++;
41                 SkSPRITE_BLIT_PIXEL(d, sc);
42                 d += 1;
43             } while (--w != 0);
44 #endif
45             dst = (SkSPRITE_DST_TYPE* SK_RESTRICT)((char*)dst + dstRB);
46             src = (const SkSPRITE_SRC_TYPE* SK_RESTRICT)((const char*)src + srcRB);
47             SkSPRITE_NEXT_ROW
48 #ifdef SkSPRITE_ROW_PROC
49             y += 1;
50 #endif
51         } while (--height != 0);
52 
53         SkSPRITE_POSTAMBLE((*fSource));
54     }
55 
56 private:
57     SkSPRITE_FIELDS
58 };
59 
60 #undef SkSPRITE_BLIT_PIXEL
61 #undef SkSPRITE_CLASSNAME
62 #undef SkSPRITE_DST_TYPE
63 #undef SkSPRITE_SRC_TYPE
64 #undef SkSPRITE_DST_GETADDR
65 #undef SkSPRITE_SRC_GETADDR
66 #undef SkSPRITE_PREAMBLE
67 #undef SkSPRITE_POSTAMBLE
68 #undef SkSPRITE_ARGS
69 #undef SkSPRITE_FIELDS
70 #undef SkSPRITE_INIT
71 #undef SkSPRITE_NEXT_ROW
72 #undef SkSPRITE_BEGIN_ROW
73 
74 #ifdef SkSPRITE_ROW_PROC
75     #undef SkSPRITE_ROW_PROC
76 #endif
77