OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkBlurMaskFilter.h" | 8 #include "SkBlurMaskFilter.h" |
9 #include "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
10 #include "SkGpuBlurUtils.h" | 10 #include "SkGpuBlurUtils.h" |
11 #include "SkReadBuffer.h" | 11 #include "SkReadBuffer.h" |
12 #include "SkWriteBuffer.h" | 12 #include "SkWriteBuffer.h" |
13 #include "SkMaskFilter.h" | 13 #include "SkMaskFilter.h" |
14 #include "SkRRect.h" | 14 #include "SkRRect.h" |
15 #include "SkStringUtils.h" | 15 #include "SkStringUtils.h" |
16 #include "SkStrokeRec.h" | 16 #include "SkStrokeRec.h" |
17 | 17 |
18 #if SK_SUPPORT_GPU | 18 #if SK_SUPPORT_GPU |
19 #include "GrCircleBlurFragmentProcessor.h" | 19 #include "GrCircleBlurFragmentProcessor.h" |
20 #include "GrContext.h" | 20 #include "GrContext.h" |
21 #include "GrDrawContext.h" | 21 #include "GrDrawContext.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 "GrStyle.h" | 25 #include "SkDraw.h" |
26 #include "effects/GrSimpleTextureEffect.h" | 26 #include "effects/GrSimpleTextureEffect.h" |
27 #include "glsl/GrGLSLFragmentProcessor.h" | 27 #include "glsl/GrGLSLFragmentProcessor.h" |
28 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 28 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
29 #include "glsl/GrGLSLProgramDataManager.h" | 29 #include "glsl/GrGLSLProgramDataManager.h" |
30 #include "glsl/GrGLSLSampler.h" | 30 #include "glsl/GrGLSLSampler.h" |
31 #include "glsl/GrGLSLUniformHandler.h" | 31 #include "glsl/GrGLSLUniformHandler.h" |
32 #endif | 32 #endif |
33 | 33 |
34 SkScalar SkBlurMaskFilter::ConvertRadiusToSigma(SkScalar radius) { | 34 SkScalar SkBlurMaskFilter::ConvertRadiusToSigma(SkScalar radius) { |
35 return SkBlurMask::ConvertRadiusToSigma(radius); | 35 return SkBlurMask::ConvertRadiusToSigma(radius); |
(...skipping 13 matching lines...) Expand all Loading... |
49 const SkIRect& clipBounds, | 49 const SkIRect& clipBounds, |
50 const SkMatrix& ctm, | 50 const SkMatrix& ctm, |
51 SkRect* maskRect) const override; | 51 SkRect* maskRect) const override; |
52 bool directFilterMaskGPU(GrTextureProvider* texProvider, | 52 bool directFilterMaskGPU(GrTextureProvider* texProvider, |
53 GrDrawContext* drawContext, | 53 GrDrawContext* drawContext, |
54 GrPaint* grp, | 54 GrPaint* grp, |
55 const GrClip&, | 55 const GrClip&, |
56 const SkMatrix& viewMatrix, | 56 const SkMatrix& viewMatrix, |
57 const SkStrokeRec& strokeRec, | 57 const SkStrokeRec& strokeRec, |
58 const SkPath& path) const override; | 58 const SkPath& path) const override; |
59 bool directFilterRRectMaskGPU(GrContext*, | 59 bool directFilterRRectMaskGPU(GrTextureProvider* texProvider, |
60 GrDrawContext* drawContext, | 60 GrDrawContext* drawContext, |
61 GrPaint* grp, | 61 GrPaint* grp, |
62 const GrClip&, | 62 const GrClip&, |
63 const SkMatrix& viewMatrix, | 63 const SkMatrix& viewMatrix, |
64 const SkStrokeRec& strokeRec, | 64 const SkStrokeRec& strokeRec, |
65 const SkRRect& rrect) const override; | 65 const SkRRect& rrect) const override; |
66 bool filterMaskGPU(GrTexture* src, | 66 bool filterMaskGPU(GrTexture* src, |
67 const SkMatrix& ctm, | 67 const SkMatrix& ctm, |
68 const SkIRect& maskRect, | 68 const SkIRect& maskRect, |
69 GrTexture** result) const override; | 69 GrTexture** result) const override; |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 | 903 |
904 drawContext->fillRectWithLocalMatrix(clip, *grp, SkMatrix::I(), rect, invers
e); | 904 drawContext->fillRectWithLocalMatrix(clip, *grp, SkMatrix::I(), rect, invers
e); |
905 return true; | 905 return true; |
906 } | 906 } |
907 | 907 |
908 ////////////////////////////////////////////////////////////////////////////// | 908 ////////////////////////////////////////////////////////////////////////////// |
909 | 909 |
910 class GrRRectBlurEffect : public GrFragmentProcessor { | 910 class GrRRectBlurEffect : public GrFragmentProcessor { |
911 public: | 911 public: |
912 | 912 |
913 static sk_sp<GrFragmentProcessor> Make(GrContext*, float sigma, const SkRRec
t&); | 913 static sk_sp<GrFragmentProcessor> Make(GrTextureProvider*, float sigma, cons
t SkRRect&); |
914 | 914 |
915 virtual ~GrRRectBlurEffect() {}; | 915 virtual ~GrRRectBlurEffect() {}; |
916 const char* name() const override { return "GrRRectBlur"; } | 916 const char* name() const override { return "GrRRectBlur"; } |
917 | 917 |
918 const SkRRect& getRRect() const { return fRRect; } | 918 const SkRRect& getRRect() const { return fRRect; } |
919 float getSigma() const { return fSigma; } | 919 float getSigma() const { return fSigma; } |
920 | 920 |
921 private: | 921 private: |
922 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; | 922 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
923 | 923 |
924 GrRRectBlurEffect(float sigma, const SkRRect&, GrTexture* profileTexture); | 924 GrRRectBlurEffect(float sigma, const SkRRect&, GrTexture* profileTexture); |
925 | 925 |
926 virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps, | 926 virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
927 GrProcessorKeyBuilder* b) const override; | 927 GrProcessorKeyBuilder* b) const override; |
928 | 928 |
929 bool onIsEqual(const GrFragmentProcessor& other) const override; | 929 bool onIsEqual(const GrFragmentProcessor& other) const override; |
930 | 930 |
931 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; | 931 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; |
932 | 932 |
933 SkRRect fRRect; | 933 SkRRect fRRect; |
934 float fSigma; | 934 float fSigma; |
935 GrTextureAccess fNinePatchAccess; | 935 GrTextureAccess fNinePatchAccess; |
936 | 936 |
937 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 937 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
938 | 938 |
939 typedef GrFragmentProcessor INHERITED; | 939 typedef GrFragmentProcessor INHERITED; |
940 }; | 940 }; |
941 | 941 |
942 bool SkBlurMaskFilter::ComputeBlurredRRectParams(const SkRRect& rrect, | |
943 SkScalar sigma, | |
944 SkRRect* rrectToDraw, | |
945 SkISize* widthHeight, | |
946 SkScalar xs[4], | |
947 int* numXs, | |
948 SkScalar ys[4], | |
949 int* numYs) { | |
950 unsigned int blurRadius = 3*SkScalarCeilToInt(sigma-1/6.0f); | |
951 | 942 |
952 const SkRect& orig = rrect.getBounds(); | 943 sk_sp<GrFragmentProcessor> GrRRectBlurEffect::Make(GrTextureProvider* texProvide
r, float sigma, |
953 const SkVector& radiiUL = rrect.radii(SkRRect::kUpperLeft_Corner); | 944 const SkRRect& rrect) { |
954 const SkVector& radiiUR = rrect.radii(SkRRect::kUpperRight_Corner); | 945 if (rrect.isCircle()) { |
955 const SkVector& radiiLR = rrect.radii(SkRRect::kLowerRight_Corner); | 946 return GrCircleBlurFragmentProcessor::Make(texProvider, rrect.rect(), si
gma); |
956 const SkVector& radiiLL = rrect.radii(SkRRect::kLowerLeft_Corner); | |
957 | |
958 const int left = SkScalarCeilToInt(SkTMax<SkScalar>(radiiUL.fX, radiiLL.fX)
); | |
959 const int top = SkScalarCeilToInt(SkTMax<SkScalar>(radiiUL.fY, radiiUR.fY)
); | |
960 const int right = SkScalarCeilToInt(SkTMax<SkScalar>(radiiUR.fX, radiiLR.fX)
); | |
961 const int bot = SkScalarCeilToInt(SkTMax<SkScalar>(radiiLL.fY, radiiLR.fY)
); | |
962 | |
963 // This is a conservative check for nine-patchability | |
964 if (orig.fLeft + left + blurRadius >= orig.fRight - right - blurRadius || | |
965 orig.fTop + top + blurRadius >= orig.fBottom - bot - blurRadius) { | |
966 return false; | |
967 } | 947 } |
968 | 948 |
969 int newRRWidth, newRRHeight; | |
970 | |
971 // 3x3 case | |
972 newRRWidth = 2*blurRadius + left + right + 1; | |
973 newRRHeight = 2*blurRadius + top + bot + 1; | |
974 widthHeight->fWidth = newRRWidth + 2 * blurRadius; | |
975 widthHeight->fHeight = newRRHeight + 2 * blurRadius; | |
976 // TODO: need to return non-normalized indices | |
977 xs[0] = 0.0f; | |
978 xs[1] = (blurRadius + left) / (float) widthHeight->fWidth; | |
979 xs[2] = (blurRadius + left + 1.0f) / widthHeight->fWidth; | |
980 xs[3] = 1.0f; | |
981 *numXs = 4; | |
982 ys[0] = 0.0f; | |
983 ys[1] = (blurRadius + top) / (float) widthHeight->fHeight; | |
984 ys[2] = (blurRadius + top + 1.0f) / widthHeight->fHeight; | |
985 ys[3] = 1.0f; | |
986 *numYs = 4; | |
987 | |
988 const SkRect newRect = SkRect::MakeXYWH(SkIntToScalar(blurRadius), SkIntToSc
alar(blurRadius), | |
989 SkIntToScalar(newRRWidth), SkIntToSc
alar(newRRHeight)); | |
990 SkVector newRadii[4]; | |
991 newRadii[0] = { SkScalarCeilToScalar(radiiUL.fX), SkScalarCeilToScalar(radii
UL.fY) }; | |
992 newRadii[1] = { SkScalarCeilToScalar(radiiUR.fX), SkScalarCeilToScalar(radii
UR.fY) }; | |
993 newRadii[2] = { SkScalarCeilToScalar(radiiLR.fX), SkScalarCeilToScalar(radii
LR.fY) }; | |
994 newRadii[3] = { SkScalarCeilToScalar(radiiLL.fX), SkScalarCeilToScalar(radii
LL.fY) }; | |
995 | |
996 rrectToDraw->setRectRadii(newRect, newRadii); | |
997 return true; | |
998 } | |
999 | |
1000 static sk_sp<GrTexture> make_rrect_blur_mask(GrContext* context, | |
1001 const SkRRect& rrect, | |
1002 float sigma) { | |
1003 SkRRect rrectToDraw; | |
1004 SkISize size; | |
1005 SkScalar xs[4], ys[4]; | |
1006 int numXs, numYs; | |
1007 | |
1008 SkBlurMaskFilter::ComputeBlurredRRectParams(rrect, sigma, &rrectToDraw, &siz
e, | |
1009 xs, &numXs, ys, &numYs); | |
1010 | |
1011 // TODO: this could be approx but the texture coords will need to be updated | |
1012 sk_sp<GrDrawContext> dc(context->makeDrawContext(SkBackingFit::kExact, | |
1013 size.fWidth, size.fHeight, | |
1014 kAlpha_8_GrPixelConfig, nul
lptr)); | |
1015 if (!dc) { | |
1016 return nullptr; | |
1017 } | |
1018 | |
1019 GrPaint grPaint; | |
1020 | |
1021 dc->clear(nullptr, SK_ColorTRANSPARENT, true); | |
1022 dc->drawRRect(GrNoClip(), grPaint, SkMatrix::I(), rrectToDraw, GrStyle::Simp
leFill()); | |
1023 | |
1024 sk_sp<GrDrawContext> dc2(SkGpuBlurUtils::GaussianBlur(context, | |
1025 dc->asTexture().releas
e(), | |
1026 nullptr, | |
1027 SkIRect::MakeWH(size.f
Width, | |
1028 size.f
Height), | |
1029 nullptr, | |
1030 sigma, sigma, SkBackin
gFit::kExact)); | |
1031 if (!dc2) { | |
1032 return nullptr; | |
1033 } | |
1034 | |
1035 return dc2->asTexture(); | |
1036 } | |
1037 | |
1038 sk_sp<GrFragmentProcessor> GrRRectBlurEffect::Make(GrContext* context, float sig
ma, | |
1039 const SkRRect& rrect) { | |
1040 if (rrect.isCircle()) { | |
1041 return GrCircleBlurFragmentProcessor::Make(context->textureProvider(), | |
1042 rrect.rect(), sigma); | |
1043 } | |
1044 | |
1045 // TODO: loosen this up | |
1046 if (!rrect.isSimpleCircular()) { | 949 if (!rrect.isSimpleCircular()) { |
1047 return nullptr; | 950 return nullptr; |
1048 } | 951 } |
1049 | 952 |
1050 // Make sure we can successfully ninepatch this rrect -- the blur sigma has
to be | 953 // Make sure we can successfully ninepatch this rrect -- the blur sigma has
to be |
1051 // sufficiently small relative to both the size of the corner radius and the | 954 // sufficiently small relative to both the size of the corner radius and the |
1052 // width (and height) of the rrect. | 955 // width (and height) of the rrect. |
1053 | 956 |
1054 unsigned int blurRadius = 3*SkScalarCeilToInt(sigma-1/6.0f); | 957 unsigned int blurRadius = 3*SkScalarCeilToInt(sigma-1/6.0f); |
1055 unsigned int cornerRadius = SkScalarCeilToInt(rrect.getSimpleRadii().x()); | 958 unsigned int cornerRadius = SkScalarCeilToInt(rrect.getSimpleRadii().x()); |
1056 if (cornerRadius + blurRadius > rrect.width()/2 || | 959 if (cornerRadius + blurRadius > rrect.width()/2 || |
1057 cornerRadius + blurRadius > rrect.height()/2) { | 960 cornerRadius + blurRadius > rrect.height()/2) { |
1058 return nullptr; | 961 return nullptr; |
1059 } | 962 } |
1060 | 963 |
1061 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); | 964 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); |
1062 GrUniqueKey key; | 965 GrUniqueKey key; |
1063 GrUniqueKey::Builder builder(&key, kDomain, 2); | 966 GrUniqueKey::Builder builder(&key, kDomain, 2); |
1064 builder[0] = blurRadius; | 967 builder[0] = blurRadius; |
1065 builder[1] = cornerRadius; | 968 builder[1] = cornerRadius; |
1066 builder.finish(); | 969 builder.finish(); |
1067 | 970 |
1068 sk_sp<GrTexture> blurNinePatchTexture( | 971 SkAutoTUnref<GrTexture> blurNinePatchTexture(texProvider->findAndRefTextureB
yUniqueKey(key)); |
1069 context->textureProvider()->findAndRefTextureByU
niqueKey(key)); | |
1070 | 972 |
1071 if (!blurNinePatchTexture) { | 973 if (!blurNinePatchTexture) { |
1072 blurNinePatchTexture = make_rrect_blur_mask(context, rrect, sigma); | 974 SkMask mask; |
| 975 |
| 976 unsigned int smallRectSide = 2*(blurRadius + cornerRadius) + 1; |
| 977 |
| 978 mask.fBounds = SkIRect::MakeWH(smallRectSide, smallRectSide); |
| 979 mask.fFormat = SkMask::kA8_Format; |
| 980 mask.fRowBytes = mask.fBounds.width(); |
| 981 mask.fImage = SkMask::AllocImage(mask.computeTotalImageSize()); |
| 982 SkAutoMaskFreeImage amfi(mask.fImage); |
| 983 |
| 984 memset(mask.fImage, 0, mask.computeTotalImageSize()); |
| 985 |
| 986 SkRect smallRect; |
| 987 smallRect.setWH(SkIntToScalar(smallRectSide), SkIntToScalar(smallRectSid
e)); |
| 988 |
| 989 SkRRect smallRRect; |
| 990 smallRRect.setRectXY(smallRect, SkIntToScalar(cornerRadius), SkIntToScal
ar(cornerRadius)); |
| 991 |
| 992 SkPath path; |
| 993 path.addRRect(smallRRect); |
| 994 |
| 995 SkDraw::DrawToMask(path, &mask.fBounds, nullptr, nullptr, &mask, |
| 996 SkMask::kJustRenderImage_CreateMode, SkStrokeRec::kFi
ll_InitStyle); |
| 997 |
| 998 SkMask blurredMask; |
| 999 if (!SkBlurMask::BoxBlur(&blurredMask, mask, sigma, kNormal_SkBlurStyle, |
| 1000 kHigh_SkBlurQuality, nullptr, true)) { |
| 1001 return nullptr; |
| 1002 } |
| 1003 |
| 1004 unsigned int texSide = smallRectSide + 2*blurRadius; |
| 1005 GrSurfaceDesc texDesc; |
| 1006 texDesc.fWidth = texSide; |
| 1007 texDesc.fHeight = texSide; |
| 1008 texDesc.fConfig = kAlpha_8_GrPixelConfig; |
| 1009 texDesc.fIsMipMapped = false; |
| 1010 |
| 1011 blurNinePatchTexture.reset( |
| 1012 texProvider->createTexture(texDesc, SkBudgeted::kYes , blurredMask.f
Image, 0)); |
| 1013 SkMask::FreeImage(blurredMask.fImage); |
1073 if (!blurNinePatchTexture) { | 1014 if (!blurNinePatchTexture) { |
1074 return nullptr; | 1015 return nullptr; |
1075 } | 1016 } |
1076 context->textureProvider()->assignUniqueKeyToTexture(key, blurNinePatchT
exture.get()); | 1017 texProvider->assignUniqueKeyToTexture(key, blurNinePatchTexture); |
1077 } | 1018 } |
1078 return sk_sp<GrFragmentProcessor>(new GrRRectBlurEffect(sigma, rrect, blurNi
nePatchTexture.get())); | 1019 return sk_sp<GrFragmentProcessor>(new GrRRectBlurEffect(sigma, rrect, blurNi
nePatchTexture)); |
1079 } | 1020 } |
1080 | 1021 |
1081 void GrRRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ | 1022 void GrRRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ |
1082 inout->mulByUnknownSingleComponent(); | 1023 inout->mulByUnknownSingleComponent(); |
1083 } | 1024 } |
1084 | 1025 |
1085 GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTextur
e *ninePatchTexture) | 1026 GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTextur
e *ninePatchTexture) |
1086 : fRRect(rrect), | 1027 : fRRect(rrect), |
1087 fSigma(sigma), | 1028 fSigma(sigma), |
1088 fNinePatchAccess(ninePatchTexture) { | 1029 fNinePatchAccess(ninePatchTexture) { |
(...skipping 13 matching lines...) Expand all Loading... |
1102 | 1043 |
1103 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRRectBlurEffect); | 1044 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRRectBlurEffect); |
1104 | 1045 |
1105 sk_sp<GrFragmentProcessor> GrRRectBlurEffect::TestCreate(GrProcessorTestData* d)
{ | 1046 sk_sp<GrFragmentProcessor> GrRRectBlurEffect::TestCreate(GrProcessorTestData* d)
{ |
1106 SkScalar w = d->fRandom->nextRangeScalar(100.f, 1000.f); | 1047 SkScalar w = d->fRandom->nextRangeScalar(100.f, 1000.f); |
1107 SkScalar h = d->fRandom->nextRangeScalar(100.f, 1000.f); | 1048 SkScalar h = d->fRandom->nextRangeScalar(100.f, 1000.f); |
1108 SkScalar r = d->fRandom->nextRangeF(1.f, 9.f); | 1049 SkScalar r = d->fRandom->nextRangeF(1.f, 9.f); |
1109 SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f); | 1050 SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f); |
1110 SkRRect rrect; | 1051 SkRRect rrect; |
1111 rrect.setRectXY(SkRect::MakeWH(w, h), r, r); | 1052 rrect.setRectXY(SkRect::MakeWH(w, h), r, r); |
1112 return GrRRectBlurEffect::Make(d->fContext, sigma, rrect); | 1053 return GrRRectBlurEffect::Make(d->fContext->textureProvider(), sigma, rrect)
; |
1113 } | 1054 } |
1114 | 1055 |
1115 ////////////////////////////////////////////////////////////////////////////// | 1056 ////////////////////////////////////////////////////////////////////////////// |
1116 | 1057 |
1117 class GrGLRRectBlurEffect : public GrGLSLFragmentProcessor { | 1058 class GrGLRRectBlurEffect : public GrGLSLFragmentProcessor { |
1118 public: | 1059 public: |
1119 void emitCode(EmitArgs&) override; | 1060 void emitCode(EmitArgs&) override; |
1120 | 1061 |
1121 protected: | 1062 protected: |
1122 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override
; | 1063 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override
; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1205 | 1146 |
1206 void GrRRectBlurEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, | 1147 void GrRRectBlurEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
1207 GrProcessorKeyBuilder* b) const { | 1148 GrProcessorKeyBuilder* b) const { |
1208 GrGLRRectBlurEffect::GenKey(*this, caps, b); | 1149 GrGLRRectBlurEffect::GenKey(*this, caps, b); |
1209 } | 1150 } |
1210 | 1151 |
1211 GrGLSLFragmentProcessor* GrRRectBlurEffect::onCreateGLSLInstance() const { | 1152 GrGLSLFragmentProcessor* GrRRectBlurEffect::onCreateGLSLInstance() const { |
1212 return new GrGLRRectBlurEffect; | 1153 return new GrGLRRectBlurEffect; |
1213 } | 1154 } |
1214 | 1155 |
1215 bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context, | 1156 bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrTextureProvider* texProvid
er, |
1216 GrDrawContext* drawContext, | 1157 GrDrawContext* drawContext, |
1217 GrPaint* grp, | 1158 GrPaint* grp, |
1218 const GrClip& clip, | 1159 const GrClip& clip, |
1219 const SkMatrix& viewMatrix, | 1160 const SkMatrix& viewMatrix, |
1220 const SkStrokeRec& strokeRec
, | 1161 const SkStrokeRec& strokeRec
, |
1221 const SkRRect& rrect) const
{ | 1162 const SkRRect& rrect) const
{ |
1222 SkASSERT(drawContext); | 1163 SkASSERT(drawContext); |
1223 | 1164 |
1224 if (fBlurStyle != kNormal_SkBlurStyle) { | 1165 if (fBlurStyle != kNormal_SkBlurStyle) { |
1225 return false; | 1166 return false; |
1226 } | 1167 } |
1227 | 1168 |
1228 if (!strokeRec.isFillStyle()) { | 1169 if (!strokeRec.isFillStyle()) { |
1229 return false; | 1170 return false; |
1230 } | 1171 } |
1231 | 1172 |
1232 SkScalar xformedSigma = this->computeXformedSigma(viewMatrix); | 1173 SkScalar xformedSigma = this->computeXformedSigma(viewMatrix); |
1233 | 1174 |
1234 sk_sp<GrFragmentProcessor> fp(GrRRectBlurEffect::Make(context, xformedSigma,
rrect)); | 1175 sk_sp<GrFragmentProcessor> fp(GrRRectBlurEffect::Make(texProvider, xformedSi
gma, rrect)); |
1235 if (!fp) { | 1176 if (!fp) { |
1236 return false; | 1177 return false; |
1237 } | 1178 } |
1238 | 1179 |
1239 grp->addCoverageFragmentProcessor(std::move(fp)); | 1180 grp->addCoverageFragmentProcessor(std::move(fp)); |
1240 | 1181 |
1241 SkMatrix inverse; | 1182 SkMatrix inverse; |
1242 if (!viewMatrix.invert(&inverse)) { | 1183 if (!viewMatrix.invert(&inverse)) { |
1243 return false; | 1184 return false; |
1244 } | 1185 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1372 } else { | 1313 } else { |
1373 str->append("None"); | 1314 str->append("None"); |
1374 } | 1315 } |
1375 str->append("))"); | 1316 str->append("))"); |
1376 } | 1317 } |
1377 #endif | 1318 #endif |
1378 | 1319 |
1379 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) | 1320 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) |
1380 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) | 1321 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) |
1381 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1322 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |