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

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

Issue 1973563002: Revert of Make SkGpuBlurUtils::GaussianBlur more drawContext centric (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 SkRect clipRect = SkRect::MakeWH(maskRect.width(), maskRect.height()); 1241 SkRect clipRect = SkRect::MakeWH(maskRect.width(), maskRect.height());
1242 1242
1243 GrContext* context = src->getContext(); 1243 GrContext* context = src->getContext();
1244 1244
1245 SkScalar xformedSigma = this->computeXformedSigma(ctm); 1245 SkScalar xformedSigma = this->computeXformedSigma(ctm);
1246 SkASSERT(xformedSigma > 0); 1246 SkASSERT(xformedSigma > 0);
1247 1247
1248 // If we're doing a normal blur, we can clobber the pathTexture in the 1248 // 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. 1249 // gaussianBlur. Otherwise, we need to save it for later compositing.
1250 bool isNormalBlur = (kNormal_SkBlurStyle == fBlurStyle); 1250 bool isNormalBlur = (kNormal_SkBlurStyle == fBlurStyle);
1251 sk_sp<GrDrawContext> drawContext(SkGpuBlurUtils::GaussianBlur(context, src, 1251 *result = SkGpuBlurUtils::GaussianBlur(context, src, isNormalBlur && canOver writeSrc,
1252 isNormalBlur & & canOverwriteSrc, 1252 clipRect, nullptr,
1253 clipRect, null ptr, 1253 xformedSigma, xformedSigma);
1254 xformedSigma, xformedSigma)); 1254 if (nullptr == *result) {
1255 if (!drawContext) {
1256 return false; 1255 return false;
1257 } 1256 }
1258 1257
1259 if (!isNormalBlur) { 1258 if (!isNormalBlur) {
1260 GrPaint paint; 1259 GrPaint paint;
1261 SkMatrix matrix; 1260 SkMatrix matrix;
1262 matrix.setIDiv(src->width(), src->height()); 1261 matrix.setIDiv(src->width(), src->height());
1263 // Blend pathTexture over blurTexture. 1262 // Blend pathTexture over blurTexture.
1264 paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(src, ma trix))->unref(); 1263 paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(src, ma trix))->unref();
1265 if (kInner_SkBlurStyle == fBlurStyle) { 1264 if (kInner_SkBlurStyle == fBlurStyle) {
1266 // inner: dst = dst * src 1265 // inner: dst = dst * src
1267 paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op); 1266 paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op);
1268 } else if (kSolid_SkBlurStyle == fBlurStyle) { 1267 } else if (kSolid_SkBlurStyle == fBlurStyle) {
1269 // solid: dst = src + dst - src * dst 1268 // solid: dst = src + dst - src * dst
1270 // = src + (1 - src) * dst 1269 // = src + (1 - src) * dst
1271 paint.setCoverageSetOpXPFactory(SkRegion::kUnion_Op); 1270 paint.setCoverageSetOpXPFactory(SkRegion::kUnion_Op);
1272 } else if (kOuter_SkBlurStyle == fBlurStyle) { 1271 } else if (kOuter_SkBlurStyle == fBlurStyle) {
1273 // outer: dst = dst * (1 - src) 1272 // outer: dst = dst * (1 - src)
1274 // = 0 * src + (1 - src) * dst 1273 // = 0 * src + (1 - src) * dst
1275 paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op); 1274 paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op);
1276 } else { 1275 } else {
1277 paint.setCoverageSetOpXPFactory(SkRegion::kReplace_Op); 1276 paint.setCoverageSetOpXPFactory(SkRegion::kReplace_Op);
1278 } 1277 }
1279 1278
1279 sk_sp<GrDrawContext> drawContext(
1280 context->drawContext(sk_ref_sp((*result)->as RenderTarget())));
1281 if (!drawContext) {
1282 return false;
1283 }
1284
1280 drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), clipRect ); 1285 drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), clipRect );
1281 } 1286 }
1282 1287
1283 *result = drawContext->asTexture().release();
1284 return true; 1288 return true;
1285 } 1289 }
1286 1290
1287 #endif // SK_SUPPORT_GPU 1291 #endif // SK_SUPPORT_GPU
1288 1292
1289 1293
1290 #ifndef SK_IGNORE_TO_STRING 1294 #ifndef SK_IGNORE_TO_STRING
1291 void SkBlurMaskFilterImpl::toString(SkString* str) const { 1295 void SkBlurMaskFilterImpl::toString(SkString* str) const {
1292 str->append("SkBlurMaskFilterImpl: ("); 1296 str->append("SkBlurMaskFilterImpl: (");
1293 1297
(...skipping 18 matching lines...) Expand all
1312 } else { 1316 } else {
1313 str->append("None"); 1317 str->append("None");
1314 } 1318 }
1315 str->append("))"); 1319 str->append("))");
1316 } 1320 }
1317 #endif 1321 #endif
1318 1322
1319 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) 1323 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
1320 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) 1324 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
1321 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1325 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