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

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

Issue 926593005: Use SkXfermode as public facing enum for GrPorterDuffXP (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Review fixes Created 5 years, 10 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 | « include/gpu/effects/GrPorterDuffXferProcessor.h ('k') | src/gpu/GrBlend.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 /* 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"
28 #include "effects/GrSimpleTextureEffect.h" 27 #include "effects/GrSimpleTextureEffect.h"
29 #include "gl/GrGLProcessor.h" 28 #include "gl/GrGLProcessor.h"
30 #include "gl/builders/GrGLProgramBuilder.h" 29 #include "gl/builders/GrGLProgramBuilder.h"
31 #endif 30 #endif
32 31
33 SkScalar SkBlurMaskFilter::ConvertRadiusToSigma(SkScalar radius) { 32 SkScalar SkBlurMaskFilter::ConvertRadiusToSigma(SkScalar radius) {
34 return SkBlurMask::ConvertRadiusToSigma(radius); 33 return SkBlurMask::ConvertRadiusToSigma(radius);
35 } 34 }
36 35
37 class SkBlurMaskFilterImpl : public SkMaskFilter { 36 class SkBlurMaskFilterImpl : public SkMaskFilter {
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 if (NULL == *result) { 1209 if (NULL == *result) {
1211 return false; 1210 return false;
1212 } 1211 }
1213 1212
1214 if (!isNormalBlur) { 1213 if (!isNormalBlur) {
1215 GrPaint paint; 1214 GrPaint paint;
1216 SkMatrix matrix; 1215 SkMatrix matrix;
1217 matrix.setIDiv(src->width(), src->height()); 1216 matrix.setIDiv(src->width(), src->height());
1218 // Blend pathTexture over blurTexture. 1217 // Blend pathTexture over blurTexture.
1219 GrContext::AutoRenderTarget art(context, (*result)->asRenderTarget()); 1218 GrContext::AutoRenderTarget art(context, (*result)->asRenderTarget());
1220 paint.addColorProcessor(GrSimpleTextureEffect::Create(src, matrix))->unr ef(); 1219 paint.addCoverageProcessor(GrSimpleTextureEffect::Create(src, matrix))-> unref();
1221 if (kInner_SkBlurStyle == fBlurStyle) { 1220 if (kInner_SkBlurStyle == fBlurStyle) {
1222 // inner: dst = dst * src 1221 // inner: dst = dst * src
1223 paint.setPorterDuffXPFactory(kDC_GrBlendCoeff, kZero_GrBlendCoeff); 1222 paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op);
1224 } else if (kSolid_SkBlurStyle == fBlurStyle) { 1223 } else if (kSolid_SkBlurStyle == fBlurStyle) {
1225 // solid: dst = src + dst - src * dst 1224 // solid: dst = src + dst - src * dst
1226 // = (1 - dst) * src + 1 * dst 1225 // = src + (1 - src) * dst
1227 paint.setPorterDuffXPFactory(kIDC_GrBlendCoeff, kOne_GrBlendCoeff); 1226 paint.setCoverageSetOpXPFactory(SkRegion::kUnion_Op);
1228 } else if (kOuter_SkBlurStyle == fBlurStyle) { 1227 } else if (kOuter_SkBlurStyle == fBlurStyle) {
1229 // outer: dst = dst * (1 - src) 1228 // outer: dst = dst * (1 - src)
1230 // = 0 * src + (1 - src) * dst 1229 // = 0 * src + (1 - src) * dst
1231 paint.setPorterDuffXPFactory(kZero_GrBlendCoeff, kISC_GrBlendCoeff); 1230 paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op);
1232 } 1231 }
1233 context->drawRect(paint, SkMatrix::I(), clipRect); 1232 context->drawRect(paint, SkMatrix::I(), clipRect);
1234 } 1233 }
1235 1234
1236 return true; 1235 return true;
1237 } 1236 }
1238 1237
1239 #endif // SK_SUPPORT_GPU 1238 #endif // SK_SUPPORT_GPU
1240 1239
1241 1240
(...skipping 22 matching lines...) Expand all
1264 } else { 1263 } else {
1265 str->append("None"); 1264 str->append("None");
1266 } 1265 }
1267 str->append("))"); 1266 str->append("))");
1268 } 1267 }
1269 #endif 1268 #endif
1270 1269
1271 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) 1270 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
1272 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) 1271 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
1273 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1272 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « include/gpu/effects/GrPorterDuffXferProcessor.h ('k') | src/gpu/GrBlend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698