aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2017-04-18 15:01:40 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-18 19:43:42 +0000
commit3f4531d3124e1053f5f0415dc6309ba3aed02b8e (patch)
tree6d6294a4c23b4ea75a1416415a92f391eb599267 /src/core
parentedbb7d8860a63b1cacb1e89ec205c72a2de7c134 (diff)
Remove SkVarAlloc
Change-Id: Id41d3e03390185f72b682225aeb140df45c84a34 Reviewed-on: https://skia-review.googlesource.com/13763 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkVarAlloc.cpp58
-rw-r--r--src/core/SkVarAlloc.h55
2 files changed, 0 insertions, 113 deletions
diff --git a/src/core/SkVarAlloc.cpp b/src/core/SkVarAlloc.cpp
deleted file mode 100644
index cfa1188c62..0000000000
--- a/src/core/SkVarAlloc.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkVarAlloc.h"
-
-#include "SkMalloc.h"
-
-struct SkVarAlloc::Block {
- Block* prev;
- char* data() { return (char*)(this + 1); }
-
- static Block* Alloc(Block* prev, size_t size) {
- SkASSERT(size >= sizeof(Block));
- Block* b = (Block*)sk_malloc_throw(size);
- b->prev = prev;
- return b;
- }
-};
-
-SkVarAlloc::SkVarAlloc(size_t minLgSize)
- : fBytesAllocated(0)
- , fByte(nullptr)
- , fRemaining(0)
- , fLgSize(minLgSize)
- , fBlock(nullptr) {}
-
-SkVarAlloc::SkVarAlloc(size_t minLgSize, char* storage, size_t len)
- : fBytesAllocated(0)
- , fByte(storage)
- , fRemaining(len)
- , fLgSize(minLgSize)
- , fBlock(nullptr) {}
-
-SkVarAlloc::~SkVarAlloc() {
- Block* b = fBlock;
- while (b) {
- Block* prev = b->prev;
- sk_free(b);
- b = prev;
- }
-}
-
-void SkVarAlloc::makeSpace(size_t bytes) {
- SkASSERT(SkIsAlignPtr(bytes));
-
- size_t alloc = static_cast<size_t>(1)<<fLgSize++;
- while (alloc < bytes + sizeof(Block)) {
- alloc *= 2;
- }
- fBytesAllocated += alloc;
- fBlock = Block::Alloc(fBlock, alloc);
- fByte = fBlock->data();
- fRemaining = alloc - sizeof(Block);
-}
diff --git a/src/core/SkVarAlloc.h b/src/core/SkVarAlloc.h
deleted file mode 100644
index 3729bad105..0000000000
--- a/src/core/SkVarAlloc.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkVarAlloc_DEFINED
-#define SkVarAlloc_DEFINED
-
-#include "SkTypes.h"
-
-class SkVarAlloc : SkNoncopyable {
-public:
- // Smallest block we'll allocate is 2**N bytes.
- explicit SkVarAlloc(size_t minLgSize);
- // Same as above, but first uses up to len bytes from storage.
- SkVarAlloc(size_t minLgSize, char* storage, size_t len);
-
- ~SkVarAlloc();
-
- // Returns contiguous bytes aligned at least for pointers.
- char* alloc(size_t bytes) {
- bytes = SkAlignPtr(bytes);
-
- if (bytes > fRemaining) {
- this->makeSpace(bytes);
- }
- SkASSERT(bytes <= fRemaining);
-
- char* ptr = fByte;
- fByte += bytes;
- fRemaining = SkToU32(fRemaining - bytes);
- return ptr;
- }
-
- // Returns our best estimate of the number of bytes we've allocated.
- // (We may not track this precisely to save space.)
- size_t approxBytesAllocated() const { return fBytesAllocated; }
-
-private:
- void makeSpace(size_t bytes);
-
- size_t fBytesAllocated;
-
- char* fByte;
- unsigned fRemaining;
- unsigned fLgSize;
-
- struct Block;
- Block* fBlock;
-};
-static_assert(sizeof(SkVarAlloc) <= 32, "SkVarAllocSize");
-
-#endif//SkVarAlloc_DEFINED