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

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: rebase 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
« no previous file with comments | « src/effects/SkAlphaThresholdFilter.cpp ('k') | src/gpu/GrBitmapTextContext.cpp » ('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 /* 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 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 if (!isNormalBlur) { 1217 if (!isNormalBlur) {
1217 context->setIdentityMatrix(); 1218 context->setIdentityMatrix();
1218 GrPaint paint; 1219 GrPaint paint;
1219 SkMatrix matrix; 1220 SkMatrix matrix;
1220 matrix.setIDiv(src->width(), src->height()); 1221 matrix.setIDiv(src->width(), src->height());
1221 // Blend pathTexture over blurTexture. 1222 // Blend pathTexture over blurTexture.
1222 GrContext::AutoRenderTarget art(context, (*result)->asRenderTarget()); 1223 GrContext::AutoRenderTarget art(context, (*result)->asRenderTarget());
1223 paint.addColorProcessor(GrSimpleTextureEffect::Create(src, matrix))->unr ef(); 1224 paint.addColorProcessor(GrSimpleTextureEffect::Create(src, matrix))->unr ef();
1224 if (kInner_SkBlurStyle == fBlurStyle) { 1225 if (kInner_SkBlurStyle == fBlurStyle) {
1225 // inner: dst = dst * src 1226 // inner: dst = dst * src
1226 paint.setBlendFunc(kDC_GrBlendCoeff, kZero_GrBlendCoeff); 1227 paint.setPorterDuffXPFactory(kDC_GrBlendCoeff, kZero_GrBlendCoeff);
1227 } else if (kSolid_SkBlurStyle == fBlurStyle) { 1228 } else if (kSolid_SkBlurStyle == fBlurStyle) {
1228 // solid: dst = src + dst - src * dst 1229 // solid: dst = src + dst - src * dst
1229 // = (1 - dst) * src + 1 * dst 1230 // = (1 - dst) * src + 1 * dst
1230 paint.setBlendFunc(kIDC_GrBlendCoeff, kOne_GrBlendCoeff); 1231 paint.setPorterDuffXPFactory(kIDC_GrBlendCoeff, kOne_GrBlendCoeff);
1231 } else if (kOuter_SkBlurStyle == fBlurStyle) { 1232 } else if (kOuter_SkBlurStyle == fBlurStyle) {
1232 // outer: dst = dst * (1 - src) 1233 // outer: dst = dst * (1 - src)
1233 // = 0 * src + (1 - src) * dst 1234 // = 0 * src + (1 - src) * dst
1234 paint.setBlendFunc(kZero_GrBlendCoeff, kISC_GrBlendCoeff); 1235 paint.setPorterDuffXPFactory(kZero_GrBlendCoeff, kISC_GrBlendCoeff);
1235 } 1236 }
1236 context->drawRect(paint, clipRect); 1237 context->drawRect(paint, clipRect);
1237 } 1238 }
1238 1239
1239 return true; 1240 return true;
1240 } 1241 }
1241 1242
1242 #endif // SK_SUPPORT_GPU 1243 #endif // SK_SUPPORT_GPU
1243 1244
1244 1245
(...skipping 22 matching lines...) Expand all
1267 } else { 1268 } else {
1268 str->append("None"); 1269 str->append("None");
1269 } 1270 }
1270 str->append("))"); 1271 str->append("))");
1271 } 1272 }
1272 #endif 1273 #endif
1273 1274
1274 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) 1275 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
1275 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) 1276 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
1276 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1277 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkAlphaThresholdFilter.cpp ('k') | src/gpu/GrBitmapTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698