diff options
author | Ben Wagner <bungeman@google.com> | 2018-07-16 17:46:10 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-16 22:23:49 +0000 |
commit | f35a1c1b24ba4a44d40425ab20348ea813c7bfd7 (patch) | |
tree | c3aa374f9eb90034e6b0b40f2183fddd887c14ad | |
parent | bfc63c1ea41047fc5e299ebf2086309eaa8e79ce (diff) |
Remove SkRefDict.
It is unused. Remove it.
Change-Id: If62a93a58d21bfccd6df112e92a709bff4d11c97
Reviewed-on: https://skia-review.googlesource.com/141566
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
-rw-r--r-- | gn/core.gni | 1 | ||||
-rw-r--r-- | gn/tests.gni | 1 | ||||
-rw-r--r-- | src/core/SkRefDict.cpp | 88 | ||||
-rw-r--r-- | src/core/SkRefDict.h | 53 | ||||
-rw-r--r-- | tests/RefDictTest.cpp | 74 |
5 files changed, 0 insertions, 217 deletions
diff --git a/gn/core.gni b/gn/core.gni index 96ac5cd327..2f60ef8162 100644 --- a/gn/core.gni +++ b/gn/core.gni @@ -250,7 +250,6 @@ skia_core_sources = [ "$_src/core/SkRecordedDrawable.cpp", "$_src/core/SkRecorder.cpp", "$_src/core/SkRect.cpp", - "$_src/core/SkRefDict.cpp", "$_src/core/SkRegion.cpp", "$_src/core/SkRegionPriv.h", "$_src/core/SkRegion_path.cpp", diff --git a/gn/tests.gni b/gn/tests.gni index b98fe46417..8bba918059 100644 --- a/gn/tests.gni +++ b/gn/tests.gni @@ -194,7 +194,6 @@ tests_sources = [ "$_tests/RectangleTextureTest.cpp", "$_tests/RectTest.cpp", "$_tests/RefCntTest.cpp", - "$_tests/RefDictTest.cpp", "$_tests/RegionTest.cpp", "$_tests/RenderTargetContextTest.cpp", "$_tests/ResourceAllocatorTest.cpp", diff --git a/src/core/SkRefDict.cpp b/src/core/SkRefDict.cpp deleted file mode 100644 index 74071888ac..0000000000 --- a/src/core/SkRefDict.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2011 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - -#include "SkRefDict.h" -#include "SkString.h" - -struct SkRefDict::Impl { - Impl* fNext; - SkString fName; - SkRefCnt* fData; -}; - -SkRefDict::SkRefDict() : fImpl(nullptr) {} - -SkRefDict::~SkRefDict() { - this->removeAll(); -} - -SkRefCnt* SkRefDict::find(const char name[]) const { - if (nullptr == name) { - return nullptr; - } - - Impl* rec = fImpl; - while (rec) { - if (rec->fName.equals(name)) { - return rec->fData; - } - rec = rec->fNext; - } - return nullptr; -} - -void SkRefDict::set(const char name[], SkRefCnt* data) { - if (nullptr == name) { - return; - } - - Impl* rec = fImpl; - Impl* prev = nullptr; - while (rec) { - if (rec->fName.equals(name)) { - if (data) { - // replace - data->ref(); - rec->fData->unref(); - rec->fData = data; - } else { - // remove - rec->fData->unref(); - if (prev) { - prev->fNext = rec->fNext; - } else { - fImpl = rec->fNext; - } - delete rec; - } - return; - } - prev = rec; - rec = rec->fNext; - } - - // if get here, name was not found, so add it - data->ref(); - rec = new Impl; - rec->fName.set(name); - rec->fData = data; - // prepend to the head of our list - rec->fNext = fImpl; - fImpl = rec; -} - -void SkRefDict::removeAll() { - Impl* rec = fImpl; - while (rec) { - Impl* next = rec->fNext; - rec->fData->unref(); - delete rec; - rec = next; - } - fImpl = nullptr; -} diff --git a/src/core/SkRefDict.h b/src/core/SkRefDict.h deleted file mode 100644 index cc2a7889bb..0000000000 --- a/src/core/SkRefDict.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2011 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - -#ifndef SkRefDict_DEFINED -#define SkRefDict_DEFINED - -#include "SkRefCnt.h" - -/** - * A dictionary of string,refcnt pairs. The dictionary is also an owner of the - * refcnt objects while they are contained. - */ -class SkRefDict : SkNoncopyable { -public: - SkRefDict(); - ~SkRefDict(); - - /** - * Return the data associated with name[], or nullptr if no matching entry - * is found. The reference-count of the entry is not affected. - */ - SkRefCnt* find(const char name[]) const; - - /** - * If data is nullptr, remove (if present) the entry matching name and call - * prev_data->unref() on the data for the matching entry. - * If data is not-nullptr, replace the existing entry matching name and - * call (prev_data->unref()), or add a new one. In either case, - * data->ref() is called. - */ - void set(const char name[], SkRefCnt* data); - - /** - * Remove the matching entry (if found) and unref its data. - */ - void remove(const char name[]) { this->set(name, nullptr); } - - /** - * Remove all entries, and unref() their associated data. - */ - void removeAll(); - -private: - struct Impl; - Impl* fImpl; -}; - -#endif diff --git a/tests/RefDictTest.cpp b/tests/RefDictTest.cpp deleted file mode 100644 index f3ba657182..0000000000 --- a/tests/RefDictTest.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2011 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "SkRefDict.h" -#include "Test.h" - -class TestRC : public SkRefCnt { -public: - -private: - typedef SkRefCnt INHERITED; -}; - -DEF_TEST(RefDict, reporter) { - TestRC data0, data1; - SkRefDict dict; - - REPORTER_ASSERT(reporter, nullptr == dict.find(nullptr)); - REPORTER_ASSERT(reporter, nullptr == dict.find("foo")); - REPORTER_ASSERT(reporter, nullptr == dict.find("bar")); - - dict.set("foo", &data0); - REPORTER_ASSERT(reporter, &data0 == dict.find("foo")); - REPORTER_ASSERT(reporter, !data0.unique()); - - dict.set("foo", &data0); - REPORTER_ASSERT(reporter, &data0 == dict.find("foo")); - REPORTER_ASSERT(reporter, !data0.unique()); - - dict.set("foo", &data1); - REPORTER_ASSERT(reporter, &data1 == dict.find("foo")); - REPORTER_ASSERT(reporter, data0.unique()); - REPORTER_ASSERT(reporter, !data1.unique()); - - dict.set("foo", nullptr); - REPORTER_ASSERT(reporter, nullptr == dict.find("foo")); - REPORTER_ASSERT(reporter, data0.unique()); - REPORTER_ASSERT(reporter, data1.unique()); - - dict.set("foo", &data0); - dict.set("bar", &data1); - REPORTER_ASSERT(reporter, &data0 == dict.find("foo")); - REPORTER_ASSERT(reporter, &data1 == dict.find("bar")); - REPORTER_ASSERT(reporter, !data0.unique()); - REPORTER_ASSERT(reporter, !data1.unique()); - - dict.set("foo", &data1); - REPORTER_ASSERT(reporter, &data1 == dict.find("foo")); - REPORTER_ASSERT(reporter, &data1 == dict.find("bar")); - REPORTER_ASSERT(reporter, data0.unique()); - REPORTER_ASSERT(reporter, !data1.unique()); - - dict.removeAll(); - REPORTER_ASSERT(reporter, nullptr == dict.find("foo")); - REPORTER_ASSERT(reporter, nullptr == dict.find("bar")); - REPORTER_ASSERT(reporter, data0.unique()); - REPORTER_ASSERT(reporter, data1.unique()); - - { - SkRefDict d; - REPORTER_ASSERT(reporter, nullptr == d.find("foo")); - REPORTER_ASSERT(reporter, data0.unique()); - d.set("foo", &data0); - REPORTER_ASSERT(reporter, &data0 == d.find("foo")); - REPORTER_ASSERT(reporter, !data0.unique()); - // let d go out of scope still with a ref on data0 - } - // be sure d's destructor lowered data0's owner count back to 1 - REPORTER_ASSERT(reporter, data0.unique()); -} |