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

Unified Diff: src/core/SkDrawLooper.cpp

Issue 2488523003: Make SkSmallAllocator obey the RAII invariants and be expandable (Closed)
Patch Set: Strip pointer to make correct type Created 4 years, 1 month 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/SkCanvas.cpp ('k') | src/core/SkRasterPipelineBlitter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkDrawLooper.cpp
diff --git a/src/core/SkDrawLooper.cpp b/src/core/SkDrawLooper.cpp
index aa53f2e3a13176893d84fabaaec25848bd93b288..e372e8f157f3214960bcb7e16a549c7d56e8135a 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.createWithIniter(
+ 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.createWithIniter(
+ this->contextSize(),
+ [&](void* buffer) {
+ return this->createContext(&canvas, buffer);
+ });
for (bool firstTime = true;; firstTime = false) {
SkPaint p(paint);
if (context->next(&canvas, &p)) {
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkRasterPipelineBlitter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698