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

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

Issue 1151283004: Split drawing functionality out of GrContext and into new GrDrawContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix no-GPU builds Created 5 years, 6 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/SkAlphaThresholdFilter.cpp ('k') | src/effects/SkDisplacementMapEffect.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 "GrDrawContext.h"
22 #include "GrTexture.h" 23 #include "GrTexture.h"
23 #include "GrFragmentProcessor.h" 24 #include "GrFragmentProcessor.h"
24 #include "GrInvariantOutput.h" 25 #include "GrInvariantOutput.h"
25 #include "SkGrPixelRef.h" 26 #include "SkGrPixelRef.h"
26 #include "SkDraw.h" 27 #include "SkDraw.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
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 if (!fp) { 864 if (!fp) {
864 return false; 865 return false;
865 } 866 }
866 867
867 grp->addCoverageProcessor(fp); 868 grp->addCoverageProcessor(fp);
868 869
869 SkMatrix inverse; 870 SkMatrix inverse;
870 if (!viewMatrix.invert(&inverse)) { 871 if (!viewMatrix.invert(&inverse)) {
871 return false; 872 return false;
872 } 873 }
873 context->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), rect, i nverse); 874
874 return true; 875 GrDrawContext* drawContext = context->drawContext();
876 if (drawContext) {
877 drawContext->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), rect, inverse);
878 return true;
879 }
880
881 return false;
875 } 882 }
876 883
877 class GrRRectBlurEffect : public GrFragmentProcessor { 884 class GrRRectBlurEffect : public GrFragmentProcessor {
878 public: 885 public:
879 886
880 static GrFragmentProcessor* Create(GrContext* context, float sigma, const Sk RRect&); 887 static GrFragmentProcessor* Create(GrContext* context, float sigma, const Sk RRect&);
881 888
882 virtual ~GrRRectBlurEffect() {}; 889 virtual ~GrRRectBlurEffect() {};
883 const char* name() const override { return "GrRRectBlur"; } 890 const char* name() const override { return "GrRRectBlur"; }
884 891
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 if (!fp) { 1154 if (!fp) {
1148 return false; 1155 return false;
1149 } 1156 }
1150 1157
1151 grp->addCoverageProcessor(fp); 1158 grp->addCoverageProcessor(fp);
1152 1159
1153 SkMatrix inverse; 1160 SkMatrix inverse;
1154 if (!viewMatrix.invert(&inverse)) { 1161 if (!viewMatrix.invert(&inverse)) {
1155 return false; 1162 return false;
1156 } 1163 }
1157 context->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), proxy_r ect, inverse); 1164
1158 return true; 1165 GrDrawContext* drawContext = context->drawContext();
1166 if (drawContext) {
1167 drawContext->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(),
1168 proxy_rect, inverse);
1169 return true;
1170 }
1171
1172 return false;
1159 } 1173 }
1160 1174
1161 bool SkBlurMaskFilterImpl::canFilterMaskGPU(const SkRect& srcBounds, 1175 bool SkBlurMaskFilterImpl::canFilterMaskGPU(const SkRect& srcBounds,
1162 const SkIRect& clipBounds, 1176 const SkIRect& clipBounds,
1163 const SkMatrix& ctm, 1177 const SkMatrix& ctm,
1164 SkRect* maskRect) const { 1178 SkRect* maskRect) const {
1165 SkScalar xformedSigma = this->computeXformedSigma(ctm); 1179 SkScalar xformedSigma = this->computeXformedSigma(ctm);
1166 if (xformedSigma <= 0) { 1180 if (xformedSigma <= 0) {
1167 return false; 1181 return false;
1168 } 1182 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op); 1243 paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op);
1230 } else if (kSolid_SkBlurStyle == fBlurStyle) { 1244 } else if (kSolid_SkBlurStyle == fBlurStyle) {
1231 // solid: dst = src + dst - src * dst 1245 // solid: dst = src + dst - src * dst
1232 // = src + (1 - src) * dst 1246 // = src + (1 - src) * dst
1233 paint.setCoverageSetOpXPFactory(SkRegion::kUnion_Op); 1247 paint.setCoverageSetOpXPFactory(SkRegion::kUnion_Op);
1234 } else if (kOuter_SkBlurStyle == fBlurStyle) { 1248 } else if (kOuter_SkBlurStyle == fBlurStyle) {
1235 // outer: dst = dst * (1 - src) 1249 // outer: dst = dst * (1 - src)
1236 // = 0 * src + (1 - src) * dst 1250 // = 0 * src + (1 - src) * dst
1237 paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op); 1251 paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op);
1238 } 1252 }
1239 context->drawRect((*result)->asRenderTarget(), GrClip::WideOpen(), paint , SkMatrix::I(), 1253
1240 clipRect); 1254 GrDrawContext* drawContext = context->drawContext();
1255 if (!drawContext) {
1256 return false;
1257 }
1258
1259 drawContext->drawRect((*result)->asRenderTarget(), GrClip::WideOpen(),
1260 paint, SkMatrix::I(), clipRect);
1241 } 1261 }
1242 1262
1243 return true; 1263 return true;
1244 } 1264 }
1245 1265
1246 #endif // SK_SUPPORT_GPU 1266 #endif // SK_SUPPORT_GPU
1247 1267
1248 1268
1249 #ifndef SK_IGNORE_TO_STRING 1269 #ifndef SK_IGNORE_TO_STRING
1250 void SkBlurMaskFilterImpl::toString(SkString* str) const { 1270 void SkBlurMaskFilterImpl::toString(SkString* str) const {
(...skipping 20 matching lines...) Expand all
1271 } else { 1291 } else {
1272 str->append("None"); 1292 str->append("None");
1273 } 1293 }
1274 str->append("))"); 1294 str->append("))");
1275 } 1295 }
1276 #endif 1296 #endif
1277 1297
1278 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) 1298 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
1279 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) 1299 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
1280 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1300 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkAlphaThresholdFilter.cpp ('k') | src/effects/SkDisplacementMapEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698