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

Unified Diff: src/core/SkMaskFilter.cpp

Issue 729463002: Cache blur mask for rects which can not break into nine-patch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix memory leak Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkMaskCache.cpp ('k') | src/effects/SkBlurMaskFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkMaskFilter.cpp
diff --git a/src/core/SkMaskFilter.cpp b/src/core/SkMaskFilter.cpp
index c9783e76d6113e7bd9abb9a800341a1d83591c42..be4ec9e9e6f3d442231a18fb15075d3c537a5005 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,42 @@ 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) {
+ SkScalar scaledSigma = matrix.mapRadius(rec.fSigma);
+ if (!SkMaskCache::FindAndCopy(scaledSigma, rec.fStyle, rec.fQuality,
reed1 2015/01/08 15:51:21 I think it will be easier to read if we change thi
qiankun 2015/01/12 04:36:26 Done.
+ rects, rectCount, &dstM)) {
+ if (!this->filterMask(&dstM, srcM, matrix, NULL)) {
+ return false;
+ }
+ SkMaskCache::AddAndCopy(scaledSigma, 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
reed1 2015/01/08 15:51:21 I'm afraid I still don't understand the scenario t
qiankun 2015/01/12 04:36:26 It was used to handle clipping bounds. Now, the ne
+ // size of the cached mask.
+ if (dstM.fBounds.width() != tmpDst.fBounds.width() ||
+ dstM.fBounds.height() != tmpDst.fBounds.height()) {
+ SkMask::FreeImage(dstM.fImage);
+ 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
« no previous file with comments | « src/core/SkMaskCache.cpp ('k') | src/effects/SkBlurMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698