Remove SkVarAlloc
authorHerb Derby <herb@google.com>
Tue, 18 Apr 2017 19:01:40 +0000 (15:01 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Tue, 18 Apr 2017 19:43:42 +0000 (19:43 +0000)
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>
gn/core.gni
gn/tests.gni
src/core/SkVarAlloc.cpp [deleted file]
src/core/SkVarAlloc.h [deleted file]
tests/VarAllocTest.cpp [deleted file]

index e59e35a..3a5a4ed 100644 (file)
@@ -358,7 +358,6 @@ skia_core_sources = [
   "$_src/core/SkValidatingReadBuffer.cpp",
   "$_src/core/SkValidatingReadBuffer.h",
   "$_src/core/SkValidationUtils.h",
-  "$_src/core/SkVarAlloc.cpp",
   "$_src/core/SkVertices.cpp",
   "$_src/core/SkVertState.cpp",
   "$_src/core/SkWriteBuffer.cpp",
index a7060b6..4350ef2 100644 (file)
@@ -248,7 +248,6 @@ tests_sources = [
   "$_tests/TypefaceTest.cpp",
   "$_tests/UnicodeTest.cpp",
   "$_tests/UtilsTest.cpp",
-  "$_tests/VarAllocTest.cpp",
   "$_tests/VerticesTest.cpp",
   "$_tests/VkClearTests.cpp",
   "$_tests/VkHeapTests.cpp",
diff --git a/src/core/SkVarAlloc.cpp b/src/core/SkVarAlloc.cpp
deleted file mode 100644 (file)
index cfa1188..0000000
+++ /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 (file)
index 3729bad..0000000
+++ /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
diff --git a/tests/VarAllocTest.cpp b/tests/VarAllocTest.cpp
deleted file mode 100644 (file)
index 77eaa89..0000000
+++ /dev/null
@@ -1,20 +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 "Test.h"
-#include "SkVarAlloc.h"
-
-DEF_TEST(VarAlloc, r) {
-    SkVarAlloc va(4/*start allocating at 16B*/);
-    char* p = va.alloc(128);
-    sk_bzero(p, 128);  // Just checking this is safe.
-
-#if !defined(SK_BUILD_FOR_ANDROID) && !defined(__UCLIBC__)
-    // This method will always return 0 on Android and UCLIBC platforms.
-    REPORTER_ASSERT(r, va.approxBytesAllocated() >= 128);
-#endif
-}