Index: src/core/SkMaskFilter.cpp |
diff --git a/src/core/SkMaskFilter.cpp b/src/core/SkMaskFilter.cpp |
index 28c9a381d3162376275a23a5cfea6ebbaae4ead2..db2e7c91486428b3c0b6bf508c6e99e263c33db0 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,34 @@ 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 |
reed1
2014/12/22 21:38:16
This 4-part predicate may be correct, but it is pr
qiankun
2014/12/23 10:54:32
What about the latest implementation?
|
+ || (this->asABlur(&rec) && !SkMaskCache::FindCachedRects(&dstM, matrix.mapRadius(rec.fSigma), rec.fStyle, |
+ rec.fQuality, rects, rectCount))) { |
+ if (!this->filterMask(&dstM, srcM, matrix, NULL)) { |
+ return false; |
+ } |
+ if (this->asABlur(&rec) && rectCount) { |
+ SkMaskCache::AddCachedRects(dstM, matrix.mapRadius(rec.fSigma), rec.fStyle, rec.fQuality, rects, rectCount); |
+ } |
+ } 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()) { |
+ this->filterMask(&dstM, srcM, matrix, NULL); |
+ } else { |
+ dstM.fBounds = tmpDst.fBounds; |
+ } |
} |
+ |
SkAutoMaskFreeImage autoDst(dstM.fImage); |
// if we get here, we need to (possibly) resolve the clip and blitter |