OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkSpriteBlitter.h" | 10 #include "SkSpriteBlitter.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 class Sprite_D32_XferFilter : public SkSpriteBlitter { | 62 class Sprite_D32_XferFilter : public SkSpriteBlitter { |
63 public: | 63 public: |
64 Sprite_D32_XferFilter(const SkPixmap& source, const SkPaint& paint) : SkSpri
teBlitter(source) { | 64 Sprite_D32_XferFilter(const SkPixmap& source, const SkPaint& paint) : SkSpri
teBlitter(source) { |
65 fColorFilter = paint.getColorFilter(); | 65 fColorFilter = paint.getColorFilter(); |
66 SkSafeRef(fColorFilter); | 66 SkSafeRef(fColorFilter); |
67 | 67 |
68 fXfermode = paint.getXfermode(); | 68 fXfermode = paint.getXfermode(); |
69 SkSafeRef(fXfermode); | 69 SkSafeRef(fXfermode); |
70 | 70 |
71 fBufferSize = 0; | 71 fBufferSize = 0; |
72 fBuffer = NULL; | 72 fBuffer = nullptr; |
73 | 73 |
74 unsigned flags32 = 0; | 74 unsigned flags32 = 0; |
75 if (255 != paint.getAlpha()) { | 75 if (255 != paint.getAlpha()) { |
76 flags32 |= SkBlitRow::kGlobalAlpha_Flag32; | 76 flags32 |= SkBlitRow::kGlobalAlpha_Flag32; |
77 } | 77 } |
78 if (!source.isOpaque()) { | 78 if (!source.isOpaque()) { |
79 flags32 |= SkBlitRow::kSrcPixelAlpha_Flag32; | 79 flags32 |= SkBlitRow::kSrcPixelAlpha_Flag32; |
80 } | 80 } |
81 | 81 |
82 fProc32 = SkBlitRow::Factory32(flags32); | 82 fProc32 = SkBlitRow::Factory32(flags32); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 do { | 131 do { |
132 const SkPMColor* tmp = src; | 132 const SkPMColor* tmp = src; |
133 | 133 |
134 if (colorFilter) { | 134 if (colorFilter) { |
135 colorFilter->filterSpan(src, width, fBuffer); | 135 colorFilter->filterSpan(src, width, fBuffer); |
136 tmp = fBuffer; | 136 tmp = fBuffer; |
137 } | 137 } |
138 | 138 |
139 if (xfermode) { | 139 if (xfermode) { |
140 xfermode->xfer32(dst, tmp, width, NULL); | 140 xfermode->xfer32(dst, tmp, width, nullptr); |
141 } else { | 141 } else { |
142 fProc32(dst, tmp, width, fAlpha); | 142 fProc32(dst, tmp, width, fAlpha); |
143 } | 143 } |
144 | 144 |
145 dst = (uint32_t* SK_RESTRICT)((char*)dst + dstRB); | 145 dst = (uint32_t* SK_RESTRICT)((char*)dst + dstRB); |
146 src = (const uint32_t* SK_RESTRICT)((const char*)src + srcRB); | 146 src = (const uint32_t* SK_RESTRICT)((const char*)src + srcRB); |
147 } while (--height != 0); | 147 } while (--height != 0); |
148 } | 148 } |
149 | 149 |
150 private: | 150 private: |
(...skipping 24 matching lines...) Expand all Loading... |
175 SkColorFilter* colorFilter = fColorFilter; | 175 SkColorFilter* colorFilter = fColorFilter; |
176 SkXfermode* xfermode = fXfermode; | 176 SkXfermode* xfermode = fXfermode; |
177 | 177 |
178 do { | 178 do { |
179 fillbuffer(buffer, src, width); | 179 fillbuffer(buffer, src, width); |
180 | 180 |
181 if (colorFilter) { | 181 if (colorFilter) { |
182 colorFilter->filterSpan(buffer, width, buffer); | 182 colorFilter->filterSpan(buffer, width, buffer); |
183 } | 183 } |
184 if (xfermode) { | 184 if (xfermode) { |
185 xfermode->xfer32(dst, buffer, width, NULL); | 185 xfermode->xfer32(dst, buffer, width, nullptr); |
186 } else { | 186 } else { |
187 fProc32(dst, buffer, width, fAlpha); | 187 fProc32(dst, buffer, width, fAlpha); |
188 } | 188 } |
189 | 189 |
190 dst = (SkPMColor* SK_RESTRICT)((char*)dst + dstRB); | 190 dst = (SkPMColor* SK_RESTRICT)((char*)dst + dstRB); |
191 src = (const SkPMColor16* SK_RESTRICT)((const char*)src + srcRB); | 191 src = (const SkPMColor16* SK_RESTRICT)((const char*)src + srcRB); |
192 } while (--height != 0); | 192 } while (--height != 0); |
193 } | 193 } |
194 | 194 |
195 private: | 195 private: |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 dst = (SkPMColor* SK_RESTRICT)((char*)dst + dstRB); | 251 dst = (SkPMColor* SK_RESTRICT)((char*)dst + dstRB); |
252 src = (const SkPMColor16* SK_RESTRICT)((const char*)src + srcRB); | 252 src = (const SkPMColor16* SK_RESTRICT)((const char*)src + srcRB); |
253 } while (--height != 0); | 253 } while (--height != 0); |
254 } | 254 } |
255 }; | 255 }; |
256 | 256 |
257 /////////////////////////////////////////////////////////////////////////////// | 257 /////////////////////////////////////////////////////////////////////////////// |
258 | 258 |
259 SkSpriteBlitter* SkSpriteBlitter::ChooseD32(const SkPixmap& source, const SkPain
t& paint, | 259 SkSpriteBlitter* SkSpriteBlitter::ChooseD32(const SkPixmap& source, const SkPain
t& paint, |
260 SkTBlitterAllocator* allocator) { | 260 SkTBlitterAllocator* allocator) { |
261 SkASSERT(allocator != NULL); | 261 SkASSERT(allocator != nullptr); |
262 | 262 |
263 if (paint.getMaskFilter() != NULL) { | 263 if (paint.getMaskFilter() != nullptr) { |
264 return NULL; | 264 return nullptr; |
265 } | 265 } |
266 | 266 |
267 U8CPU alpha = paint.getAlpha(); | 267 U8CPU alpha = paint.getAlpha(); |
268 SkXfermode* xfermode = paint.getXfermode(); | 268 SkXfermode* xfermode = paint.getXfermode(); |
269 SkColorFilter* filter = paint.getColorFilter(); | 269 SkColorFilter* filter = paint.getColorFilter(); |
270 SkSpriteBlitter* blitter = NULL; | 270 SkSpriteBlitter* blitter = nullptr; |
271 | 271 |
272 switch (source.colorType()) { | 272 switch (source.colorType()) { |
273 case kARGB_4444_SkColorType: | 273 case kARGB_4444_SkColorType: |
274 if (alpha != 0xFF) { | 274 if (alpha != 0xFF) { |
275 return NULL; // we only have opaque sprites | 275 return nullptr; // we only have opaque sprites |
276 } | 276 } |
277 if (xfermode || filter) { | 277 if (xfermode || filter) { |
278 blitter = allocator->createT<Sprite_D32_S4444_XferFilter>(source
, paint); | 278 blitter = allocator->createT<Sprite_D32_S4444_XferFilter>(source
, paint); |
279 } else if (source.isOpaque()) { | 279 } else if (source.isOpaque()) { |
280 blitter = allocator->createT<Sprite_D32_S4444_Opaque>(source); | 280 blitter = allocator->createT<Sprite_D32_S4444_Opaque>(source); |
281 } else { | 281 } else { |
282 blitter = allocator->createT<Sprite_D32_S4444>(source); | 282 blitter = allocator->createT<Sprite_D32_S4444>(source); |
283 } | 283 } |
284 break; | 284 break; |
285 case kN32_SkColorType: | 285 case kN32_SkColorType: |
286 if (xfermode || filter) { | 286 if (xfermode || filter) { |
287 if (255 == alpha) { | 287 if (255 == alpha) { |
288 // this can handle xfermode or filter, but not alpha | 288 // this can handle xfermode or filter, but not alpha |
289 blitter = allocator->createT<Sprite_D32_S32A_XferFilter>(sou
rce, paint); | 289 blitter = allocator->createT<Sprite_D32_S32A_XferFilter>(sou
rce, paint); |
290 } | 290 } |
291 } else { | 291 } else { |
292 // this can handle alpha, but not xfermode or filter | 292 // this can handle alpha, but not xfermode or filter |
293 blitter = allocator->createT<Sprite_D32_S32>(source, alpha); | 293 blitter = allocator->createT<Sprite_D32_S32>(source, alpha); |
294 } | 294 } |
295 break; | 295 break; |
296 default: | 296 default: |
297 break; | 297 break; |
298 } | 298 } |
299 return blitter; | 299 return blitter; |
300 } | 300 } |
OLD | NEW |