Chromium Code Reviews| Index: src/core/SkMaskFilter.cpp |
| diff --git a/src/core/SkMaskFilter.cpp b/src/core/SkMaskFilter.cpp |
| index c9783e76d6113e7bd9abb9a800341a1d83591c42..687adffcadd4cfe401a9db384f85d334d8d31cad 100644 |
| --- a/src/core/SkMaskFilter.cpp |
| +++ b/src/core/SkMaskFilter.cpp |
| @@ -10,6 +10,7 @@ |
| #include "SkMaskFilter.h" |
| #include "SkBlitter.h" |
| #include "SkDraw.h" |
| +#include "SkMaskCache.h" |
| #include "SkRasterClip.h" |
| #include "SkRRect.h" |
| #include "SkTypes.h" |
| @@ -263,9 +264,41 @@ bool SkMaskFilter::filterPath(const SkPath& devPath, const SkMatrix& matrix, |
| } |
| SkAutoMaskFreeImage autoSrc(srcM.fImage); |
| - if (!this->filterMask(&dstM, srcM, matrix, NULL)) { |
| - return false; |
| + BlurRec rec; |
| + if (this->asABlur(&rec) && rectCount) { |
| + if (!SkMaskCache::FindAndCopy(matrix.mapRadius(rec.fSigma), rec.fStyle, |
|
reed1
2015/01/07 16:45:46
nit: tmp variable caching the computed radius?
Sk
qiankun
2015/01/08 03:01:12
Done.
|
| + rec.fQuality, rects, rectCount, &dstM)) { |
| + if (!this->filterMask(&dstM, srcM, matrix, NULL)) { |
| + return false; |
| + } |
| + SkMaskCache::AddAndCopy(matrix.mapRadius(rec.fSigma), rec.fStyle, |
| + rec.fQuality, rects, rectCount, dstM); |
| + } else { |
| + // Compute the correct bounds of dst mask if dst mask is got from cache. |
| + SkMask tmpSrc, tmpDst; |
| + tmpSrc = srcM; |
| + tmpSrc.fImage = NULL; |
| + if (!this->filterMask(&tmpDst, tmpSrc, matrix, NULL)) { |
| + return false; |
| + } |
| + |
| + // Fallback to original calculation if size of bounds is different with |
| + // size of the cached mask. |
| + if (dstM.fBounds.width() != tmpDst.fBounds.width() || |
| + dstM.fBounds.height() != tmpDst.fBounds.height()) { |
| + if (this->filterMask(&dstM, srcM, matrix, NULL)) { |
| + return false; |
| + } |
| + } else { |
| + dstM.fBounds = tmpDst.fBounds; |
| + } |
| + } |
| + } else { |
| + if (!this->filterMask(&dstM, srcM, matrix, NULL)) { |
| + return false; |
| + } |
| } |
| + |
| SkAutoMaskFreeImage autoDst(dstM.fImage); |
| // if we get here, we need to (possibly) resolve the clip and blitter |