diff options
Diffstat (limited to 'tests/CodecPriv.h')
-rw-r--r-- | tests/CodecPriv.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/CodecPriv.h b/tests/CodecPriv.h index d80bb69672..cfa794ed68 100644 --- a/tests/CodecPriv.h +++ b/tests/CodecPriv.h @@ -17,9 +17,21 @@ inline bool decode_memory(const void* mem, size_t size, SkBitmap* bm) { return false; } - bm->allocPixels(codec->getInfo()); + // Construct a color table for the decode if necessary + sk_sp<SkColorTable> colorTable(nullptr); + SkPMColor* colorPtr = nullptr; + int* colorCountPtr = nullptr; + int maxColors = 256; + if (kIndex_8_SkColorType == codec->getInfo().colorType()) { + SkPMColor colors[256]; + colorTable.reset(new SkColorTable(colors, maxColors)); + colorPtr = const_cast<SkPMColor*>(colorTable->readColors()); + colorCountPtr = &maxColors; + } + + bm->allocPixels(codec->getInfo(), colorTable); const SkCodec::Result result = codec->getPixels(codec->getInfo(), bm->getPixels(), - bm->rowBytes()); + bm->rowBytes(), nullptr, colorPtr, colorCountPtr); return result == SkCodec::kSuccess || result == SkCodec::kIncompleteInput; } #endif // CodecPriv_DEFINED |