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

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

Issue 608253002: Add isSingleComponent bool to getConstantColorComponent (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix isSolidWhite 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
568 /** 566 /**
569 * Create a simple filter effect with custom bicubic coefficients. 567 * Create a simple filter effect with custom bicubic coefficients.
570 */ 568 */
571 static GrFragmentProcessor* Create(GrContext *context, const SkRect& rect, f loat sigma) { 569 static GrFragmentProcessor* Create(GrContext *context, const SkRect& rect, f loat sigma) {
572 GrTexture *blurProfileTexture = NULL; 570 GrTexture *blurProfileTexture = NULL;
573 int doubleProfileSize = SkScalarCeilToInt(12*sigma); 571 int doubleProfileSize = SkScalarCeilToInt(12*sigma);
574 572
575 if (doubleProfileSize >= rect.width() || doubleProfileSize >= rect.heigh t()) { 573 if (doubleProfileSize >= rect.width() || doubleProfileSize >= rect.heigh t()) {
576 // if the blur sigma is too large so the gaussian overlaps the whole 574 // if the blur sigma is too large so the gaussian overlaps the whole
577 // rect in either direction, fall back to CPU path for now. 575 // rect in either direction, fall back to CPU path for now.
578 576
579 return NULL; 577 return NULL;
580 } 578 }
581 579
582 bool createdBlurProfileTexture = CreateBlurProfileTexture(context, sigma , &blurProfileTexture); 580 bool createdBlurProfileTexture = CreateBlurProfileTexture(context, sigma , &blurProfileTexture);
583 SkAutoTUnref<GrTexture> hunref(blurProfileTexture); 581 SkAutoTUnref<GrTexture> hunref(blurProfileTexture);
584 if (!createdBlurProfileTexture) { 582 if (!createdBlurProfileTexture) {
585 return NULL; 583 return NULL;
586 } 584 }
587 return SkNEW_ARGS(GrRectBlurEffect, (rect, sigma, blurProfileTexture)); 585 return SkNEW_ARGS(GrRectBlurEffect, (rect, sigma, blurProfileTexture));
588 } 586 }
589 587
590 const SkRect& getRect() const { return fRect; } 588 const SkRect& getRect() const { return fRect; }
591 float getSigma() const { return fSigma; } 589 float getSigma() const { return fSigma; }
592 590
593 private: 591 private:
594 GrRectBlurEffect(const SkRect& rect, float sigma, GrTexture *blur_profile); 592 GrRectBlurEffect(const SkRect& rect, float sigma, GrTexture *blur_profile);
595 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; 593 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE;
596 594
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::getConstantColorComponents(GrColor* color, uint32_t* vali dFlags) const { 768 void GrRectBlurEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
769 *validFlags = 0; 769 inout->fValidFlags = 0;
770 return; 770 inout->fIsSingleComponent = false;
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
842 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR IDE; 840 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR IDE;
843 841
844 private: 842 private:
845 GrRRectBlurEffect(float sigma, const SkRRect&, GrTexture* profileTexture); 843 GrRRectBlurEffect(float sigma, const SkRRect&, GrTexture* profileTexture);
846 844
847 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE; 845 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE;
848 846
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::getConstantColorComponents(GrColor* color, uint32_t* val idFlags) const { 932 void GrRRectBlurEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
933 *validFlags = 0; 933 inout->fValidFlags = 0;
934 inout->fIsSingleComponent = false;
934 } 935 }
935 936
936 const GrBackendFragmentProcessorFactory& GrRRectBlurEffect::getFactory() const { 937 const GrBackendFragmentProcessorFactory& GrRRectBlurEffect::getFactory() const {
937 return GrTBackendFragmentProcessorFactory<GrRRectBlurEffect>::getInstance(); 938 return GrTBackendFragmentProcessorFactory<GrRRectBlurEffect>::getInstance();
938 } 939 }
939 940
940 GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTextur e *ninePatchTexture) 941 GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTextur e *ninePatchTexture)
941 : fRRect(rrect), 942 : fRRect(rrect),
942 fSigma(sigma), 943 fSigma(sigma),
943 fNinePatchAccess(ninePatchTexture) { 944 fNinePatchAccess(ninePatchTexture) {
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 } else { 1220 } else {
1220 str->append("None"); 1221 str->append("None");
1221 } 1222 }
1222 str->append("))"); 1223 str->append("))");
1223 } 1224 }
1224 #endif 1225 #endif
1225 1226
1226 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) 1227 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
1227 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) 1228 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
1228 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1229 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