Chromium Code Reviews| Index: src/lazy/SkDiscardablePixelRef.cpp |
| diff --git a/src/lazy/SkDiscardablePixelRef.cpp b/src/lazy/SkDiscardablePixelRef.cpp |
| index ccf812ce6f7a6a13619645d16adb9e9b374cc675..2bf608438598484126522d7c3a2a7652720d9b3e 100644 |
| --- a/src/lazy/SkDiscardablePixelRef.cpp |
| +++ b/src/lazy/SkDiscardablePixelRef.cpp |
| @@ -60,15 +60,25 @@ bool SkDiscardablePixelRef::onNewLockPixels(LockRec* rec) { |
| } |
| void* pixels = fDiscardableMemory->data(); |
| - if (!fGenerator->getPixels(this->info(), pixels, fRowBytes)) { |
| + const SkImageInfo& info = this->info(); |
| + SkPMColor colors[256]; |
| + int colorCount = 0; |
| + |
| + if (!fGenerator->getPixels(info, pixels, fRowBytes, colors, &colorCount)) { |
| fDiscardableMemory->unlock(); |
| SkDELETE(fDiscardableMemory); |
| fDiscardableMemory = NULL; |
| return false; |
| } |
| + if (colorCount > 0) { |
| + fCTable.reset(SkNEW_ARGS(SkColorTable, (colors, colorCount))); |
| + } else { |
| + fCTable.reset(NULL); |
| + } |
| + |
| rec->fPixels = pixels; |
| - rec->fColorTable = NULL; |
| + rec->fColorTable = fCTable.get(); |
|
scroggo
2014/05/28 15:01:37
This version does not purge the color table on mem
reed1
2014/05/28 15:48:02
Agreed, I don't know how to ram the colortable int
|
| rec->fRowBytes = fRowBytes; |
| return true; |
| } |