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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 GrDrawContext* drawContext, | 61 GrDrawContext* drawContext, |
62 GrPaint* grp, | 62 GrPaint* grp, |
63 const GrClip&, | 63 const GrClip&, |
64 const SkMatrix& viewMatrix, | 64 const SkMatrix& viewMatrix, |
65 const SkStrokeRec& strokeRec, | 65 const SkStrokeRec& strokeRec, |
66 const SkRRect& rrect) const override; | 66 const SkRRect& rrect) const override; |
67 bool filterMaskGPU(GrTexture* src, | 67 bool filterMaskGPU(GrTexture* src, |
68 const SkMatrix& ctm, | 68 const SkMatrix& ctm, |
69 const SkRect& maskRect, | 69 const SkRect& maskRect, |
70 GrTexture** result, | 70 GrTexture** result, |
71 bool canOverwriteSrc) const override; | 71 bool canOverwriteSrc, |
72 bool allowSRGBInputs) const override; | |
72 #endif | 73 #endif |
73 | 74 |
74 void computeFastBounds(const SkRect&, SkRect*) const override; | 75 void computeFastBounds(const SkRect&, SkRect*) const override; |
75 bool asABlur(BlurRec*) const override; | 76 bool asABlur(BlurRec*) const override; |
76 | 77 |
77 SK_TO_STRING_OVERRIDE() | 78 SK_TO_STRING_OVERRIDE() |
78 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurMaskFilterImpl) | 79 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurMaskFilterImpl) |
79 | 80 |
80 protected: | 81 protected: |
81 FilterReturn filterRectsToNine(const SkRect[], int count, const SkMatrix&, | 82 FilterReturn filterRectsToNine(const SkRect[], int count, const SkMatrix&, |
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1224 srcRect.setEmpty(); | 1225 srcRect.setEmpty(); |
1225 } | 1226 } |
1226 *maskRect = srcRect; | 1227 *maskRect = srcRect; |
1227 return true; | 1228 return true; |
1228 } | 1229 } |
1229 | 1230 |
1230 bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src, | 1231 bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src, |
1231 const SkMatrix& ctm, | 1232 const SkMatrix& ctm, |
1232 const SkRect& maskRect, | 1233 const SkRect& maskRect, |
1233 GrTexture** result, | 1234 GrTexture** result, |
1234 bool canOverwriteSrc) const { | 1235 bool canOverwriteSrc, |
1236 bool allowSRGBInputs) const { | |
1235 SkRect clipRect = SkRect::MakeWH(maskRect.width(), maskRect.height()); | 1237 SkRect clipRect = SkRect::MakeWH(maskRect.width(), maskRect.height()); |
1236 | 1238 |
1237 GrContext* context = src->getContext(); | 1239 GrContext* context = src->getContext(); |
1238 | 1240 |
1239 SkScalar xformedSigma = this->computeXformedSigma(ctm); | 1241 SkScalar xformedSigma = this->computeXformedSigma(ctm); |
1240 SkASSERT(xformedSigma > 0); | 1242 SkASSERT(xformedSigma > 0); |
1241 | 1243 |
1242 // If we're doing a normal blur, we can clobber the pathTexture in the | 1244 // If we're doing a normal blur, we can clobber the pathTexture in the |
1243 // gaussianBlur. Otherwise, we need to save it for later compositing. | 1245 // gaussianBlur. Otherwise, we need to save it for later compositing. |
1244 bool isNormalBlur = (kNormal_SkBlurStyle == fBlurStyle); | 1246 bool isNormalBlur = (kNormal_SkBlurStyle == fBlurStyle); |
1245 *result = SkGpuBlurUtils::GaussianBlur(context, src, isNormalBlur && canOver writeSrc, | 1247 *result = SkGpuBlurUtils::GaussianBlur(context, src, isNormalBlur && canOver writeSrc, |
1246 clipRect, nullptr, xformedSigma, xfor medSigma); | 1248 allowSRGBInputs, clipRect, nullptr, |
bsalomon
2016/04/05 13:24:01
AFAIK, this is taking an input mask and produced a
Brian Osman
2016/04/05 15:36:41
Acknowledged.
| |
1249 xformedSigma, xformedSigma); | |
1247 if (nullptr == *result) { | 1250 if (nullptr == *result) { |
1248 return false; | 1251 return false; |
1249 } | 1252 } |
1250 | 1253 |
1251 if (!isNormalBlur) { | 1254 if (!isNormalBlur) { |
1252 GrPaint paint; | 1255 GrPaint paint; |
1256 // SRGBTODO: AllowSRGBInputs? | |
bsalomon
2016/04/05 13:24:01
No, this is taking the blurred mask and the origin
Brian Osman
2016/04/05 15:36:41
Acknowledged.
| |
1253 SkMatrix matrix; | 1257 SkMatrix matrix; |
1254 matrix.setIDiv(src->width(), src->height()); | 1258 matrix.setIDiv(src->width(), src->height()); |
1255 // Blend pathTexture over blurTexture. | 1259 // Blend pathTexture over blurTexture. |
1256 paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(src, ma trix))->unref(); | 1260 paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(src, ma trix))->unref(); |
1257 if (kInner_SkBlurStyle == fBlurStyle) { | 1261 if (kInner_SkBlurStyle == fBlurStyle) { |
1258 // inner: dst = dst * src | 1262 // inner: dst = dst * src |
1259 paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op); | 1263 paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op); |
1260 } else if (kSolid_SkBlurStyle == fBlurStyle) { | 1264 } else if (kSolid_SkBlurStyle == fBlurStyle) { |
1261 // solid: dst = src + dst - src * dst | 1265 // solid: dst = src + dst - src * dst |
1262 // = src + (1 - src) * dst | 1266 // = src + (1 - src) * dst |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1308 } else { | 1312 } else { |
1309 str->append("None"); | 1313 str->append("None"); |
1310 } | 1314 } |
1311 str->append("))"); | 1315 str->append("))"); |
1312 } | 1316 } |
1313 #endif | 1317 #endif |
1314 | 1318 |
1315 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) | 1319 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) |
1316 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) | 1320 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) |
1317 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1321 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |