aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar krajcevski <krajcevski@google.com>2014-07-21 09:54:23 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-21 09:54:23 -0700
commit75f88512a1b74ebb1bbb4f0046e43f1a5a234320 (patch)
treec82c3f4c261b84e21824d83085c7297d2297705f /src
parent63e99f7a03b2ac90ae7a00232674fd39c0bdcc68 (diff)
Let blitters be notified when they're done being used
R=reed@google.com, robertphillips@google.com Author: krajcevski@google.com Review URL: https://codereview.chromium.org/399593007
Diffstat (limited to 'src')
-rw-r--r--src/core/SkBlitter.h22
-rw-r--r--src/core/SkScan_AntiPath.cpp3
2 files changed, 23 insertions, 2 deletions
diff --git a/src/core/SkBlitter.h b/src/core/SkBlitter.h
index 0f1006fcfb..992eb86fa0 100644
--- a/src/core/SkBlitter.h
+++ b/src/core/SkBlitter.h
@@ -76,6 +76,16 @@ public:
*/
virtual int requestRowsPreserved() const { return 1; }
+ /**
+ * This function allocates memory for the blitter that the blitter then owns.
+ * The memory can be used by the calling function at will, but it will be
+ * released when the blitter's destructor is called. This function returns
+ * NULL if no persistent memory is needed by the blitter.
+ */
+ virtual void* allocBlitMemory(size_t sz) {
+ return fBlitMemory.reset(sz, SkAutoMalloc::kReuse_OnShrink);
+ }
+
///@name non-virtual helpers
void blitMaskRegion(const SkMask& mask, const SkRegion& clip);
void blitRectRegion(const SkIRect& rect, const SkRegion& clip);
@@ -98,6 +108,10 @@ public:
SkTBlitterAllocator*);
///@}
+protected:
+
+ SkAutoMalloc fBlitMemory;
+
private:
};
@@ -137,6 +151,10 @@ public:
virtual void blitMask(const SkMask&, const SkIRect& clip) SK_OVERRIDE;
virtual const SkBitmap* justAnOpaqueColor(uint32_t* value) SK_OVERRIDE;
+ virtual void* allocBlitMemory(size_t sz) SK_OVERRIDE {
+ return fBlitter->allocBlitMemory(sz);
+ }
+
private:
SkBlitter* fBlitter;
SkIRect fClipRect;
@@ -164,6 +182,10 @@ public:
virtual void blitMask(const SkMask&, const SkIRect& clip) SK_OVERRIDE;
virtual const SkBitmap* justAnOpaqueColor(uint32_t* value) SK_OVERRIDE;
+ virtual void* allocBlitMemory(size_t sz) SK_OVERRIDE {
+ return fBlitter->allocBlitMemory(sz);
+ }
+
private:
SkBlitter* fBlitter;
const SkRegion* fRgn;
diff --git a/src/core/SkScan_AntiPath.cpp b/src/core/SkScan_AntiPath.cpp
index 0943646ce8..b7d470715d 100644
--- a/src/core/SkScan_AntiPath.cpp
+++ b/src/core/SkScan_AntiPath.cpp
@@ -108,7 +108,6 @@ public:
virtual ~SuperBlitter() {
this->flush();
- sk_free(fRunsBuffer);
}
/// Once fRuns contains a complete supersampled row, flush() blits
@@ -154,7 +153,7 @@ SuperBlitter::SuperBlitter(SkBlitter* realBlitter, const SkIRect& ir,
const SkRegion& clip)
: BaseSuperBlitter(realBlitter, ir, clip) {
fRunsToBuffer = realBlitter->requestRowsPreserved();
- fRunsBuffer = sk_malloc_throw(fRunsToBuffer * this->getRunsSz());
+ fRunsBuffer = realBlitter->allocBlitMemory(fRunsToBuffer * this->getRunsSz());
fCurrentRun = -1;
this->advanceRuns();