SkDiscardablePixelRef returns correct indexed color on relock.
R=djsollen@google.com Author: halcanary@google.com Review URL: https://codereview.chromium.org/428603002
This commit is contained in:
parent
edb10e79f5
commit
7f8aad84de
@ -40,7 +40,7 @@ bool SkDiscardablePixelRef::onNewLockPixels(LockRec* rec) {
|
|||||||
if (fDiscardableMemory != NULL) {
|
if (fDiscardableMemory != NULL) {
|
||||||
if (fDiscardableMemory->lock()) {
|
if (fDiscardableMemory->lock()) {
|
||||||
rec->fPixels = fDiscardableMemory->data();
|
rec->fPixels = fDiscardableMemory->data();
|
||||||
rec->fColorTable = NULL;
|
rec->fColorTable = fCTable.get();
|
||||||
rec->fRowBytes = fRowBytes;
|
rec->fRowBytes = fRowBytes;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user