| 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 "SkCoreBlitters.h" | 8 #include "SkCoreBlitters.h" |
| 9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
| 10 #include "SkShader.h" | 10 #include "SkShader.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 fSrcB = SkAlphaMul(SkColorGetB(color), scale); | 52 fSrcB = SkAlphaMul(SkColorGetB(color), scale); |
| 53 | 53 |
| 54 fPMColor = SkPackARGB32(fSrcA, fSrcR, fSrcG, fSrcB); | 54 fPMColor = SkPackARGB32(fSrcA, fSrcR, fSrcG, fSrcB); |
| 55 } | 55 } |
| 56 | 56 |
| 57 const SkPixmap* SkARGB32_Blitter::justAnOpaqueColor(uint32_t* value) { | 57 const SkPixmap* SkARGB32_Blitter::justAnOpaqueColor(uint32_t* value) { |
| 58 if (255 == fSrcA) { | 58 if (255 == fSrcA) { |
| 59 *value = fPMColor; | 59 *value = fPMColor; |
| 60 return &fDevice; | 60 return &fDevice; |
| 61 } | 61 } |
| 62 return NULL; | 62 return nullptr; |
| 63 } | 63 } |
| 64 | 64 |
| 65 #if defined _WIN32 && _MSC_VER >= 1300 // disable warning : local variable used
without having been initialized | 65 #if defined _WIN32 && _MSC_VER >= 1300 // disable warning : local variable used
without having been initialized |
| 66 #pragma warning ( push ) | 66 #pragma warning ( push ) |
| 67 #pragma warning ( disable : 4701 ) | 67 #pragma warning ( disable : 4701 ) |
| 68 #endif | 68 #endif |
| 69 | 69 |
| 70 void SkARGB32_Blitter::blitH(int x, int y, int width) { | 70 void SkARGB32_Blitter::blitH(int x, int y, int width) { |
| 71 SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width()); | 71 SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width()); |
| 72 | 72 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 int flags = 0; | 331 int flags = 0; |
| 332 if (!(shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag)) { | 332 if (!(shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag)) { |
| 333 flags |= SkBlitRow::kSrcPixelAlpha_Flag32; | 333 flags |= SkBlitRow::kSrcPixelAlpha_Flag32; |
| 334 } | 334 } |
| 335 // we call this on the output from the shader | 335 // we call this on the output from the shader |
| 336 fProc32 = SkBlitRow::Factory32(flags); | 336 fProc32 = SkBlitRow::Factory32(flags); |
| 337 // we call this on the output from the shader + alpha from the aa buffer | 337 // we call this on the output from the shader + alpha from the aa buffer |
| 338 fProc32Blend = SkBlitRow::Factory32(flags | SkBlitRow::kGlobalAlpha_Flag32); | 338 fProc32Blend = SkBlitRow::Factory32(flags | SkBlitRow::kGlobalAlpha_Flag32); |
| 339 | 339 |
| 340 fShadeDirectlyIntoDevice = false; | 340 fShadeDirectlyIntoDevice = false; |
| 341 if (fXfermode == NULL) { | 341 if (fXfermode == nullptr) { |
| 342 if (shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag) { | 342 if (shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag) { |
| 343 fShadeDirectlyIntoDevice = true; | 343 fShadeDirectlyIntoDevice = true; |
| 344 } | 344 } |
| 345 } else { | 345 } else { |
| 346 SkXfermode::Mode mode; | 346 SkXfermode::Mode mode; |
| 347 if (fXfermode->asMode(&mode)) { | 347 if (fXfermode->asMode(&mode)) { |
| 348 if (SkXfermode::kSrc_Mode == mode) { | 348 if (SkXfermode::kSrc_Mode == mode) { |
| 349 fShadeDirectlyIntoDevice = true; | 349 fShadeDirectlyIntoDevice = true; |
| 350 fProc32Blend = blend_srcmode; | 350 fProc32Blend = blend_srcmode; |
| 351 } | 351 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 364 SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width()); | 364 SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width()); |
| 365 | 365 |
| 366 uint32_t* device = fDevice.writable_addr32(x, y); | 366 uint32_t* device = fDevice.writable_addr32(x, y); |
| 367 | 367 |
| 368 if (fShadeDirectlyIntoDevice) { | 368 if (fShadeDirectlyIntoDevice) { |
| 369 fShaderContext->shadeSpan(x, y, device, width); | 369 fShaderContext->shadeSpan(x, y, device, width); |
| 370 } else { | 370 } else { |
| 371 SkPMColor* span = fBuffer; | 371 SkPMColor* span = fBuffer; |
| 372 fShaderContext->shadeSpan(x, y, span, width); | 372 fShaderContext->shadeSpan(x, y, span, width); |
| 373 if (fXfermode) { | 373 if (fXfermode) { |
| 374 fXfermode->xfer32(device, span, width, NULL); | 374 fXfermode->xfer32(device, span, width, nullptr); |
| 375 } else { | 375 } else { |
| 376 fProc32(device, span, width, 255); | 376 fProc32(device, span, width, 255); |
| 377 } | 377 } |
| 378 } | 378 } |
| 379 } | 379 } |
| 380 | 380 |
| 381 void SkARGB32_Shader_Blitter::blitRect(int x, int y, int width, int height) { | 381 void SkARGB32_Shader_Blitter::blitRect(int x, int y, int width, int height) { |
| 382 SkASSERT(x >= 0 && y >= 0 && | 382 SkASSERT(x >= 0 && y >= 0 && |
| 383 x + width <= fDevice.width() && y + height <= fDevice.height()); | 383 x + width <= fDevice.width() && y + height <= fDevice.height()); |
| 384 | 384 |
| 385 uint32_t* device = fDevice.writable_addr32(x, y); | 385 uint32_t* device = fDevice.writable_addr32(x, y); |
| 386 size_t deviceRB = fDevice.rowBytes(); | 386 size_t deviceRB = fDevice.rowBytes(); |
| 387 SkShader::Context* shaderContext = fShaderContext; | 387 SkShader::Context* shaderContext = fShaderContext; |
| 388 SkPMColor* span = fBuffer; | 388 SkPMColor* span = fBuffer; |
| 389 | 389 |
| 390 if (fConstInY) { | 390 if (fConstInY) { |
| 391 if (fShadeDirectlyIntoDevice) { | 391 if (fShadeDirectlyIntoDevice) { |
| 392 // shade the first row directly into the device | 392 // shade the first row directly into the device |
| 393 shaderContext->shadeSpan(x, y, device, width); | 393 shaderContext->shadeSpan(x, y, device, width); |
| 394 span = device; | 394 span = device; |
| 395 while (--height > 0) { | 395 while (--height > 0) { |
| 396 device = (uint32_t*)((char*)device + deviceRB); | 396 device = (uint32_t*)((char*)device + deviceRB); |
| 397 memcpy(device, span, width << 2); | 397 memcpy(device, span, width << 2); |
| 398 } | 398 } |
| 399 } else { | 399 } else { |
| 400 shaderContext->shadeSpan(x, y, span, width); | 400 shaderContext->shadeSpan(x, y, span, width); |
| 401 SkXfermode* xfer = fXfermode; | 401 SkXfermode* xfer = fXfermode; |
| 402 if (xfer) { | 402 if (xfer) { |
| 403 do { | 403 do { |
| 404 xfer->xfer32(device, span, width, NULL); | 404 xfer->xfer32(device, span, width, nullptr); |
| 405 y += 1; | 405 y += 1; |
| 406 device = (uint32_t*)((char*)device + deviceRB); | 406 device = (uint32_t*)((char*)device + deviceRB); |
| 407 } while (--height > 0); | 407 } while (--height > 0); |
| 408 } else { | 408 } else { |
| 409 SkBlitRow::Proc32 proc = fProc32; | 409 SkBlitRow::Proc32 proc = fProc32; |
| 410 do { | 410 do { |
| 411 proc(device, span, width, 255); | 411 proc(device, span, width, 255); |
| 412 y += 1; | 412 y += 1; |
| 413 device = (uint32_t*)((char*)device + deviceRB); | 413 device = (uint32_t*)((char*)device + deviceRB); |
| 414 } while (--height > 0); | 414 } while (--height > 0); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 431 shaderContext->shadeSpan(x, y, device, width); | 431 shaderContext->shadeSpan(x, y, device, width); |
| 432 y += 1; | 432 y += 1; |
| 433 device = (uint32_t*)((char*)device + deviceRB); | 433 device = (uint32_t*)((char*)device + deviceRB); |
| 434 } while (--height > 0); | 434 } while (--height > 0); |
| 435 } | 435 } |
| 436 } else { | 436 } else { |
| 437 SkXfermode* xfer = fXfermode; | 437 SkXfermode* xfer = fXfermode; |
| 438 if (xfer) { | 438 if (xfer) { |
| 439 do { | 439 do { |
| 440 shaderContext->shadeSpan(x, y, span, width); | 440 shaderContext->shadeSpan(x, y, span, width); |
| 441 xfer->xfer32(device, span, width, NULL); | 441 xfer->xfer32(device, span, width, nullptr); |
| 442 y += 1; | 442 y += 1; |
| 443 device = (uint32_t*)((char*)device + deviceRB); | 443 device = (uint32_t*)((char*)device + deviceRB); |
| 444 } while (--height > 0); | 444 } while (--height > 0); |
| 445 } else { | 445 } else { |
| 446 SkBlitRow::Proc32 proc = fProc32; | 446 SkBlitRow::Proc32 proc = fProc32; |
| 447 do { | 447 do { |
| 448 shaderContext->shadeSpan(x, y, span, width); | 448 shaderContext->shadeSpan(x, y, span, width); |
| 449 proc(device, span, width, 255); | 449 proc(device, span, width, 255); |
| 450 y += 1; | 450 y += 1; |
| 451 device = (uint32_t*)((char*)device + deviceRB); | 451 device = (uint32_t*)((char*)device + deviceRB); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 464 for (;;) { | 464 for (;;) { |
| 465 SkXfermode* xfer = fXfermode; | 465 SkXfermode* xfer = fXfermode; |
| 466 | 466 |
| 467 int count = *runs; | 467 int count = *runs; |
| 468 if (count <= 0) | 468 if (count <= 0) |
| 469 break; | 469 break; |
| 470 int aa = *antialias; | 470 int aa = *antialias; |
| 471 if (aa) { | 471 if (aa) { |
| 472 shaderContext->shadeSpan(x, y, span, count); | 472 shaderContext->shadeSpan(x, y, span, count); |
| 473 if (aa == 255) { | 473 if (aa == 255) { |
| 474 xfer->xfer32(device, span, count, NULL); | 474 xfer->xfer32(device, span, count, nullptr); |
| 475 } else { | 475 } else { |
| 476 // count is almost always 1 | 476 // count is almost always 1 |
| 477 for (int i = count - 1; i >= 0; --i) { | 477 for (int i = count - 1; i >= 0; --i) { |
| 478 xfer->xfer32(&device[i], &span[i], 1, antialias); | 478 xfer->xfer32(&device[i], &span[i], 1, antialias); |
| 479 } | 479 } |
| 480 } | 480 } |
| 481 } | 481 } |
| 482 device += count; | 482 device += count; |
| 483 runs += count; | 483 runs += count; |
| 484 antialias += count; | 484 antialias += count; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 void SkARGB32_Shader_Blitter::blitMask(const SkMask& mask, const SkIRect& clip)
{ | 532 void SkARGB32_Shader_Blitter::blitMask(const SkMask& mask, const SkIRect& clip)
{ |
| 533 // we only handle kA8 with an xfermode | 533 // we only handle kA8 with an xfermode |
| 534 if (fXfermode && (SkMask::kA8_Format != mask.fFormat)) { | 534 if (fXfermode && (SkMask::kA8_Format != mask.fFormat)) { |
| 535 this->INHERITED::blitMask(mask, clip); | 535 this->INHERITED::blitMask(mask, clip); |
| 536 return; | 536 return; |
| 537 } | 537 } |
| 538 | 538 |
| 539 SkASSERT(mask.fBounds.contains(clip)); | 539 SkASSERT(mask.fBounds.contains(clip)); |
| 540 | 540 |
| 541 SkShader::Context* shaderContext = fShaderContext; | 541 SkShader::Context* shaderContext = fShaderContext; |
| 542 SkBlitMask::RowProc proc = NULL; | 542 SkBlitMask::RowProc proc = nullptr; |
| 543 if (!fXfermode) { | 543 if (!fXfermode) { |
| 544 unsigned flags = 0; | 544 unsigned flags = 0; |
| 545 if (shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag) { | 545 if (shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag) { |
| 546 flags |= SkBlitMask::kSrcIsOpaque_RowFlag; | 546 flags |= SkBlitMask::kSrcIsOpaque_RowFlag; |
| 547 } | 547 } |
| 548 proc = SkBlitMask::RowFactory(kN32_SkColorType, mask.fFormat, | 548 proc = SkBlitMask::RowFactory(kN32_SkColorType, mask.fFormat, |
| 549 (SkBlitMask::RowFlags)flags); | 549 (SkBlitMask::RowFlags)flags); |
| 550 if (NULL == proc) { | 550 if (nullptr == proc) { |
| 551 this->INHERITED::blitMask(mask, clip); | 551 this->INHERITED::blitMask(mask, clip); |
| 552 return; | 552 return; |
| 553 } | 553 } |
| 554 } | 554 } |
| 555 | 555 |
| 556 const int x = clip.fLeft; | 556 const int x = clip.fLeft; |
| 557 const int width = clip.width(); | 557 const int width = clip.width(); |
| 558 int y = clip.fTop; | 558 int y = clip.fTop; |
| 559 int height = clip.height(); | 559 int height = clip.height(); |
| 560 | 560 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 SkBlitRow::Proc32 proc = (255 == alpha) ? fProc32 : fProc32Blend; | 676 SkBlitRow::Proc32 proc = (255 == alpha) ? fProc32 : fProc32Blend; |
| 677 do { | 677 do { |
| 678 shaderContext->shadeSpan(x, y, span, 1); | 678 shaderContext->shadeSpan(x, y, span, 1); |
| 679 proc(device, span, 1, alpha); | 679 proc(device, span, 1, alpha); |
| 680 y += 1; | 680 y += 1; |
| 681 device = (uint32_t*)((char*)device + deviceRB); | 681 device = (uint32_t*)((char*)device + deviceRB); |
| 682 } while (--height > 0); | 682 } while (--height > 0); |
| 683 } | 683 } |
| 684 } | 684 } |
| 685 } | 685 } |
| OLD | NEW |