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

Unified Diff: src/core/SkMaskFilter.cpp

Issue 889303005: return reference to cache instead of copying the mask (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: reorder declarations Created 5 years, 10 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/SkMask.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..ee58b7433f81a59c0d60101bdc1fa4b921c0cc3f 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 "SkCachedData.h"
#include "SkRasterClip.h"
#include "SkRRect.h"
#include "SkTypes.h"
@@ -20,6 +21,15 @@
#include "SkGrPixelRef.h"
#endif
+SkMaskFilter::NinePatch::~NinePatch() {
+ if (fCache) {
+ SkASSERT((const void*)fMask.fImage == fCache->data());
+ fCache->unref();
+ } else {
+ SkMask::FreeImage(fMask.fImage);
+ }
+}
+
bool SkMaskFilter::filterMask(SkMask*, const SkMask&, const SkMatrix&,
SkIPoint*) const {
return false;
@@ -219,7 +229,6 @@ bool SkMaskFilter::filterRRect(const SkRRect& devRRect, const SkMatrix& matrix,
return false;
}
draw_nine(patch.fMask, patch.fOuterRect, patch.fCenter, true, clip, blitter);
- SkMask::FreeImage(patch.fMask.fImage);
return true;
}
@@ -234,9 +243,7 @@ bool SkMaskFilter::filterPath(const SkPath& devPath, const SkMatrix& matrix,
if (rectCount > 0) {
NinePatch patch;
- patch.fMask.fImage = NULL;
- switch (this->filterRectsToNine(rects, rectCount, matrix,
- clip.getBounds(), &patch)) {
+ switch (this->filterRectsToNine(rects, rectCount, matrix, clip.getBounds(), &patch)) {
case kFalse_FilterReturn:
SkASSERT(NULL == patch.fMask.fImage);
return false;
@@ -244,7 +251,6 @@ bool SkMaskFilter::filterPath(const SkPath& devPath, const SkMatrix& matrix,
case kTrue_FilterReturn:
draw_nine(patch.fMask, patch.fOuterRect, patch.fCenter, 1 == rectCount, clip,
blitter);
- SkMask::FreeImage(patch.fMask.fImage);
return true;
case kUnimplemented_FilterReturn:
« no previous file with comments | « src/core/SkMask.cpp ('k') | src/effects/SkBlurMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698