| 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 "SkPM4f.h" | 10 #include "SkPM4f.h" |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 } | 542 } |
| 543 | 543 |
| 544 void bilerpSpan(Span span, SkScalar y) override { | 544 void bilerpSpan(Span span, SkScalar y) override { |
| 545 fSampler.bilerpSpanWithY(span, y); | 545 fSampler.bilerpSpanWithY(span, y); |
| 546 } | 546 } |
| 547 | 547 |
| 548 private: | 548 private: |
| 549 GeneralSampler<SourceStrategy, Next> fSampler; | 549 GeneralSampler<SourceStrategy, Next> fSampler; |
| 550 }; | 550 }; |
| 551 | 551 |
| 552 ////////////////////////////////////////////////////////////////////////////////
//////////////////// |
| 553 // Specialized Samplers |
| 554 |
| 552 // RGBA8888UnitRepeatSrc - A sampler that takes advantage of the fact the the sr
c and destination | 555 // RGBA8888UnitRepeatSrc - A sampler that takes advantage of the fact the the sr
c and destination |
| 553 // are the same format and do not need in transformations in pixel space. Theref
ore, there is no | 556 // are the same format and do not need in transformations in pixel space. Theref
ore, there is no |
| 554 // need to convert them to HiFi pixel format. | 557 // need to convert them to HiFi pixel format. |
| 555 class RGBA8888UnitRepeat final : public SkLinearBitmapPipeline::SampleProcessorI
nterface, | 558 class RGBA8888UnitRepeat final : public SkLinearBitmapPipeline::SampleProcessorI
nterface, |
| 556 public SkLinearBitmapPipeline::DestinationInter
face { | 559 public SkLinearBitmapPipeline::DestinationInter
face { |
| 557 public: | 560 public: |
| 558 RGBA8888UnitRepeat(const uint32_t* src, int32_t width) | 561 RGBA8888UnitRepeat(const uint32_t* src, int32_t width) |
| 559 : fSrc{src}, fWidth{width} { } | 562 : fSrc{src}, fWidth{width} { } |
| 560 | 563 |
| 561 void VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) override { | 564 void VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) override { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 sampleStage->initStage<Sampler<Pixel8888LBGR, Blender>>(next, sr
cPixmap); | 647 sampleStage->initStage<Sampler<Pixel8888LBGR, Blender>>(next, sr
cPixmap); |
| 645 } | 648 } |
| 646 break; | 649 break; |
| 647 case kIndex_8_SkColorType: | 650 case kIndex_8_SkColorType: |
| 648 if (imageInfo.profileType() == kSRGB_SkColorProfileType) { | 651 if (imageInfo.profileType() == kSRGB_SkColorProfileType) { |
| 649 sampleStage->initStage<Sampler<PixelIndex8SRGB, Blender>>(next,
srcPixmap); | 652 sampleStage->initStage<Sampler<PixelIndex8SRGB, Blender>>(next,
srcPixmap); |
| 650 } else { | 653 } else { |
| 651 sampleStage->initStage<Sampler<PixelIndex8LRGB, Blender>>(next,
srcPixmap); | 654 sampleStage->initStage<Sampler<PixelIndex8LRGB, Blender>>(next,
srcPixmap); |
| 652 } | 655 } |
| 653 break; | 656 break; |
| 657 case kRGBA_F16_SkColorType: |
| 658 sampleStage->initStage<Sampler<PixelHalfLinear, Blender>>(next, srcP
ixmap); |
| 659 break; |
| 654 default: | 660 default: |
| 655 SkFAIL("Not implemented. Unsupported src"); | 661 SkFAIL("Not implemented. Unsupported src"); |
| 656 break; | 662 break; |
| 657 } | 663 } |
| 658 return sampleStage->get(); | 664 return sampleStage->get(); |
| 659 } | 665 } |
| 660 | 666 |
| 661 SkLinearBitmapPipeline::SampleProcessorInterface* choose_pixel_sampler( | 667 SkLinearBitmapPipeline::SampleProcessorInterface* choose_pixel_sampler( |
| 662 Blender* next, | 668 Blender* next, |
| 663 SkFilterQuality filterQuality, | 669 SkFilterQuality filterQuality, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 static Sk4f VECTORCALL Premultiply(Sk4f pixel) { | 717 static Sk4f VECTORCALL Premultiply(Sk4f pixel) { |
| 712 float alpha = pixel[3]; | 718 float alpha = pixel[3]; |
| 713 return pixel * Sk4f{alpha, alpha, alpha, 1.0f}; | 719 return pixel * Sk4f{alpha, alpha, alpha, 1.0f}; |
| 714 } | 720 } |
| 715 | 721 |
| 716 SkPM4f* fDst; | 722 SkPM4f* fDst; |
| 717 SkPM4f* fEnd; | 723 SkPM4f* fEnd; |
| 718 Sk4f fPostAlpha; | 724 Sk4f fPostAlpha; |
| 719 }; | 725 }; |
| 720 | 726 |
| 721 static SkLinearBitmapPipeline::BlendProcessorInterface* choose_blender( | 727 static SkLinearBitmapPipeline::BlendProcessorInterface* choose_blender_for_shadi
ng( |
| 722 SkAlphaType alphaType, | 728 SkAlphaType alphaType, |
| 723 float postAlpha, | 729 float postAlpha, |
| 724 SkLinearBitmapPipeline::BlenderStage* blenderStage) { | 730 SkLinearBitmapPipeline::BlenderStage* blenderStage) { |
| 725 if (alphaType == kUnpremul_SkAlphaType) { | 731 if (alphaType == kUnpremul_SkAlphaType) { |
| 726 blenderStage->initSink<SrcFPPixel<kUnpremul_SkAlphaType>>(postAlpha); | 732 blenderStage->initSink<SrcFPPixel<kUnpremul_SkAlphaType>>(postAlpha); |
| 727 } else { | 733 } else { |
| 728 // kOpaque_SkAlphaType is treated the same as kPremul_SkAlphaType | 734 // kOpaque_SkAlphaType is treated the same as kPremul_SkAlphaType |
| 729 blenderStage->initSink<SrcFPPixel<kPremul_SkAlphaType>>(postAlpha); | 735 blenderStage->initSink<SrcFPPixel<kPremul_SkAlphaType>>(postAlpha); |
| 730 } | 736 } |
| 731 return blenderStage->get(); | 737 return blenderStage->get(); |
| 732 } | 738 } |
| 739 |
| 733 } // namespace | 740 } // namespace |
| 734 | 741 |
| 735 ////////////////////////////////////////////////////////////////////////////////
//////////////////// | 742 ////////////////////////////////////////////////////////////////////////////////
//////////////////// |
| 736 // SkLinearBitmapPipeline | 743 // SkLinearBitmapPipeline |
| 737 SkLinearBitmapPipeline::~SkLinearBitmapPipeline() {} | 744 SkLinearBitmapPipeline::~SkLinearBitmapPipeline() {} |
| 738 | 745 |
| 739 SkLinearBitmapPipeline::SkLinearBitmapPipeline( | 746 SkLinearBitmapPipeline::SkLinearBitmapPipeline( |
| 740 const SkMatrix& inverse, | 747 const SkMatrix& inverse, |
| 741 SkFilterQuality filterQuality, | 748 SkFilterQuality filterQuality, |
| 742 SkShader::TileMode xTile, SkShader::TileMode yTile, | 749 SkShader::TileMode xTile, SkShader::TileMode yTile, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 761 SkScalar dx = adjustedInverse.getScaleX(); | 768 SkScalar dx = adjustedInverse.getScaleX(); |
| 762 | 769 |
| 763 // If it is an index 8 color type, the sampler converts to unpremul for bett
er fidelity. | 770 // If it is an index 8 color type, the sampler converts to unpremul for bett
er fidelity. |
| 764 SkAlphaType alphaType = srcImageInfo.alphaType(); | 771 SkAlphaType alphaType = srcImageInfo.alphaType(); |
| 765 if (srcPixmap.colorType() == kIndex_8_SkColorType) { | 772 if (srcPixmap.colorType() == kIndex_8_SkColorType) { |
| 766 alphaType = kUnpremul_SkAlphaType; | 773 alphaType = kUnpremul_SkAlphaType; |
| 767 } | 774 } |
| 768 | 775 |
| 769 // As the stages are built, the chooser function may skip a stage. For examp
le, with the | 776 // As the stages are built, the chooser function may skip a stage. For examp
le, with the |
| 770 // identity matrix, the matrix stage is skipped, and the tilerStage is the f
irst stage. | 777 // identity matrix, the matrix stage is skipped, and the tilerStage is the f
irst stage. |
| 771 auto blenderStage = choose_blender(alphaType, postAlpha, &fBlenderStage); | 778 auto blenderStage = choose_blender_for_shading(alphaType, postAlpha, &fBlend
erStage); |
| 772 auto samplerStage = choose_pixel_sampler(blenderStage, filterQuality, srcPix
map, &fSampleStage); | 779 auto samplerStage = choose_pixel_sampler(blenderStage, filterQuality, srcPix
map, &fSampleStage); |
| 773 auto tilerStage = choose_tiler(samplerStage, dimensions, xTile, yTile, | 780 auto tilerStage = choose_tiler(samplerStage, dimensions, xTile, yTile, |
| 774 filterQuality, dx, &fTileStage); | 781 filterQuality, dx, &fTileStage); |
| 775 fFirstStage = choose_matrix(tilerStage, adjustedInverse, &fMatrixStage
); | 782 fFirstStage = choose_matrix(tilerStage, adjustedInverse, &fMatrixStage
); |
| 776 fLastStage = blenderStage; | 783 fLastStage = blenderStage; |
| 777 } | 784 } |
| 778 | 785 |
| 779 bool SkLinearBitmapPipeline::ClonePipelineForBlitting( | 786 bool SkLinearBitmapPipeline::ClonePipelineForBlitting( |
| 780 void* blitterStorage, | 787 void* blitterStorage, |
| 781 const SkLinearBitmapPipeline& pipeline, | 788 const SkLinearBitmapPipeline& pipeline, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 void SkLinearBitmapPipeline::blitSpan(int x, int y, void* dst, int count) { | 847 void SkLinearBitmapPipeline::blitSpan(int x, int y, void* dst, int count) { |
| 841 SkASSERT(count > 0); | 848 SkASSERT(count > 0); |
| 842 fLastStage->setDestination(dst, count); | 849 fLastStage->setDestination(dst, count); |
| 843 | 850 |
| 844 // The count and length arguments start out in a precise relation in order t
o keep the | 851 // The count and length arguments start out in a precise relation in order t
o keep the |
| 845 // math correct through the different stages. Count is the number of pixel t
o produce. | 852 // math correct through the different stages. Count is the number of pixel t
o produce. |
| 846 // Since the code samples at pixel centers, length is the distance from the
center of the | 853 // Since the code samples at pixel centers, length is the distance from the
center of the |
| 847 // first pixel to the center of the last pixel. This implies that length is
count-1. | 854 // first pixel to the center of the last pixel. This implies that length is
count-1. |
| 848 fFirstStage->pointSpan(Span{{x + 0.5f, y + 0.5f}, count - 1.0f, count}); | 855 fFirstStage->pointSpan(Span{{x + 0.5f, y + 0.5f}, count - 1.0f, count}); |
| 849 } | 856 } |
| OLD | NEW |