aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2017-02-08 15:12:19 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-08 21:08:02 +0000
commit73fe7b07e6391da81dfc48d600d7b3141be1f471 (patch)
tree34df5836e6c9360d69a9da9293cd2823d316191a /src
parent16c149664d3f95e1cabded8a1b7b3d105222c236 (diff)
Remove use of SkSmallAllocator from all Loopers.
R=reed@google.com Change-Id: I22b140ee8e12900de13bc623adb30b5fca3051f9 Reviewed-on: https://skia-review.googlesource.com/7658 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkCanvas.cpp13
-rw-r--r--src/core/SkDrawLooper.cpp21
-rw-r--r--src/effects/SkBlurDrawLooper.cpp6
-rw-r--r--src/effects/SkLayerDrawLooper.cpp6
4 files changed, 21 insertions, 25 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 64ef348e13..6c6752e636 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "SkArenaAlloc.h"
#include "SkBitmapDevice.h"
#include "SkCanvas.h"
#include "SkCanvasPriv.h"
@@ -33,7 +34,6 @@
#include "SkRRect.h"
#include "SkShadowPaintFilterCanvas.h"
#include "SkShadowShader.h"
-#include "SkSmallAllocator.h"
#include "SkSpecialImage.h"
#include "SkSurface_Base.h"
#include "SkTextBlob.h"
@@ -509,11 +509,7 @@ public:
}
if (SkDrawLooper* looper = paint.getLooper()) {
- fLooperContext = fLooperContextAllocator.createWithIniter(
- looper->contextSize(),
- [&](void* buffer) {
- return looper->createContext(canvas, buffer);
- });
+ fLooperContext = looper->makeContext(canvas, &fAlloc);
fIsSimple = false;
} else {
fLooperContext = nullptr;
@@ -546,7 +542,7 @@ public:
}
private:
- SkLazyPaint fLazyPaintInit; // base paint storage in case we need to modify it
+ SkLazyPaint fLazyPaintInit; // base paint storage in case we need to modify it
SkLazyPaint fLazyPaintPerLooper; // per-draw-looper storage, so the looper can modify it
SkCanvas* fCanvas;
const SkPaint& fOrigPaint;
@@ -557,7 +553,8 @@ private:
bool fDone;
bool fIsSimple;
SkDrawLooper::Context* fLooperContext;
- SkSmallAllocator<1, 32> fLooperContextAllocator;
+ char fStorage[48];
+ SkArenaAlloc fAlloc {fStorage};
bool doNext(SkDrawFilter::Type drawType);
};
diff --git a/src/core/SkDrawLooper.cpp b/src/core/SkDrawLooper.cpp
index e372e8f157..54c9af19fa 100644
--- a/src/core/SkDrawLooper.cpp
+++ b/src/core/SkDrawLooper.cpp
@@ -5,22 +5,19 @@
* found in the LICENSE file.
*/
+#include "SkArenaAlloc.h"
#include "SkDrawLooper.h"
#include "SkCanvas.h"
#include "SkMatrix.h"
#include "SkPaint.h"
#include "SkRect.h"
-#include "SkSmallAllocator.h"
bool SkDrawLooper::canComputeFastBounds(const SkPaint& paint) const {
SkCanvas canvas;
- SkSmallAllocator<1, 32> allocator;
+ char storage[48];
+ SkArenaAlloc alloc {storage};
- SkDrawLooper::Context* context = allocator.createWithIniter(
- this->contextSize(),
- [&](void* buffer) {
- return this->createContext(&canvas, buffer);
- });
+ SkDrawLooper::Context* context = this->makeContext(&canvas, &alloc);
for (;;) {
SkPaint p(paint);
if (context->next(&canvas, &p)) {
@@ -41,14 +38,12 @@ void SkDrawLooper::computeFastBounds(const SkPaint& paint, const SkRect& s,
const SkRect src = s;
SkCanvas canvas;
- SkSmallAllocator<1, 32> allocator;
+ char storage[48];
+ SkArenaAlloc alloc {storage};
*dst = src; // catch case where there are no loops
- SkDrawLooper::Context* context = allocator.createWithIniter(
- this->contextSize(),
- [&](void* buffer) {
- return this->createContext(&canvas, buffer);
- });
+ SkDrawLooper::Context* context = this->makeContext(&canvas, &alloc);
+
for (bool firstTime = true;; firstTime = false) {
SkPaint p(paint);
if (context->next(&canvas, &p)) {
diff --git a/src/effects/SkBlurDrawLooper.cpp b/src/effects/SkBlurDrawLooper.cpp
index e55429510c..4d21c004c9 100644
--- a/src/effects/SkBlurDrawLooper.cpp
+++ b/src/effects/SkBlurDrawLooper.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "SkArenaAlloc.h"
#include "SkBlurDrawLooper.h"
#include "SkBlurMask.h" // just for SkBlurMask::ConvertRadiusToSigma
#include "SkBlurMaskFilter.h"
@@ -96,8 +97,9 @@ bool SkBlurDrawLooper::asABlurShadow(BlurShadowRec* rec) const {
////////////////////////////////////////////////////////////////////////////////////////
-SkDrawLooper::Context* SkBlurDrawLooper::createContext(SkCanvas*, void* storage) const {
- return new (storage) BlurDrawLooperContext(this);
+
+SkDrawLooper::Context* SkBlurDrawLooper::makeContext(SkCanvas*, SkArenaAlloc* alloc) const {
+ return alloc->make<BlurDrawLooperContext>(this);
}
SkBlurDrawLooper::BlurDrawLooperContext::BlurDrawLooperContext(
diff --git a/src/effects/SkLayerDrawLooper.cpp b/src/effects/SkLayerDrawLooper.cpp
index 737cdf6cc2..5c0cf6bf7b 100644
--- a/src/effects/SkLayerDrawLooper.cpp
+++ b/src/effects/SkLayerDrawLooper.cpp
@@ -4,6 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "SkArenaAlloc.h"
#include "SkCanvas.h"
#include "SkColor.h"
#include "SkReadBuffer.h"
@@ -34,9 +35,10 @@ SkLayerDrawLooper::~SkLayerDrawLooper() {
}
}
-SkLayerDrawLooper::Context* SkLayerDrawLooper::createContext(SkCanvas* canvas, void* storage) const {
+SkLayerDrawLooper::Context*
+SkLayerDrawLooper::makeContext(SkCanvas* canvas, SkArenaAlloc* alloc) const {
canvas->save();
- return new (storage) LayerDrawLooperContext(this);
+ return alloc->make<LayerDrawLooperContext>(this);
}
static SkColor xferColor(SkColor src, SkColor dst, SkBlendMode mode) {