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

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: Update from review comments 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 "SkGrPixelRef.h" 25 #include "SkGrPixelRef.h"
26 #include "SkDraw.h" 26 #include "SkDraw.h"
27 #include "effects/GrPorterDuffXferProcessor.h"
27 #include "effects/GrSimpleTextureEffect.h" 28 #include "effects/GrSimpleTextureEffect.h"
28 #include "gl/GrGLProcessor.h" 29 #include "gl/GrGLProcessor.h"
29 #include "gl/builders/GrGLProgramBuilder.h" 30 #include "gl/builders/GrGLProgramBuilder.h"
30 #endif 31 #endif
31 32
32 SkScalar SkBlurMaskFilter::ConvertRadiusToSigma(SkScalar radius) { 33 SkScalar SkBlurMaskFilter::ConvertRadiusToSigma(SkScalar radius) {
33 return SkBlurMask::ConvertRadiusToSigma(radius); 34 return SkBlurMask::ConvertRadiusToSigma(radius);
34 } 35 }
35 36
36 class SkBlurMaskFilterImpl : public SkMaskFilter { 37 class SkBlurMaskFilterImpl : public SkMaskFilter {
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 if (!isNormalBlur) { 1212 if (!isNormalBlur) {
1212 context->setIdentityMatrix(); 1213 context->setIdentityMatrix();
1213 GrPaint paint; 1214 GrPaint paint;
1214 SkMatrix matrix; 1215 SkMatrix matrix;
1215 matrix.setIDiv(src->width(), src->height()); 1216 matrix.setIDiv(src->width(), src->height());
1216 // Blend pathTexture over blurTexture. 1217 // Blend pathTexture over blurTexture.
1217 GrContext::AutoRenderTarget art(context, (*result)->asRenderTarget()); 1218 GrContext::AutoRenderTarget art(context, (*result)->asRenderTarget());
1218 paint.addColorProcessor(GrSimpleTextureEffect::Create(src, matrix))->unr ef(); 1219 paint.addColorProcessor(GrSimpleTextureEffect::Create(src, matrix))->unr ef();
1219 if (kInner_SkBlurStyle == fBlurStyle) { 1220 if (kInner_SkBlurStyle == fBlurStyle) {
1220 // inner: dst = dst * src 1221 // inner: dst = dst * src
1221 paint.setBlendFunc(kDC_GrBlendCoeff, kZero_GrBlendCoeff); 1222 paint.setPorterDuffXPFactory(kDC_GrBlendCoeff, kZero_GrBlendCoeff);
1222 } else if (kSolid_SkBlurStyle == fBlurStyle) { 1223 } else if (kSolid_SkBlurStyle == fBlurStyle) {
1223 // solid: dst = src + dst - src * dst 1224 // solid: dst = src + dst - src * dst
1224 // = (1 - dst) * src + 1 * dst 1225 // = (1 - dst) * src + 1 * dst
1225 paint.setBlendFunc(kIDC_GrBlendCoeff, kOne_GrBlendCoeff); 1226 paint.setPorterDuffXPFactory(kIDC_GrBlendCoeff, kOne_GrBlendCoeff);
1226 } else if (kOuter_SkBlurStyle == fBlurStyle) { 1227 } else if (kOuter_SkBlurStyle == fBlurStyle) {
1227 // outer: dst = dst * (1 - src) 1228 // outer: dst = dst * (1 - src)
1228 // = 0 * src + (1 - src) * dst 1229 // = 0 * src + (1 - src) * dst
1229 paint.setBlendFunc(kZero_GrBlendCoeff, kISC_GrBlendCoeff); 1230 paint.setPorterDuffXPFactory(kZero_GrBlendCoeff, kISC_GrBlendCoeff);
1230 } 1231 }
1231 context->drawRect(paint, clipRect); 1232 context->drawRect(paint, clipRect);
1232 } 1233 }
1233 1234
1234 return true; 1235 return true;
1235 } 1236 }
1236 1237
1237 #endif // SK_SUPPORT_GPU 1238 #endif // SK_SUPPORT_GPU
1238 1239
1239 1240
(...skipping 22 matching lines...) Expand all
1262 } else { 1263 } else {
1263 str->append("None"); 1264 str->append("None");
1264 } 1265 }
1265 str->append("))"); 1266 str->append("))");
1266 } 1267 }
1267 #endif 1268 #endif
1268 1269
1269 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) 1270 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
1270 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) 1271 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
1271 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1272 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698