Index: src/core/SkDrawLooper.cpp |
diff --git a/src/core/SkDrawLooper.cpp b/src/core/SkDrawLooper.cpp |
index bac2d969c0505d318fe7881c638c1a4750544fd3..56d76fffc141ac124f4b8bdce1b6a58df7182da5 100644 |
--- a/src/core/SkDrawLooper.cpp |
+++ b/src/core/SkDrawLooper.cpp |
@@ -13,31 +13,37 @@ |
bool SkDrawLooper::canComputeFastBounds(const SkPaint& paint) { |
SkCanvas canvas; |
+ uint32_t storage[kDrawLooperContextStorageLongCount]; |
- this->init(&canvas); |
+ SkDrawLooper::DrawContext* context = |
+ this->init(&canvas, storage, sizeof(storage)); |
for (;;) { |
SkPaint p(paint); |
- if (this->next(&canvas, &p)) { |
+ if (context->next(&canvas, &p)) { |
p.setLooper(NULL); |
if (!p.canComputeFastBounds()) { |
+ context->cleanup(storage); |
return false; |
} |
} else { |
break; |
} |
} |
+ context->cleanup(storage); |
return true; |
} |
void SkDrawLooper::computeFastBounds(const SkPaint& paint, const SkRect& src, |
SkRect* dst) { |
SkCanvas canvas; |
+ uint32_t storage[kDrawLooperContextStorageLongCount]; |
*dst = src; // catch case where there are no loops |
- this->init(&canvas); |
+ SkDrawLooper::DrawContext* context = this->init( |
+ &canvas, storage, sizeof(storage)); |
for (bool firstTime = true;; firstTime = false) { |
SkPaint p(paint); |
- if (this->next(&canvas, &p)) { |
+ if (context->next(&canvas, &p)) { |
SkRect r(src); |
p.setLooper(NULL); |
@@ -53,4 +59,13 @@ void SkDrawLooper::computeFastBounds(const SkPaint& paint, const SkRect& src, |
break; |
} |
} |
+ context->cleanup(storage); |
+} |
+ |
+void SkDrawLooper::DrawContext::cleanup(void* storage) { |
+ if ((void*)this == storage) { |
+ this->~DrawContext(); |
+ } else { |
+ SkDELETE(this); |
+ } |
} |