OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * 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 |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkOpts.h" | 8 #include "SkOpts.h" |
9 #include "SkSmallAllocator.h" | 9 #include "SkSmallAllocator.h" |
10 #include "SkSpriteBlitter.h" | 10 #include "SkSpriteBlitter.h" |
11 | 11 |
12 SkSpriteBlitter::SkSpriteBlitter(const SkPixmap& source) : fSource(source) {} | 12 SkSpriteBlitter::SkSpriteBlitter(const SkPixmap& source) |
| 13 : fSource(source) {} |
13 | 14 |
14 void SkSpriteBlitter::setup(const SkPixmap& dst, int left, int top, const SkPain
t& paint) { | 15 void SkSpriteBlitter::setup(const SkPixmap& dst, int left, int top, const SkPain
t& paint) { |
15 fDst = dst; | 16 fDst = dst; |
16 fLeft = left; | 17 fLeft = left; |
17 fTop = top; | 18 fTop = top; |
18 fPaint = &paint; | 19 fPaint = &paint; |
19 } | 20 } |
20 | 21 |
21 #ifdef SK_DEBUG | |
22 void SkSpriteBlitter::blitH(int x, int y, int width) { | 22 void SkSpriteBlitter::blitH(int x, int y, int width) { |
23 SkDEBUGFAIL("how did we get here?"); | 23 SkDEBUGFAIL("how did we get here?"); |
| 24 |
| 25 // Fallback to blitRect. |
| 26 this->blitRect(x, y, width, 1); |
24 } | 27 } |
25 | 28 |
26 void SkSpriteBlitter::blitAntiH(int x, int y, const SkAlpha antialias[], | 29 void SkSpriteBlitter::blitAntiH(int x, int y, const SkAlpha antialias[], const i
nt16_t runs[]) { |
27 const int16_t runs[]) { | |
28 SkDEBUGFAIL("how did we get here?"); | 30 SkDEBUGFAIL("how did we get here?"); |
| 31 |
| 32 // No fallback strategy. |
29 } | 33 } |
30 | 34 |
31 void SkSpriteBlitter::blitV(int x, int y, int height, SkAlpha alpha) { | 35 void SkSpriteBlitter::blitV(int x, int y, int height, SkAlpha alpha) { |
32 SkDEBUGFAIL("how did we get here?"); | 36 SkDEBUGFAIL("how did we get here?"); |
| 37 |
| 38 // Fall back to superclass if the code gets here in release mode. |
| 39 INHERITED::blitV(x, y, height, alpha); |
33 } | 40 } |
34 | 41 |
35 void SkSpriteBlitter::blitMask(const SkMask&, const SkIRect& clip) { | 42 void SkSpriteBlitter::blitMask(const SkMask& mask, const SkIRect& clip) { |
36 SkDEBUGFAIL("how did we get here?"); | 43 SkDEBUGFAIL("how did we get here?"); |
| 44 |
| 45 // Fall back to superclass if the code gets here in release mode. |
| 46 INHERITED::blitMask(mask, clip); |
37 } | 47 } |
38 #endif | |
39 | 48 |
40 /////////////////////////////////////////////////////////////////////////////// | 49 /////////////////////////////////////////////////////////////////////////////// |
41 | 50 |
42 // Only valid if... | 51 // Only valid if... |
43 // 1. src == dst format | 52 // 1. src == dst format |
44 // 2. paint has no modifiers (i.e. alpha, colorfilter, etc.) | 53 // 2. paint has no modifiers (i.e. alpha, colorfilter, etc.) |
45 // 3. xfermode needs no blending: e.g. kSrc_Mode or kSrcOver_Mode + opaque
src | 54 // 3. xfermode needs no blending: e.g. kSrc_Mode or kSrcOver_Mode + opaque
src |
46 // | 55 // |
47 class SkSpriteBlitter_Src_SrcOver : public SkSpriteBlitter { | 56 class SkSpriteBlitter_Src_SrcOver final : public SkSpriteBlitter { |
48 public: | 57 public: |
49 static bool Supports(const SkPixmap& dst, const SkPixmap& src, const SkPaint
& paint) { | 58 static bool Supports(const SkPixmap& dst, const SkPixmap& src, const SkPaint
& paint) { |
50 if (dst.colorType() != src.colorType()) { | 59 if (dst.colorType() != src.colorType()) { |
51 return false; | 60 return false; |
52 } | 61 } |
53 if (dst.info().profileType() != src.info().profileType()) { | 62 if (dst.info().profileType() != src.info().profileType()) { |
54 return false; | 63 return false; |
55 } | 64 } |
56 if (paint.getMaskFilter() || paint.getColorFilter() || paint.getImageFil
ter()) { | 65 if (paint.getMaskFilter() || paint.getColorFilter() || paint.getImageFil
ter()) { |
57 return false; | 66 return false; |
(...skipping 15 matching lines...) Expand all Loading... |
73 // At this point memcpy can't be used. The following check for using Src
Over. | 82 // At this point memcpy can't be used. The following check for using Src
Over. |
74 | 83 |
75 if (dst.colorType() != kN32_SkColorType | 84 if (dst.colorType() != kN32_SkColorType |
76 || dst.info().profileType() != kSRGB_SkColorProfileType) { | 85 || dst.info().profileType() != kSRGB_SkColorProfileType) { |
77 return false; | 86 return false; |
78 } | 87 } |
79 | 88 |
80 return SkXfermode::kSrcOver_Mode == mode; | 89 return SkXfermode::kSrcOver_Mode == mode; |
81 } | 90 } |
82 | 91 |
83 SkSpriteBlitter_Src_SrcOver(const SkPixmap& src) : INHERITED(src) {} | 92 SkSpriteBlitter_Src_SrcOver(const SkPixmap& src) |
| 93 : INHERITED(src) {} |
84 | 94 |
85 void setup(const SkPixmap& dst, int left, int top, const SkPaint& paint) ove
rride { | 95 void setup(const SkPixmap& dst, int left, int top, const SkPaint& paint) ove
rride { |
86 SkASSERT(Supports(dst, fSource, paint)); | 96 SkASSERT(Supports(dst, fSource, paint)); |
87 this->INHERITED::setup(dst, left, top, paint); | 97 this->INHERITED::setup(dst, left, top, paint); |
88 SkXfermode::Mode mode; | 98 SkXfermode::Mode mode; |
89 if (!SkXfermode::AsMode(paint.getXfermode(), &mode)) { | 99 if (!SkXfermode::AsMode(paint.getXfermode(), &mode)) { |
90 SkFAIL("Should never happen."); | 100 SkFAIL("Should never happen."); |
91 } | 101 } |
92 | 102 |
93 SkASSERT(mode == SkXfermode::kSrcOver_Mode || mode == SkXfermode::kSrc_M
ode); | 103 SkASSERT(mode == SkXfermode::kSrcOver_Mode || mode == SkXfermode::kSrc_M
ode); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 default: | 187 default: |
178 break; | 188 break; |
179 } | 189 } |
180 } | 190 } |
181 | 191 |
182 if (blitter) { | 192 if (blitter) { |
183 blitter->setup(dst, left, top, paint); | 193 blitter->setup(dst, left, top, paint); |
184 } | 194 } |
185 return blitter; | 195 return blitter; |
186 } | 196 } |
OLD | NEW |