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

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

Issue 759713002: Make all blending up to GrOptDrawState be handled by the xp/xp factory. (Closed) Base URL: https://skia.googlesource.com/skia.git@xferFactorySolo
Patch Set: Clean up Created 6 years 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkBlurMaskFilter.h" 9 #include "SkBlurMaskFilter.h"
10 #include "SkBlurMask.h" 10 #include "SkBlurMask.h"
11 #include "SkGpuBlurUtils.h" 11 #include "SkGpuBlurUtils.h"
12 #include "SkReadBuffer.h" 12 #include "SkReadBuffer.h"
13 #include "SkWriteBuffer.h" 13 #include "SkWriteBuffer.h"
14 #include "SkMaskFilter.h" 14 #include "SkMaskFilter.h"
15 #include "SkRRect.h" 15 #include "SkRRect.h"
16 #include "SkRTConf.h" 16 #include "SkRTConf.h"
17 #include "SkStringUtils.h" 17 #include "SkStringUtils.h"
18 #include "SkStrokeRec.h" 18 #include "SkStrokeRec.h"
19 19
20 #if SK_SUPPORT_GPU 20 #if SK_SUPPORT_GPU
21 #include "GrContext.h" 21 #include "GrContext.h"
22 #include "GrTexture.h" 22 #include "GrTexture.h"
23 #include "GrFragmentProcessor.h" 23 #include "GrFragmentProcessor.h"
24 #include "GrInvariantOutput.h" 24 #include "GrInvariantOutput.h"
25 #include "gl/GrGLProcessor.h" 25 #include "gl/GrGLProcessor.h"
26 #include "gl/builders/GrGLProgramBuilder.h" 26 #include "gl/builders/GrGLProgramBuilder.h"
27 #include "effects/GrPorterDuffXferProcessor.h"
27 #include "effects/GrSimpleTextureEffect.h" 28 #include "effects/GrSimpleTextureEffect.h"
28 #include "GrTBackendProcessorFactory.h" 29 #include "GrTBackendProcessorFactory.h"
29 #include "SkGrPixelRef.h" 30 #include "SkGrPixelRef.h"
30 #include "SkDraw.h" 31 #include "SkDraw.h"
31 #endif 32 #endif
32 33
33 SkScalar SkBlurMaskFilter::ConvertRadiusToSigma(SkScalar radius) { 34 SkScalar SkBlurMaskFilter::ConvertRadiusToSigma(SkScalar radius) {
34 return SkBlurMask::ConvertRadiusToSigma(radius); 35 return SkBlurMask::ConvertRadiusToSigma(radius);
35 } 36 }
36 37
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 if (!isNormalBlur) { 1215 if (!isNormalBlur) {
1215 context->setIdentityMatrix(); 1216 context->setIdentityMatrix();
1216 GrPaint paint; 1217 GrPaint paint;
1217 SkMatrix matrix; 1218 SkMatrix matrix;
1218 matrix.setIDiv(src->width(), src->height()); 1219 matrix.setIDiv(src->width(), src->height());
1219 // Blend pathTexture over blurTexture. 1220 // Blend pathTexture over blurTexture.
1220 GrContext::AutoRenderTarget art(context, (*result)->asRenderTarget()); 1221 GrContext::AutoRenderTarget art(context, (*result)->asRenderTarget());
1221 paint.addColorProcessor(GrSimpleTextureEffect::Create(src, matrix))->unr ef(); 1222 paint.addColorProcessor(GrSimpleTextureEffect::Create(src, matrix))->unr ef();
1222 if (kInner_SkBlurStyle == fBlurStyle) { 1223 if (kInner_SkBlurStyle == fBlurStyle) {
1223 // inner: dst = dst * src 1224 // inner: dst = dst * src
1224 paint.setBlendFunc(kDC_GrBlendCoeff, kZero_GrBlendCoeff); 1225 GrXPFactory* xpFactory = GrPorterDuffXPFactory::Create(kDC_GrBlendCo eff,
1226 kZero_GrBlend Coeff);
1227 paint.setXPFactory(xpFactory)->unref();
1225 } else if (kSolid_SkBlurStyle == fBlurStyle) { 1228 } else if (kSolid_SkBlurStyle == fBlurStyle) {
1226 // solid: dst = src + dst - src * dst 1229 // solid: dst = src + dst - src * dst
1227 // = (1 - dst) * src + 1 * dst 1230 // = (1 - dst) * src + 1 * dst
1228 paint.setBlendFunc(kIDC_GrBlendCoeff, kOne_GrBlendCoeff); 1231 GrXPFactory* xpFactory = GrPorterDuffXPFactory::Create(kIDC_GrBlendC oeff,
1232 kOne_GrBlendC oeff);
1233 paint.setXPFactory(xpFactory)->unref();
1229 } else if (kOuter_SkBlurStyle == fBlurStyle) { 1234 } else if (kOuter_SkBlurStyle == fBlurStyle) {
1230 // outer: dst = dst * (1 - src) 1235 // outer: dst = dst * (1 - src)
1231 // = 0 * src + (1 - src) * dst 1236 // = 0 * src + (1 - src) * dst
1232 paint.setBlendFunc(kZero_GrBlendCoeff, kISC_GrBlendCoeff); 1237 GrXPFactory* xpFactory = GrPorterDuffXPFactory::Create(kZero_GrBlend Coeff,
1238 kISC_GrBlendC oeff);
1239 paint.setXPFactory(xpFactory)->unref();
1233 } 1240 }
1234 context->drawRect(paint, clipRect); 1241 context->drawRect(paint, clipRect);
1235 } 1242 }
1236 1243
1237 return true; 1244 return true;
1238 } 1245 }
1239 1246
1240 #endif // SK_SUPPORT_GPU 1247 #endif // SK_SUPPORT_GPU
1241 1248
1242 1249
(...skipping 22 matching lines...) Expand all
1265 } else { 1272 } else {
1266 str->append("None"); 1273 str->append("None");
1267 } 1274 }
1268 str->append("))"); 1275 str->append("))");
1269 } 1276 }
1270 #endif 1277 #endif
1271 1278
1272 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) 1279 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
1273 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) 1280 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
1274 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1281 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698