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

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

Issue 1959493002: Retract GrRenderTarget from SkGpuBlurUtils Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Clean up Created 4 years, 7 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/SkBlurImageFilter.cpp ('k') | src/effects/SkGpuBlurUtils.h » ('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 * 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
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
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(
1252 isNormalBlur & & canOverwriteSrc, 1253 context, src,
1253 clipRect, null ptr, 1254 isNormalBlur && c anOverwriteSrc,
1254 xformedSigma, xformedSigma)); 1255 clipRect, nullptr ,
1256 xformedSigma, xfo rmedSigma));
1255 if (!drawContext) { 1257 if (!drawContext) {
1256 return false; 1258 return false;
1257 } 1259 }
1258 1260
1259 if (!isNormalBlur) { 1261 if (!isNormalBlur) {
1260 GrPaint paint; 1262 GrPaint paint;
1261 SkMatrix matrix; 1263 SkMatrix matrix;
1262 matrix.setIDiv(src->width(), src->height()); 1264 matrix.setIDiv(src->width(), src->height());
1263 // Blend pathTexture over blurTexture. 1265 // Blend pathTexture over blurTexture.
1264 paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(src, ma trix))->unref(); 1266 paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(src, ma trix))->unref();
1265 if (kInner_SkBlurStyle == fBlurStyle) { 1267 if (kInner_SkBlurStyle == fBlurStyle) {
1266 // inner: dst = dst * src 1268 // inner: dst = dst * src
1267 paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op); 1269 paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op);
1268 } else if (kSolid_SkBlurStyle == fBlurStyle) { 1270 } else if (kSolid_SkBlurStyle == fBlurStyle) {
1269 // solid: dst = src + dst - src * dst 1271 // solid: dst = src + dst - src * dst
1270 // = src + (1 - src) * dst 1272 // = src + (1 - src) * dst
1271 paint.setCoverageSetOpXPFactory(SkRegion::kUnion_Op); 1273 paint.setCoverageSetOpXPFactory(SkRegion::kUnion_Op);
1272 } else if (kOuter_SkBlurStyle == fBlurStyle) { 1274 } else if (kOuter_SkBlurStyle == fBlurStyle) {
1273 // outer: dst = dst * (1 - src) 1275 // outer: dst = dst * (1 - src)
1274 // = 0 * src + (1 - src) * dst 1276 // = 0 * src + (1 - src) * dst
1275 paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op); 1277 paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op);
1276 } else { 1278 } else {
1277 paint.setCoverageSetOpXPFactory(SkRegion::kReplace_Op); 1279 paint.setCoverageSetOpXPFactory(SkRegion::kReplace_Op);
1278 } 1280 }
1279 1281
1280 drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), clipRect ); 1282 drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), SkRect:: Make(clipRect));
1281 } 1283 }
1282 1284
1283 *result = drawContext->asTexture().release(); 1285 *result = drawContext->asTexture().release();
1284 return true; 1286 return true;
1285 } 1287 }
1286 1288
1287 #endif // SK_SUPPORT_GPU 1289 #endif // SK_SUPPORT_GPU
1288 1290
1289 1291
1290 #ifndef SK_IGNORE_TO_STRING 1292 #ifndef SK_IGNORE_TO_STRING
(...skipping 21 matching lines...) Expand all
1312 } else { 1314 } else {
1313 str->append("None"); 1315 str->append("None");
1314 } 1316 }
1315 str->append("))"); 1317 str->append("))");
1316 } 1318 }
1317 #endif 1319 #endif
1318 1320
1319 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) 1321 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
1320 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) 1322 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
1321 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1323 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkBlurImageFilter.cpp ('k') | src/effects/SkGpuBlurUtils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698