| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 const SkPath& path) const override; | 59 const SkPath& path) const override; |
| 60 bool directFilterRRectMaskGPU(GrTextureProvider* texProvider, | 60 bool directFilterRRectMaskGPU(GrTextureProvider* texProvider, |
| 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 SkIRect& maskRect, |
| 70 GrTexture** result, | 70 GrTexture** result, |
| 71 bool canOverwriteSrc) const override; | 71 bool canOverwriteSrc) const override; |
| 72 #endif | 72 #endif |
| 73 | 73 |
| 74 void computeFastBounds(const SkRect&, SkRect*) const override; | 74 void computeFastBounds(const SkRect&, SkRect*) const override; |
| 75 bool asABlur(BlurRec*) const override; | 75 bool asABlur(BlurRec*) const override; |
| 76 | 76 |
| 77 SK_TO_STRING_OVERRIDE() | 77 SK_TO_STRING_OVERRIDE() |
| 78 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurMaskFilterImpl) | 78 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurMaskFilterImpl) |
| 79 | 79 |
| (...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 clipRect.outset(sigma3, sigma3); | 1228 clipRect.outset(sigma3, sigma3); |
| 1229 if (!srcRect.intersect(clipRect)) { | 1229 if (!srcRect.intersect(clipRect)) { |
| 1230 srcRect.setEmpty(); | 1230 srcRect.setEmpty(); |
| 1231 } | 1231 } |
| 1232 *maskRect = srcRect; | 1232 *maskRect = srcRect; |
| 1233 return true; | 1233 return true; |
| 1234 } | 1234 } |
| 1235 | 1235 |
| 1236 bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src, | 1236 bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src, |
| 1237 const SkMatrix& ctm, | 1237 const SkMatrix& ctm, |
| 1238 const SkRect& maskRect, | 1238 const SkIRect& maskRect, |
| 1239 GrTexture** result, | 1239 GrTexture** result, |
| 1240 bool canOverwriteSrc) const { | 1240 bool canOverwriteSrc) const { |
| 1241 SkRect clipRect = SkRect::MakeWH(maskRect.width(), maskRect.height()); | 1241 // 'maskRect' isn't snapped to the UL corner but the mask in 'src' is. |
| 1242 const SkIRect clipRect = SkIRect::MakeWH(maskRect.width(), maskRect.height()
); |
| 1242 | 1243 |
| 1243 GrContext* context = src->getContext(); | 1244 GrContext* context = src->getContext(); |
| 1244 | 1245 |
| 1245 SkScalar xformedSigma = this->computeXformedSigma(ctm); | 1246 SkScalar xformedSigma = this->computeXformedSigma(ctm); |
| 1246 SkASSERT(xformedSigma > 0); | 1247 SkASSERT(xformedSigma > 0); |
| 1247 | 1248 |
| 1248 // If we're doing a normal blur, we can clobber the pathTexture in the | 1249 // If we're doing a normal blur, we can clobber the pathTexture in the |
| 1249 // gaussianBlur. Otherwise, we need to save it for later compositing. | 1250 // gaussianBlur. Otherwise, we need to save it for later compositing. |
| 1250 bool isNormalBlur = (kNormal_SkBlurStyle == fBlurStyle); | 1251 bool isNormalBlur = (kNormal_SkBlurStyle == fBlurStyle); |
| 1251 sk_sp<GrDrawContext> drawContext(SkGpuBlurUtils::GaussianBlur(context, src, | 1252 sk_sp<GrDrawContext> drawContext(SkGpuBlurUtils::GaussianBlur(context, src, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1270 // = src + (1 - src) * dst | 1271 // = src + (1 - src) * dst |
| 1271 paint.setCoverageSetOpXPFactory(SkRegion::kUnion_Op); | 1272 paint.setCoverageSetOpXPFactory(SkRegion::kUnion_Op); |
| 1272 } else if (kOuter_SkBlurStyle == fBlurStyle) { | 1273 } else if (kOuter_SkBlurStyle == fBlurStyle) { |
| 1273 // outer: dst = dst * (1 - src) | 1274 // outer: dst = dst * (1 - src) |
| 1274 // = 0 * src + (1 - src) * dst | 1275 // = 0 * src + (1 - src) * dst |
| 1275 paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op); | 1276 paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op); |
| 1276 } else { | 1277 } else { |
| 1277 paint.setCoverageSetOpXPFactory(SkRegion::kReplace_Op); | 1278 paint.setCoverageSetOpXPFactory(SkRegion::kReplace_Op); |
| 1278 } | 1279 } |
| 1279 | 1280 |
| 1280 drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), clipRect
); | 1281 drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), SkRect::
Make(clipRect)); |
| 1281 } | 1282 } |
| 1282 | 1283 |
| 1283 *result = drawContext->asTexture().release(); | 1284 *result = drawContext->asTexture().release(); |
| 1284 return true; | 1285 return true; |
| 1285 } | 1286 } |
| 1286 | 1287 |
| 1287 #endif // SK_SUPPORT_GPU | 1288 #endif // SK_SUPPORT_GPU |
| 1288 | 1289 |
| 1289 | 1290 |
| 1290 #ifndef SK_IGNORE_TO_STRING | 1291 #ifndef SK_IGNORE_TO_STRING |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1312 } else { | 1313 } else { |
| 1313 str->append("None"); | 1314 str->append("None"); |
| 1314 } | 1315 } |
| 1315 str->append("))"); | 1316 str->append("))"); |
| 1316 } | 1317 } |
| 1317 #endif | 1318 #endif |
| 1318 | 1319 |
| 1319 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) | 1320 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) |
| 1320 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) | 1321 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) |
| 1321 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1322 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| OLD | NEW |