| 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 static void blend_srcmode(SkPMColor* SK_RESTRICT device, | 268 static void blend_srcmode(SkPMColor* SK_RESTRICT device, |
| 269 const SkPMColor* SK_RESTRICT span, | 269 const SkPMColor* SK_RESTRICT span, |
| 270 int count, U8CPU aa) { | 270 int count, U8CPU aa) { |
| 271 int aa256 = SkAlpha255To256(aa); | 271 int aa256 = SkAlpha255To256(aa); |
| 272 for (int i = 0; i < count; ++i) { | 272 for (int i = 0; i < count; ++i) { |
| 273 device[i] = SkFourByteInterp256(span[i], device[i], aa256); | 273 device[i] = SkFourByteInterp256(span[i], device[i], aa256); |
| 274 } | 274 } |
| 275 } | 275 } |
| 276 | 276 |
| 277 SkARGB32_Shader_Blitter::SkARGB32_Shader_Blitter(const SkBitmap& device, | 277 SkARGB32_Shader_Blitter::SkARGB32_Shader_Blitter(const SkBitmap& device, |
| 278 const SkPaint& paint, SkShader::Context* shaderContext) | 278 const SkPaint& paint) : INHERITED(device, paint) { |
| 279 : INHERITED(device, paint, shaderContext) | |
| 280 { | |
| 281 fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * (sizeof(SkPMColor))); | 279 fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * (sizeof(SkPMColor))); |
| 282 | 280 |
| 283 fXfermode = paint.getXfermode(); | 281 fXfermode = paint.getXfermode(); |
| 284 SkSafeRef(fXfermode); | 282 SkSafeRef(fXfermode); |
| 285 | 283 |
| 286 int flags = 0; | 284 int flags = 0; |
| 287 if (!(shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag)) { | 285 if (!(fShader->getFlags() & SkShader::kOpaqueAlpha_Flag)) { |
| 288 flags |= SkBlitRow::kSrcPixelAlpha_Flag32; | 286 flags |= SkBlitRow::kSrcPixelAlpha_Flag32; |
| 289 } | 287 } |
| 290 // we call this on the output from the shader | 288 // we call this on the output from the shader |
| 291 fProc32 = SkBlitRow::Factory32(flags); | 289 fProc32 = SkBlitRow::Factory32(flags); |
| 292 // we call this on the output from the shader + alpha from the aa buffer | 290 // we call this on the output from the shader + alpha from the aa buffer |
| 293 fProc32Blend = SkBlitRow::Factory32(flags | SkBlitRow::kGlobalAlpha_Flag32); | 291 fProc32Blend = SkBlitRow::Factory32(flags | SkBlitRow::kGlobalAlpha_Flag32); |
| 294 | 292 |
| 295 fShadeDirectlyIntoDevice = false; | 293 fShadeDirectlyIntoDevice = false; |
| 296 if (fXfermode == NULL) { | 294 if (fXfermode == NULL) { |
| 297 if (shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag) { | 295 if (fShader->getFlags() & SkShader::kOpaqueAlpha_Flag) { |
| 298 fShadeDirectlyIntoDevice = true; | 296 fShadeDirectlyIntoDevice = true; |
| 299 } | 297 } |
| 300 } else { | 298 } else { |
| 301 SkXfermode::Mode mode; | 299 SkXfermode::Mode mode; |
| 302 if (fXfermode->asMode(&mode)) { | 300 if (fXfermode->asMode(&mode)) { |
| 303 if (SkXfermode::kSrc_Mode == mode) { | 301 if (SkXfermode::kSrc_Mode == mode) { |
| 304 fShadeDirectlyIntoDevice = true; | 302 fShadeDirectlyIntoDevice = true; |
| 305 fProc32Blend = blend_srcmode; | 303 fProc32Blend = blend_srcmode; |
| 306 } | 304 } |
| 307 } | 305 } |
| 308 } | 306 } |
| 309 | 307 |
| 310 fConstInY = SkToBool(shaderContext->getFlags() & SkShader::kConstInY32_Flag)
; | 308 fConstInY = SkToBool(fShader->getFlags() & SkShader::kConstInY32_Flag); |
| 311 } | 309 } |
| 312 | 310 |
| 313 SkARGB32_Shader_Blitter::~SkARGB32_Shader_Blitter() { | 311 SkARGB32_Shader_Blitter::~SkARGB32_Shader_Blitter() { |
| 314 SkSafeUnref(fXfermode); | 312 SkSafeUnref(fXfermode); |
| 315 sk_free(fBuffer); | 313 sk_free(fBuffer); |
| 316 } | 314 } |
| 317 | 315 |
| 318 void SkARGB32_Shader_Blitter::blitH(int x, int y, int width) { | 316 void SkARGB32_Shader_Blitter::blitH(int x, int y, int width) { |
| 319 SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width()); | 317 SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width()); |
| 320 | 318 |
| 321 uint32_t* device = fDevice.getAddr32(x, y); | 319 uint32_t* device = fDevice.getAddr32(x, y); |
| 322 | 320 |
| 323 if (fShadeDirectlyIntoDevice) { | 321 if (fShadeDirectlyIntoDevice) { |
| 324 fShaderContext->shadeSpan(x, y, device, width); | 322 fShader->shadeSpan(x, y, device, width); |
| 325 } else { | 323 } else { |
| 326 SkPMColor* span = fBuffer; | 324 SkPMColor* span = fBuffer; |
| 327 fShaderContext->shadeSpan(x, y, span, width); | 325 fShader->shadeSpan(x, y, span, width); |
| 328 if (fXfermode) { | 326 if (fXfermode) { |
| 329 fXfermode->xfer32(device, span, width, NULL); | 327 fXfermode->xfer32(device, span, width, NULL); |
| 330 } else { | 328 } else { |
| 331 fProc32(device, span, width, 255); | 329 fProc32(device, span, width, 255); |
| 332 } | 330 } |
| 333 } | 331 } |
| 334 } | 332 } |
| 335 | 333 |
| 336 void SkARGB32_Shader_Blitter::blitRect(int x, int y, int width, int height) { | 334 void SkARGB32_Shader_Blitter::blitRect(int x, int y, int width, int height) { |
| 337 SkASSERT(x >= 0 && y >= 0 && | 335 SkASSERT(x >= 0 && y >= 0 && |
| 338 x + width <= fDevice.width() && y + height <= fDevice.height()); | 336 x + width <= fDevice.width() && y + height <= fDevice.height()); |
| 339 | 337 |
| 340 uint32_t* device = fDevice.getAddr32(x, y); | 338 uint32_t* device = fDevice.getAddr32(x, y); |
| 341 size_t deviceRB = fDevice.rowBytes(); | 339 size_t deviceRB = fDevice.rowBytes(); |
| 342 SkShader::Context* shaderContext = fShaderContext; | 340 SkShader* shader = fShader; |
| 343 SkPMColor* span = fBuffer; | 341 SkPMColor* span = fBuffer; |
| 344 | 342 |
| 345 if (fConstInY) { | 343 if (fConstInY) { |
| 346 if (fShadeDirectlyIntoDevice) { | 344 if (fShadeDirectlyIntoDevice) { |
| 347 // shade the first row directly into the device | 345 // shade the first row directly into the device |
| 348 shaderContext->shadeSpan(x, y, device, width); | 346 fShader->shadeSpan(x, y, device, width); |
| 349 span = device; | 347 span = device; |
| 350 while (--height > 0) { | 348 while (--height > 0) { |
| 351 device = (uint32_t*)((char*)device + deviceRB); | 349 device = (uint32_t*)((char*)device + deviceRB); |
| 352 memcpy(device, span, width << 2); | 350 memcpy(device, span, width << 2); |
| 353 } | 351 } |
| 354 } else { | 352 } else { |
| 355 shaderContext->shadeSpan(x, y, span, width); | 353 fShader->shadeSpan(x, y, span, width); |
| 356 SkXfermode* xfer = fXfermode; | 354 SkXfermode* xfer = fXfermode; |
| 357 if (xfer) { | 355 if (xfer) { |
| 358 do { | 356 do { |
| 359 xfer->xfer32(device, span, width, NULL); | 357 xfer->xfer32(device, span, width, NULL); |
| 360 y += 1; | 358 y += 1; |
| 361 device = (uint32_t*)((char*)device + deviceRB); | 359 device = (uint32_t*)((char*)device + deviceRB); |
| 362 } while (--height > 0); | 360 } while (--height > 0); |
| 363 } else { | 361 } else { |
| 364 SkBlitRow::Proc32 proc = fProc32; | 362 SkBlitRow::Proc32 proc = fProc32; |
| 365 do { | 363 do { |
| 366 proc(device, span, width, 255); | 364 proc(device, span, width, 255); |
| 367 y += 1; | 365 y += 1; |
| 368 device = (uint32_t*)((char*)device + deviceRB); | 366 device = (uint32_t*)((char*)device + deviceRB); |
| 369 } while (--height > 0); | 367 } while (--height > 0); |
| 370 } | 368 } |
| 371 } | 369 } |
| 372 return; | 370 return; |
| 373 } | 371 } |
| 374 | 372 |
| 375 if (fShadeDirectlyIntoDevice) { | 373 if (fShadeDirectlyIntoDevice) { |
| 376 void* ctx; | 374 void* ctx; |
| 377 SkShader::Context::ShadeProc shadeProc = shaderContext->asAShadeProc(&ct
x); | 375 SkShader::ShadeProc shadeProc = fShader->asAShadeProc(&ctx); |
| 378 if (shadeProc) { | 376 if (shadeProc) { |
| 379 do { | 377 do { |
| 380 shadeProc(ctx, x, y, device, width); | 378 shadeProc(ctx, x, y, device, width); |
| 381 y += 1; | 379 y += 1; |
| 382 device = (uint32_t*)((char*)device + deviceRB); | 380 device = (uint32_t*)((char*)device + deviceRB); |
| 383 } while (--height > 0); | 381 } while (--height > 0); |
| 384 } else { | 382 } else { |
| 385 do { | 383 do { |
| 386 shaderContext->shadeSpan(x, y, device, width); | 384 shader->shadeSpan(x, y, device, width); |
| 387 y += 1; | 385 y += 1; |
| 388 device = (uint32_t*)((char*)device + deviceRB); | 386 device = (uint32_t*)((char*)device + deviceRB); |
| 389 } while (--height > 0); | 387 } while (--height > 0); |
| 390 } | 388 } |
| 391 } else { | 389 } else { |
| 392 SkXfermode* xfer = fXfermode; | 390 SkXfermode* xfer = fXfermode; |
| 393 if (xfer) { | 391 if (xfer) { |
| 394 do { | 392 do { |
| 395 shaderContext->shadeSpan(x, y, span, width); | 393 shader->shadeSpan(x, y, span, width); |
| 396 xfer->xfer32(device, span, width, NULL); | 394 xfer->xfer32(device, span, width, NULL); |
| 397 y += 1; | 395 y += 1; |
| 398 device = (uint32_t*)((char*)device + deviceRB); | 396 device = (uint32_t*)((char*)device + deviceRB); |
| 399 } while (--height > 0); | 397 } while (--height > 0); |
| 400 } else { | 398 } else { |
| 401 SkBlitRow::Proc32 proc = fProc32; | 399 SkBlitRow::Proc32 proc = fProc32; |
| 402 do { | 400 do { |
| 403 shaderContext->shadeSpan(x, y, span, width); | 401 shader->shadeSpan(x, y, span, width); |
| 404 proc(device, span, width, 255); | 402 proc(device, span, width, 255); |
| 405 y += 1; | 403 y += 1; |
| 406 device = (uint32_t*)((char*)device + deviceRB); | 404 device = (uint32_t*)((char*)device + deviceRB); |
| 407 } while (--height > 0); | 405 } while (--height > 0); |
| 408 } | 406 } |
| 409 } | 407 } |
| 410 } | 408 } |
| 411 | 409 |
| 412 void SkARGB32_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], | 410 void SkARGB32_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], |
| 413 const int16_t runs[]) { | 411 const int16_t runs[]) { |
| 414 SkPMColor* span = fBuffer; | 412 SkPMColor* span = fBuffer; |
| 415 uint32_t* device = fDevice.getAddr32(x, y); | 413 uint32_t* device = fDevice.getAddr32(x, y); |
| 416 SkShader::Context* shaderContext = fShaderContext; | 414 SkShader* shader = fShader; |
| 417 | 415 |
| 418 if (fXfermode && !fShadeDirectlyIntoDevice) { | 416 if (fXfermode && !fShadeDirectlyIntoDevice) { |
| 419 for (;;) { | 417 for (;;) { |
| 420 SkXfermode* xfer = fXfermode; | 418 SkXfermode* xfer = fXfermode; |
| 421 | 419 |
| 422 int count = *runs; | 420 int count = *runs; |
| 423 if (count <= 0) | 421 if (count <= 0) |
| 424 break; | 422 break; |
| 425 int aa = *antialias; | 423 int aa = *antialias; |
| 426 if (aa) { | 424 if (aa) { |
| 427 shaderContext->shadeSpan(x, y, span, count); | 425 shader->shadeSpan(x, y, span, count); |
| 428 if (aa == 255) { | 426 if (aa == 255) { |
| 429 xfer->xfer32(device, span, count, NULL); | 427 xfer->xfer32(device, span, count, NULL); |
| 430 } else { | 428 } else { |
| 431 // count is almost always 1 | 429 // count is almost always 1 |
| 432 for (int i = count - 1; i >= 0; --i) { | 430 for (int i = count - 1; i >= 0; --i) { |
| 433 xfer->xfer32(&device[i], &span[i], 1, antialias); | 431 xfer->xfer32(&device[i], &span[i], 1, antialias); |
| 434 } | 432 } |
| 435 } | 433 } |
| 436 } | 434 } |
| 437 device += count; | 435 device += count; |
| 438 runs += count; | 436 runs += count; |
| 439 antialias += count; | 437 antialias += count; |
| 440 x += count; | 438 x += count; |
| 441 } | 439 } |
| 442 } else if (fShadeDirectlyIntoDevice || | 440 } else if (fShadeDirectlyIntoDevice || |
| 443 (shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag)) { | 441 (fShader->getFlags() & SkShader::kOpaqueAlpha_Flag)) { |
| 444 for (;;) { | 442 for (;;) { |
| 445 int count = *runs; | 443 int count = *runs; |
| 446 if (count <= 0) { | 444 if (count <= 0) { |
| 447 break; | 445 break; |
| 448 } | 446 } |
| 449 int aa = *antialias; | 447 int aa = *antialias; |
| 450 if (aa) { | 448 if (aa) { |
| 451 if (aa == 255) { | 449 if (aa == 255) { |
| 452 // cool, have the shader draw right into the device | 450 // cool, have the shader draw right into the device |
| 453 shaderContext->shadeSpan(x, y, device, count); | 451 shader->shadeSpan(x, y, device, count); |
| 454 } else { | 452 } else { |
| 455 shaderContext->shadeSpan(x, y, span, count); | 453 shader->shadeSpan(x, y, span, count); |
| 456 fProc32Blend(device, span, count, aa); | 454 fProc32Blend(device, span, count, aa); |
| 457 } | 455 } |
| 458 } | 456 } |
| 459 device += count; | 457 device += count; |
| 460 runs += count; | 458 runs += count; |
| 461 antialias += count; | 459 antialias += count; |
| 462 x += count; | 460 x += count; |
| 463 } | 461 } |
| 464 } else { | 462 } else { |
| 465 for (;;) { | 463 for (;;) { |
| 466 int count = *runs; | 464 int count = *runs; |
| 467 if (count <= 0) { | 465 if (count <= 0) { |
| 468 break; | 466 break; |
| 469 } | 467 } |
| 470 int aa = *antialias; | 468 int aa = *antialias; |
| 471 if (aa) { | 469 if (aa) { |
| 472 shaderContext->shadeSpan(x, y, span, count); | 470 fShader->shadeSpan(x, y, span, count); |
| 473 if (aa == 255) { | 471 if (aa == 255) { |
| 474 fProc32(device, span, count, 255); | 472 fProc32(device, span, count, 255); |
| 475 } else { | 473 } else { |
| 476 fProc32Blend(device, span, count, aa); | 474 fProc32Blend(device, span, count, aa); |
| 477 } | 475 } |
| 478 } | 476 } |
| 479 device += count; | 477 device += count; |
| 480 runs += count; | 478 runs += count; |
| 481 antialias += count; | 479 antialias += count; |
| 482 x += count; | 480 x += count; |
| 483 } | 481 } |
| 484 } | 482 } |
| 485 } | 483 } |
| 486 | 484 |
| 487 void SkARGB32_Shader_Blitter::blitMask(const SkMask& mask, const SkIRect& clip)
{ | 485 void SkARGB32_Shader_Blitter::blitMask(const SkMask& mask, const SkIRect& clip)
{ |
| 488 // we only handle kA8 with an xfermode | 486 // we only handle kA8 with an xfermode |
| 489 if (fXfermode && (SkMask::kA8_Format != mask.fFormat)) { | 487 if (fXfermode && (SkMask::kA8_Format != mask.fFormat)) { |
| 490 this->INHERITED::blitMask(mask, clip); | 488 this->INHERITED::blitMask(mask, clip); |
| 491 return; | 489 return; |
| 492 } | 490 } |
| 493 | 491 |
| 494 SkASSERT(mask.fBounds.contains(clip)); | 492 SkASSERT(mask.fBounds.contains(clip)); |
| 495 | 493 |
| 496 SkShader::Context* shaderContext = fShaderContext; | |
| 497 SkBlitMask::RowProc proc = NULL; | 494 SkBlitMask::RowProc proc = NULL; |
| 498 if (!fXfermode) { | 495 if (!fXfermode) { |
| 499 unsigned flags = 0; | 496 unsigned flags = 0; |
| 500 if (shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag) { | 497 if (fShader->getFlags() & SkShader::kOpaqueAlpha_Flag) { |
| 501 flags |= SkBlitMask::kSrcIsOpaque_RowFlag; | 498 flags |= SkBlitMask::kSrcIsOpaque_RowFlag; |
| 502 } | 499 } |
| 503 proc = SkBlitMask::RowFactory(SkBitmap::kARGB_8888_Config, mask.fFormat, | 500 proc = SkBlitMask::RowFactory(SkBitmap::kARGB_8888_Config, mask.fFormat, |
| 504 (SkBlitMask::RowFlags)flags); | 501 (SkBlitMask::RowFlags)flags); |
| 505 if (NULL == proc) { | 502 if (NULL == proc) { |
| 506 this->INHERITED::blitMask(mask, clip); | 503 this->INHERITED::blitMask(mask, clip); |
| 507 return; | 504 return; |
| 508 } | 505 } |
| 509 } | 506 } |
| 510 | 507 |
| 511 const int x = clip.fLeft; | 508 const int x = clip.fLeft; |
| 512 const int width = clip.width(); | 509 const int width = clip.width(); |
| 513 int y = clip.fTop; | 510 int y = clip.fTop; |
| 514 int height = clip.height(); | 511 int height = clip.height(); |
| 515 | 512 |
| 516 char* dstRow = (char*)fDevice.getAddr32(x, y); | 513 char* dstRow = (char*)fDevice.getAddr32(x, y); |
| 517 const size_t dstRB = fDevice.rowBytes(); | 514 const size_t dstRB = fDevice.rowBytes(); |
| 518 const uint8_t* maskRow = (const uint8_t*)mask.getAddr(x, y); | 515 const uint8_t* maskRow = (const uint8_t*)mask.getAddr(x, y); |
| 519 const size_t maskRB = mask.fRowBytes; | 516 const size_t maskRB = mask.fRowBytes; |
| 520 | 517 |
| 518 SkShader* shader = fShader; |
| 521 SkPMColor* span = fBuffer; | 519 SkPMColor* span = fBuffer; |
| 522 | 520 |
| 523 if (fXfermode) { | 521 if (fXfermode) { |
| 524 SkASSERT(SkMask::kA8_Format == mask.fFormat); | 522 SkASSERT(SkMask::kA8_Format == mask.fFormat); |
| 525 SkXfermode* xfer = fXfermode; | 523 SkXfermode* xfer = fXfermode; |
| 526 do { | 524 do { |
| 527 shaderContext->shadeSpan(x, y, span, width); | 525 shader->shadeSpan(x, y, span, width); |
| 528 xfer->xfer32((SkPMColor*)dstRow, span, width, maskRow); | 526 xfer->xfer32((SkPMColor*)dstRow, span, width, maskRow); |
| 529 dstRow += dstRB; | 527 dstRow += dstRB; |
| 530 maskRow += maskRB; | 528 maskRow += maskRB; |
| 531 y += 1; | 529 y += 1; |
| 532 } while (--height > 0); | 530 } while (--height > 0); |
| 533 } else { | 531 } else { |
| 534 do { | 532 do { |
| 535 shaderContext->shadeSpan(x, y, span, width); | 533 shader->shadeSpan(x, y, span, width); |
| 536 proc(dstRow, maskRow, span, width); | 534 proc(dstRow, maskRow, span, width); |
| 537 dstRow += dstRB; | 535 dstRow += dstRB; |
| 538 maskRow += maskRB; | 536 maskRow += maskRB; |
| 539 y += 1; | 537 y += 1; |
| 540 } while (--height > 0); | 538 } while (--height > 0); |
| 541 } | 539 } |
| 542 } | 540 } |
| 543 | 541 |
| 544 void SkARGB32_Shader_Blitter::blitV(int x, int y, int height, SkAlpha alpha) { | 542 void SkARGB32_Shader_Blitter::blitV(int x, int y, int height, SkAlpha alpha) { |
| 545 SkASSERT(x >= 0 && y >= 0 && y + height <= fDevice.height()); | 543 SkASSERT(x >= 0 && y >= 0 && y + height <= fDevice.height()); |
| 546 | 544 |
| 547 uint32_t* device = fDevice.getAddr32(x, y); | 545 uint32_t* device = fDevice.getAddr32(x, y); |
| 548 size_t deviceRB = fDevice.rowBytes(); | 546 size_t deviceRB = fDevice.rowBytes(); |
| 549 SkShader::Context* shaderContext = fShaderContext; | 547 SkShader* shader = fShader; |
| 550 | 548 |
| 551 if (fConstInY) { | 549 if (fConstInY) { |
| 552 SkPMColor c; | 550 SkPMColor c; |
| 553 shaderContext->shadeSpan(x, y, &c, 1); | 551 fShader->shadeSpan(x, y, &c, 1); |
| 554 | 552 |
| 555 if (fShadeDirectlyIntoDevice) { | 553 if (fShadeDirectlyIntoDevice) { |
| 556 if (255 == alpha) { | 554 if (255 == alpha) { |
| 557 do { | 555 do { |
| 558 *device = c; | 556 *device = c; |
| 559 device = (uint32_t*)((char*)device + deviceRB); | 557 device = (uint32_t*)((char*)device + deviceRB); |
| 560 } while (--height > 0); | 558 } while (--height > 0); |
| 561 } else { | 559 } else { |
| 562 do { | 560 do { |
| 563 *device = SkFourByteInterp(c, *device, alpha); | 561 *device = SkFourByteInterp(c, *device, alpha); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 577 proc(device, &c, 1, alpha); | 575 proc(device, &c, 1, alpha); |
| 578 device = (uint32_t*)((char*)device + deviceRB); | 576 device = (uint32_t*)((char*)device + deviceRB); |
| 579 } while (--height > 0); | 577 } while (--height > 0); |
| 580 } | 578 } |
| 581 } | 579 } |
| 582 return; | 580 return; |
| 583 } | 581 } |
| 584 | 582 |
| 585 if (fShadeDirectlyIntoDevice) { | 583 if (fShadeDirectlyIntoDevice) { |
| 586 void* ctx; | 584 void* ctx; |
| 587 SkShader::Context::ShadeProc shadeProc = shaderContext->asAShadeProc(&ct
x); | 585 SkShader::ShadeProc shadeProc = fShader->asAShadeProc(&ctx); |
| 588 if (255 == alpha) { | 586 if (255 == alpha) { |
| 589 if (shadeProc) { | 587 if (shadeProc) { |
| 590 do { | 588 do { |
| 591 shadeProc(ctx, x, y, device, 1); | 589 shadeProc(ctx, x, y, device, 1); |
| 592 y += 1; | 590 y += 1; |
| 593 device = (uint32_t*)((char*)device + deviceRB); | 591 device = (uint32_t*)((char*)device + deviceRB); |
| 594 } while (--height > 0); | 592 } while (--height > 0); |
| 595 } else { | 593 } else { |
| 596 do { | 594 do { |
| 597 shaderContext->shadeSpan(x, y, device, 1); | 595 shader->shadeSpan(x, y, device, 1); |
| 598 y += 1; | 596 y += 1; |
| 599 device = (uint32_t*)((char*)device + deviceRB); | 597 device = (uint32_t*)((char*)device + deviceRB); |
| 600 } while (--height > 0); | 598 } while (--height > 0); |
| 601 } | 599 } |
| 602 } else { // alpha < 255 | 600 } else { // alpha < 255 |
| 603 SkPMColor c; | 601 SkPMColor c; |
| 604 if (shadeProc) { | 602 if (shadeProc) { |
| 605 do { | 603 do { |
| 606 shadeProc(ctx, x, y, &c, 1); | 604 shadeProc(ctx, x, y, &c, 1); |
| 607 *device = SkFourByteInterp(c, *device, alpha); | 605 *device = SkFourByteInterp(c, *device, alpha); |
| 608 y += 1; | 606 y += 1; |
| 609 device = (uint32_t*)((char*)device + deviceRB); | 607 device = (uint32_t*)((char*)device + deviceRB); |
| 610 } while (--height > 0); | 608 } while (--height > 0); |
| 611 } else { | 609 } else { |
| 612 do { | 610 do { |
| 613 shaderContext->shadeSpan(x, y, &c, 1); | 611 shader->shadeSpan(x, y, &c, 1); |
| 614 *device = SkFourByteInterp(c, *device, alpha); | 612 *device = SkFourByteInterp(c, *device, alpha); |
| 615 y += 1; | 613 y += 1; |
| 616 device = (uint32_t*)((char*)device + deviceRB); | 614 device = (uint32_t*)((char*)device + deviceRB); |
| 617 } while (--height > 0); | 615 } while (--height > 0); |
| 618 } | 616 } |
| 619 } | 617 } |
| 620 } else { | 618 } else { |
| 621 SkPMColor* span = fBuffer; | 619 SkPMColor* span = fBuffer; |
| 622 SkXfermode* xfer = fXfermode; | 620 SkXfermode* xfer = fXfermode; |
| 623 if (xfer) { | 621 if (xfer) { |
| 624 do { | 622 do { |
| 625 shaderContext->shadeSpan(x, y, span, 1); | 623 shader->shadeSpan(x, y, span, 1); |
| 626 xfer->xfer32(device, span, 1, &alpha); | 624 xfer->xfer32(device, span, 1, &alpha); |
| 627 y += 1; | 625 y += 1; |
| 628 device = (uint32_t*)((char*)device + deviceRB); | 626 device = (uint32_t*)((char*)device + deviceRB); |
| 629 } while (--height > 0); | 627 } while (--height > 0); |
| 630 } else { | 628 } else { |
| 631 SkBlitRow::Proc32 proc = (255 == alpha) ? fProc32 : fProc32Blend; | 629 SkBlitRow::Proc32 proc = (255 == alpha) ? fProc32 : fProc32Blend; |
| 632 do { | 630 do { |
| 633 shaderContext->shadeSpan(x, y, span, 1); | 631 shader->shadeSpan(x, y, span, 1); |
| 634 proc(device, span, 1, alpha); | 632 proc(device, span, 1, alpha); |
| 635 y += 1; | 633 y += 1; |
| 636 device = (uint32_t*)((char*)device + deviceRB); | 634 device = (uint32_t*)((char*)device + deviceRB); |
| 637 } while (--height > 0); | 635 } while (--height > 0); |
| 638 } | 636 } |
| 639 } | 637 } |
| 640 } | 638 } |
| OLD | NEW |