aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkDrawLooper.cpp
diff options
context:
space:
mode:
authorGravatar herb <herb@google.com>2016-11-09 13:01:46 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-11-09 13:01:46 -0800
commitd5dc657b8c3ac916f98005dafdedafe02f023449 (patch)
tree6ace2e801a064fb78e42d8bd7564385fc884e045 /src/core/SkDrawLooper.cpp
parent28930b46487fc94fde206d1283623204c595b0f1 (diff)
Make SkSmallAllocator obey the RAII invariants and move to heap structures when needed.
The biggest change is to the API which allowed code to bypass the destruction invariants. This destruction bypass feature was needed in only one use, and is totally encapsulated using createWithIniterT. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2488523003 Review-Url: https://codereview.chromium.org/2488523003
Diffstat (limited to 'src/core/SkDrawLooper.cpp')
-rw-r--r--src/core/SkDrawLooper.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/core/SkDrawLooper.cpp b/src/core/SkDrawLooper.cpp
index aa53f2e3a1..4f495a71df 100644
--- a/src/core/SkDrawLooper.cpp
+++ b/src/core/SkDrawLooper.cpp
@@ -15,9 +15,12 @@
bool SkDrawLooper::canComputeFastBounds(const SkPaint& paint) const {
SkCanvas canvas;
SkSmallAllocator<1, 32> allocator;
- void* buffer = allocator.reserveT<SkDrawLooper::Context>(this->contextSize());
- SkDrawLooper::Context* context = this->createContext(&canvas, buffer);
+ SkDrawLooper::Context* context = allocator.createWithIniterT<SkDrawLooper::Context>(
+ this->contextSize(),
+ [&](void* buffer) {
+ return this->createContext(&canvas, buffer);
+ });
for (;;) {
SkPaint p(paint);
if (context->next(&canvas, &p)) {
@@ -39,10 +42,13 @@ void SkDrawLooper::computeFastBounds(const SkPaint& paint, const SkRect& s,
SkCanvas canvas;
SkSmallAllocator<1, 32> allocator;
- void* buffer = allocator.reserveT<SkDrawLooper::Context>(this->contextSize());
*dst = src; // catch case where there are no loops
- SkDrawLooper::Context* context = this->createContext(&canvas, buffer);
+ SkDrawLooper::Context* context = allocator.createWithIniterT<SkDrawLooper::Context>(
+ this->contextSize(),
+ [&](void* buffer) {
+ return this->createContext(&canvas, buffer);
+ });
for (bool firstTime = true;; firstTime = false) {
SkPaint p(paint);
if (context->next(&canvas, &p)) {