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

Side by Side Diff: src/effects/SkBlurMaskFilter.cpp

Issue 617853003: Revert of Add isSingleComponent bool to getConstantColorComponent (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « src/effects/SkArithmeticMode.cpp ('k') | src/effects/SkColorFilters.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "SkBlurMaskFilter.h" 9 #include "SkBlurMaskFilter.h"
10 #include "SkBlurMask.h" 10 #include "SkBlurMask.h"
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 556
557 class GrRectBlurEffect : public GrFragmentProcessor { 557 class GrRectBlurEffect : public GrFragmentProcessor {
558 public: 558 public:
559 virtual ~GrRectBlurEffect(); 559 virtual ~GrRectBlurEffect();
560 560
561 static const char* Name() { return "RectBlur"; } 561 static const char* Name() { return "RectBlur"; }
562 562
563 typedef GrGLRectBlurEffect GLProcessor; 563 typedef GrGLRectBlurEffect GLProcessor;
564 564
565 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR IDE; 565 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR IDE;
566 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE;
567
566 /** 568 /**
567 * Create a simple filter effect with custom bicubic coefficients. 569 * Create a simple filter effect with custom bicubic coefficients.
568 */ 570 */
569 static GrFragmentProcessor* Create(GrContext *context, const SkRect& rect, f loat sigma) { 571 static GrFragmentProcessor* Create(GrContext *context, const SkRect& rect, f loat sigma) {
570 GrTexture *blurProfileTexture = NULL; 572 GrTexture *blurProfileTexture = NULL;
571 int doubleProfileSize = SkScalarCeilToInt(12*sigma); 573 int doubleProfileSize = SkScalarCeilToInt(12*sigma);
572 574
573 if (doubleProfileSize >= rect.width() || doubleProfileSize >= rect.heigh t()) { 575 if (doubleProfileSize >= rect.width() || doubleProfileSize >= rect.heigh t()) {
574 // if the blur sigma is too large so the gaussian overlaps the whole 576 // if the blur sigma is too large so the gaussian overlaps the whole
575 // rect in either direction, fall back to CPU path for now. 577 // rect in either direction, fall back to CPU path for now.
576 578
577 return NULL; 579 return NULL;
578 } 580 }
579 581
580 bool createdBlurProfileTexture = CreateBlurProfileTexture(context, sigma , &blurProfileTexture); 582 bool createdBlurProfileTexture = CreateBlurProfileTexture(context, sigma , &blurProfileTexture);
581 SkAutoTUnref<GrTexture> hunref(blurProfileTexture); 583 SkAutoTUnref<GrTexture> hunref(blurProfileTexture);
582 if (!createdBlurProfileTexture) { 584 if (!createdBlurProfileTexture) {
583 return NULL; 585 return NULL;
584 } 586 }
585 return SkNEW_ARGS(GrRectBlurEffect, (rect, sigma, blurProfileTexture)); 587 return SkNEW_ARGS(GrRectBlurEffect, (rect, sigma, blurProfileTexture));
586 } 588 }
587 589
588 const SkRect& getRect() const { return fRect; } 590 const SkRect& getRect() const { return fRect; }
589 float getSigma() const { return fSigma; } 591 float getSigma() const { return fSigma; }
590 592
591 private: 593 private:
592 GrRectBlurEffect(const SkRect& rect, float sigma, GrTexture *blur_profile); 594 GrRectBlurEffect(const SkRect& rect, float sigma, GrTexture *blur_profile);
593 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; 595 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE;
594 596
595 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR IDE;
596
597 static bool CreateBlurProfileTexture(GrContext *context, float sigma, 597 static bool CreateBlurProfileTexture(GrContext *context, float sigma,
598 GrTexture **blurProfileTexture); 598 GrTexture **blurProfileTexture);
599 599
600 SkRect fRect; 600 SkRect fRect;
601 float fSigma; 601 float fSigma;
602 GrTextureAccess fBlurProfileAccess; 602 GrTextureAccess fBlurProfileAccess;
603 603
604 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 604 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
605 605
606 typedef GrFragmentProcessor INHERITED; 606 typedef GrFragmentProcessor INHERITED;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 758
759 const GrBackendFragmentProcessorFactory& GrRectBlurEffect::getFactory() const { 759 const GrBackendFragmentProcessorFactory& GrRectBlurEffect::getFactory() const {
760 return GrTBackendFragmentProcessorFactory<GrRectBlurEffect>::getInstance(); 760 return GrTBackendFragmentProcessorFactory<GrRectBlurEffect>::getInstance();
761 } 761 }
762 762
763 bool GrRectBlurEffect::onIsEqual(const GrProcessor& sBase) const { 763 bool GrRectBlurEffect::onIsEqual(const GrProcessor& sBase) const {
764 const GrRectBlurEffect& s = sBase.cast<GrRectBlurEffect>(); 764 const GrRectBlurEffect& s = sBase.cast<GrRectBlurEffect>();
765 return this->getSigma() == s.getSigma() && this->getRect() == s.getRect(); 765 return this->getSigma() == s.getSigma() && this->getRect() == s.getRect();
766 } 766 }
767 767
768 void GrRectBlurEffect::onComputeInvariantOutput(InvariantOutput* inout) const { 768 void GrRectBlurEffect::getConstantColorComponents(GrColor* color, uint32_t* vali dFlags) const {
769 inout->fValidFlags = 0; 769 *validFlags = 0;
770 inout->fIsSingleComponent = false; 770 return;
771 } 771 }
772 772
773 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRectBlurEffect); 773 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRectBlurEffect);
774 774
775 GrFragmentProcessor* GrRectBlurEffect::TestCreate(SkRandom* random, 775 GrFragmentProcessor* GrRectBlurEffect::TestCreate(SkRandom* random,
776 GrContext* context, 776 GrContext* context,
777 const GrDrawTargetCaps&, 777 const GrDrawTargetCaps&,
778 GrTexture**) { 778 GrTexture**) {
779 float sigma = random->nextRangeF(3,8); 779 float sigma = random->nextRangeF(3,8);
780 float width = random->nextRangeF(200,300); 780 float width = random->nextRangeF(200,300);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 static GrFragmentProcessor* Create(GrContext* context, float sigma, const Sk RRect&); 830 static GrFragmentProcessor* Create(GrContext* context, float sigma, const Sk RRect&);
831 831
832 virtual ~GrRRectBlurEffect() {}; 832 virtual ~GrRRectBlurEffect() {};
833 static const char* Name() { return "GrRRectBlur"; } 833 static const char* Name() { return "GrRRectBlur"; }
834 834
835 const SkRRect& getRRect() const { return fRRect; } 835 const SkRRect& getRRect() const { return fRRect; }
836 float getSigma() const { return fSigma; } 836 float getSigma() const { return fSigma; }
837 837
838 typedef GrGLRRectBlurEffect GLProcessor; 838 typedef GrGLRRectBlurEffect GLProcessor;
839 839
840 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE;
841
840 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR IDE; 842 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR IDE;
841 843
842 private: 844 private:
843 GrRRectBlurEffect(float sigma, const SkRRect&, GrTexture* profileTexture); 845 GrRRectBlurEffect(float sigma, const SkRRect&, GrTexture* profileTexture);
844 846
845 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE; 847 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE;
846 848
847 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR IDE;
848
849 SkRRect fRRect; 849 SkRRect fRRect;
850 float fSigma; 850 float fSigma;
851 GrTextureAccess fNinePatchAccess; 851 GrTextureAccess fNinePatchAccess;
852 852
853 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 853 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
854 854
855 typedef GrFragmentProcessor INHERITED; 855 typedef GrFragmentProcessor INHERITED;
856 }; 856 };
857 857
858 858
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 } 922 }
923 923
924 SkAutoTUnref<GrTexture> blurunref(blurNinePatchTexture); 924 SkAutoTUnref<GrTexture> blurunref(blurNinePatchTexture);
925 if (NULL == blurNinePatchTexture) { 925 if (NULL == blurNinePatchTexture) {
926 return NULL; 926 return NULL;
927 } 927 }
928 928
929 return SkNEW_ARGS(GrRRectBlurEffect, (sigma, rrect, blurNinePatchTexture)); 929 return SkNEW_ARGS(GrRRectBlurEffect, (sigma, rrect, blurNinePatchTexture));
930 } 930 }
931 931
932 void GrRRectBlurEffect::onComputeInvariantOutput(InvariantOutput* inout) const { 932 void GrRRectBlurEffect::getConstantColorComponents(GrColor* color, uint32_t* val idFlags) const {
933 inout->fValidFlags = 0; 933 *validFlags = 0;
934 inout->fIsSingleComponent = false;
935 } 934 }
936 935
937 const GrBackendFragmentProcessorFactory& GrRRectBlurEffect::getFactory() const { 936 const GrBackendFragmentProcessorFactory& GrRRectBlurEffect::getFactory() const {
938 return GrTBackendFragmentProcessorFactory<GrRRectBlurEffect>::getInstance(); 937 return GrTBackendFragmentProcessorFactory<GrRRectBlurEffect>::getInstance();
939 } 938 }
940 939
941 GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTextur e *ninePatchTexture) 940 GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTextur e *ninePatchTexture)
942 : fRRect(rrect), 941 : fRRect(rrect),
943 fSigma(sigma), 942 fSigma(sigma),
944 fNinePatchAccess(ninePatchTexture) { 943 fNinePatchAccess(ninePatchTexture) {
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 } else { 1219 } else {
1221 str->append("None"); 1220 str->append("None");
1222 } 1221 }
1223 str->append("))"); 1222 str->append("))");
1224 } 1223 }
1225 #endif 1224 #endif
1226 1225
1227 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) 1226 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
1228 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) 1227 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
1229 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1228 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkArithmeticMode.cpp ('k') | src/effects/SkColorFilters.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698