OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 #include "SkBlurMaskFilter.h" | 8 #include "SkBlurMaskFilter.h" |
9 #include "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
10 #include "SkGpuBlurUtils.h" | 10 #include "SkGpuBlurUtils.h" |
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 : fRRect(rrect), | 1017 : fRRect(rrect), |
1018 fSigma(sigma), | 1018 fSigma(sigma), |
1019 fNinePatchAccess(ninePatchTexture) { | 1019 fNinePatchAccess(ninePatchTexture) { |
1020 this->initClassID<GrRRectBlurEffect>(); | 1020 this->initClassID<GrRRectBlurEffect>(); |
1021 this->addTextureAccess(&fNinePatchAccess); | 1021 this->addTextureAccess(&fNinePatchAccess); |
1022 this->setWillReadFragmentPosition(); | 1022 this->setWillReadFragmentPosition(); |
1023 } | 1023 } |
1024 | 1024 |
1025 bool GrRRectBlurEffect::onIsEqual(const GrFragmentProcessor& other) const { | 1025 bool GrRRectBlurEffect::onIsEqual(const GrFragmentProcessor& other) const { |
1026 const GrRRectBlurEffect& rrbe = other.cast<GrRRectBlurEffect>(); | 1026 const GrRRectBlurEffect& rrbe = other.cast<GrRRectBlurEffect>(); |
1027 return fRRect.getSimpleRadii().fX == rrbe.fRRect.getSimpleRadii().fX && fSig
ma == rrbe.fSigma; | 1027 return fRRect.getSimpleRadii().fX == rrbe.fRRect.getSimpleRadii().fX && |
| 1028 fSigma == rrbe.fSigma && |
| 1029 fRRect.rect() == rrbe.fRRect.rect(); |
1028 } | 1030 } |
1029 | 1031 |
1030 ////////////////////////////////////////////////////////////////////////////// | 1032 ////////////////////////////////////////////////////////////////////////////// |
1031 | 1033 |
1032 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRRectBlurEffect); | 1034 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRRectBlurEffect); |
1033 | 1035 |
1034 const GrFragmentProcessor* GrRRectBlurEffect::TestCreate(GrProcessorTestData* d)
{ | 1036 const GrFragmentProcessor* GrRRectBlurEffect::TestCreate(GrProcessorTestData* d)
{ |
1035 SkScalar w = d->fRandom->nextRangeScalar(100.f, 1000.f); | 1037 SkScalar w = d->fRandom->nextRangeScalar(100.f, 1000.f); |
1036 SkScalar h = d->fRandom->nextRangeScalar(100.f, 1000.f); | 1038 SkScalar h = d->fRandom->nextRangeScalar(100.f, 1000.f); |
1037 SkScalar r = d->fRandom->nextRangeF(1.f, 9.f); | 1039 SkScalar r = d->fRandom->nextRangeF(1.f, 9.f); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 fragBuilder->codeAppendf("vec2 texCoord = translatedFragPos / proxyDims;"); | 1112 fragBuilder->codeAppendf("vec2 texCoord = translatedFragPos / proxyDims;"); |
1111 | 1113 |
1112 fragBuilder->codeAppendf("%s = ", args.fOutputColor); | 1114 fragBuilder->codeAppendf("%s = ", args.fOutputColor); |
1113 fragBuilder->appendTextureLookupAndModulate(args.fInputColor, args.fSamplers
[0], "texCoord"); | 1115 fragBuilder->appendTextureLookupAndModulate(args.fInputColor, args.fSamplers
[0], "texCoord"); |
1114 fragBuilder->codeAppend(";"); | 1116 fragBuilder->codeAppend(";"); |
1115 } | 1117 } |
1116 | 1118 |
1117 void GrGLRRectBlurEffect::onSetData(const GrGLSLProgramDataManager& pdman, | 1119 void GrGLRRectBlurEffect::onSetData(const GrGLSLProgramDataManager& pdman, |
1118 const GrProcessor& proc) { | 1120 const GrProcessor& proc) { |
1119 const GrRRectBlurEffect& brre = proc.cast<GrRRectBlurEffect>(); | 1121 const GrRRectBlurEffect& brre = proc.cast<GrRRectBlurEffect>(); |
1120 SkRRect rrect = brre.getRRect(); | 1122 const SkRRect& rrect = brre.getRRect(); |
1121 | 1123 |
1122 float blurRadius = 3.f*SkScalarCeilToScalar(brre.getSigma()-1/6.0f); | 1124 float blurRadius = 3.f*SkScalarCeilToScalar(brre.getSigma()-1/6.0f); |
1123 pdman.set1f(fBlurRadiusUniform, blurRadius); | 1125 pdman.set1f(fBlurRadiusUniform, blurRadius); |
1124 | 1126 |
1125 SkRect rect = rrect.getBounds(); | 1127 SkRect rect = rrect.getBounds(); |
1126 rect.outset(blurRadius, blurRadius); | 1128 rect.outset(blurRadius, blurRadius); |
1127 pdman.set4f(fProxyRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.fBot
tom); | 1129 pdman.set4f(fProxyRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.fBot
tom); |
1128 | 1130 |
1129 SkScalar radius = 0; | 1131 SkScalar radius = 0; |
1130 SkASSERT(rrect.isSimpleCircular() || rrect.isRect()); | 1132 SkASSERT(rrect.isSimpleCircular() || rrect.isRect()); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 } else { | 1306 } else { |
1305 str->append("None"); | 1307 str->append("None"); |
1306 } | 1308 } |
1307 str->append("))"); | 1309 str->append("))"); |
1308 } | 1310 } |
1309 #endif | 1311 #endif |
1310 | 1312 |
1311 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) | 1313 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) |
1312 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) | 1314 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) |
1313 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1315 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |