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" |
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 SkASSERT(mask); | 1151 SkASSERT(mask); |
1152 context->textureProvider()->assignUniqueKeyToTexture(key, mask.get()); | 1152 context->textureProvider()->assignUniqueKeyToTexture(key, mask.get()); |
1153 } | 1153 } |
1154 | 1154 |
1155 return mask; | 1155 return mask; |
1156 } | 1156 } |
1157 | 1157 |
1158 sk_sp<GrFragmentProcessor> GrRRectBlurEffect::Make(GrContext* context, | 1158 sk_sp<GrFragmentProcessor> GrRRectBlurEffect::Make(GrContext* context, |
1159 float sigma, float xformedSig
ma, | 1159 float sigma, float xformedSig
ma, |
1160 const SkRRect& srcRRect, cons
t SkRRect& devRRect) { | 1160 const SkRRect& srcRRect, cons
t SkRRect& devRRect) { |
1161 SkASSERT(!devRRect.isCircle()); // Should've been caught up-stream | 1161 SkASSERT(!devRRect.isCircle() && !devRRect.isRect()); // Should've been caug
ht up-stream |
1162 | 1162 |
1163 // TODO: loosen this up | 1163 // TODO: loosen this up |
1164 if (!devRRect.isSimpleCircular()) { | 1164 if (!devRRect.isSimpleCircular()) { |
1165 return nullptr; | 1165 return nullptr; |
1166 } | 1166 } |
1167 | 1167 |
1168 // Make sure we can successfully ninepatch this rrect -- the blur sigma has
to be | 1168 // Make sure we can successfully ninepatch this rrect -- the blur sigma has
to be |
1169 // sufficiently small relative to both the size of the corner radius and the | 1169 // sufficiently small relative to both the size of the corner radius and the |
1170 // width (and height) of the rrect. | 1170 // width (and height) of the rrect. |
1171 SkRRect rrectToDraw; | 1171 SkRRect rrectToDraw; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1344 if (fBlurStyle != kNormal_SkBlurStyle) { | 1344 if (fBlurStyle != kNormal_SkBlurStyle) { |
1345 return false; | 1345 return false; |
1346 } | 1346 } |
1347 | 1347 |
1348 if (!strokeRec.isFillStyle()) { | 1348 if (!strokeRec.isFillStyle()) { |
1349 return false; | 1349 return false; |
1350 } | 1350 } |
1351 | 1351 |
1352 SkScalar xformedSigma = this->computeXformedSigma(viewMatrix); | 1352 SkScalar xformedSigma = this->computeXformedSigma(viewMatrix); |
1353 | 1353 |
1354 if (devRRect.isCircle()) { | 1354 if (devRRect.isRect() || devRRect.isCircle()) { |
1355 sk_sp<GrFragmentProcessor> fp(GrCircleBlurFragmentProcessor::Make( | 1355 if (this->ignoreXform()) { |
1356 context-
>textureProvider(), | 1356 return false; |
1357 devRRect
.rect(), | 1357 } |
1358 xformedS
igma)); | 1358 |
| 1359 sk_sp<GrFragmentProcessor> fp; |
| 1360 if (devRRect.isRect()) { |
| 1361 SkScalar pad = 3.0f * xformedSigma; |
| 1362 const SkRect dstCoverageRect = devRRect.rect().makeOutset(pad, pad); |
| 1363 |
| 1364 fp = GrRectBlurEffect::Make(context->textureProvider(), dstCoverageR
ect, xformedSigma); |
| 1365 } else { |
| 1366 fp = GrCircleBlurFragmentProcessor::Make(context->textureProvider(), |
| 1367 devRRect.rect(), |
| 1368 xformedSigma); |
| 1369 } |
| 1370 |
1359 if (!fp) { | 1371 if (!fp) { |
1360 return false; | 1372 return false; |
1361 } | 1373 } |
1362 | 1374 |
1363 GrPaint newPaint(*grp); | 1375 GrPaint newPaint(*grp); |
1364 newPaint.addCoverageFragmentProcessor(std::move(fp)); | 1376 newPaint.addCoverageFragmentProcessor(std::move(fp)); |
1365 newPaint.setAntiAlias(false); | 1377 newPaint.setAntiAlias(false); |
1366 | 1378 |
1367 SkRect srcProxyRect = srcRRect.rect(); | 1379 SkRect srcProxyRect = srcRRect.rect(); |
1368 srcProxyRect.outset(3.0f*fSigma, 3.0f*fSigma); | 1380 srcProxyRect.outset(3.0f*fSigma, 3.0f*fSigma); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1550 } else { | 1562 } else { |
1551 str->append("None"); | 1563 str->append("None"); |
1552 } | 1564 } |
1553 str->append("))"); | 1565 str->append("))"); |
1554 } | 1566 } |
1555 #endif | 1567 #endif |
1556 | 1568 |
1557 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) | 1569 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) |
1558 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) | 1570 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) |
1559 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1571 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |