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 "SkCoreBlitters.h" | 10 #include "SkCoreBlitters.h" |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 for (int i = width - 1; i >= 0; --i) { | 340 for (int i = width - 1; i >= 0; --i) { |
341 device[i] = aa_blend8(span[i], device[i], alpha[i]); | 341 device[i] = aa_blend8(span[i], device[i], alpha[i]); |
342 } | 342 } |
343 } | 343 } |
344 | 344 |
345 y += 1; | 345 y += 1; |
346 device += fDevice.rowBytes(); | 346 device += fDevice.rowBytes(); |
347 alpha += mask.fRowBytes; | 347 alpha += mask.fRowBytes; |
348 } | 348 } |
349 } | 349 } |
| 350 |
| 351 /////////////////////////////////////////////////////////////////////////////// |
| 352 |
| 353 #define SK_A8_COVERAGE_BLIT_SKIP_ZEROS |
| 354 |
| 355 SkA8_Coverage_Blitter::SkA8_Coverage_Blitter(const SkBitmap& device, |
| 356 const SkPaint& paint) : SkRasterBlitter(device) { |
| 357 SkASSERT(NULL == paint.getShader()); |
| 358 SkASSERT(NULL == paint.getXfermode()); |
| 359 SkASSERT(NULL == paint.getColorFilter()); |
| 360 } |
| 361 |
| 362 void SkA8_Coverage_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], |
| 363 const int16_t runs[]) { |
| 364 SkASSERT(0 == x); |
| 365 |
| 366 uint8_t* device = fDevice.getAddr8(x, y); |
| 367 SkDEBUGCODE(int totalCount = 0;) |
| 368 |
| 369 for (;;) { |
| 370 int count = runs[0]; |
| 371 SkASSERT(count >= 0); |
| 372 if (count == 0) { |
| 373 return; |
| 374 } |
| 375 #ifdef SK_A8_COVERAGE_BLIT_SKIP_ZEROS |
| 376 if (antialias[0]) |
| 377 #endif |
| 378 { |
| 379 memset(device, antialias[0], count); |
| 380 } |
| 381 runs += count; |
| 382 antialias += count; |
| 383 device += count; |
| 384 |
| 385 SkDEBUGCODE(totalCount += count;) |
| 386 } |
| 387 SkASSERT(fDevice.width() == totalCount); |
| 388 } |
| 389 |
| 390 void SkA8_Coverage_Blitter::blitH(int x, int y, int width) { |
| 391 memset(fDevice.getAddr8(x, y), 0xFF, width); |
| 392 } |
| 393 |
| 394 void SkA8_Coverage_Blitter::blitV(int x, int y, int height, SkAlpha alpha) { |
| 395 #ifdef SK_A8_COVERAGE_BLIT_SKIP_ZEROS |
| 396 if (0 == alpha) { |
| 397 return; |
| 398 } |
| 399 #endif |
| 400 uint8_t* dst = fDevice.getAddr8(x, y); |
| 401 const size_t dstRB = fDevice.rowBytes(); |
| 402 while (--height >= 0) { |
| 403 *dst = alpha; |
| 404 dst += dstRB; |
| 405 } |
| 406 } |
| 407 |
| 408 void SkA8_Coverage_Blitter::blitRect(int x, int y, int width, int height) { |
| 409 uint8_t* dst = fDevice.getAddr8(x, y); |
| 410 const size_t dstRB = fDevice.rowBytes(); |
| 411 while (--height >= 0) { |
| 412 memset(dst, 0xFF, width); |
| 413 dst += dstRB; |
| 414 } |
| 415 } |
| 416 |
| 417 void SkA8_Coverage_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) { |
| 418 SkASSERT(SkMask::kA8_Format == mask.fFormat); |
| 419 |
| 420 int x = clip.fLeft; |
| 421 int y = clip.fTop; |
| 422 int width = clip.width(); |
| 423 int height = clip.height(); |
| 424 |
| 425 uint8_t* dst = fDevice.getAddr8(x, y); |
| 426 const uint8_t* src = mask.getAddr8(x, y); |
| 427 const size_t srcRB = mask.fRowBytes; |
| 428 const size_t dstRB = fDevice.rowBytes(); |
| 429 |
| 430 while (--height >= 0) { |
| 431 memcpy(dst, src, width); |
| 432 dst += dstRB; |
| 433 src += srcRB; |
| 434 } |
| 435 } |
| 436 |
| 437 const SkBitmap* SkA8_Coverage_Blitter::justAnOpaqueColor(uint32_t*) { |
| 438 return NULL; |
| 439 } |
OLD | NEW |