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