diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-10-15 20:39:57 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-10-15 20:39:57 +0000 |
commit | 2f92966c6a2419023570d5951a4234cdaebcc3c9 (patch) | |
tree | fdbc8ee6ef7f9ee49e5695eea74b97ea2ff2be3d | |
parent | e0e1da34f3c00ec93c61643d4cf4eea6d27c5fef (diff) |
Remove SkDataTable from SkFlattenable hierarchy.
As far as I can tell, we never really needed this. No code outside the unit
test calls this code.
BUG=
R=reed@google.com
Author: mtklein@google.com
Review URL: https://codereview.chromium.org/26223009
git-svn-id: http://skia.googlecode.com/svn/trunk@11792 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | include/core/SkDataTable.h | 11 | ||||
-rw-r--r-- | src/core/SkDataTable.cpp | 60 | ||||
-rw-r--r-- | tests/DataRefTest.cpp | 20 |
3 files changed, 2 insertions, 89 deletions
diff --git a/include/core/SkDataTable.h b/include/core/SkDataTable.h index cb74c3cb39..9440000e00 100644 --- a/include/core/SkDataTable.h +++ b/include/core/SkDataTable.h @@ -10,7 +10,6 @@ #include "SkChunkAlloc.h" #include "SkData.h" -#include "SkFlattenable.h" #include "SkString.h" #include "SkTDArray.h" @@ -19,7 +18,7 @@ * organized into a table of entries, each with a length, so the entries are * not required to all be the same size. */ -class SK_API SkDataTable : public SkFlattenable { +class SK_API SkDataTable : public SkRefCnt { public: SK_DECLARE_INST_COUNT(SkDataTable) @@ -94,12 +93,6 @@ public: static SkDataTable* NewArrayProc(const void* array, size_t elemSize, int count, FreeProc proc, void* context); - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDataTable) - -protected: - SkDataTable(SkFlattenableReadBuffer&); - virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; - private: struct Dir { const void* fPtr; @@ -124,7 +117,7 @@ private: friend class SkDataTableBuilder; // access to Dir - typedef SkFlattenable INHERITED; + typedef SkRefCnt INHERITED; }; /** diff --git a/src/core/SkDataTable.cpp b/src/core/SkDataTable.cpp index 608d147024..917445c98f 100644 --- a/src/core/SkDataTable.cpp +++ b/src/core/SkDataTable.cpp @@ -7,7 +7,6 @@ #include "SkData.h" #include "SkDataTable.h" -#include "SkFlattenableBuffers.h" SK_DEFINE_INST_COUNT(SkDataTable) @@ -77,65 +76,6 @@ const void* SkDataTable::at(int index, size_t* size) const { } } -SkDataTable::SkDataTable(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) { - fElemSize = 0; - fU.fElems = NULL; - fFreeProc = NULL; - fFreeProcContext = NULL; - - fCount = buffer.read32(); - if (fCount) { - fElemSize = buffer.read32(); - if (fElemSize) { - size_t size = buffer.getArrayCount(); - // size is the size of our elems data - SkASSERT(fCount * fElemSize == size); - void* addr = sk_malloc_throw(size); - if (buffer.readByteArray(addr) != size) { - sk_throw(); - } - fU.fElems = (const char*)addr; - fFreeProcContext = addr; - } else { - size_t dataSize = buffer.read32(); - - size_t allocSize = fCount * sizeof(Dir) + dataSize; - void* addr = sk_malloc_throw(allocSize); - Dir* dir = (Dir*)addr; - char* elem = (char*)(dir + fCount); - for (int i = 0; i < fCount; ++i) { - dir[i].fPtr = elem; - dir[i].fSize = buffer.readByteArray(elem); - elem += dir[i].fSize; - } - fU.fDir = dir; - fFreeProcContext = addr; - } - fFreeProc = malloc_freeproc; - } -} - -void SkDataTable::flatten(SkFlattenableWriteBuffer& buffer) const { - this->INHERITED::flatten(buffer); - - buffer.write32(fCount); - if (fCount) { - buffer.write32(fElemSize); - if (fElemSize) { - buffer.writeByteArray(fU.fElems, fCount * fElemSize); - } else { - size_t dataSize = 0; - for (int i = 0; i < fCount; ++i) { - dataSize += fU.fDir[i].fSize; - } - buffer.write32(dataSize); - for (int i = 0; i < fCount; ++i) { - buffer.writeByteArray(fU.fDir[i].fPtr, fU.fDir[i].fSize); - } - } - } -} - /////////////////////////////////////////////////////////////////////////////// SkDataTable* SkDataTable::NewEmpty() { diff --git a/tests/DataRefTest.cpp b/tests/DataRefTest.cpp index 9043a58722..c32c4553ca 100644 --- a/tests/DataRefTest.cpp +++ b/tests/DataRefTest.cpp @@ -25,26 +25,10 @@ static void test_is_equal(skiatest::Reporter* reporter, } } -static void test_datatable_flatten(skiatest::Reporter* reporter, - SkDataTable* table) { - SkOrderedWriteBuffer wb(1024); - wb.writeFlattenable(table); - - size_t wsize = wb.size(); - SkAutoMalloc storage(wsize); - wb.writeToMemory(storage.get()); - - SkOrderedReadBuffer rb(storage.get(), wsize); - SkAutoTUnref<SkDataTable> newTable((SkDataTable*)rb.readFlattenable()); - - test_is_equal(reporter, table, newTable); -} - static void test_datatable_is_empty(skiatest::Reporter* reporter, SkDataTable* table) { REPORTER_ASSERT(reporter, table->isEmpty()); REPORTER_ASSERT(reporter, 0 == table->count()); - test_datatable_flatten(reporter, table); } static void test_emptytable(skiatest::Reporter* reporter) { @@ -77,7 +61,6 @@ static void test_simpletable(skiatest::Reporter* reporter) { REPORTER_ASSERT(reporter, *itable->atT<int>(i, &size) == idata[i]); REPORTER_ASSERT(reporter, sizeof(int) == size); } - test_datatable_flatten(reporter, itable); } static void test_vartable(skiatest::Reporter* reporter) { @@ -104,7 +87,6 @@ static void test_vartable(skiatest::Reporter* reporter) { const char* s = table->atStr(i); REPORTER_ASSERT(reporter, strlen(s) == strlen(str[i])); } - test_datatable_flatten(reporter, table); } static void test_tablebuilder(skiatest::Reporter* reporter) { @@ -131,7 +113,6 @@ static void test_tablebuilder(skiatest::Reporter* reporter) { const char* s = table->atStr(i); REPORTER_ASSERT(reporter, strlen(s) == strlen(str[i])); } - test_datatable_flatten(reporter, table); } static void test_globaltable(skiatest::Reporter* reporter) { @@ -150,7 +131,6 @@ static void test_globaltable(skiatest::Reporter* reporter) { REPORTER_ASSERT(reporter, *table->atT<const char>(i, &size) == i); REPORTER_ASSERT(reporter, sizeof(int) == size); } - test_datatable_flatten(reporter, table); } static void TestDataTable(skiatest::Reporter* reporter) { |