Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Side by Side Diff: src/core/SkBlitter.cpp

Issue 198193005: Work (in progress) to make SkShader immutable. (Closed) Base URL: https://skia.googlesource.com/skia.git@shaderGenerator
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkBlitter.h" 10 #include "SkBlitter.h"
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 } 557 }
558 } 558 }
559 return blitter; 559 return blitter;
560 } 560 }
561 561
562 /////////////////////////////////////////////////////////////////////////////// 562 ///////////////////////////////////////////////////////////////////////////////
563 563
564 #include "SkColorShader.h" 564 #include "SkColorShader.h"
565 #include "SkColorPriv.h" 565 #include "SkColorPriv.h"
566 566
567 class Sk3DShader : public SkShader { 567 class Sk3DShader : public SkShaderGenerator {
568 public: 568 public:
569 Sk3DShader(SkShader* proxy) : fProxy(proxy) { 569 Sk3DShader(SkShader* proxy) : fProxy(proxy) {
570 SkSafeRef(proxy); 570 SkSafeRef(proxy);
571 fMask = NULL;
572 } 571 }
573 572
574 virtual ~Sk3DShader() { 573 virtual ~Sk3DShader() {
575 SkSafeUnref(fProxy); 574 SkSafeUnref(fProxy);
576 } 575 }
577 576
578 void setMask(const SkMask* mask) { fMask = mask; } 577 virtual bool validContext(const SkBitmap& device, const SkPaint& paint,
579 578 const SkMatrix& matrix) const SK_OVERRIDE
580 virtual bool setContext(const SkBitmap& device, const SkPaint& paint, 579 {
581 const SkMatrix& matrix) SK_OVERRIDE { 580 if (!this->INHERITED::validateContext(device, paint, matrix)) {
582 if (!this->INHERITED::setContext(device, paint, matrix)) {
583 return false; 581 return false;
584 } 582 }
585 if (fProxy) { 583 if (fProxy) {
586 if (!fProxy->setContext(device, paint, matrix)) { 584 return fProxy->validateContext(device, paint, matrix);
587 // must keep our set/end context calls balanced
588 this->INHERITED::endContext();
589 return false;
590 }
591 } else {
592 fPMColor = SkPreMultiplyColor(paint.getColor());
593 } 585 }
594 return true; 586 return true;
595 } 587 }
596 588
597 virtual void endContext() SK_OVERRIDE { 589 virtual size_t shaderImplSize() const SK_OVERRIDE {
590 size_t size = sizeof(Sk3DShaderImpl);
598 if (fProxy) { 591 if (fProxy) {
599 fProxy->endContext(); 592 size += fProxy->shaderImplSize();
600 } 593 }
601 this->INHERITED::endContext(); 594 return size;
602 } 595 }
603 596
604 virtual void shadeSpan(int x, int y, SkPMColor span[], int count) SK_OVERRID E { 597 virtual ShaderImpl* createShaderImpl(const SkBitmap& device, const SkPaint& paint,
598 const SkMatrix& matrix, void* storage) const Sk_OVERRIDE
599 {
600 SkASSERT(this->validContext(device, paint, matrix));
601 ShaderImpl* proxyImpl;
605 if (fProxy) { 602 if (fProxy) {
606 fProxy->shadeSpan(x, y, span, count); 603 char* proxyImplStorage = (char*) storage + sizeof(Sk3DShaderImpl);
604 proxyImpl = fProxy->createShaderImpl(device, paint, matrix, proxyImp lStorage);
605 } else {
606 proxyImpl = NULL;
607 }
608 return SkNEW_PLACEMENT_ARGS(storage, Sk3DShaderImpl, (*this, device, pai nt, matrix,
609 proxyImpl));
610 }
611
612 class Sk3DShaderImpl : public ShaderImpl {
613 Sk3DShaderImpl(const Sk3DShader& shader, const SkBitmap& device, const S kPaint& paint,
614 const SkMatrix& matrix, ShaderImpl* proxyImpl)
615 : INHERITED(shader, device, paint, matrix)
616 , fMask(NULL)
617 , fProxyImpl(proxyImpl)
618 {
619 if (!fProxyImpl) {
620 fPMColor = SkPreMultiplyColor(paint.getColor());
621 }
607 } 622 }
608 623
609 if (fMask == NULL) { 624 virtual ~Sk3DShaderImpl() {
610 if (fProxy == NULL) { 625 if (fProxyImpl) {
611 sk_memset32(span, fPMColor, count); 626 fProxyImpl->~ShaderImpl();
612 } 627 }
613 return;
614 } 628 }
615 629
616 SkASSERT(fMask->fBounds.contains(x, y)); 630 void setMask(const SkMask* mask) { fMask = mask; }
617 SkASSERT(fMask->fBounds.contains(x + count - 1, y));
618 631
619 size_t size = fMask->computeImageSize(); 632 virtual void shadeSpan(int x, int y, SkPMColor span[], int count) SK_OVE RRIDE {
620 const uint8_t* alpha = fMask->getAddr8(x, y); 633 const Sk3DShader& shader3D = static_cast<const Sk3DShader&>(fShader) ;
621 const uint8_t* mulp = alpha + size; 634 if (fProxyImpl) {
622 const uint8_t* addp = mulp + size; 635 fProxyImpl->shadeSpan(x, y, span, count);
636 }
623 637
624 if (fProxy) { 638 if (fMask == NULL) {
625 for (int i = 0; i < count; i++) { 639 if (fProxyImpl == NULL) {
626 if (alpha[i]) { 640 sk_memset32(span, fPMColor, count);
627 SkPMColor c = span[i]; 641 }
628 if (c) { 642 return;
629 unsigned a = SkGetPackedA32(c); 643 }
630 unsigned r = SkGetPackedR32(c);
631 unsigned g = SkGetPackedG32(c);
632 unsigned b = SkGetPackedB32(c);
633 644
645 SkASSERT(fMask->fBounds.contains(x, y));
646 SkASSERT(fMask->fBounds.contains(x + count - 1, y));
647
648 size_t size = fMask->computeImageSize();
649 const uint8_t* alpha = fMask->getAddr8(x, y);
650 const uint8_t* mulp = alpha + size;
651 const uint8_t* addp = mulp + size;
652
653 if (fProxyImpl) {
654 for (int i = 0; i < count; i++) {
655 if (alpha[i]) {
656 SkPMColor c = span[i];
657 if (c) {
658 unsigned a = SkGetPackedA32(c);
659 unsigned r = SkGetPackedR32(c);
660 unsigned g = SkGetPackedG32(c);
661 unsigned b = SkGetPackedB32(c);
662
663 unsigned mul = SkAlpha255To256(mulp[i]);
664 unsigned add = addp[i];
665
666 r = SkFastMin32(SkAlphaMul(r, mul) + add, a);
667 g = SkFastMin32(SkAlphaMul(g, mul) + add, a);
668 b = SkFastMin32(SkAlphaMul(b, mul) + add, a);
669
670 span[i] = SkPackARGB32(a, r, g, b);
671 }
672 } else {
673 span[i] = 0;
674 }
675 }
676 } else { // color
677 unsigned a = SkGetPackedA32(fPMColor);
678 unsigned r = SkGetPackedR32(fPMColor);
679 unsigned g = SkGetPackedG32(fPMColor);
680 unsigned b = SkGetPackedB32(fPMColor);
681 for (int i = 0; i < count; i++) {
682 if (alpha[i]) {
634 unsigned mul = SkAlpha255To256(mulp[i]); 683 unsigned mul = SkAlpha255To256(mulp[i]);
635 unsigned add = addp[i]; 684 unsigned add = addp[i];
636 685
637 r = SkFastMin32(SkAlphaMul(r, mul) + add, a); 686 span[i] = SkPackARGB32( a,
638 g = SkFastMin32(SkAlphaMul(g, mul) + add, a); 687 SkFastMin32(SkAlphaMul(r, mul) + add, a) ,
639 b = SkFastMin32(SkAlphaMul(b, mul) + add, a); 688 SkFastMin32(SkAlphaMul(g, mul) + add, a) ,
640 689 SkFastMin32(SkAlphaMul(b, mul) + add, a) );
641 span[i] = SkPackARGB32(a, r, g, b); 690 } else {
691 span[i] = 0;
642 } 692 }
643 } else {
644 span[i] = 0;
645 }
646 }
647 } else { // color
648 unsigned a = SkGetPackedA32(fPMColor);
649 unsigned r = SkGetPackedR32(fPMColor);
650 unsigned g = SkGetPackedG32(fPMColor);
651 unsigned b = SkGetPackedB32(fPMColor);
652 for (int i = 0; i < count; i++) {
653 if (alpha[i]) {
654 unsigned mul = SkAlpha255To256(mulp[i]);
655 unsigned add = addp[i];
656
657 span[i] = SkPackARGB32( a,
658 SkFastMin32(SkAlphaMul(r, mul) + add, a),
659 SkFastMin32(SkAlphaMul(g, mul) + add, a),
660 SkFastMin32(SkAlphaMul(b, mul) + add, a));
661 } else {
662 span[i] = 0;
663 } 693 }
664 } 694 }
665 } 695 }
666 } 696 private:
697 // Unowned.
698 const SkMask* fMask;
699 // Memory is unowned, but we need to call the destructor.
700 ShaderImpl* fProxyImpl;
701 SkPMColor fPMColor;
702 };
667 703
668 #ifdef SK_DEVELOPER 704 #ifdef SK_DEVELOPER
669 virtual void toString(SkString* str) const SK_OVERRIDE { 705 virtual void toString(SkString* str) const SK_OVERRIDE {
670 str->append("Sk3DShader: ("); 706 str->append("Sk3DShader: (");
671 707
672 if (NULL != fProxy) { 708 if (NULL != fProxy) {
673 str->append("Proxy: "); 709 str->append("Proxy: ");
674 fProxy->toString(str); 710 fProxy->toString(str);
675 } 711 }
676 712
677 this->INHERITED::toString(str); 713 this->INHERITED::toString(str);
678 714
679 str->append(")"); 715 str->append(")");
680 } 716 }
681 #endif 717 #endif
682 718
683 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk3DShader) 719 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk3DShader)
684 720
685 protected: 721 protected:
686 Sk3DShader(SkReadBuffer& buffer) : INHERITED(buffer) { 722 Sk3DShader(SkReadBuffer& buffer) : INHERITED(buffer) {
687 fProxy = buffer.readShader(); 723 fProxy = buffer.readShader();
688 fPMColor = buffer.readColor(); 724 // Leaving this here until we bump the picture version, though this
689 fMask = NULL; 725 // shader should never be recorded.
726 buffer.readColor();
690 } 727 }
691 728
692 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { 729 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {
693 this->INHERITED::flatten(buffer); 730 this->INHERITED::flatten(buffer);
694 buffer.writeFlattenable(fProxy); 731 buffer.writeFlattenable(fProxy);
695 buffer.writeColor(fPMColor); 732 // Leaving this here until we bump the picture version, though this
733 // shader should never be recorded.
734 buffer.writeColor(SkColor());
696 } 735 }
697 736
698 private: 737 private:
699 SkShader* fProxy; 738 SkShader* fProxy;
700 SkPMColor fPMColor;
701 const SkMask* fMask;
702 739
703 typedef SkShader INHERITED; 740 typedef SkShaderGenerator INHERITED;
704 }; 741 };
705 742
706 class Sk3DBlitter : public SkBlitter { 743 class Sk3DBlitter : public SkBlitter {
707 public: 744 public:
708 Sk3DBlitter(SkBlitter* proxy, Sk3DShader* shader) 745 Sk3DBlitter(SkBlitter* proxy, Sk3DShader* shader)
709 : fProxy(proxy) 746 : fProxy(proxy)
710 , f3DShader(SkRef(shader)) 747 , f3DShaderImpl(SkRef(shader))
711 {} 748 {}
712 749
713 virtual void blitH(int x, int y, int width) { 750 virtual void blitH(int x, int y, int width) {
714 fProxy->blitH(x, y, width); 751 fProxy->blitH(x, y, width);
715 } 752 }
716 753
717 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], 754 virtual void blitAntiH(int x, int y, const SkAlpha antialias[],
718 const int16_t runs[]) { 755 const int16_t runs[]) {
719 fProxy->blitAntiH(x, y, antialias, runs); 756 fProxy->blitAntiH(x, y, antialias, runs);
720 } 757 }
721 758
722 virtual void blitV(int x, int y, int height, SkAlpha alpha) { 759 virtual void blitV(int x, int y, int height, SkAlpha alpha) {
723 fProxy->blitV(x, y, height, alpha); 760 fProxy->blitV(x, y, height, alpha);
724 } 761 }
725 762
726 virtual void blitRect(int x, int y, int width, int height) { 763 virtual void blitRect(int x, int y, int width, int height) {
727 fProxy->blitRect(x, y, width, height); 764 fProxy->blitRect(x, y, width, height);
728 } 765 }
729 766
730 virtual void blitMask(const SkMask& mask, const SkIRect& clip) { 767 virtual void blitMask(const SkMask& mask, const SkIRect& clip) {
731 if (mask.fFormat == SkMask::k3D_Format) { 768 if (mask.fFormat == SkMask::k3D_Format) {
732 f3DShader->setMask(&mask); 769 f3DShaderImpl->setMask(&mask);
733 770
734 ((SkMask*)&mask)->fFormat = SkMask::kA8_Format; 771 ((SkMask*)&mask)->fFormat = SkMask::kA8_Format;
735 fProxy->blitMask(mask, clip); 772 fProxy->blitMask(mask, clip);
736 ((SkMask*)&mask)->fFormat = SkMask::k3D_Format; 773 ((SkMask*)&mask)->fFormat = SkMask::k3D_Format;
737 774
738 f3DShader->setMask(NULL); 775 f3DShaderImpl->setMask(NULL);
739 } else { 776 } else {
740 fProxy->blitMask(mask, clip); 777 fProxy->blitMask(mask, clip);
741 } 778 }
742 } 779 }
743 780
744 private: 781 private:
745 // fProxy is unowned. It will be deleted by SkSmallAllocator. 782 // Both pointers are unowned. They will be deleted by SkSmallAllocator.
746 SkBlitter* fProxy; 783 SkBlitter* fProxy;
747 SkAutoTUnref<Sk3DShader> f3DShader; 784 Sk3DShader::Sk3DShaderImpl* f3DShaderImpl;
748 }; 785 };
749 786
750 /////////////////////////////////////////////////////////////////////////////// 787 ///////////////////////////////////////////////////////////////////////////////
751 788
752 #include "SkCoreBlitters.h" 789 #include "SkCoreBlitters.h"
753 790
754 static bool just_solid_color(const SkPaint& paint) { 791 static bool just_solid_color(const SkPaint& paint) {
755 if (paint.getAlpha() == 0xFF && paint.getColorFilter() == NULL) { 792 if (paint.getAlpha() == 0xFF && paint.getColorFilter() == NULL) {
756 SkShader* shader = paint.getShader(); 793 SkShaderGenerator* shader = paint.getShader();
757 if (NULL == shader || 794 // FIXME: This is ONLY called BEFORE setContext, when the flags are not
758 (shader->getFlags() & SkShader::kOpaqueAlpha_Flag)) { 795 // supposed to be meaningful. Do we need flags on the shader as well as
796 // the impl?
797 if (NULL == shader /*||
798 (shader->getFlags() & SkShader::kOpaqueAlpha_Flag)*/) {
759 return true; 799 return true;
760 } 800 }
761 } 801 }
762 return false; 802 return false;
763 } 803 }
764 804
765 /** By analyzing the paint (with an xfermode), we may decide we can take 805 /** By analyzing the paint (with an xfermode), we may decide we can take
766 special action. This enum lists our possible actions 806 special action. This enum lists our possible actions
767 */ 807 */
768 enum XferInterp { 808 enum XferInterp {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 SkBlitter* blitter = NULL; 859 SkBlitter* blitter = NULL;
820 860
821 // which check, in case we're being called by a client with a dummy device 861 // which check, in case we're being called by a client with a dummy device
822 // (e.g. they have a bounder that always aborts the draw) 862 // (e.g. they have a bounder that always aborts the draw)
823 if (kUnknown_SkColorType == device.colorType() || 863 if (kUnknown_SkColorType == device.colorType() ||
824 (drawCoverage && (kAlpha_8_SkColorType != device.colorType()))) { 864 (drawCoverage && (kAlpha_8_SkColorType != device.colorType()))) {
825 blitter = allocator->createT<SkNullBlitter>(); 865 blitter = allocator->createT<SkNullBlitter>();
826 return blitter; 866 return blitter;
827 } 867 }
828 868
829 SkShader* shader = origPaint.getShader(); 869 SkShaderGenerator* shader = origPaint.getShader();
830 SkColorFilter* cf = origPaint.getColorFilter(); 870 SkColorFilter* cf = origPaint.getColorFilter();
831 SkXfermode* mode = origPaint.getXfermode(); 871 SkXfermode* mode = origPaint.getXfermode();
832 Sk3DShader* shader3D = NULL; 872 Sk3DShader* shader3D = NULL;
833 873
834 SkTCopyOnFirstWrite<SkPaint> paint(origPaint); 874 SkTCopyOnFirstWrite<SkPaint> paint(origPaint);
835 875
836 if (origPaint.getMaskFilter() != NULL && 876 if (origPaint.getMaskFilter() != NULL &&
837 origPaint.getMaskFilter()->getFormat() == SkMask::k3D_Format) { 877 origPaint.getMaskFilter()->getFormat() == SkMask::k3D_Format) {
838 shader3D = SkNEW_ARGS(Sk3DShader, (shader)); 878 shader3D = SkNEW_ARGS(Sk3DShader, (shader));
839 // we know we haven't initialized lazyPaint yet, so just do it 879 // we know we haven't initialized lazyPaint yet, so just do it
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 926
887 if (cf) { 927 if (cf) {
888 SkASSERT(shader); 928 SkASSERT(shader);
889 shader = SkNEW_ARGS(SkFilterShader, (shader, cf)); 929 shader = SkNEW_ARGS(SkFilterShader, (shader, cf));
890 paint.writable()->setShader(shader)->unref(); 930 paint.writable()->setShader(shader)->unref();
891 // blitters should ignore the presence/absence of a filter, since 931 // blitters should ignore the presence/absence of a filter, since
892 // if there is one, the shader will take care of it. 932 // if there is one, the shader will take care of it.
893 } 933 }
894 934
895 /* 935 /*
896 * We need to have balanced calls to the shader: 936 * We create a ShaderImpl object, and store it on the blitter.
897 * setContext
898 * endContext
899 * We make the first call here, in case it fails we can abort the draw.
900 * The endContext() call is made by the blitter (assuming setContext did
901 * not fail) in its destructor.
902 */ 937 */
903 if (shader && !shader->setContext(device, *paint, matrix)) { 938 SkShaderGenerator::ShaderImpl* shaderImpl;
904 blitter = allocator->createT<SkNullBlitter>(); 939 if (shader) {
905 return blitter; 940 if (!shader->validContext(device, *paint, matrix)) {
941 blitter = allocator->createT<SkNullBlitter>();
942 return blitter;
943 }
944 // Now create the ShaderImpl
945 void* storage = allocator->reserveT<SkShaderGenerator::ShaderImpl>(
946 shader->shaderImplSize());
947 shaderImpl = shader->createShaderImpl(device, *paint, matrix);
948 SkASSERT(shaderImpl);
949 SkASSERT((void*) shaderImpl == storage);
950 } else {
951 shaderImpl = NULL;
906 } 952 }
907 953
908 954
909 switch (device.colorType()) { 955 switch (device.colorType()) {
910 case kAlpha_8_SkColorType: 956 case kAlpha_8_SkColorType:
911 if (drawCoverage) { 957 if (drawCoverage) {
912 SkASSERT(NULL == shader); 958 SkASSERT(NULL == shader);
913 SkASSERT(NULL == paint->getXfermode()); 959 SkASSERT(NULL == paint->getXfermode());
914 blitter = allocator->createT<SkA8_Coverage_Blitter>(device, *pai nt); 960 blitter = allocator->createT<SkA8_Coverage_Blitter>(device, *pai nt);
915 } else if (shader) { 961 } else if (shader) {
916 blitter = allocator->createT<SkA8_Shader_Blitter>(device, *paint ); 962 blitter = allocator->createT<SkA8_Shader_Blitter>(device, *paint , shaderImpl);
917 } else { 963 } else {
918 blitter = allocator->createT<SkA8_Blitter>(device, *paint); 964 blitter = allocator->createT<SkA8_Blitter>(device, *paint);
919 } 965 }
920 break; 966 break;
921 967
922 case kRGB_565_SkColorType: 968 case kRGB_565_SkColorType:
923 blitter = SkBlitter_ChooseD565(device, *paint, allocator); 969 blitter = SkBlitter_ChooseD565(device, *paint, shaderImpl, allocator );
924 break; 970 break;
925 971
926 case kPMColor_SkColorType: 972 case kPMColor_SkColorType:
927 if (shader) { 973 if (shader) {
928 blitter = allocator->createT<SkARGB32_Shader_Blitter>(device, *p aint); 974 blitter = allocator->createT<SkARGB32_Shader_Blitter>(device, *p aint, shaderImpl);
929 } else if (paint->getColor() == SK_ColorBLACK) { 975 } else if (paint->getColor() == SK_ColorBLACK) {
930 blitter = allocator->createT<SkARGB32_Black_Blitter>(device, *pa int); 976 blitter = allocator->createT<SkARGB32_Black_Blitter>(device, *pa int);
931 } else if (paint->getAlpha() == 0xFF) { 977 } else if (paint->getAlpha() == 0xFF) {
932 blitter = allocator->createT<SkARGB32_Opaque_Blitter>(device, *p aint); 978 blitter = allocator->createT<SkARGB32_Opaque_Blitter>(device, *p aint);
933 } else { 979 } else {
934 blitter = allocator->createT<SkARGB32_Blitter>(device, *paint); 980 blitter = allocator->createT<SkARGB32_Blitter>(device, *paint);
935 } 981 }
936 break; 982 break;
937 983
938 default: 984 default:
939 SkDEBUGFAIL("unsupported device config"); 985 SkDEBUGFAIL("unsupported device config");
940 blitter = allocator->createT<SkNullBlitter>(); 986 blitter = allocator->createT<SkNullBlitter>();
941 break; 987 break;
942 } 988 }
943 989
944 if (shader3D) { 990 if (shader3D) {
945 SkBlitter* innerBlitter = blitter; 991 SkBlitter* innerBlitter = blitter;
946 // innerBlitter was allocated by allocator, which will delete it. 992 // innerBlitter was allocated by allocator, which will delete it.
947 blitter = allocator->createT<Sk3DBlitter>(innerBlitter, shader3D); 993 blitter = allocator->createT<Sk3DBlitter>(innerBlitter,
994 static_cast<Sk3DShader::Sk3DShaderImpl*>(shaderImpl);
948 } 995 }
949 return blitter; 996 return blitter;
950 } 997 }
951 998
952 /////////////////////////////////////////////////////////////////////////////// 999 ///////////////////////////////////////////////////////////////////////////////
953 1000
954 const uint16_t gMask_0F0F = 0xF0F; 1001 const uint16_t gMask_0F0F = 0xF0F;
955 const uint32_t gMask_00FF00FF = 0xFF00FF; 1002 const uint32_t gMask_00FF00FF = 0xFF00FF;
956 1003
957 /////////////////////////////////////////////////////////////////////////////// 1004 ///////////////////////////////////////////////////////////////////////////////
958 1005
959 SkShaderBlitter::SkShaderBlitter(const SkBitmap& device, const SkPaint& paint) 1006 SkShaderBlitter::SkShaderBlitter(const SkBitmap& device, const SkPaint& paint,
1007 SkShaderGenerator::ShaderImpl* shaderImpl)
960 : INHERITED(device) { 1008 : INHERITED(device) {
961 fShader = paint.getShader(); 1009 fShaderImpl = shaderImpl;
962 SkASSERT(fShader); 1010 SkASSERT(paint.getShader());
963 SkASSERT(fShader->setContextHasBeenCalled()); 1011 SkASSERT(fShaderImpl);
964 1012
965 fShader->ref(); 1013 fShaderFlags = paint.getShader()->getFlags();
966 fShaderFlags = fShader->getFlags();
967 } 1014 }
968 1015
969 SkShaderBlitter::~SkShaderBlitter() {
970 SkASSERT(fShader->setContextHasBeenCalled());
971 fShader->endContext();
972 fShader->unref();
973 }
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcShader.h ('k') | src/core/SkBlitter_A8.cpp » ('j') | src/core/SkShader.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698