Remove SkDataTableBuilder. It is not used.
Change-Id: Ieae9adba73b8ada959e08d69a06d0f3d010209c6 Reviewed-on: https://skia-review.googlesource.com/9076 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
parent
2c2bc11aea
commit
5990680a09
@ -8,7 +8,6 @@
|
|||||||
#ifndef SkDataTable_DEFINED
|
#ifndef SkDataTable_DEFINED
|
||||||
#define SkDataTable_DEFINED
|
#define SkDataTable_DEFINED
|
||||||
|
|
||||||
#include "../private/SkChunkAlloc.h"
|
|
||||||
#include "../private/SkTDArray.h"
|
#include "../private/SkTDArray.h"
|
||||||
#include "SkData.h"
|
#include "SkData.h"
|
||||||
#include "SkString.h"
|
#include "SkString.h"
|
||||||
@ -117,58 +116,4 @@ private:
|
|||||||
typedef SkRefCnt INHERITED;
|
typedef SkRefCnt INHERITED;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper class that allows for incrementally building up the data needed to
|
|
||||||
* create a SkDataTable.
|
|
||||||
*/
|
|
||||||
class SK_API SkDataTableBuilder : SkNoncopyable {
|
|
||||||
public:
|
|
||||||
SkDataTableBuilder(size_t minChunkSize);
|
|
||||||
~SkDataTableBuilder();
|
|
||||||
|
|
||||||
int count() const { return fDir.count(); }
|
|
||||||
size_t minChunkSize() const { return fMinChunkSize; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Forget any previously appended entries, setting count() back to 0.
|
|
||||||
*/
|
|
||||||
void reset(size_t minChunkSize);
|
|
||||||
void reset() {
|
|
||||||
this->reset(fMinChunkSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy size-bytes from data, and append it to the growing SkDataTable.
|
|
||||||
*/
|
|
||||||
void append(const void* data, size_t size);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper version of append() passes strlen() + 1 for the size,
|
|
||||||
* so the trailing-zero will be copied as well.
|
|
||||||
*/
|
|
||||||
void appendStr(const char str[]) {
|
|
||||||
this->append(str, strlen(str) + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper version of append() passes string.size() + 1 for the size,
|
|
||||||
* so the trailing-zero will be copied as well.
|
|
||||||
*/
|
|
||||||
void appendString(const SkString& string) {
|
|
||||||
this->append(string.c_str(), string.size() + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return an SkDataTable from the accumulated entries that were added by
|
|
||||||
* calls to append(). This call also clears any accumluated entries from
|
|
||||||
* this builder, so its count() will be 0 after this call.
|
|
||||||
*/
|
|
||||||
sk_sp<SkDataTable> detachDataTable();
|
|
||||||
|
|
||||||
private:
|
|
||||||
SkTDArray<SkDataTable::Dir> fDir;
|
|
||||||
SkChunkAlloc* fHeap;
|
|
||||||
size_t fMinChunkSize;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -129,53 +129,3 @@ sk_sp<SkDataTable> SkDataTable::MakeArrayProc(const void* array, size_t elemSize
|
|||||||
}
|
}
|
||||||
return sk_sp<SkDataTable>(new SkDataTable(array, elemSize, count, proc, ctx));
|
return sk_sp<SkDataTable>(new SkDataTable(array, elemSize, count, proc, ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
static void chunkalloc_freeproc(void* context) { delete (SkChunkAlloc*)context; }
|
|
||||||
|
|
||||||
SkDataTableBuilder::SkDataTableBuilder(size_t minChunkSize)
|
|
||||||
: fHeap(nullptr)
|
|
||||||
, fMinChunkSize(minChunkSize) {}
|
|
||||||
|
|
||||||
SkDataTableBuilder::~SkDataTableBuilder() { this->reset(); }
|
|
||||||
|
|
||||||
void SkDataTableBuilder::reset(size_t minChunkSize) {
|
|
||||||
fMinChunkSize = minChunkSize;
|
|
||||||
fDir.reset();
|
|
||||||
if (fHeap) {
|
|
||||||
delete fHeap;
|
|
||||||
fHeap = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SkDataTableBuilder::append(const void* src, size_t size) {
|
|
||||||
if (nullptr == fHeap) {
|
|
||||||
fHeap = new SkChunkAlloc(fMinChunkSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void* dst = fHeap->alloc(size, SkChunkAlloc::kThrow_AllocFailType);
|
|
||||||
memcpy(dst, src, size);
|
|
||||||
|
|
||||||
SkDataTable::Dir* dir = fDir.append();
|
|
||||||
dir->fPtr = dst;
|
|
||||||
dir->fSize = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
sk_sp<SkDataTable> SkDataTableBuilder::detachDataTable() {
|
|
||||||
const int count = fDir.count();
|
|
||||||
if (0 == count) {
|
|
||||||
return SkDataTable::MakeEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy the dir into the heap;
|
|
||||||
void* dir = fHeap->alloc(count * sizeof(SkDataTable::Dir), SkChunkAlloc::kThrow_AllocFailType);
|
|
||||||
memcpy(dir, fDir.begin(), count * sizeof(SkDataTable::Dir));
|
|
||||||
|
|
||||||
sk_sp<SkDataTable> table(
|
|
||||||
new SkDataTable((SkDataTable::Dir*)dir, count, chunkalloc_freeproc, fHeap));
|
|
||||||
// we have to detach our fHeap, since we are giving that to the table
|
|
||||||
fHeap = nullptr;
|
|
||||||
fDir.reset();
|
|
||||||
return table;
|
|
||||||
}
|
|
||||||
|
@ -85,32 +85,6 @@ static void test_vartable(skiatest::Reporter* reporter) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_tablebuilder(skiatest::Reporter* reporter) {
|
|
||||||
const char* str[] = {
|
|
||||||
"", "a", "be", "see", "deigh", "ef", "ggggggggggggggggggggggggggg"
|
|
||||||
};
|
|
||||||
int count = SK_ARRAY_COUNT(str);
|
|
||||||
|
|
||||||
SkDataTableBuilder builder(16);
|
|
||||||
|
|
||||||
for (int i = 0; i < count; ++i) {
|
|
||||||
builder.append(str[i], strlen(str[i]) + 1);
|
|
||||||
}
|
|
||||||
sk_sp<SkDataTable> table(builder.detachDataTable());
|
|
||||||
|
|
||||||
REPORTER_ASSERT(reporter, table->count() == count);
|
|
||||||
for (int i = 0; i < count; ++i) {
|
|
||||||
size_t size;
|
|
||||||
REPORTER_ASSERT(reporter, table->atSize(i) == strlen(str[i]) + 1);
|
|
||||||
REPORTER_ASSERT(reporter, !strcmp(table->atT<const char>(i, &size),
|
|
||||||
str[i]));
|
|
||||||
REPORTER_ASSERT(reporter, size == strlen(str[i]) + 1);
|
|
||||||
|
|
||||||
const char* s = table->atStr(i);
|
|
||||||
REPORTER_ASSERT(reporter, strlen(s) == strlen(str[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_globaltable(skiatest::Reporter* reporter) {
|
static void test_globaltable(skiatest::Reporter* reporter) {
|
||||||
static const int gData[] = {
|
static const int gData[] = {
|
||||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
|
||||||
@ -133,7 +107,6 @@ DEF_TEST(DataTable, reporter) {
|
|||||||
test_emptytable(reporter);
|
test_emptytable(reporter);
|
||||||
test_simpletable(reporter);
|
test_simpletable(reporter);
|
||||||
test_vartable(reporter);
|
test_vartable(reporter);
|
||||||
test_tablebuilder(reporter);
|
|
||||||
test_globaltable(reporter);
|
test_globaltable(reporter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user