diff options
Diffstat (limited to 'src/core/SkColorTable.cpp')
-rw-r--r-- | src/core/SkColorTable.cpp | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/core/SkColorTable.cpp b/src/core/SkColorTable.cpp index 928f5158d4..97103463db 100644 --- a/src/core/SkColorTable.cpp +++ b/src/core/SkColorTable.cpp @@ -23,7 +23,11 @@ void SkColorTable::init(const SkPMColor colors[], int count) { SkColorTable::SkColorTable(const SkPMColor colors[], int count) { SkASSERT(0 == count || colors); - SkASSERT(count >= 0 && count <= 256); + if (count < 0) { + count = 0; + } else if (count > 256) { + count = 256; + } this->init(colors, count); } @@ -52,16 +56,6 @@ const uint16_t* SkColorTable::read16BitCache() const { return f16BitCache; } -sk_sp<SkColorTable> SkColorTable::Make(const SkPMColor colors[], int count) { - if (count < 0 || count > 256) { - return nullptr; - } - if (count && !colors) { - return nullptr; - } - return sk_make_sp<SkColorTable>(colors, count); -} - /////////////////////////////////////////////////////////////////////////////// #if 0 @@ -91,14 +85,14 @@ void SkColorTable::writeToBuffer(SkWriteBuffer& buffer) const { buffer.writeColorArray(fColors, fCount); } -sk_sp<SkColorTable> SkColorTable::Create(SkReadBuffer& buffer) { +SkColorTable* SkColorTable::Create(SkReadBuffer& buffer) { if (buffer.isVersionLT(SkReadBuffer::kRemoveColorTableAlpha_Version)) { /*fAlphaType = */buffer.readUInt(); } const int count = buffer.getArrayCount(); if (0 == count) { - return sk_sp<SkColorTable>(new SkColorTable(nullptr, 0)); + return new SkColorTable(nullptr, 0); } if (count < 0 || count > 256) { @@ -112,5 +106,5 @@ sk_sp<SkColorTable> SkColorTable::Create(SkReadBuffer& buffer) { return nullptr; } - return sk_sp<SkColorTable>(new SkColorTable(colors.release(), count, kAllocatedWithMalloc)); + return new SkColorTable(colors.release(), count, kAllocatedWithMalloc); } |