Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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(), proxy_rect, inverse); | |
|
bsalomon
2015/05/22 20:33:57
wrap?
robertphillips
2015/05/26 16:12:58
Done.
| |
| 1168 return true; | |
| 1169 } | |
| 1170 | |
| 1171 return false; | |
| 1159 } | 1172 } |
| 1160 | 1173 |
| 1161 bool SkBlurMaskFilterImpl::canFilterMaskGPU(const SkRect& srcBounds, | 1174 bool SkBlurMaskFilterImpl::canFilterMaskGPU(const SkRect& srcBounds, |
| 1162 const SkIRect& clipBounds, | 1175 const SkIRect& clipBounds, |
| 1163 const SkMatrix& ctm, | 1176 const SkMatrix& ctm, |
| 1164 SkRect* maskRect) const { | 1177 SkRect* maskRect) const { |
| 1165 SkScalar xformedSigma = this->computeXformedSigma(ctm); | 1178 SkScalar xformedSigma = this->computeXformedSigma(ctm); |
| 1166 if (xformedSigma <= 0) { | 1179 if (xformedSigma <= 0) { |
| 1167 return false; | 1180 return false; |
| 1168 } | 1181 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1229 paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op); | 1242 paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op); |
| 1230 } else if (kSolid_SkBlurStyle == fBlurStyle) { | 1243 } else if (kSolid_SkBlurStyle == fBlurStyle) { |
| 1231 // solid: dst = src + dst - src * dst | 1244 // solid: dst = src + dst - src * dst |
| 1232 // = src + (1 - src) * dst | 1245 // = src + (1 - src) * dst |
| 1233 paint.setCoverageSetOpXPFactory(SkRegion::kUnion_Op); | 1246 paint.setCoverageSetOpXPFactory(SkRegion::kUnion_Op); |
| 1234 } else if (kOuter_SkBlurStyle == fBlurStyle) { | 1247 } else if (kOuter_SkBlurStyle == fBlurStyle) { |
| 1235 // outer: dst = dst * (1 - src) | 1248 // outer: dst = dst * (1 - src) |
| 1236 // = 0 * src + (1 - src) * dst | 1249 // = 0 * src + (1 - src) * dst |
| 1237 paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op); | 1250 paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op); |
| 1238 } | 1251 } |
| 1239 context->drawRect((*result)->asRenderTarget(), GrClip::WideOpen(), paint , SkMatrix::I(), | 1252 |
| 1240 clipRect); | 1253 GrDrawContext* drawContext = context->drawContext(); |
| 1254 if (!drawContext) { | |
| 1255 return false; | |
| 1256 } | |
| 1257 | |
| 1258 drawContext->drawRect((*result)->asRenderTarget(), GrClip::WideOpen(), | |
| 1259 paint, SkMatrix::I(), clipRect); | |
| 1241 } | 1260 } |
| 1242 | 1261 |
| 1243 return true; | 1262 return true; |
| 1244 } | 1263 } |
| 1245 | 1264 |
| 1246 #endif // SK_SUPPORT_GPU | 1265 #endif // SK_SUPPORT_GPU |
| 1247 | 1266 |
| 1248 | 1267 |
| 1249 #ifndef SK_IGNORE_TO_STRING | 1268 #ifndef SK_IGNORE_TO_STRING |
| 1250 void SkBlurMaskFilterImpl::toString(SkString* str) const { | 1269 void SkBlurMaskFilterImpl::toString(SkString* str) const { |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1271 } else { | 1290 } else { |
| 1272 str->append("None"); | 1291 str->append("None"); |
| 1273 } | 1292 } |
| 1274 str->append("))"); | 1293 str->append("))"); |
| 1275 } | 1294 } |
| 1276 #endif | 1295 #endif |
| 1277 | 1296 |
| 1278 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) | 1297 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) |
| 1279 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) | 1298 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) |
| 1280 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1299 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| OLD | NEW |