diff --git a/src/lazy/SkDiscardablePixelRef.cpp b/src/lazy/SkDiscardablePixelRef.cpp index f0d7affdc8..ce38a4a877 100644 --- a/src/lazy/SkDiscardablePixelRef.cpp +++ b/src/lazy/SkDiscardablePixelRef.cpp @@ -40,7 +40,7 @@ bool SkDiscardablePixelRef::onNewLockPixels(LockRec* rec) { if (fDiscardableMemory != NULL) { if (fDiscardableMemory->lock()) { rec->fPixels = fDiscardableMemory->data(); - rec->fColorTable = NULL; + rec->fColorTable = fCTable.get(); rec->fRowBytes = fRowBytes; return true; } diff --git a/tests/ImageDecodingTest.cpp b/tests/ImageDecodingTest.cpp index d070f615b3..d8e813d10e 100644 --- a/tests/ImageDecodingTest.cpp +++ b/tests/ImageDecodingTest.cpp @@ -723,3 +723,27 @@ DEF_TEST(ImageDecoderOptions, reporter) { } } } + +DEF_TEST(DiscardablePixelRef_SecondLockColorTableCheck, r) { + SkString resourceDir = GetResourcePath(); + SkString path = SkOSPath::SkPathJoin(resourceDir.c_str(), "randPixels.gif"); + if (!sk_exists(path.c_str())) { + return; + } + SkAutoDataUnref encoded(SkData::NewFromFileName(path.c_str())); + SkBitmap bitmap; + if (!SkInstallDiscardablePixelRef( + SkDecodingImageGenerator::Create( + encoded, SkDecodingImageGenerator::Options()), &bitmap)) { + ERRORF(r, "SkInstallDiscardablePixelRef [randPixels.gif] failed."); + return; + } + { + SkAutoLockPixels alp(bitmap); + REPORTER_ASSERT(r, bitmap.getColorTable() && "first pass"); + } + { + SkAutoLockPixels alp(bitmap); + REPORTER_ASSERT(r, bitmap.getColorTable() && "second pass"); + } +}