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

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

Issue 643743003: Create helper functions to use in computeInvariantOutput calls (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update blurMaskFilter 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/SkColorCubeFilter.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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 fsBuilder->codeAppendf("\tfloat height = %s.w - %s.y;\n", rectName, rectName ); 685 fsBuilder->codeAppendf("\tfloat height = %s.w - %s.y;\n", rectName, rectName );
686 686
687 fsBuilder->codeAppendf("\tvec2 smallDims = vec2(width - %s, height-%s);\n", profileSizeName, profileSizeName); 687 fsBuilder->codeAppendf("\tvec2 smallDims = vec2(width - %s, height-%s);\n", profileSizeName, profileSizeName);
688 fsBuilder->codeAppendf("\tfloat center = 2.0 * floor(%s/2.0 + .25) - 1.0;\n" , profileSizeName); 688 fsBuilder->codeAppendf("\tfloat center = 2.0 * floor(%s/2.0 + .25) - 1.0;\n" , profileSizeName);
689 fsBuilder->codeAppendf("\tvec2 wh = smallDims - vec2(center,center);\n"); 689 fsBuilder->codeAppendf("\tvec2 wh = smallDims - vec2(center,center);\n");
690 690
691 OutputRectBlurProfileLookup(fsBuilder, samplers[0], "horiz_lookup", profileS izeName, "translatedPos.x", "width", "wh.x"); 691 OutputRectBlurProfileLookup(fsBuilder, samplers[0], "horiz_lookup", profileS izeName, "translatedPos.x", "width", "wh.x");
692 OutputRectBlurProfileLookup(fsBuilder, samplers[0], "vert_lookup", profileSi zeName, "translatedPos.y", "height", "wh.y"); 692 OutputRectBlurProfileLookup(fsBuilder, samplers[0], "vert_lookup", profileSi zeName, "translatedPos.y", "height", "wh.y");
693 693
694 fsBuilder->codeAppendf("\tfloat final = horiz_lookup * vert_lookup;\n"); 694 fsBuilder->codeAppendf("\tfloat final = horiz_lookup * vert_lookup;\n");
695 fsBuilder->codeAppendf("\t%s = src * vec4(final);\n", outputColor ); 695 fsBuilder->codeAppendf("\t%s = src * final;\n", outputColor );
696 } 696 }
697 697
698 void GrGLRectBlurEffect::setData(const GrGLProgramDataManager& pdman, 698 void GrGLRectBlurEffect::setData(const GrGLProgramDataManager& pdman,
699 const GrProcessor& proc) { 699 const GrProcessor& proc) {
700 const GrRectBlurEffect& rbe = proc.cast<GrRectBlurEffect>(); 700 const GrRectBlurEffect& rbe = proc.cast<GrRectBlurEffect>();
701 SkRect rect = rbe.getRect(); 701 SkRect rect = rbe.getRect();
702 702
703 pdman.set4f(fProxyRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.fBot tom); 703 pdman.set4f(fProxyRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.fBot tom);
704 pdman.set1f(fProfileSizeUniform, SkScalarCeilToScalar(6*rbe.getSigma())); 704 pdman.set1f(fProfileSizeUniform, SkScalarCeilToScalar(6*rbe.getSigma()));
705 } 705 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::onComputeInvariantOutput(InvariantOutput* inout) const {
769 inout->fValidFlags = 0; 769 inout->mulByUnknownAlpha();
770 inout->fIsSingleComponent = false;
771 } 770 }
772 771
773 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRectBlurEffect); 772 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRectBlurEffect);
774 773
775 GrFragmentProcessor* GrRectBlurEffect::TestCreate(SkRandom* random, 774 GrFragmentProcessor* GrRectBlurEffect::TestCreate(SkRandom* random,
776 GrContext* context, 775 GrContext* context,
777 const GrDrawTargetCaps&, 776 const GrDrawTargetCaps&,
778 GrTexture**) { 777 GrTexture**) {
779 float sigma = random->nextRangeF(3,8); 778 float sigma = random->nextRangeF(3,8);
780 float width = random->nextRangeF(200,300); 779 float width = random->nextRangeF(200,300);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 922
924 SkAutoTUnref<GrTexture> blurunref(blurNinePatchTexture); 923 SkAutoTUnref<GrTexture> blurunref(blurNinePatchTexture);
925 if (NULL == blurNinePatchTexture) { 924 if (NULL == blurNinePatchTexture) {
926 return NULL; 925 return NULL;
927 } 926 }
928 927
929 return SkNEW_ARGS(GrRRectBlurEffect, (sigma, rrect, blurNinePatchTexture)); 928 return SkNEW_ARGS(GrRRectBlurEffect, (sigma, rrect, blurNinePatchTexture));
930 } 929 }
931 930
932 void GrRRectBlurEffect::onComputeInvariantOutput(InvariantOutput* inout) const { 931 void GrRRectBlurEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
933 inout->fValidFlags = 0; 932 inout->mulByUnknownAlpha();
934 inout->fIsSingleComponent = false;
935 } 933 }
936 934
937 const GrBackendFragmentProcessorFactory& GrRRectBlurEffect::getFactory() const { 935 const GrBackendFragmentProcessorFactory& GrRRectBlurEffect::getFactory() const {
938 return GrTBackendFragmentProcessorFactory<GrRRectBlurEffect>::getInstance(); 936 return GrTBackendFragmentProcessorFactory<GrRRectBlurEffect>::getInstance();
939 } 937 }
940 938
941 GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTextur e *ninePatchTexture) 939 GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTextur e *ninePatchTexture)
942 : fRRect(rrect), 940 : fRRect(rrect),
943 fSigma(sigma), 941 fSigma(sigma),
944 fNinePatchAccess(ninePatchTexture) { 942 fNinePatchAccess(ninePatchTexture) {
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 } else { 1218 } else {
1221 str->append("None"); 1219 str->append("None");
1222 } 1220 }
1223 str->append("))"); 1221 str->append("))");
1224 } 1222 }
1225 #endif 1223 #endif
1226 1224
1227 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) 1225 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
1228 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) 1226 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
1229 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1227 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkArithmeticMode.cpp ('k') | src/effects/SkColorCubeFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698