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 #ifndef SkLinearBitmapPipeline_sampler_DEFINED | 8 #ifndef SkLinearBitmapPipeline_sampler_DEFINED |
9 #define SkLinearBitmapPipeline_sampler_DEFINED | 9 #define SkLinearBitmapPipeline_sampler_DEFINED |
10 | 10 |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 template <SkColorType colorType, SkColorProfileType colorProfile> class PixelGet
ter; | 614 template <SkColorType colorType, SkColorProfileType colorProfile> class PixelGet
ter; |
615 | 615 |
616 template <SkColorProfileType colorProfile> | 616 template <SkColorProfileType colorProfile> |
617 class PixelGetter<kRGBA_8888_SkColorType, colorProfile> { | 617 class PixelGetter<kRGBA_8888_SkColorType, colorProfile> { |
618 public: | 618 public: |
619 PixelGetter(const SkPixmap& srcPixmap) | 619 PixelGetter(const SkPixmap& srcPixmap) |
620 : fSrc{srcPixmap.addr32()} | 620 : fSrc{srcPixmap.addr32()} |
621 , fWidth{srcPixmap.rowBytesAsPixels()} { } | 621 , fWidth{srcPixmap.rowBytesAsPixels()} { } |
622 | 622 |
623 Sk4f getPixelFromRow(const void* row, int index) { | 623 Sk4f getPixelFromRow(const void* row, int index) { |
624 const uint32_t* src = static_cast<const uint32_t*>(row); | 624 const uint32_t* src = static_cast<const uint32_t*>(row) + index; |
625 return colorProfile == kSRGB_SkColorProfileType | 625 return colorProfile == kSRGB_SkColorProfileType |
626 ? Sk4f_fromS32(*src) | 626 ? Sk4f_fromS32(*src) |
627 : Sk4f_fromL32(*src); | 627 : Sk4f_fromL32(*src); |
628 } | 628 } |
629 | 629 |
630 Sk4f getPixelAt(int index) { | 630 Sk4f getPixelAt(int index) { |
631 return this->getPixelFromRow(fSrc, index); | 631 return this->getPixelFromRow(fSrc, index); |
632 } | 632 } |
633 | 633 |
634 const void* row(int y) { return fSrc + y * fWidth; } | 634 const void* row(int y) { return fSrc + y * fWidth; } |
635 | 635 |
636 private: | 636 private: |
637 const uint32_t* const fSrc; | 637 const uint32_t* const fSrc; |
638 const int fWidth; | 638 const int fWidth; |
639 }; | 639 }; |
640 | 640 |
641 using Pixel8888SRGB = PixelAccessor<PixelGetter<kRGBA_8888_SkColorType, kSRGB_Sk
ColorProfileType>>; | 641 using Pixel8888SRGB = PixelAccessor<PixelGetter<kRGBA_8888_SkColorType, kSRGB_Sk
ColorProfileType>>; |
642 using Pixel8888LRGB = PixelAccessor<PixelGetter<kRGBA_8888_SkColorType, kLinear_
SkColorProfileType>>; | 642 using Pixel8888LRGB = PixelAccessor<PixelGetter<kRGBA_8888_SkColorType, kLinear_
SkColorProfileType>>; |
643 | 643 |
644 template <SkColorProfileType colorProfile> | 644 template <SkColorProfileType colorProfile> |
645 class PixelGetter<kBGRA_8888_SkColorType, colorProfile> { | 645 class PixelGetter<kBGRA_8888_SkColorType, colorProfile> { |
646 public: | 646 public: |
647 PixelGetter(const SkPixmap& srcPixmap) | 647 PixelGetter(const SkPixmap& srcPixmap) |
648 : fSrc{srcPixmap.addr32()} | 648 : fSrc{srcPixmap.addr32()} |
649 , fWidth{srcPixmap.rowBytesAsPixels()} { } | 649 , fWidth{srcPixmap.rowBytesAsPixels()} { } |
650 | 650 |
651 Sk4f getPixelFromRow(const void* row, int index) { | 651 Sk4f getPixelFromRow(const void* row, int index) { |
652 const uint32_t* src = static_cast<const uint32_t*>(row); | 652 const uint32_t* src = static_cast<const uint32_t*>(row) + index; |
653 Sk4f pixel = colorProfile == kSRGB_SkColorProfileType | 653 Sk4f pixel = colorProfile == kSRGB_SkColorProfileType |
654 ? Sk4f_fromS32(*src) | 654 ? Sk4f_fromS32(*src) |
655 : Sk4f_fromL32(*src); | 655 : Sk4f_fromL32(*src); |
656 return SkNx_shuffle<2, 1, 0, 3>(pixel); | 656 return SkNx_shuffle<2, 1, 0, 3>(pixel); |
657 } | 657 } |
658 | 658 |
659 Sk4f getPixelAt(int index) { | 659 Sk4f getPixelAt(int index) { |
660 return this->getPixelFromRow(fSrc, index); | 660 return this->getPixelFromRow(fSrc, index); |
661 } | 661 } |
662 | 662 |
(...skipping 25 matching lines...) Expand all Loading... |
688 PixelGetter(const PixelGetter& strategy) | 688 PixelGetter(const PixelGetter& strategy) |
689 : fSrc{strategy.fSrc}, fWidth{strategy.fWidth} { | 689 : fSrc{strategy.fSrc}, fWidth{strategy.fWidth} { |
690 fColorTable = (Sk4f*)SkAlign16((intptr_t)fColorTableStorage.get()); | 690 fColorTable = (Sk4f*)SkAlign16((intptr_t)fColorTableStorage.get()); |
691 // TODO: figure out the count. | 691 // TODO: figure out the count. |
692 for (int i = 0; i < 256; i++) { | 692 for (int i = 0; i < 256; i++) { |
693 fColorTable[i] = strategy.fColorTable[i]; | 693 fColorTable[i] = strategy.fColorTable[i]; |
694 } | 694 } |
695 } | 695 } |
696 | 696 |
697 Sk4f getPixelFromRow(const void* row, int index) { | 697 Sk4f getPixelFromRow(const void* row, int index) { |
698 const uint8_t* src = static_cast<const uint8_t*>(row); | 698 const uint8_t* src = static_cast<const uint8_t*>(row) + index; |
699 Sk4f pixel = fColorTable[*src]; | 699 Sk4f pixel = fColorTable[*src]; |
700 return pixel; | 700 return pixel; |
701 } | 701 } |
702 | 702 |
703 Sk4f getPixelAt(int index) { | 703 Sk4f getPixelAt(int index) { |
704 return this->getPixelFromRow(fSrc, index); | 704 return this->getPixelFromRow(fSrc, index); |
705 } | 705 } |
706 | 706 |
707 const void* row(int y) { return fSrc + y * fWidth; } | 707 const void* row(int y) { return fSrc + y * fWidth; } |
708 | 708 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 private: | 753 private: |
754 const uint64_t* const fSrc; | 754 const uint64_t* const fSrc; |
755 const int fWidth; | 755 const int fWidth; |
756 }; | 756 }; |
757 | 757 |
758 using PixelHalfLinear = PixelAccessor<PixelGetter<kRGBA_F16_SkColorType, kLinear
_SkColorProfileType>>; | 758 using PixelHalfLinear = PixelAccessor<PixelGetter<kRGBA_F16_SkColorType, kLinear
_SkColorProfileType>>; |
759 | 759 |
760 } // namespace | 760 } // namespace |
761 | 761 |
762 #endif // SkLinearBitmapPipeline_sampler_DEFINED | 762 #endif // SkLinearBitmapPipeline_sampler_DEFINED |
OLD | NEW |