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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 case SkShader::kMirror_TileMode: | 461 case SkShader::kMirror_TileMode: |
462 choose_tiler_ymode<XMirrorStrategy>(yMode, filterQuality, dimensions
, next, tileStage); | 462 choose_tiler_ymode<XMirrorStrategy>(yMode, filterQuality, dimensions
, next, tileStage); |
463 break; | 463 break; |
464 } | 464 } |
465 | 465 |
466 return tileStage->get(); | 466 return tileStage->get(); |
467 } | 467 } |
468 | 468 |
469 ////////////////////////////////////////////////////////////////////////////////
//////////////////// | 469 ////////////////////////////////////////////////////////////////////////////////
//////////////////// |
470 // Source Sampling Stage | 470 // Source Sampling Stage |
471 template <typename SourceStrategy, typename Next> | 471 template <SkColorType colorType, SkColorProfileType colorProfile, typename Next> |
472 class NearestNeighborSampler final : public SkLinearBitmapPipeline::SampleProces
sorInterface { | 472 class NearestNeighborSampler final : public SkLinearBitmapPipeline::SampleProces
sorInterface { |
473 public: | 473 public: |
474 template <typename... Args> | 474 template <typename... Args> |
475 NearestNeighborSampler(Next* next, Args&&... args) | 475 NearestNeighborSampler(Next* next, Args&&... args) |
476 : fSampler{next, std::forward<Args>(args)...} { } | 476 : fSampler{next, std::forward<Args>(args)...} { } |
477 | 477 |
478 NearestNeighborSampler(Next* next, const NearestNeighborSampler& sampler) | 478 NearestNeighborSampler(Next* next, const NearestNeighborSampler& sampler) |
479 : fSampler{next, sampler.fSampler} { } | 479 : fSampler{next, sampler.fSampler} { } |
480 | 480 |
481 void VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) override { | 481 void VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) override { |
(...skipping 17 matching lines...) Expand all Loading... |
499 | 499 |
500 void VECTORCALL bilerpEdge(Sk4s xs, Sk4s ys) override { | 500 void VECTORCALL bilerpEdge(Sk4s xs, Sk4s ys) override { |
501 SkFAIL("Using nearest neighbor sampler, but calling a bilerpEdge."); | 501 SkFAIL("Using nearest neighbor sampler, but calling a bilerpEdge."); |
502 } | 502 } |
503 | 503 |
504 void bilerpSpan(Span span, SkScalar y) override { | 504 void bilerpSpan(Span span, SkScalar y) override { |
505 SkFAIL("Using nearest neighbor sampler, but calling a bilerpSpan."); | 505 SkFAIL("Using nearest neighbor sampler, but calling a bilerpSpan."); |
506 } | 506 } |
507 | 507 |
508 private: | 508 private: |
509 GeneralSampler<SourceStrategy, Next> fSampler; | 509 GeneralSampler<colorType, colorProfile, Next> fSampler; |
510 }; | 510 }; |
511 | 511 |
512 template <typename SourceStrategy, typename Next> | 512 template <SkColorType colorType, SkColorProfileType colorProfile, typename Next> |
513 class BilerpSampler final : public SkLinearBitmapPipeline::SampleProcessorInterf
ace { | 513 class BilerpSampler final : public SkLinearBitmapPipeline::SampleProcessorInterf
ace { |
514 public: | 514 public: |
515 template <typename... Args> | 515 template <typename... Args> |
516 BilerpSampler(Next* next, Args&&... args) | 516 BilerpSampler(Next* next, Args&&... args) |
517 : fSampler{next, std::forward<Args>(args)...} { } | 517 : fSampler{next, std::forward<Args>(args)...} { } |
518 | 518 |
519 BilerpSampler(Next* next, const BilerpSampler& sampler) | 519 BilerpSampler(Next* next, const BilerpSampler& sampler) |
520 : fSampler{next, sampler.fSampler} { } | 520 : fSampler{next, sampler.fSampler} { } |
521 | 521 |
522 void VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) override { | 522 void VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) override { |
(...skipping 17 matching lines...) Expand all Loading... |
540 | 540 |
541 void VECTORCALL bilerpEdge(Sk4s xs, Sk4s ys) override { | 541 void VECTORCALL bilerpEdge(Sk4s xs, Sk4s ys) override { |
542 fSampler.bilerpEdge(xs, ys); | 542 fSampler.bilerpEdge(xs, ys); |
543 } | 543 } |
544 | 544 |
545 void bilerpSpan(Span span, SkScalar y) override { | 545 void bilerpSpan(Span span, SkScalar y) override { |
546 fSampler.bilerpSpanWithY(span, y); | 546 fSampler.bilerpSpanWithY(span, y); |
547 } | 547 } |
548 | 548 |
549 private: | 549 private: |
550 GeneralSampler<SourceStrategy, Next> fSampler; | 550 GeneralSampler<colorType, colorProfile, Next> fSampler; |
551 }; | 551 }; |
552 | 552 |
553 ////////////////////////////////////////////////////////////////////////////////
//////////////////// | 553 ////////////////////////////////////////////////////////////////////////////////
//////////////////// |
554 // Specialized Samplers | 554 // Specialized Samplers |
555 | 555 |
556 // RGBA8888UnitRepeatSrc - A sampler that takes advantage of the fact the the sr
c and destination | 556 // RGBA8888UnitRepeatSrc - A sampler that takes advantage of the fact the the sr
c and destination |
557 // are the same format and do not need in transformations in pixel space. Theref
ore, there is no | 557 // are the same format and do not need in transformations in pixel space. Theref
ore, there is no |
558 // need to convert them to HiFi pixel format. | 558 // need to convert them to HiFi pixel format. |
559 class RGBA8888UnitRepeatSrc final : public SkLinearBitmapPipeline::SampleProcess
orInterface, | 559 class RGBA8888UnitRepeatSrc final : public SkLinearBitmapPipeline::SampleProcess
orInterface, |
560 public SkLinearBitmapPipeline::DestinationIn
terface { | 560 public SkLinearBitmapPipeline::DestinationIn
terface { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 }; | 701 }; |
702 | 702 |
703 const uint32_t* const fSrc; | 703 const uint32_t* const fSrc; |
704 const int32_t fWidth; | 704 const int32_t fWidth; |
705 uint32_t* fDest; | 705 uint32_t* fDest; |
706 uint32_t* fEnd; | 706 uint32_t* fEnd; |
707 }; | 707 }; |
708 | 708 |
709 using Blender = SkLinearBitmapPipeline::BlendProcessorInterface; | 709 using Blender = SkLinearBitmapPipeline::BlendProcessorInterface; |
710 | 710 |
711 template<template <typename, typename> class Sampler> | 711 template<template <SkColorType, SkColorProfileType, typename> class Sampler> |
712 static SkLinearBitmapPipeline::SampleProcessorInterface* choose_pixel_sampler_ba
se( | 712 static SkLinearBitmapPipeline::SampleProcessorInterface* choose_pixel_sampler_ba
se( |
713 Blender* next, | 713 Blender* next, |
714 const SkPixmap& srcPixmap, | 714 const SkPixmap& srcPixmap, |
715 SkLinearBitmapPipeline::SampleStage* sampleStage) { | 715 SkLinearBitmapPipeline::SampleStage* sampleStage) { |
716 const SkImageInfo& imageInfo = srcPixmap.info(); | 716 const SkImageInfo& imageInfo = srcPixmap.info(); |
717 switch (imageInfo.colorType()) { | 717 switch (imageInfo.colorType()) { |
718 case kRGBA_8888_SkColorType: | 718 case kRGBA_8888_SkColorType: |
719 if (imageInfo.profileType() == kSRGB_SkColorProfileType) { | 719 if (imageInfo.profileType() == kSRGB_SkColorProfileType) { |
720 sampleStage->initStage<Sampler<Pixel8888SRGB, Blender>>(next, sr
cPixmap); | 720 using S = Sampler<kRGBA_8888_SkColorType, kSRGB_SkColorProfileTy
pe, Blender>; |
| 721 sampleStage->initStage<S>(next, srcPixmap); |
721 } else { | 722 } else { |
722 sampleStage->initStage<Sampler<Pixel8888LRGB, Blender>>(next, sr
cPixmap); | 723 using S = Sampler<kRGBA_8888_SkColorType, kLinear_SkColorProfile
Type, Blender>; |
| 724 sampleStage->initStage<S>(next, srcPixmap); |
723 } | 725 } |
724 break; | 726 break; |
725 case kBGRA_8888_SkColorType: | 727 case kBGRA_8888_SkColorType: |
726 if (imageInfo.profileType() == kSRGB_SkColorProfileType) { | 728 if (imageInfo.profileType() == kSRGB_SkColorProfileType) { |
727 sampleStage->initStage<Sampler<Pixel8888SBGR, Blender>>(next, sr
cPixmap); | 729 using S = Sampler<kBGRA_8888_SkColorType, kSRGB_SkColorProfileTy
pe, Blender>; |
| 730 sampleStage->initStage<S>(next, srcPixmap); |
728 } else { | 731 } else { |
729 sampleStage->initStage<Sampler<Pixel8888LBGR, Blender>>(next, sr
cPixmap); | 732 using S = Sampler<kBGRA_8888_SkColorType, kLinear_SkColorProfile
Type, Blender>; |
| 733 sampleStage->initStage<S>(next, srcPixmap); |
730 } | 734 } |
731 break; | 735 break; |
732 case kIndex_8_SkColorType: | 736 case kIndex_8_SkColorType: |
733 if (imageInfo.profileType() == kSRGB_SkColorProfileType) { | 737 if (imageInfo.profileType() == kSRGB_SkColorProfileType) { |
734 sampleStage->initStage<Sampler<PixelIndex8SRGB, Blender>>(next,
srcPixmap); | 738 using S = Sampler<kIndex_8_SkColorType, kSRGB_SkColorProfileType
, Blender>; |
| 739 sampleStage->initStage<S>(next, srcPixmap); |
735 } else { | 740 } else { |
736 sampleStage->initStage<Sampler<PixelIndex8LRGB, Blender>>(next,
srcPixmap); | 741 using S = Sampler<kIndex_8_SkColorType, kLinear_SkColorProfileTy
pe, Blender>; |
| 742 sampleStage->initStage<S>(next, srcPixmap); |
737 } | 743 } |
738 break; | 744 break; |
739 case kRGBA_F16_SkColorType: | 745 case kRGBA_F16_SkColorType: { |
740 sampleStage->initStage<Sampler<PixelHalfLinear, Blender>>(next, srcP
ixmap); | 746 using S = Sampler<kRGBA_F16_SkColorType, kLinear_SkColorProfileT
ype, Blender>; |
| 747 sampleStage->initStage<S>(next, srcPixmap); |
| 748 } |
741 break; | 749 break; |
742 default: | 750 default: |
743 SkFAIL("Not implemented. Unsupported src"); | 751 SkFAIL("Not implemented. Unsupported src"); |
744 break; | 752 break; |
745 } | 753 } |
746 return sampleStage->get(); | 754 return sampleStage->get(); |
747 } | 755 } |
748 | 756 |
749 SkLinearBitmapPipeline::SampleProcessorInterface* choose_pixel_sampler( | 757 SkLinearBitmapPipeline::SampleProcessorInterface* choose_pixel_sampler( |
750 Blender* next, | 758 Blender* next, |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 void SkLinearBitmapPipeline::blitSpan(int x, int y, void* dst, int count) { | 944 void SkLinearBitmapPipeline::blitSpan(int x, int y, void* dst, int count) { |
937 SkASSERT(count > 0); | 945 SkASSERT(count > 0); |
938 fLastStage->setDestination(dst, count); | 946 fLastStage->setDestination(dst, count); |
939 | 947 |
940 // The count and length arguments start out in a precise relation in order t
o keep the | 948 // The count and length arguments start out in a precise relation in order t
o keep the |
941 // math correct through the different stages. Count is the number of pixel t
o produce. | 949 // math correct through the different stages. Count is the number of pixel t
o produce. |
942 // Since the code samples at pixel centers, length is the distance from the
center of the | 950 // Since the code samples at pixel centers, length is the distance from the
center of the |
943 // first pixel to the center of the last pixel. This implies that length is
count-1. | 951 // first pixel to the center of the last pixel. This implies that length is
count-1. |
944 fFirstStage->pointSpan(Span{{x + 0.5f, y + 0.5f}, count - 1.0f, count}); | 952 fFirstStage->pointSpan(Span{{x + 0.5f, y + 0.5f}, count - 1.0f, count}); |
945 } | 953 } |
OLD | NEW |