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 | 8 |
9 #include "SkCoreBlitters.h" | 9 #include "SkCoreBlitters.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 } | 223 } |
224 } | 224 } |
225 } | 225 } |
226 | 226 |
227 /////////////////////////////////////////////////////////////////////// | 227 /////////////////////////////////////////////////////////////////////// |
228 | 228 |
229 SkA8_Shader_Blitter::SkA8_Shader_Blitter(const SkPixmap& device, const SkPaint&
paint, | 229 SkA8_Shader_Blitter::SkA8_Shader_Blitter(const SkPixmap& device, const SkPaint&
paint, |
230 SkShader::Context* shaderContext) | 230 SkShader::Context* shaderContext) |
231 : INHERITED(device, paint, shaderContext) | 231 : INHERITED(device, paint, shaderContext) |
232 { | 232 { |
233 if ((fXfermode = paint.getXfermode()) != nullptr) { | 233 fXfermode = SkXfermode::Peek(paint.getBlendMode()); |
234 fXfermode->ref(); | 234 SkASSERT(!fXfermode || fShaderContext); |
235 SkASSERT(fShaderContext); | |
236 } | |
237 | 235 |
238 int width = device.width(); | 236 int width = device.width(); |
239 fBuffer = (SkPMColor*)sk_malloc_throw(sizeof(SkPMColor) * (width + (SkAlign4
(width) >> 2))); | 237 fBuffer = (SkPMColor*)sk_malloc_throw(sizeof(SkPMColor) * (width + (SkAlign4
(width) >> 2))); |
240 fAAExpand = (uint8_t*)(fBuffer + width); | 238 fAAExpand = (uint8_t*)(fBuffer + width); |
241 } | 239 } |
242 | 240 |
243 SkA8_Shader_Blitter::~SkA8_Shader_Blitter() { | 241 SkA8_Shader_Blitter::~SkA8_Shader_Blitter() { |
244 if (fXfermode) SkSafeUnref(fXfermode); | |
245 sk_free(fBuffer); | 242 sk_free(fBuffer); |
246 } | 243 } |
247 | 244 |
248 void SkA8_Shader_Blitter::blitH(int x, int y, int width) { | 245 void SkA8_Shader_Blitter::blitH(int x, int y, int width) { |
249 SkASSERT(x >= 0 && y >= 0 && | 246 SkASSERT(x >= 0 && y >= 0 && |
250 (unsigned)(x + width) <= (unsigned)fDevice.width()); | 247 (unsigned)(x + width) <= (unsigned)fDevice.width()); |
251 | 248 |
252 uint8_t* device = fDevice.writable_addr8(x, y); | 249 uint8_t* device = fDevice.writable_addr8(x, y); |
253 SkShader::Context* shaderContext = fShaderContext; | 250 SkShader::Context* shaderContext = fShaderContext; |
254 | 251 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 device += fDevice.rowBytes(); | 345 device += fDevice.rowBytes(); |
349 alpha += mask.fRowBytes; | 346 alpha += mask.fRowBytes; |
350 } | 347 } |
351 } | 348 } |
352 | 349 |
353 /////////////////////////////////////////////////////////////////////////////// | 350 /////////////////////////////////////////////////////////////////////////////// |
354 | 351 |
355 SkA8_Coverage_Blitter::SkA8_Coverage_Blitter(const SkPixmap& device, | 352 SkA8_Coverage_Blitter::SkA8_Coverage_Blitter(const SkPixmap& device, |
356 const SkPaint& paint) : SkRasterBlitter(device) { | 353 const SkPaint& paint) : SkRasterBlitter(device) { |
357 SkASSERT(nullptr == paint.getShader()); | 354 SkASSERT(nullptr == paint.getShader()); |
358 SkASSERT(nullptr == paint.getXfermode()); | 355 SkASSERT(paint.isSrcOver()); |
359 SkASSERT(nullptr == paint.getColorFilter()); | 356 SkASSERT(nullptr == paint.getColorFilter()); |
360 } | 357 } |
361 | 358 |
362 void SkA8_Coverage_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], | 359 void SkA8_Coverage_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], |
363 const int16_t runs[]) { | 360 const int16_t runs[]) { |
364 uint8_t* device = fDevice.writable_addr8(x, y); | 361 uint8_t* device = fDevice.writable_addr8(x, y); |
365 SkDEBUGCODE(int totalCount = 0;) | 362 SkDEBUGCODE(int totalCount = 0;) |
366 | 363 |
367 for (;;) { | 364 for (;;) { |
368 int count = runs[0]; | 365 int count = runs[0]; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 while (--height >= 0) { | 421 while (--height >= 0) { |
425 memcpy(dst, src, width); | 422 memcpy(dst, src, width); |
426 dst += dstRB; | 423 dst += dstRB; |
427 src += srcRB; | 424 src += srcRB; |
428 } | 425 } |
429 } | 426 } |
430 | 427 |
431 const SkPixmap* SkA8_Coverage_Blitter::justAnOpaqueColor(uint32_t*) { | 428 const SkPixmap* SkA8_Coverage_Blitter::justAnOpaqueColor(uint32_t*) { |
432 return nullptr; | 429 return nullptr; |
433 } | 430 } |
OLD | NEW |