| 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 "SkLinearBitmapPipeline.h" | 8 #include "SkLinearBitmapPipeline.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 }; | 560 }; |
| 561 | 561 |
| 562 const uint32_t* const fSrc; | 562 const uint32_t* const fSrc; |
| 563 const int32_t fWidth; | 563 const int32_t fWidth; |
| 564 uint32_t* fDest; | 564 uint32_t* fDest; |
| 565 uint32_t* fEnd; | 565 uint32_t* fEnd; |
| 566 }; | 566 }; |
| 567 | 567 |
| 568 using Blender = SkLinearBitmapPipeline::BlendProcessorInterface; | 568 using Blender = SkLinearBitmapPipeline::BlendProcessorInterface; |
| 569 | 569 |
| 570 template <SkColorType colorType, template <SkColorType, SkColorProfileType, type
name> class Sampler> | 570 template <SkColorType colorType, template <SkColorType, SkGammaType, typename> c
lass Sampler> |
| 571 static void choose_specific_sampler( | 571 static void choose_specific_sampler( |
| 572 Blender* next, | 572 Blender* next, |
| 573 const SkPixmap& srcPixmap, | 573 const SkPixmap& srcPixmap, |
| 574 SkLinearBitmapPipeline::SampleStage* sampleStage) | 574 SkLinearBitmapPipeline::SampleStage* sampleStage) |
| 575 { | 575 { |
| 576 if (srcPixmap.info().profileType() == kSRGB_SkColorProfileType) { | 576 if (srcPixmap.info().gammaCloseToSRGB()) { |
| 577 using S = Sampler<colorType, kSRGB_SkColorProfileType, Blender>; | 577 using S = Sampler<colorType, kSRGB_SkGammaType, Blender>; |
| 578 sampleStage->initStage<S>(next, srcPixmap); | 578 sampleStage->initStage<S>(next, srcPixmap); |
| 579 } else { | 579 } else { |
| 580 using S = Sampler<colorType, kLinear_SkColorProfileType, Blender>; | 580 using S = Sampler<colorType, kLinear_SkGammaType, Blender>; |
| 581 sampleStage->initStage<S>(next, srcPixmap); | 581 sampleStage->initStage<S>(next, srcPixmap); |
| 582 } | 582 } |
| 583 } | 583 } |
| 584 | 584 |
| 585 template<template <SkColorType, SkColorProfileType, typename> class Sampler> | 585 template<template <SkColorType, SkGammaType, typename> class Sampler> |
| 586 static SkLinearBitmapPipeline::SampleProcessorInterface* choose_pixel_sampler_ba
se( | 586 static SkLinearBitmapPipeline::SampleProcessorInterface* choose_pixel_sampler_ba
se( |
| 587 Blender* next, | 587 Blender* next, |
| 588 const SkPixmap& srcPixmap, | 588 const SkPixmap& srcPixmap, |
| 589 const SkColor A8TintColor, | 589 const SkColor A8TintColor, |
| 590 SkLinearBitmapPipeline::SampleStage* sampleStage) | 590 SkLinearBitmapPipeline::SampleStage* sampleStage) |
| 591 { | 591 { |
| 592 const SkImageInfo& imageInfo = srcPixmap.info(); | 592 const SkImageInfo& imageInfo = srcPixmap.info(); |
| 593 switch (imageInfo.colorType()) { | 593 switch (imageInfo.colorType()) { |
| 594 case kAlpha_8_SkColorType: { | 594 case kAlpha_8_SkColorType: { |
| 595 using S = Sampler<kAlpha_8_SkColorType, kLinear_SkColorProfileTy
pe, Blender>; | 595 using S = Sampler<kAlpha_8_SkColorType, kLinear_SkGammaType, Ble
nder>; |
| 596 sampleStage->initStage<S>(next, srcPixmap, A8TintColor); | 596 sampleStage->initStage<S>(next, srcPixmap, A8TintColor); |
| 597 } | 597 } |
| 598 break; | 598 break; |
| 599 case kARGB_4444_SkColorType: | 599 case kARGB_4444_SkColorType: |
| 600 choose_specific_sampler<kARGB_4444_SkColorType, Sampler>(next, srcPi
xmap, sampleStage); | 600 choose_specific_sampler<kARGB_4444_SkColorType, Sampler>(next, srcPi
xmap, sampleStage); |
| 601 break; | 601 break; |
| 602 case kRGB_565_SkColorType: | 602 case kRGB_565_SkColorType: |
| 603 choose_specific_sampler<kRGB_565_SkColorType, Sampler>(next, srcPixm
ap, sampleStage); | 603 choose_specific_sampler<kRGB_565_SkColorType, Sampler>(next, srcPixm
ap, sampleStage); |
| 604 break; | 604 break; |
| 605 case kRGBA_8888_SkColorType: | 605 case kRGBA_8888_SkColorType: |
| 606 choose_specific_sampler<kRGBA_8888_SkColorType, Sampler>(next, srcPi
xmap, sampleStage); | 606 choose_specific_sampler<kRGBA_8888_SkColorType, Sampler>(next, srcPi
xmap, sampleStage); |
| 607 break; | 607 break; |
| 608 case kBGRA_8888_SkColorType: | 608 case kBGRA_8888_SkColorType: |
| 609 choose_specific_sampler<kBGRA_8888_SkColorType, Sampler>(next, srcPi
xmap, sampleStage); | 609 choose_specific_sampler<kBGRA_8888_SkColorType, Sampler>(next, srcPi
xmap, sampleStage); |
| 610 break; | 610 break; |
| 611 case kIndex_8_SkColorType: | 611 case kIndex_8_SkColorType: |
| 612 choose_specific_sampler<kIndex_8_SkColorType, Sampler>(next, srcPixm
ap, sampleStage); | 612 choose_specific_sampler<kIndex_8_SkColorType, Sampler>(next, srcPixm
ap, sampleStage); |
| 613 break; | 613 break; |
| 614 case kGray_8_SkColorType: | 614 case kGray_8_SkColorType: |
| 615 choose_specific_sampler<kGray_8_SkColorType, Sampler>(next, srcPixma
p, sampleStage); | 615 choose_specific_sampler<kGray_8_SkColorType, Sampler>(next, srcPixma
p, sampleStage); |
| 616 break; | 616 break; |
| 617 case kRGBA_F16_SkColorType: { | 617 case kRGBA_F16_SkColorType: { |
| 618 using S = Sampler<kRGBA_F16_SkColorType, kLinear_SkColorProfileT
ype, Blender>; | 618 using S = Sampler<kRGBA_F16_SkColorType, kLinear_SkGammaType, Bl
ender>; |
| 619 sampleStage->initStage<S>(next, srcPixmap); | 619 sampleStage->initStage<S>(next, srcPixmap); |
| 620 } | 620 } |
| 621 break; | 621 break; |
| 622 default: | 622 default: |
| 623 SkFAIL("Not implemented. Unsupported src"); | 623 SkFAIL("Not implemented. Unsupported src"); |
| 624 break; | 624 break; |
| 625 } | 625 } |
| 626 return sampleStage->get(); | 626 return sampleStage->get(); |
| 627 } | 627 } |
| 628 | 628 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 && srcPixmap.info().alphaType() == kOpaque_SkAlphaType) { | 765 && srcPixmap.info().alphaType() == kOpaque_SkAlphaType) { |
| 766 xferMode = SkXfermode::kSrc_Mode; | 766 xferMode = SkXfermode::kSrc_Mode; |
| 767 } | 767 } |
| 768 | 768 |
| 769 if (matrixMask & ~SkMatrix::kTranslate_Mask ) { return false; } | 769 if (matrixMask & ~SkMatrix::kTranslate_Mask ) { return false; } |
| 770 if (filterQuality != SkFilterQuality::kNone_SkFilterQuality) { return false;
} | 770 if (filterQuality != SkFilterQuality::kNone_SkFilterQuality) { return false;
} |
| 771 if (finalAlpha != 1.0f) { return false; } | 771 if (finalAlpha != 1.0f) { return false; } |
| 772 if (srcPixmap.info().colorType() != kRGBA_8888_SkColorType | 772 if (srcPixmap.info().colorType() != kRGBA_8888_SkColorType |
| 773 || dstInfo.colorType() != kRGBA_8888_SkColorType) { return false; } | 773 || dstInfo.colorType() != kRGBA_8888_SkColorType) { return false; } |
| 774 | 774 |
| 775 if (srcPixmap.info().profileType() != kSRGB_SkColorProfileType | 775 if (!srcPixmap.info().gammaCloseToSRGB() || !dstInfo.gammaCloseToSRGB()) { |
| 776 || dstInfo.profileType() != kSRGB_SkColorProfileType) { return false; } | 776 return false; |
| 777 } |
| 777 | 778 |
| 778 if (xferMode != SkXfermode::kSrc_Mode && xferMode != SkXfermode::kSrcOver_Mo
de) { | 779 if (xferMode != SkXfermode::kSrc_Mode && xferMode != SkXfermode::kSrcOver_Mo
de) { |
| 779 return false; | 780 return false; |
| 780 } | 781 } |
| 781 | 782 |
| 782 pipelineStorage->init(pipeline, srcPixmap, xferMode, dstInfo); | 783 pipelineStorage->init(pipeline, srcPixmap, xferMode, dstInfo); |
| 783 | 784 |
| 784 return true; | 785 return true; |
| 785 } | 786 } |
| 786 | 787 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 void SkLinearBitmapPipeline::blitSpan(int x, int y, void* dst, int count) { | 821 void SkLinearBitmapPipeline::blitSpan(int x, int y, void* dst, int count) { |
| 821 SkASSERT(count > 0); | 822 SkASSERT(count > 0); |
| 822 fLastStage->setDestination(dst, count); | 823 fLastStage->setDestination(dst, count); |
| 823 | 824 |
| 824 // The count and length arguments start out in a precise relation in order t
o keep the | 825 // The count and length arguments start out in a precise relation in order t
o keep the |
| 825 // math correct through the different stages. Count is the number of pixel t
o produce. | 826 // math correct through the different stages. Count is the number of pixel t
o produce. |
| 826 // Since the code samples at pixel centers, length is the distance from the
center of the | 827 // Since the code samples at pixel centers, length is the distance from the
center of the |
| 827 // first pixel to the center of the last pixel. This implies that length is
count-1. | 828 // first pixel to the center of the last pixel. This implies that length is
count-1. |
| 828 fFirstStage->pointSpan(Span{{x + 0.5f, y + 0.5f}, count - 1.0f, count}); | 829 fFirstStage->pointSpan(Span{{x + 0.5f, y + 0.5f}, count - 1.0f, count}); |
| 829 } | 830 } |
| OLD | NEW |