OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
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 "Sk4fLinearGradient.h" | 8 #include "Sk4fLinearGradient.h" |
9 #include "SkUtils.h" | 9 #include "SkUtils.h" |
10 #include "SkXfermode.h" | 10 #include "SkXfermode.h" |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 } | 435 } |
436 } else { | 436 } else { |
437 for (int i = 0; i < count; ++i) { | 437 for (int i = 0; i < count; ++i) { |
438 fDstToPosProc(fDstToPos, sx, sy, &pt); | 438 fDstToPosProc(fDstToPos, sx, sy, &pt); |
439 ts[i] = pt.x(); | 439 ts[i] = pt.x(); |
440 sx += SK_Scalar1; | 440 sx += SK_Scalar1; |
441 } | 441 } |
442 } | 442 } |
443 } | 443 } |
444 | 444 |
445 SkShader::Context::BlitProc SkLinearGradient:: | 445 bool SkLinearGradient::LinearGradient4fContext::onChooseBlitProcs(const SkImageI
nfo& info, |
446 LinearGradient4fContext::onChooseBlitProc(const SkImageInfo& info, BlitState* st
ate) { | 446 BlitState* sta
te) { |
447 SkXfermode::Mode mode; | 447 SkXfermode::Mode mode; |
448 if (!SkXfermode::AsMode(state->fXfer, &mode)) { | 448 if (!SkXfermode::AsMode(state->fXfer, &mode)) { |
449 return nullptr; | 449 return false; |
450 } | 450 } |
451 | 451 |
452 const SkGradientShaderBase& shader = static_cast<const SkGradientShaderBase&
>(fShader); | 452 const SkGradientShaderBase& shader = static_cast<const SkGradientShaderBase&
>(fShader); |
453 if (mode != SkXfermode::kSrc_Mode && | 453 if (mode != SkXfermode::kSrc_Mode && |
454 !(mode == SkXfermode::kSrcOver_Mode && shader.colorsAreOpaque())) { | 454 !(mode == SkXfermode::kSrcOver_Mode && shader.colorsAreOpaque())) { |
455 return nullptr; | 455 return false; |
456 } | 456 } |
457 | 457 |
458 switch (info.colorType()) { | 458 switch (info.colorType()) { |
459 case kN32_SkColorType: | 459 case kN32_SkColorType: |
460 return D32_BlitProc; | 460 state->fBlitBW = D32_BlitBW; |
| 461 return true; |
461 case kRGBA_F16_SkColorType: | 462 case kRGBA_F16_SkColorType: |
462 return D64_BlitProc; | 463 state->fBlitBW = D64_BlitBW; |
| 464 return true; |
463 default: | 465 default: |
464 return nullptr; | 466 return false; |
465 } | 467 } |
466 } | 468 } |
467 | 469 |
468 void SkLinearGradient:: | 470 void SkLinearGradient:: |
469 LinearGradient4fContext::D32_BlitProc(BlitState* state, int x, int y, const SkPi
xmap& dst, | 471 LinearGradient4fContext::D32_BlitBW(BlitState* state, int x, int y, const SkPixm
ap& dst, |
470 int count, const SkAlpha aa[]) { | 472 int count) { |
471 // FIXME: ignoring coverage for now | 473 // FIXME: ignoring coverage for now |
472 const LinearGradient4fContext* ctx = | 474 const LinearGradient4fContext* ctx = |
473 static_cast<const LinearGradient4fContext*>(state->fCtx); | 475 static_cast<const LinearGradient4fContext*>(state->fCtx); |
474 | 476 |
475 if (dst.info().isLinear()) { | 477 if (dst.info().isLinear()) { |
476 if (ctx->fColorsArePremul) { | 478 if (ctx->fColorsArePremul) { |
477 ctx->shadePremulSpan<SkPMColor, kLinear_SkColorProfileType, ApplyPre
mul::False>( | 479 ctx->shadePremulSpan<SkPMColor, kLinear_SkColorProfileType, ApplyPre
mul::False>( |
478 x, y, dst.writable_addr32(x, y), count); | 480 x, y, dst.writable_addr32(x, y), count); |
479 } else { | 481 } else { |
480 ctx->shadePremulSpan<SkPMColor, kLinear_SkColorProfileType, ApplyPre
mul::True>( | 482 ctx->shadePremulSpan<SkPMColor, kLinear_SkColorProfileType, ApplyPre
mul::True>( |
481 x, y, dst.writable_addr32(x, y), count); | 483 x, y, dst.writable_addr32(x, y), count); |
482 } | 484 } |
483 } else { | 485 } else { |
484 if (ctx->fColorsArePremul) { | 486 if (ctx->fColorsArePremul) { |
485 ctx->shadePremulSpan<SkPMColor, kSRGB_SkColorProfileType, ApplyPremu
l::False>( | 487 ctx->shadePremulSpan<SkPMColor, kSRGB_SkColorProfileType, ApplyPremu
l::False>( |
486 x, y, dst.writable_addr32(x, y), count); | 488 x, y, dst.writable_addr32(x, y), count); |
487 } else { | 489 } else { |
488 ctx->shadePremulSpan<SkPMColor, kSRGB_SkColorProfileType, ApplyPremu
l::True>( | 490 ctx->shadePremulSpan<SkPMColor, kSRGB_SkColorProfileType, ApplyPremu
l::True>( |
489 x, y, dst.writable_addr32(x, y), count); | 491 x, y, dst.writable_addr32(x, y), count); |
490 } | 492 } |
491 } | 493 } |
492 } | 494 } |
493 | 495 |
494 void SkLinearGradient:: | 496 void SkLinearGradient:: |
495 LinearGradient4fContext::D64_BlitProc(BlitState* state, int x, int y, const SkPi
xmap& dst, | 497 LinearGradient4fContext::D64_BlitBW(BlitState* state, int x, int y, const SkPixm
ap& dst, |
496 int count, const SkAlpha aa[]) { | 498 int count) { |
497 // FIXME: ignoring coverage for now | 499 // FIXME: ignoring coverage for now |
498 const LinearGradient4fContext* ctx = | 500 const LinearGradient4fContext* ctx = |
499 static_cast<const LinearGradient4fContext*>(state->fCtx); | 501 static_cast<const LinearGradient4fContext*>(state->fCtx); |
500 | 502 |
501 if (ctx->fColorsArePremul) { | 503 if (ctx->fColorsArePremul) { |
502 ctx->shadePremulSpan<uint64_t, kLinear_SkColorProfileType, ApplyPremul::
False>( | 504 ctx->shadePremulSpan<uint64_t, kLinear_SkColorProfileType, ApplyPremul::
False>( |
503 x, y, dst.writable_addr64(x, y), count); | 505 x, y, dst.writable_addr64(x, y), count); |
504 } else { | 506 } else { |
505 ctx->shadePremulSpan<uint64_t, kLinear_SkColorProfileType, ApplyPremul::
True>( | 507 ctx->shadePremulSpan<uint64_t, kLinear_SkColorProfileType, ApplyPremul::
True>( |
506 x, y, dst.writable_addr64(x, y), count); | 508 x, y, dst.writable_addr64(x, y), count); |
507 } | 509 } |
508 } | 510 } |
OLD | NEW |