aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2017-01-13 17:34:33 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-16 17:01:57 +0000
commitac04fef619ad3939a25e66bdaef6f6b1e7f5ca50 (patch)
treed30efcbac91ac1a4b434d910a64487e70efbde0d
parent26e73c057755df4fbffeee372be98e430867034d (diff)
Remove SkFallbackAlloc and SkFixedAlloc.
CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-ASAN;skia.primary:Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN TBR=reed@google.com Change-Id: I1000dc9ed8ad65b249798759d9af99f47fc237d2 Reviewed-on: https://skia-review.googlesource.com/6809 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Herb Derby <herb@google.com>
-rw-r--r--bench/SkLinearBitmapPipelineBench.cpp2
-rw-r--r--gn/core.gni4
-rw-r--r--gn/tests.gni2
-rw-r--r--include/core/SkColorFilter.h6
-rw-r--r--include/core/SkShader.h6
-rw-r--r--include/effects/SkLumaColorFilter.h2
-rw-r--r--src/core/SkArenaAlloc.cpp (renamed from src/core/SkFixedAlloc.cpp)46
-rw-r--r--src/core/SkArenaAlloc.h (renamed from src/core/SkFixedAlloc.h)99
-rw-r--r--src/core/SkColorFilter.cpp6
-rw-r--r--src/core/SkColorMatrixFilterRowMajor255.cpp2
-rw-r--r--src/core/SkColorMatrixFilterRowMajor255.h2
-rw-r--r--src/core/SkColorShader.cpp6
-rw-r--r--src/core/SkColorShader.h4
-rw-r--r--src/core/SkLinearBitmapPipeline.cpp2
-rw-r--r--src/core/SkLinearBitmapPipeline.h2
-rw-r--r--src/core/SkModeColorFilter.cpp4
-rw-r--r--src/core/SkModeColorFilter.h2
-rw-r--r--src/core/SkPM4fPriv.h4
-rw-r--r--src/core/SkRasterPipelineBlitter.cpp11
-rw-r--r--src/core/SkShader.cpp2
-rw-r--r--src/effects/SkLumaColorFilter.cpp2
-rw-r--r--src/image/SkImageShader.cpp4
-rw-r--r--src/image/SkImageShader.h2
-rw-r--r--tests/ArenaAllocTest.cpp (renamed from tests/FixedAllocTest.cpp)88
24 files changed, 39 insertions, 271 deletions
diff --git a/bench/SkLinearBitmapPipelineBench.cpp b/bench/SkLinearBitmapPipelineBench.cpp
index 020ce7f7bb..4e892b6a06 100644
--- a/bench/SkLinearBitmapPipelineBench.cpp
+++ b/bench/SkLinearBitmapPipelineBench.cpp
@@ -9,7 +9,7 @@
#include "Benchmark.h"
#include "SkBitmapProcShader.h"
#include "SkColor.h"
-#include "SkFixedAlloc.h"
+#include "SkArenaAlloc.h"
#include "SkImage.h"
#include "SkLinearBitmapPipeline.h"
#include "SkPM4f.h"
diff --git a/gn/core.gni b/gn/core.gni
index e5d72b33fc..432526364e 100644
--- a/gn/core.gni
+++ b/gn/core.gni
@@ -130,8 +130,8 @@ skia_core_sources = [
"$_src/core/SkFilterProc.cpp",
"$_src/core/SkFilterProc.h",
"$_src/core/SkFindAndPlaceGlyph.h",
- "$_src/core/SkFixedAlloc.cpp",
- "$_src/core/SkFixedAlloc.h",
+ "$_src/core/SkArenaAlloc.cpp",
+ "$_src/core/SkArenaAlloc.h",
"$_src/core/SkFlattenable.cpp",
"$_src/core/SkFlattenableSerialization.cpp",
"$_src/core/SkFont.cpp",
diff --git a/gn/tests.gni b/gn/tests.gni
index caafae456a..483f574ed6 100644
--- a/gn/tests.gni
+++ b/gn/tests.gni
@@ -10,6 +10,7 @@ tests_sources = [
"$_tests/AAClipTest.cpp",
"$_tests/AnnotationTest.cpp",
"$_tests/ApplyGammaTest.cpp",
+ "$_tests/ArenaAllocTest.cpp",
"$_tests/AsADashTest.cpp",
"$_tests/BadIcoTest.cpp",
"$_tests/BitmapCopyTest.cpp",
@@ -62,7 +63,6 @@ tests_sources = [
"$_tests/ExifTest.cpp",
"$_tests/FillPathTest.cpp",
"$_tests/FitsInTest.cpp",
- "$_tests/FixedAllocTest.cpp",
"$_tests/FlattenableCustomFactory.cpp",
"$_tests/FlattenableFactoryToName.cpp",
"$_tests/FlattenDrawableTest.cpp",
diff --git a/include/core/SkColorFilter.h b/include/core/SkColorFilter.h
index fd3ccbc72a..a59308774f 100644
--- a/include/core/SkColorFilter.h
+++ b/include/core/SkColorFilter.h
@@ -15,9 +15,9 @@
class GrContext;
class GrFragmentProcessor;
+class SkArenaAlloc;
class SkBitmap;
class SkColorSpace;
-class SkFallbackAlloc;
class SkRasterPipeline;
/**
@@ -73,7 +73,7 @@ public:
virtual void filterSpan4f(const SkPM4f src[], int count, SkPM4f result[]) const;
- bool appendStages(SkRasterPipeline*, SkColorSpace*, SkFallbackAlloc*,
+ bool appendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
bool shaderIsOpaque) const;
enum Flags {
@@ -160,7 +160,7 @@ public:
protected:
SkColorFilter() {}
- virtual bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkFallbackAlloc*,
+ virtual bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
bool shaderIsOpaque) const;
private:
diff --git a/include/core/SkShader.h b/include/core/SkShader.h
index 6d24c1a73c..4bb887edd6 100644
--- a/include/core/SkShader.h
+++ b/include/core/SkShader.h
@@ -19,7 +19,7 @@
class SkColorFilter;
class SkColorSpace;
-class SkFallbackAlloc;
+class SkArenaAlloc;
class SkImage;
class SkPath;
class SkPicture;
@@ -475,7 +475,7 @@ public:
SK_DEFINE_FLATTENABLE_TYPE(SkShader)
SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
- bool appendStages(SkRasterPipeline*, SkColorSpace*, SkFallbackAlloc*,
+ bool appendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
const SkMatrix& ctm, const SkPaint&) const;
protected:
@@ -509,7 +509,7 @@ protected:
return nullptr;
}
- virtual bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkFallbackAlloc*,
+ virtual bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
const SkMatrix&, const SkPaint&) const {
return false;
}
diff --git a/include/effects/SkLumaColorFilter.h b/include/effects/SkLumaColorFilter.h
index 5cddec6846..209394490d 100644
--- a/include/effects/SkLumaColorFilter.h
+++ b/include/effects/SkLumaColorFilter.h
@@ -42,7 +42,7 @@ protected:
private:
SkLumaColorFilter();
- bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkFallbackAlloc*,
+ bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
bool shaderIsOpaque) const override;
typedef SkColorFilter INHERITED;
diff --git a/src/core/SkFixedAlloc.cpp b/src/core/SkArenaAlloc.cpp
index c6b07250a8..d6c249b573 100644
--- a/src/core/SkFixedAlloc.cpp
+++ b/src/core/SkArenaAlloc.cpp
@@ -5,52 +5,8 @@
* found in the LICENSE file.
*/
-#include "SkFixedAlloc.h"
-
#include <algorithm>
-
-SkFixedAlloc::SkFixedAlloc(void* ptr, size_t len)
- : fStorage((char*)ptr), fCursor(fStorage), fEnd(fStorage + len) {}
-
-void SkFixedAlloc::undo() {
- // This function is essentially make() in reverse.
-
- // First, read the Footer we stamped at the end.
- Footer footer;
- memcpy(&footer, fCursor - sizeof(Footer), sizeof(Footer));
-
- Releaser releaser = (Releaser)((char*)Base + (footer >> 5));
- ptrdiff_t padding = footer & 31;
-
- fCursor = releaser(fCursor);
- fCursor -= padding;
-}
-
-void SkFixedAlloc::reset() {
- while (fCursor > fStorage) {
- this->undo();
- }
-}
-
-void SkFixedAlloc::Base() { }
-
-SkFallbackAlloc::SkFallbackAlloc(SkFixedAlloc* fixed) : fFixedAlloc(fixed) {}
-
-void SkFallbackAlloc::undo() {
- if (fHeapAllocs.empty()) {
- return fFixedAlloc->undo();
- }
- HeapAlloc alloc = fHeapAllocs.back();
- alloc.deleter(alloc.ptr);
- fHeapAllocs.pop_back();
-}
-
-void SkFallbackAlloc::reset() {
- while (!fHeapAllocs.empty()) {
- this->undo();
- }
- fFixedAlloc->reset();
-}
+#include "SkArenaAlloc.h"
struct Skipper {
char* operator()(char* objEnd, ptrdiff_t size) { return objEnd + size; }
diff --git a/src/core/SkFixedAlloc.h b/src/core/SkArenaAlloc.h
index acb68956e4..8152c94cbd 100644
--- a/src/core/SkFixedAlloc.h
+++ b/src/core/SkArenaAlloc.h
@@ -16,105 +16,6 @@
#include <utility>
#include <vector>
-// SkFixedAlloc allocates objects out of a fixed-size buffer and destroys them when destroyed.
-class SkFixedAlloc {
-public:
- SkFixedAlloc(void* ptr, size_t len);
- ~SkFixedAlloc() { this->reset(); }
-
- // Allocates a new T in the buffer if possible. If not, returns nullptr.
- // Assumptions:
- // * max alignment value is 32 - if alignment is greater than 32, the allocation is best effort.
- // * footer is 32 bits - 5 bits of alignment and 27 bits of deleter difference from Base.
- // * deleter difference - the difference D is -2^26 <= D < 2^26.
- template <typename T, typename... Args>
- T* make(Args&&... args) {
- auto mask = alignof(T) - 1;
-
- // Align fCursor for this allocation.
- char* objStart = (char*)((uintptr_t)(fCursor + mask) & ~mask);
- ptrdiff_t padding = objStart - fCursor;
- Releaser releaser = [](char* objEnd) {
- char* objStart = objEnd - (sizeof(T) + sizeof(Footer));
- ((T*)objStart)->~T();
- return objStart;
- };
-
- ptrdiff_t deleterDiff = (char*)releaser - (char*)Base;
-
- if (objStart + sizeof(T) + sizeof(Footer) > fEnd
- || padding >= 32
- || deleterDiff >= (1 << 26)
- || deleterDiff < -(1 << 26)) {
- // Ran out of space, or code not store info in the Footer.
- return nullptr;
- }
-
- // Advance cursor to end of the object.
- fCursor = objStart + sizeof(T);
-
- Footer footer = (Footer)(SkLeftShift((int64_t)deleterDiff, 5) | padding);
- memcpy(fCursor, &footer, sizeof(Footer));
- fCursor += sizeof(Footer);
-
- return new (objStart) T(std::forward<Args>(args)...);
- }
-
- // Destroys the last object allocated and frees its space in the buffer.
- void undo();
-
- // Destroys all objects and frees all space in the buffer.
- void reset();
-
-private:
- using Footer = int32_t;
- using Releaser = char*(*)(char*);
-
- // A function pointer to use for offsets of releasers.
- static void Base();
-
- char* const fStorage;
- char* fCursor;
- char* const fEnd;
-};
-
-class SkFallbackAlloc {
-public:
- explicit SkFallbackAlloc(SkFixedAlloc*);
- ~SkFallbackAlloc() { this->reset(); }
-
- // Allocates a new T with the SkFixedAlloc if possible. If not, uses the heap.
- template <typename T, typename... Args>
- T* make(Args&&... args) {
- // Once we go heap we never go back to fixed. This keeps destructor ordering sane.
- if (fHeapAllocs.empty()) {
- if (T* ptr = fFixedAlloc->make<T>(std::forward<Args>(args)...)) {
- return ptr;
- }
- }
-
- char* ptr = new char[sizeof(T)];
- fHeapAllocs.push_back({[](char* ptr) { ((T*)ptr)->~T(); delete [] ptr; }, ptr});
- return new (ptr) T(std::forward<Args>(args)...);
- }
-
-
- // Destroys all objects and frees all space in the SkFixedAlloc.
- void reset();
-
-private:
- // Destroys the last object allocated and frees any space it used in the SkFixedAlloc.
- void undo();
-
- struct HeapAlloc {
- void (*deleter)(char*);
- char* ptr;
- };
-
- SkFixedAlloc* fFixedAlloc;
- std::vector<HeapAlloc> fHeapAllocs;
-};
-
// SkArenaAlloc allocates object and destroys the allocated objects when destroyed. It's designed
// to minimize the number of underlying block allocations. SkArenaAlloc allocates first out of an
// (optional) user-provided block of memory, and when that's exhausted it allocates on the heap,
diff --git a/src/core/SkColorFilter.cpp b/src/core/SkColorFilter.cpp
index 664109af5e..d835853a31 100644
--- a/src/core/SkColorFilter.cpp
+++ b/src/core/SkColorFilter.cpp
@@ -6,7 +6,7 @@
*/
#include "SkColorFilter.h"
-#include "SkFixedAlloc.h"
+#include "SkArenaAlloc.h"
#include "SkReadBuffer.h"
#include "SkRefCnt.h"
#include "SkString.h"
@@ -40,12 +40,12 @@ sk_sp<GrFragmentProcessor> SkColorFilter::asFragmentProcessor(GrContext*, SkColo
bool SkColorFilter::appendStages(SkRasterPipeline* pipeline,
SkColorSpace* dst,
- SkFallbackAlloc* scratch,
+ SkArenaAlloc* scratch,
bool shaderIsOpaque) const {
return this->onAppendStages(pipeline, dst, scratch, shaderIsOpaque);
}
-bool SkColorFilter::onAppendStages(SkRasterPipeline*, SkColorSpace*, SkFallbackAlloc*, bool) const {
+bool SkColorFilter::onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*, bool) const {
return false;
}
diff --git a/src/core/SkColorMatrixFilterRowMajor255.cpp b/src/core/SkColorMatrixFilterRowMajor255.cpp
index e17f73a561..778fe98c4e 100644
--- a/src/core/SkColorMatrixFilterRowMajor255.cpp
+++ b/src/core/SkColorMatrixFilterRowMajor255.cpp
@@ -233,7 +233,7 @@ static void set_concat(SkScalar result[20], const SkScalar outer[20], const SkSc
bool SkColorMatrixFilterRowMajor255::onAppendStages(SkRasterPipeline* p,
SkColorSpace* dst,
- SkFallbackAlloc* scratch,
+ SkArenaAlloc* scratch,
bool shaderIsOpaque) const {
bool willStayOpaque = shaderIsOpaque && (fFlags & kAlphaUnchanged_Flag);
bool needsClamp0 = false,
diff --git a/src/core/SkColorMatrixFilterRowMajor255.h b/src/core/SkColorMatrixFilterRowMajor255.h
index f4312c5b8b..5c2d616ba0 100644
--- a/src/core/SkColorMatrixFilterRowMajor255.h
+++ b/src/core/SkColorMatrixFilterRowMajor255.h
@@ -36,7 +36,7 @@ protected:
void flatten(SkWriteBuffer&) const override;
private:
- bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkFallbackAlloc*,
+ bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
bool shaderIsOpaque) const override;
SkScalar fMatrix[20];
diff --git a/src/core/SkColorShader.cpp b/src/core/SkColorShader.cpp
index da87cdfe2c..725bbf0a35 100644
--- a/src/core/SkColorShader.cpp
+++ b/src/core/SkColorShader.cpp
@@ -5,9 +5,9 @@
* found in the LICENSE file.
*/
+#include "SkArenaAlloc.h"
#include "SkColorShader.h"
#include "SkColorSpace.h"
-#include "SkFixedAlloc.h"
#include "SkPM4fPriv.h"
#include "SkRasterPipeline.h"
#include "SkReadBuffer.h"
@@ -311,7 +311,7 @@ bool SkColor4Shader::Color4Context::onChooseBlitProcs(const SkImageInfo& info, B
bool SkColorShader::onAppendStages(SkRasterPipeline* p,
SkColorSpace* dst,
- SkFallbackAlloc* scratch,
+ SkArenaAlloc* scratch,
const SkMatrix& ctm,
const SkPaint&) const {
auto color = scratch->make<SkPM4f>(SkPM4f_from_SkColor(fColor, dst));
@@ -322,7 +322,7 @@ bool SkColorShader::onAppendStages(SkRasterPipeline* p,
bool SkColor4Shader::onAppendStages(SkRasterPipeline* p,
SkColorSpace* dst,
- SkFallbackAlloc* scratch,
+ SkArenaAlloc* scratch,
const SkMatrix& ctm,
const SkPaint&) const {
auto color = scratch->make<SkPM4f>(fColor4.premul());
diff --git a/src/core/SkColorShader.h b/src/core/SkColorShader.h
index 19c106ddfd..3f00317015 100644
--- a/src/core/SkColorShader.h
+++ b/src/core/SkColorShader.h
@@ -65,7 +65,7 @@ protected:
*lum = fColor;
return true;
}
- bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkFallbackAlloc*,
+ bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
const SkMatrix& ctm, const SkPaint&) const override;
private:
@@ -121,7 +121,7 @@ protected:
*lum = fCachedByteColor;
return true;
}
- bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkFallbackAlloc*,
+ bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
const SkMatrix& ctm, const SkPaint&) const override;
private:
diff --git a/src/core/SkLinearBitmapPipeline.cpp b/src/core/SkLinearBitmapPipeline.cpp
index 1c3b7a5135..2878f19a9f 100644
--- a/src/core/SkLinearBitmapPipeline.cpp
+++ b/src/core/SkLinearBitmapPipeline.cpp
@@ -12,7 +12,7 @@
#include <limits>
#include <tuple>
-#include "SkFixedAlloc.h"
+#include "SkArenaAlloc.h"
#include "SkLinearBitmapPipeline_core.h"
#include "SkLinearBitmapPipeline_matrix.h"
#include "SkLinearBitmapPipeline_tile.h"
diff --git a/src/core/SkLinearBitmapPipeline.h b/src/core/SkLinearBitmapPipeline.h
index 237a1658ba..8ce02009b2 100644
--- a/src/core/SkLinearBitmapPipeline.h
+++ b/src/core/SkLinearBitmapPipeline.h
@@ -8,8 +8,8 @@
#ifndef SkLinearBitmapPipeline_DEFINED
#define SkLinearBitmapPipeline_DEFINED
+#include "SkArenaAlloc.h"
#include "SkColor.h"
-#include "SkFixedAlloc.h"
#include "SkImageInfo.h"
#include "SkMatrix.h"
#include "SkShader.h"
diff --git a/src/core/SkModeColorFilter.cpp b/src/core/SkModeColorFilter.cpp
index 9c76f9efed..fb09c27bef 100644
--- a/src/core/SkModeColorFilter.cpp
+++ b/src/core/SkModeColorFilter.cpp
@@ -9,7 +9,7 @@
#include "SkBlendModePriv.h"
#include "SkColorFilter.h"
#include "SkColorPriv.h"
-#include "SkFixedAlloc.h"
+#include "SkArenaAlloc.h"
#include "SkModeColorFilter.h"
#include "SkPM4fPriv.h"
#include "SkRasterPipeline.h"
@@ -88,7 +88,7 @@ sk_sp<SkFlattenable> SkModeColorFilter::CreateProc(SkReadBuffer& buffer) {
bool SkModeColorFilter::onAppendStages(SkRasterPipeline* p,
SkColorSpace* dst,
- SkFallbackAlloc* scratch,
+ SkArenaAlloc* scratch,
bool shaderIsOpaque) const {
auto color = scratch->make<SkPM4f>(SkPM4f_from_SkColor(fColor, dst));
diff --git a/src/core/SkModeColorFilter.h b/src/core/SkModeColorFilter.h
index 8e0374495f..4d0b172930 100644
--- a/src/core/SkModeColorFilter.h
+++ b/src/core/SkModeColorFilter.h
@@ -44,7 +44,7 @@ protected:
void flatten(SkWriteBuffer&) const override;
- bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkFallbackAlloc*,
+ bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
bool shaderIsOpaque) const override;
private:
diff --git a/src/core/SkPM4fPriv.h b/src/core/SkPM4fPriv.h
index 26d8b7d4e0..dd0e550b32 100644
--- a/src/core/SkPM4fPriv.h
+++ b/src/core/SkPM4fPriv.h
@@ -11,7 +11,7 @@
#include "SkColorPriv.h"
#include "SkColorSpace.h"
#include "SkColorSpace_Base.h"
-#include "SkFixedAlloc.h"
+#include "SkArenaAlloc.h"
#include "SkPM4f.h"
#include "SkRasterPipeline.h"
#include "SkSRGB.h"
@@ -130,7 +130,7 @@ static inline bool append_gamut_transform(SkRasterPipeline* p, float scratch_mat
return true;
}
-static inline bool append_gamut_transform(SkRasterPipeline* p, SkFallbackAlloc* scratch,
+static inline bool append_gamut_transform(SkRasterPipeline* p, SkArenaAlloc* scratch,
SkColorSpace* src, SkColorSpace* dst) {
struct matrix_3x4 { float arr[12]; };
return append_gamut_transform(p, scratch->make<matrix_3x4>()->arr, src, dst);
diff --git a/src/core/SkRasterPipelineBlitter.cpp b/src/core/SkRasterPipelineBlitter.cpp
index 4d21b19bf0..7f91cbf334 100644
--- a/src/core/SkRasterPipelineBlitter.cpp
+++ b/src/core/SkRasterPipelineBlitter.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
+#include "SkArenaAlloc.h"
#include "SkBlitter.h"
#include "SkBlendModePriv.h"
#include "SkColor.h"
#include "SkColorFilter.h"
-#include "SkFixedAlloc.h"
#include "SkOpts.h"
#include "SkPM4f.h"
#include "SkPM4fPriv.h"
@@ -27,8 +27,6 @@ public:
: fDst(dst)
, fBlend(blend)
, fPaintColor(paintColor)
- , fScratchAlloc(fScratch, sizeof(fScratch))
- , fScratchFallback(&fScratchAlloc)
{}
void blitH (int x, int y, int w) override;
@@ -64,8 +62,7 @@ private:
// Scratch space for shaders and color filters to use.
char fScratch[64];
- SkFixedAlloc fScratchAlloc;
- SkFallbackAlloc fScratchFallback;
+ SkArenaAlloc fArena{fScratch, sizeof(fScratch), 128};
typedef SkBlitter INHERITED;
};
@@ -116,7 +113,7 @@ SkBlitter* SkRasterPipelineBlitter::Create(const SkPixmap& dst,
bool is_opaque = paintColor->a() == 1.0f,
is_constant = true;
if (shader) {
- if (!shader->appendStages(pipeline, dst.colorSpace(), &blitter->fScratchFallback,
+ if (!shader->appendStages(pipeline, dst.colorSpace(), &blitter->fArena,
ctm, paint)) {
return earlyOut();
}
@@ -132,7 +129,7 @@ SkBlitter* SkRasterPipelineBlitter::Create(const SkPixmap& dst,
}
if (colorFilter) {
- if (!colorFilter->appendStages(pipeline, dst.colorSpace(), &blitter->fScratchFallback,
+ if (!colorFilter->appendStages(pipeline, dst.colorSpace(), &blitter->fArena,
is_opaque)) {
return earlyOut();
}
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp
index 87b2cc3f30..3a2ec7b912 100644
--- a/src/core/SkShader.cpp
+++ b/src/core/SkShader.cpp
@@ -259,7 +259,7 @@ void SkShader::toString(SkString* str) const {
bool SkShader::appendStages(SkRasterPipeline* pipeline,
SkColorSpace* dst,
- SkFallbackAlloc* scratch,
+ SkArenaAlloc* scratch,
const SkMatrix& ctm,
const SkPaint& paint) const {
return this->onAppendStages(pipeline, dst, scratch, ctm, paint);
diff --git a/src/effects/SkLumaColorFilter.cpp b/src/effects/SkLumaColorFilter.cpp
index 6845c50ff0..bd5c1463eb 100644
--- a/src/effects/SkLumaColorFilter.cpp
+++ b/src/effects/SkLumaColorFilter.cpp
@@ -40,7 +40,7 @@ void SkLumaColorFilter::filterSpan(const SkPMColor src[], int count,
bool SkLumaColorFilter::onAppendStages(SkRasterPipeline* p,
SkColorSpace* dst,
- SkFallbackAlloc* scratch,
+ SkArenaAlloc* scratch,
bool shaderIsOpaque) const {
p->append(SkRasterPipeline::luminance_to_alpha);
return true;
diff --git a/src/image/SkImageShader.cpp b/src/image/SkImageShader.cpp
index 1417ac863e..5b79fb1d9e 100644
--- a/src/image/SkImageShader.cpp
+++ b/src/image/SkImageShader.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
+#include "SkArenaAlloc.h"
#include "SkBitmapController.h"
#include "SkBitmapProcShader.h"
#include "SkBitmapProvider.h"
#include "SkColorTable.h"
#include "SkEmptyShader.h"
-#include "SkFixedAlloc.h"
#include "SkImage_Base.h"
#include "SkImageShader.h"
#include "SkImageShaderContext.h"
@@ -227,7 +227,7 @@ SkFlattenable::Register("SkBitmapProcShader", SkBitmapProcShader_CreateProc, kSk
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
-bool SkImageShader::onAppendStages(SkRasterPipeline* p, SkColorSpace* dst, SkFallbackAlloc* scratch,
+bool SkImageShader::onAppendStages(SkRasterPipeline* p, SkColorSpace* dst, SkArenaAlloc* scratch,
const SkMatrix& ctm, const SkPaint& paint) const {
auto matrix = SkMatrix::Concat(ctm, this->getLocalMatrix());
if (!matrix.invert(&matrix)) {
diff --git a/src/image/SkImageShader.h b/src/image/SkImageShader.h
index 074ecca3a7..fa77928cf9 100644
--- a/src/image/SkImageShader.h
+++ b/src/image/SkImageShader.h
@@ -37,7 +37,7 @@ protected:
#endif
SkImage* onIsAImage(SkMatrix*, TileMode*) const override;
- bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkFallbackAlloc*,
+ bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
const SkMatrix& ctm, const SkPaint&) const override;
sk_sp<SkImage> fImage;
diff --git a/tests/FixedAllocTest.cpp b/tests/ArenaAllocTest.cpp
index 75bc232b4b..647ea25283 100644
--- a/tests/FixedAllocTest.cpp
+++ b/tests/ArenaAllocTest.cpp
@@ -6,7 +6,7 @@
*/
#include "Test.h"
-#include "SkFixedAlloc.h"
+#include "SkArenaAlloc.h"
namespace {
@@ -28,91 +28,6 @@ namespace {
}
-DEF_TEST(FixedAlloc, r) {
- // Basic mechanics.
- {
- uint8_t buf[128];
- SkFixedAlloc fa(buf, sizeof(buf));
-
- Foo* foo = fa.make<Foo>(3, 4.0f);
- REPORTER_ASSERT(r, foo);
- REPORTER_ASSERT(r, foo->x == 3);
- REPORTER_ASSERT(r, foo->y == 4.0f);
- REPORTER_ASSERT(r, created == 1);
- REPORTER_ASSERT(r, destroyed == 0);
-
- Foo* bar = fa.make<Foo>(8, 1.0f);
- REPORTER_ASSERT(r, bar);
- REPORTER_ASSERT(r, bar->x == 8);
- REPORTER_ASSERT(r, bar->y == 1.0f);
- REPORTER_ASSERT(r, created == 2);
- REPORTER_ASSERT(r, destroyed == 0);
-
- fa.undo();
- REPORTER_ASSERT(r, created == 2);
- REPORTER_ASSERT(r, destroyed == 1);
- }
- REPORTER_ASSERT(r, created == 2);
- REPORTER_ASSERT(r, destroyed == 2);
-
- {
- // Test alignment gurantees.
- uint8_t buf[64];
- SkFixedAlloc fa(buf+3, sizeof(buf)-3);
-
- Foo* foo = fa.make<Foo>(3, 4.0f);
- REPORTER_ASSERT(r, SkIsAlign4((uintptr_t)foo));
- REPORTER_ASSERT(r, created == 3);
- REPORTER_ASSERT(r, destroyed == 2);
-
- // Might as well test reset() while we're at it.
- fa.reset();
- REPORTER_ASSERT(r, created == 3);
- REPORTER_ASSERT(r, destroyed == 3);
- }
- REPORTER_ASSERT(r, created == 3);
- REPORTER_ASSERT(r, destroyed == 3);
-}
-
-DEF_TEST(FallbackAlloc, r) {
- // SkFixedAlloc will eventually fail when it runs out of space in its buffer.
- int buf[32];
- SkFixedAlloc fixed(buf, sizeof(buf));
- bool fixed_failed = false;
- for (int i = 0; i < 32; i++) {
- // (Remember, there is some overhead to each make() call.)
- fixed_failed = fixed_failed || (fixed.make<int>(i) == nullptr);
- }
- REPORTER_ASSERT(r, fixed_failed);
-
-
- // SkFallbackAlloc will always succeed, using the heap as required.
- fixed.reset();
- SkFallbackAlloc fallback(&fixed);
-
- bool fallback_failed = false;
- for (int i = 0; i < 32; i++) {
- fallback_failed = fallback_failed || (fallback.make<int>(i) == nullptr);
- }
- REPORTER_ASSERT(r, !fallback_failed);
-
-
- // Test small, big, small allocations to make sure once we go to the heap we stay there.
- fallback.reset();
- auto smallA = fallback.make<int>(2);
- auto big = fallback.make<Big>();
- auto smallB = fallback.make<int>(3);
-
- auto in_buf = [&](void* ptr) {
- return (uintptr_t)(buf+0 ) <= (uintptr_t)ptr
- && (uintptr_t)(buf+32) > (uintptr_t)ptr;
- };
-
- REPORTER_ASSERT(r, in_buf(smallA));
- REPORTER_ASSERT(r, !in_buf(big));
- REPORTER_ASSERT(r, !in_buf(smallB));
-}
-
struct WithDtor {
~WithDtor() { }
};
@@ -198,5 +113,4 @@ DEF_TEST(ArenaAlloc, r) {
}
REPORTER_ASSERT(r, created == 11);
REPORTER_ASSERT(r, destroyed == 11);
-
}