epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2006 The Android Open Source Project |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 9 | |
| 10 | #include "SkSpriteBlitter.h" |
reed@android.com | c4cae85 | 2009-09-23 15:06:10 +0000 | [diff] [blame] | 11 | #include "SkBlitRow.h" |
| 12 | #include "SkColorFilter.h" |
| 13 | #include "SkColorPriv.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 14 | #include "SkTemplates.h" |
| 15 | #include "SkUtils.h" |
reed@android.com | c4cae85 | 2009-09-23 15:06:10 +0000 | [diff] [blame] | 16 | #include "SkXfermode.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 17 | |
| 18 | /////////////////////////////////////////////////////////////////////////////// |
| 19 | |
reed@android.com | c4cae85 | 2009-09-23 15:06:10 +0000 | [diff] [blame] | 20 | class Sprite_D32_S32 : public SkSpriteBlitter { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 21 | public: |
reed@android.com | c4cae85 | 2009-09-23 15:06:10 +0000 | [diff] [blame] | 22 | Sprite_D32_S32(const SkBitmap& src, U8CPU alpha) : INHERITED(src) { |
commit-bot@chromium.org | 149e9a1 | 2014-04-09 20:45:29 +0000 | [diff] [blame^] | 23 | SkASSERT(src.colorType() == kN32_SkColorType); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 24 | |
reed@android.com | c4cae85 | 2009-09-23 15:06:10 +0000 | [diff] [blame] | 25 | unsigned flags32 = 0; |
| 26 | if (255 != alpha) { |
| 27 | flags32 |= SkBlitRow::kGlobalAlpha_Flag32; |
| 28 | } |
| 29 | if (!src.isOpaque()) { |
| 30 | flags32 |= SkBlitRow::kSrcPixelAlpha_Flag32; |
| 31 | } |
| 32 | |
| 33 | fProc32 = SkBlitRow::Factory32(flags32); |
| 34 | fAlpha = alpha; |
| 35 | } |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 36 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 37 | virtual void blitRect(int x, int y, int width, int height) { |
| 38 | SkASSERT(width > 0 && height > 0); |
tomhudson@google.com | a87cd2a | 2011-06-15 16:50:27 +0000 | [diff] [blame] | 39 | uint32_t* SK_RESTRICT dst = fDevice->getAddr32(x, y); |
| 40 | const uint32_t* SK_RESTRICT src = fSource->getAddr32(x - fLeft, |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 41 | y - fTop); |
reed@android.com | c4cae85 | 2009-09-23 15:06:10 +0000 | [diff] [blame] | 42 | size_t dstRB = fDevice->rowBytes(); |
| 43 | size_t srcRB = fSource->rowBytes(); |
| 44 | SkBlitRow::Proc32 proc = fProc32; |
| 45 | U8CPU alpha = fAlpha; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 46 | |
| 47 | do { |
reed@android.com | c4cae85 | 2009-09-23 15:06:10 +0000 | [diff] [blame] | 48 | proc(dst, src, width, alpha); |
tomhudson@google.com | a87cd2a | 2011-06-15 16:50:27 +0000 | [diff] [blame] | 49 | dst = (uint32_t* SK_RESTRICT)((char*)dst + dstRB); |
| 50 | src = (const uint32_t* SK_RESTRICT)((const char*)src + srcRB); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 51 | } while (--height != 0); |
| 52 | } |
reed@android.com | c4cae85 | 2009-09-23 15:06:10 +0000 | [diff] [blame] | 53 | |
| 54 | private: |
| 55 | SkBlitRow::Proc32 fProc32; |
| 56 | U8CPU fAlpha; |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 57 | |
reed@android.com | c4cae85 | 2009-09-23 15:06:10 +0000 | [diff] [blame] | 58 | typedef SkSpriteBlitter INHERITED; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | /////////////////////////////////////////////////////////////////////////////// |
| 62 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 63 | class Sprite_D32_XferFilter : public SkSpriteBlitter { |
| 64 | public: |
| 65 | Sprite_D32_XferFilter(const SkBitmap& source, const SkPaint& paint) |
| 66 | : SkSpriteBlitter(source) { |
| 67 | fColorFilter = paint.getColorFilter(); |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 68 | SkSafeRef(fColorFilter); |
| 69 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 70 | fXfermode = paint.getXfermode(); |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 71 | SkSafeRef(fXfermode); |
| 72 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 73 | fBufferSize = 0; |
| 74 | fBuffer = NULL; |
reed@android.com | c4cae85 | 2009-09-23 15:06:10 +0000 | [diff] [blame] | 75 | |
| 76 | unsigned flags32 = 0; |
| 77 | if (255 != paint.getAlpha()) { |
| 78 | flags32 |= SkBlitRow::kGlobalAlpha_Flag32; |
| 79 | } |
| 80 | if (!source.isOpaque()) { |
| 81 | flags32 |= SkBlitRow::kSrcPixelAlpha_Flag32; |
| 82 | } |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 83 | |
reed@android.com | c4cae85 | 2009-09-23 15:06:10 +0000 | [diff] [blame] | 84 | fProc32 = SkBlitRow::Factory32(flags32); |
| 85 | fAlpha = paint.getAlpha(); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 86 | } |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 87 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 88 | virtual ~Sprite_D32_XferFilter() { |
| 89 | delete[] fBuffer; |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 90 | SkSafeUnref(fXfermode); |
| 91 | SkSafeUnref(fColorFilter); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 92 | } |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 93 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 94 | virtual void setup(const SkBitmap& device, int left, int top, |
| 95 | const SkPaint& paint) { |
| 96 | this->INHERITED::setup(device, left, top, paint); |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 97 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 98 | int width = device.width(); |
| 99 | if (width > fBufferSize) { |
| 100 | fBufferSize = width; |
| 101 | delete[] fBuffer; |
| 102 | fBuffer = new SkPMColor[width]; |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | protected: |
reed@android.com | c4cae85 | 2009-09-23 15:06:10 +0000 | [diff] [blame] | 107 | SkColorFilter* fColorFilter; |
| 108 | SkXfermode* fXfermode; |
| 109 | int fBufferSize; |
| 110 | SkPMColor* fBuffer; |
| 111 | SkBlitRow::Proc32 fProc32; |
| 112 | U8CPU fAlpha; |
| 113 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 114 | private: |
| 115 | typedef SkSpriteBlitter INHERITED; |
| 116 | }; |
| 117 | |
| 118 | /////////////////////////////////////////////////////////////////////////////// |
| 119 | |
| 120 | class Sprite_D32_S32A_XferFilter : public Sprite_D32_XferFilter { |
| 121 | public: |
| 122 | Sprite_D32_S32A_XferFilter(const SkBitmap& source, const SkPaint& paint) |
| 123 | : Sprite_D32_XferFilter(source, paint) {} |
| 124 | |
| 125 | virtual void blitRect(int x, int y, int width, int height) { |
| 126 | SkASSERT(width > 0 && height > 0); |
tomhudson@google.com | a87cd2a | 2011-06-15 16:50:27 +0000 | [diff] [blame] | 127 | uint32_t* SK_RESTRICT dst = fDevice->getAddr32(x, y); |
| 128 | const uint32_t* SK_RESTRICT src = fSource->getAddr32(x - fLeft, |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 129 | y - fTop); |
scroggo@google.com | e5f4824 | 2013-02-25 21:47:41 +0000 | [diff] [blame] | 130 | size_t dstRB = fDevice->rowBytes(); |
| 131 | size_t srcRB = fSource->rowBytes(); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 132 | SkColorFilter* colorFilter = fColorFilter; |
| 133 | SkXfermode* xfermode = fXfermode; |
| 134 | |
| 135 | do { |
| 136 | const SkPMColor* tmp = src; |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 137 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 138 | if (NULL != colorFilter) { |
| 139 | colorFilter->filterSpan(src, width, fBuffer); |
| 140 | tmp = fBuffer; |
| 141 | } |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 142 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 143 | if (NULL != xfermode) { |
| 144 | xfermode->xfer32(dst, tmp, width, NULL); |
| 145 | } else { |
reed@android.com | c4cae85 | 2009-09-23 15:06:10 +0000 | [diff] [blame] | 146 | fProc32(dst, tmp, width, fAlpha); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 147 | } |
| 148 | |
tomhudson@google.com | a87cd2a | 2011-06-15 16:50:27 +0000 | [diff] [blame] | 149 | dst = (uint32_t* SK_RESTRICT)((char*)dst + dstRB); |
| 150 | src = (const uint32_t* SK_RESTRICT)((const char*)src + srcRB); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 151 | } while (--height != 0); |
| 152 | } |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 153 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 154 | private: |
| 155 | typedef Sprite_D32_XferFilter INHERITED; |
| 156 | }; |
| 157 | |
tomhudson@google.com | a87cd2a | 2011-06-15 16:50:27 +0000 | [diff] [blame] | 158 | static void fillbuffer(SkPMColor* SK_RESTRICT dst, |
| 159 | const SkPMColor16* SK_RESTRICT src, int count) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 160 | SkASSERT(count > 0); |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 161 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 162 | do { |
| 163 | *dst++ = SkPixel4444ToPixel32(*src++); |
| 164 | } while (--count != 0); |
| 165 | } |
| 166 | |
| 167 | class Sprite_D32_S4444_XferFilter : public Sprite_D32_XferFilter { |
| 168 | public: |
| 169 | Sprite_D32_S4444_XferFilter(const SkBitmap& source, const SkPaint& paint) |
| 170 | : Sprite_D32_XferFilter(source, paint) {} |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 171 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 172 | virtual void blitRect(int x, int y, int width, int height) { |
| 173 | SkASSERT(width > 0 && height > 0); |
tomhudson@google.com | a87cd2a | 2011-06-15 16:50:27 +0000 | [diff] [blame] | 174 | SkPMColor* SK_RESTRICT dst = fDevice->getAddr32(x, y); |
| 175 | const SkPMColor16* SK_RESTRICT src = fSource->getAddr16(x - fLeft, |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 176 | y - fTop); |
scroggo@google.com | e5f4824 | 2013-02-25 21:47:41 +0000 | [diff] [blame] | 177 | size_t dstRB = fDevice->rowBytes(); |
| 178 | size_t srcRB = fSource->rowBytes(); |
tomhudson@google.com | a87cd2a | 2011-06-15 16:50:27 +0000 | [diff] [blame] | 179 | SkPMColor* SK_RESTRICT buffer = fBuffer; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 180 | SkColorFilter* colorFilter = fColorFilter; |
| 181 | SkXfermode* xfermode = fXfermode; |
| 182 | |
| 183 | do { |
| 184 | fillbuffer(buffer, src, width); |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 185 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 186 | if (NULL != colorFilter) { |
| 187 | colorFilter->filterSpan(buffer, width, buffer); |
| 188 | } |
| 189 | if (NULL != xfermode) { |
| 190 | xfermode->xfer32(dst, buffer, width, NULL); |
| 191 | } else { |
reed@android.com | c4cae85 | 2009-09-23 15:06:10 +0000 | [diff] [blame] | 192 | fProc32(dst, buffer, width, fAlpha); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 193 | } |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 194 | |
tomhudson@google.com | a87cd2a | 2011-06-15 16:50:27 +0000 | [diff] [blame] | 195 | dst = (SkPMColor* SK_RESTRICT)((char*)dst + dstRB); |
| 196 | src = (const SkPMColor16* SK_RESTRICT)((const char*)src + srcRB); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 197 | } while (--height != 0); |
| 198 | } |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 199 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 200 | private: |
| 201 | typedef Sprite_D32_XferFilter INHERITED; |
| 202 | }; |
| 203 | |
| 204 | /////////////////////////////////////////////////////////////////////////////// |
| 205 | |
tomhudson@google.com | a87cd2a | 2011-06-15 16:50:27 +0000 | [diff] [blame] | 206 | static void src_row(SkPMColor* SK_RESTRICT dst, |
| 207 | const SkPMColor16* SK_RESTRICT src, int count) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 208 | do { |
| 209 | *dst = SkPixel4444ToPixel32(*src); |
| 210 | src += 1; |
| 211 | dst += 1; |
| 212 | } while (--count != 0); |
| 213 | } |
| 214 | |
| 215 | class Sprite_D32_S4444_Opaque : public SkSpriteBlitter { |
| 216 | public: |
| 217 | Sprite_D32_S4444_Opaque(const SkBitmap& source) : SkSpriteBlitter(source) {} |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 218 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 219 | virtual void blitRect(int x, int y, int width, int height) { |
| 220 | SkASSERT(width > 0 && height > 0); |
tomhudson@google.com | a87cd2a | 2011-06-15 16:50:27 +0000 | [diff] [blame] | 221 | SkPMColor* SK_RESTRICT dst = fDevice->getAddr32(x, y); |
| 222 | const SkPMColor16* SK_RESTRICT src = fSource->getAddr16(x - fLeft, |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 223 | y - fTop); |
scroggo@google.com | e5f4824 | 2013-02-25 21:47:41 +0000 | [diff] [blame] | 224 | size_t dstRB = fDevice->rowBytes(); |
| 225 | size_t srcRB = fSource->rowBytes(); |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 226 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 227 | do { |
| 228 | src_row(dst, src, width); |
tomhudson@google.com | a87cd2a | 2011-06-15 16:50:27 +0000 | [diff] [blame] | 229 | dst = (SkPMColor* SK_RESTRICT)((char*)dst + dstRB); |
| 230 | src = (const SkPMColor16* SK_RESTRICT)((const char*)src + srcRB); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 231 | } while (--height != 0); |
| 232 | } |
| 233 | }; |
| 234 | |
tomhudson@google.com | a87cd2a | 2011-06-15 16:50:27 +0000 | [diff] [blame] | 235 | static void srcover_row(SkPMColor* SK_RESTRICT dst, |
| 236 | const SkPMColor16* SK_RESTRICT src, int count) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 237 | do { |
| 238 | *dst = SkPMSrcOver(SkPixel4444ToPixel32(*src), *dst); |
| 239 | src += 1; |
| 240 | dst += 1; |
| 241 | } while (--count != 0); |
| 242 | } |
| 243 | |
| 244 | class Sprite_D32_S4444 : public SkSpriteBlitter { |
| 245 | public: |
| 246 | Sprite_D32_S4444(const SkBitmap& source) : SkSpriteBlitter(source) {} |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 247 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 248 | virtual void blitRect(int x, int y, int width, int height) { |
| 249 | SkASSERT(width > 0 && height > 0); |
tomhudson@google.com | a87cd2a | 2011-06-15 16:50:27 +0000 | [diff] [blame] | 250 | SkPMColor* SK_RESTRICT dst = fDevice->getAddr32(x, y); |
| 251 | const SkPMColor16* SK_RESTRICT src = fSource->getAddr16(x - fLeft, |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 252 | y - fTop); |
scroggo@google.com | e5f4824 | 2013-02-25 21:47:41 +0000 | [diff] [blame] | 253 | size_t dstRB = fDevice->rowBytes(); |
| 254 | size_t srcRB = fSource->rowBytes(); |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 255 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 256 | do { |
| 257 | srcover_row(dst, src, width); |
tomhudson@google.com | a87cd2a | 2011-06-15 16:50:27 +0000 | [diff] [blame] | 258 | dst = (SkPMColor* SK_RESTRICT)((char*)dst + dstRB); |
| 259 | src = (const SkPMColor16* SK_RESTRICT)((const char*)src + srcRB); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 260 | } while (--height != 0); |
| 261 | } |
| 262 | }; |
| 263 | |
| 264 | /////////////////////////////////////////////////////////////////////////////// |
| 265 | |
commit-bot@chromium.org | a5572e5 | 2014-03-07 03:24:41 +0000 | [diff] [blame] | 266 | SkSpriteBlitter* SkSpriteBlitter::ChooseD32(const SkBitmap& source, const SkPaint& paint, |
| 267 | SkTBlitterAllocator* allocator) { |
| 268 | SkASSERT(allocator != NULL); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 269 | |
reed@android.com | c4cae85 | 2009-09-23 15:06:10 +0000 | [diff] [blame] | 270 | if (paint.getMaskFilter() != NULL) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 271 | return NULL; |
| 272 | } |
| 273 | |
reed@android.com | c4cae85 | 2009-09-23 15:06:10 +0000 | [diff] [blame] | 274 | U8CPU alpha = paint.getAlpha(); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 275 | SkXfermode* xfermode = paint.getXfermode(); |
| 276 | SkColorFilter* filter = paint.getColorFilter(); |
| 277 | SkSpriteBlitter* blitter = NULL; |
| 278 | |
reed@google.com | 900ecf2 | 2014-02-20 20:55:37 +0000 | [diff] [blame] | 279 | switch (source.colorType()) { |
| 280 | case kARGB_4444_SkColorType: |
reed@android.com | c4cae85 | 2009-09-23 15:06:10 +0000 | [diff] [blame] | 281 | if (alpha != 0xFF) { |
| 282 | return NULL; // we only have opaque sprites |
| 283 | } |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 284 | if (xfermode || filter) { |
commit-bot@chromium.org | a5572e5 | 2014-03-07 03:24:41 +0000 | [diff] [blame] | 285 | blitter = allocator->createT<Sprite_D32_S4444_XferFilter>(source, paint); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 286 | } else if (source.isOpaque()) { |
commit-bot@chromium.org | a5572e5 | 2014-03-07 03:24:41 +0000 | [diff] [blame] | 287 | blitter = allocator->createT<Sprite_D32_S4444_Opaque>(source); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 288 | } else { |
commit-bot@chromium.org | a5572e5 | 2014-03-07 03:24:41 +0000 | [diff] [blame] | 289 | blitter = allocator->createT<Sprite_D32_S4444>(source); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 290 | } |
| 291 | break; |
commit-bot@chromium.org | 149e9a1 | 2014-04-09 20:45:29 +0000 | [diff] [blame^] | 292 | case kN32_SkColorType: |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 293 | if (xfermode || filter) { |
reed@android.com | c4cae85 | 2009-09-23 15:06:10 +0000 | [diff] [blame] | 294 | if (255 == alpha) { |
| 295 | // this can handle xfermode or filter, but not alpha |
commit-bot@chromium.org | a5572e5 | 2014-03-07 03:24:41 +0000 | [diff] [blame] | 296 | blitter = allocator->createT<Sprite_D32_S32A_XferFilter>(source, paint); |
reed@android.com | c4cae85 | 2009-09-23 15:06:10 +0000 | [diff] [blame] | 297 | } |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 298 | } else { |
reed@android.com | c4cae85 | 2009-09-23 15:06:10 +0000 | [diff] [blame] | 299 | // this can handle alpha, but not xfermode or filter |
commit-bot@chromium.org | a5572e5 | 2014-03-07 03:24:41 +0000 | [diff] [blame] | 300 | blitter = allocator->createT<Sprite_D32_S32>(source, alpha); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 301 | } |
| 302 | break; |
| 303 | default: |
| 304 | break; |
| 305 | } |
| 306 | return blitter; |
| 307 | } |