aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2018-07-13 15:52:17 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-16 13:41:36 +0000
commit7e83f89dd67e7c66d853e78b4630450bfb406de0 (patch)
treef51820554baa912e3ba7acaffc8e209df6bebc20
parenteef6d69abc78c5e3dff86469db8c3b2d0ad0b863 (diff)
plumb through arenaalloc
- simplifies the older pattern of storage/size - removes a dynamic allocation in defaultbitmapcontroller Bug: skia: Change-Id: Ibc937d3e0c057e78cc0c8bf7d9ad2d824eb240d9 Reviewed-on: https://skia-review.googlesource.com/141321 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Mike Reed <reed@google.com>
-rw-r--r--src/core/SkBitmapController.cpp10
-rw-r--r--src/core/SkBitmapController.h10
-rw-r--r--src/core/SkBitmapProcState.cpp8
-rw-r--r--src/core/SkBitmapProcState.h3
-rw-r--r--src/shaders/SkImageShader.cpp6
5 files changed, 14 insertions, 23 deletions
diff --git a/src/core/SkBitmapController.cpp b/src/core/SkBitmapController.cpp
index 005c5a559f..ed16f9bc21 100644
--- a/src/core/SkBitmapController.cpp
+++ b/src/core/SkBitmapController.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "SkArenaAlloc.h"
#include "SkBitmap.h"
#include "SkBitmapCache.h"
#include "SkBitmapController.h"
@@ -18,11 +19,10 @@
SkBitmapController::State* SkBitmapController::requestBitmap(const SkBitmapProvider& provider,
const SkMatrix& inv,
SkFilterQuality quality,
- void* storage, size_t storageSize) {
- State* state = this->onRequestBitmap(provider, inv, quality, storage, storageSize);
+ SkArenaAlloc* alloc) {
+ State* state = this->onRequestBitmap(provider, inv, quality, alloc);
if (state) {
if (nullptr == state->fPixmap.addr()) {
- SkInPlaceDeleteCheck(state, storage);
state = nullptr;
}
}
@@ -146,6 +146,6 @@ SkDefaultBitmapControllerState::SkDefaultBitmapControllerState(const SkBitmapPro
SkBitmapController::State* SkDefaultBitmapController::onRequestBitmap(const SkBitmapProvider& bm,
const SkMatrix& inverse,
SkFilterQuality quality,
- void* storage, size_t size) {
- return SkInPlaceNewCheck<SkDefaultBitmapControllerState>(storage, size, bm, inverse, quality);
+ SkArenaAlloc* alloc) {
+ return alloc->make<SkDefaultBitmapControllerState>(bm, inverse, quality);
}
diff --git a/src/core/SkBitmapController.h b/src/core/SkBitmapController.h
index 9eff2d28ff..394a7cfd1a 100644
--- a/src/core/SkBitmapController.h
+++ b/src/core/SkBitmapController.h
@@ -40,15 +40,11 @@ public:
virtual ~SkBitmapController() {}
State* requestBitmap(const SkBitmapProvider&, const SkMatrix& inverse, SkFilterQuality,
- void* storage, size_t storageSize);
-
- State* requestBitmap(const SkBitmapProvider& bp, const SkMatrix& inv, SkFilterQuality quality) {
- return this->requestBitmap(bp, inv, quality, nullptr, 0);
- }
+ SkArenaAlloc*);
protected:
virtual State* onRequestBitmap(const SkBitmapProvider&, const SkMatrix& inv, SkFilterQuality,
- void* storage, size_t storageSize) = 0;
+ SkArenaAlloc*) = 0;
};
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -61,7 +57,7 @@ public:
protected:
State* onRequestBitmap(const SkBitmapProvider&, const SkMatrix& inverse, SkFilterQuality,
- void* storage, size_t storageSize) override;
+ SkArenaAlloc*) override;
};
#endif
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp
index 105637176a..8fea0a3b6e 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -37,9 +37,7 @@ SkBitmapProcInfo::SkBitmapProcInfo(const SkBitmapProvider& provider,
, fBMState(nullptr)
{}
-SkBitmapProcInfo::~SkBitmapProcInfo() {
- SkInPlaceDeleteCheck(fBMState, fBMStateStorage.get());
-}
+SkBitmapProcInfo::~SkBitmapProcInfo() {}
///////////////////////////////////////////////////////////////////////////////
@@ -87,8 +85,8 @@ bool SkBitmapProcInfo::init(const SkMatrix& inv, const SkPaint& paint) {
fFilterQuality = paint.getFilterQuality();
SkDefaultBitmapController controller;
- fBMState = controller.requestBitmap(fProvider, inv, paint.getFilterQuality(),
- fBMStateStorage.get(), fBMStateStorage.size());
+ fBMState = controller.requestBitmap(fProvider, inv, paint.getFilterQuality(), &fAlloc);
+
// Note : we allow the controller to return an empty (zero-dimension) result. Should we?
if (nullptr == fBMState || fBMState->pixmap().info().isEmpty()) {
return false;
diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h
index 46e418cc02..7d16ba6686 100644
--- a/src/core/SkBitmapProcState.h
+++ b/src/core/SkBitmapProcState.h
@@ -8,6 +8,7 @@
#ifndef SkBitmapProcState_DEFINED
#define SkBitmapProcState_DEFINED
+#include "SkArenaAlloc.h"
#include "SkBitmap.h"
#include "SkBitmapController.h"
#include "SkBitmapProvider.h"
@@ -49,7 +50,7 @@ private:
enum {
kBMStateSize = 136 // found by inspection. if too small, we will call new/delete
};
- SkAlignedSStorage<kBMStateSize> fBMStateStorage;
+ SkSTArenaAlloc<kBMStateSize> fAlloc;
SkBitmapController::State* fBMState;
};
diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp
index 22c3f95c04..cf85d85f2d 100644
--- a/src/shaders/SkImageShader.cpp
+++ b/src/shaders/SkImageShader.cpp
@@ -276,9 +276,7 @@ bool SkImageShader::onAppendStages(const StageRec& rec) const {
SkBitmapProvider provider(fImage.get());
SkDefaultBitmapController controller;
- std::unique_ptr<SkBitmapController::State> state {
- controller.requestBitmap(provider, matrix, quality)
- };
+ SkBitmapController::State* state = controller.requestBitmap(provider, matrix, quality, alloc);
if (!state) {
return false;
}
@@ -311,11 +309,9 @@ bool SkImageShader::onAppendStages(const StageRec& rec) const {
p->append(SkRasterPipeline::seed_shader);
struct MiscCtx {
- std::unique_ptr<SkBitmapController::State> state;
SkColor4f paint_color;
};
auto misc = alloc->make<MiscCtx>();
- misc->state = std::move(state); // Extend lifetime to match the pipeline's.
swizzle_rb(Sk4f_fromL32(rec.fPaint.getColor())).store(misc->paint_color.vec()); // sRGBA floats
p->append_matrix(alloc, matrix);