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