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

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

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update Created 5 years, 5 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
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"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 SkMask::Format getFormat() const override; 42 SkMask::Format getFormat() const override;
43 virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&, 43 virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&,
44 SkIPoint* margin) const override; 44 SkIPoint* margin) const override;
45 45
46 #if SK_SUPPORT_GPU 46 #if SK_SUPPORT_GPU
47 virtual bool canFilterMaskGPU(const SkRect& devBounds, 47 virtual bool canFilterMaskGPU(const SkRect& devBounds,
48 const SkIRect& clipBounds, 48 const SkIRect& clipBounds,
49 const SkMatrix& ctm, 49 const SkMatrix& ctm,
50 SkRect* maskRect) const override; 50 SkRect* maskRect) const override;
51 virtual bool directFilterMaskGPU(GrContext* context, 51 virtual bool directFilterMaskGPU(GrContext* context,
52 GrDrawContext* drawContext,
52 GrRenderTarget* rt, 53 GrRenderTarget* rt,
53 GrPaint* grp, 54 GrPaint* grp,
54 const GrClip&, 55 const GrClip&,
55 const SkMatrix& viewMatrix, 56 const SkMatrix& viewMatrix,
56 const SkStrokeRec& strokeRec, 57 const SkStrokeRec& strokeRec,
57 const SkPath& path) const override; 58 const SkPath& path) const override;
58 virtual bool directFilterRRectMaskGPU(GrContext* context, 59 virtual bool directFilterRRectMaskGPU(GrContext* context,
59 GrRenderTarget* rt, 60 GrRenderTarget* rt,
60 GrPaint* grp, 61 GrPaint* grp,
61 const GrClip&, 62 const GrClip&,
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 GrTexture**) { 828 GrTexture**) {
828 float sigma = random->nextRangeF(3,8); 829 float sigma = random->nextRangeF(3,8);
829 float width = random->nextRangeF(200,300); 830 float width = random->nextRangeF(200,300);
830 float height = random->nextRangeF(200,300); 831 float height = random->nextRangeF(200,300);
831 return GrRectBlurEffect::Create(context->textureProvider(), SkRect::MakeWH(w idth, height), 832 return GrRectBlurEffect::Create(context->textureProvider(), SkRect::MakeWH(w idth, height),
832 sigma); 833 sigma);
833 } 834 }
834 835
835 836
836 bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context, 837 bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context,
838 GrDrawContext* drawContext,
837 GrRenderTarget* rt, 839 GrRenderTarget* rt,
838 GrPaint* grp, 840 GrPaint* grp,
839 const GrClip& clip, 841 const GrClip& clip,
840 const SkMatrix& viewMatrix, 842 const SkMatrix& viewMatrix,
841 const SkStrokeRec& strokeRec, 843 const SkStrokeRec& strokeRec,
842 const SkPath& path) const { 844 const SkPath& path) const {
845 SkASSERT(drawContext);
846
843 if (fBlurStyle != kNormal_SkBlurStyle) { 847 if (fBlurStyle != kNormal_SkBlurStyle) {
844 return false; 848 return false;
845 } 849 }
846 850
847 SkRect rect; 851 SkRect rect;
848 if (!path.isRect(&rect)) { 852 if (!path.isRect(&rect)) {
849 return false; 853 return false;
850 } 854 }
851 855
852 if (!strokeRec.isFillStyle()) { 856 if (!strokeRec.isFillStyle()) {
853 return false; 857 return false;
854 } 858 }
855 859
856 SkMatrix ctm = viewMatrix; 860 SkScalar xformedSigma = this->computeXformedSigma(viewMatrix);
857 SkScalar xformedSigma = this->computeXformedSigma(ctm);
858 861
859 int pad=SkScalarCeilToInt(6*xformedSigma)/2; 862 int pad = SkScalarCeilToInt(6*xformedSigma)/2;
860 rect.outset(SkIntToScalar(pad), SkIntToScalar(pad)); 863 rect.outset(SkIntToScalar(pad), SkIntToScalar(pad));
861 864
862 SkAutoTUnref<GrFragmentProcessor> fp(GrRectBlurEffect::Create( 865 SkAutoTUnref<GrFragmentProcessor> fp(GrRectBlurEffect::Create(
863 context->textureProvider(), rect, xformedSigma)); 866 context->textureProvider(), rect, xformedSigma));
864 if (!fp) { 867 if (!fp) {
865 return false; 868 return false;
866 } 869 }
867 870
868 grp->addCoverageProcessor(fp); 871 grp->addCoverageProcessor(fp);
869 872
870 SkMatrix inverse; 873 SkMatrix inverse;
871 if (!viewMatrix.invert(&inverse)) { 874 if (!viewMatrix.invert(&inverse)) {
872 return false; 875 return false;
873 } 876 }
874 877
875 GrDrawContext* drawContext = context->drawContext(); 878 drawContext->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), rec t, inverse);
876 if (drawContext) { 879 return true;
877 drawContext->drawNonAARectWithLocalMatrix(rt, clip, *grp, SkMatrix::I(), rect, inverse);
878 return true;
879 }
880
881 return false;
882 } 880 }
883 881
884 class GrRRectBlurEffect : public GrFragmentProcessor { 882 class GrRRectBlurEffect : public GrFragmentProcessor {
885 public: 883 public:
886 884
887 static GrFragmentProcessor* Create(GrContext* context, float sigma, const Sk RRect&); 885 static GrFragmentProcessor* Create(GrContext* context, float sigma, const Sk RRect&);
888 886
889 virtual ~GrRRectBlurEffect() {}; 887 virtual ~GrRRectBlurEffect() {};
890 const char* name() const override { return "GrRRectBlur"; } 888 const char* name() const override { return "GrRRectBlur"; }
891 889
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 } else { 1289 } else {
1292 str->append("None"); 1290 str->append("None");
1293 } 1291 }
1294 str->append("))"); 1292 str->append("))");
1295 } 1293 }
1296 #endif 1294 #endif
1297 1295
1298 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) 1296 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
1299 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) 1297 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
1300 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1298 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698