Chromium Code Reviews| Index: src/lazy/SkDiscardablePixelRef.cpp |
| diff --git a/src/lazy/SkDiscardablePixelRef.cpp b/src/lazy/SkDiscardablePixelRef.cpp |
| index ccf812ce6f7a6a13619645d16adb9e9b374cc675..3316c65477428338c08c70b7c0c2fc3c9a934123 100644 |
| --- a/src/lazy/SkDiscardablePixelRef.cpp |
| +++ b/src/lazy/SkDiscardablePixelRef.cpp |
| @@ -60,15 +60,30 @@ 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; |
| } |
| + // Note: our ctable is not purgable, as it is not stored in the discardablememory block. |
| + // This is because SkColorTable is refcntable, and therefore our caller could hold onto it |
| + // beyond the scope of a lock/unlock. If we change the API/lifecycle for SkColorTable, we |
| + // could move it into the block, but then again perhaps it is small enought that this doesn't |
|
scroggo
2014/05/28 15:53:38
enough*
reed1
2014/05/28 15:56:15
Done.
|
| + // really matter. |
| + if (colorCount > 0) { |
| + fCTable.reset(SkNEW_ARGS(SkColorTable, (colors, colorCount))); |
| + } else { |
| + fCTable.reset(NULL); |
| + } |
| + |
| rec->fPixels = pixels; |
| - rec->fColorTable = NULL; |
| + rec->fColorTable = fCTable.get(); |
| rec->fRowBytes = fRowBytes; |
| return true; |
| } |