diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-29 15:57:20 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-29 15:57:20 +0000 |
commit | 00f8d6c75d22ce8f95f932c5b101354b196fa0df (patch) | |
tree | 7ff413f0df54836620b2ba58c524d62ce7d033ff /src/lazy | |
parent | 2246e325b8710389d8f718843356e410f683dd25 (diff) |
Revert "Revert of add colortable support to imagegenerator (https://codereview.chromium.org/304443003/)"
Fix is to add colortable param to installPixels()
This reverts commit 924205aaf2e0c3c65dda13e0eaccde3e7b2a5c40.
BUG=skia:
R=scroggo@google.com, reed@chromium.org
Author: reed@google.com
Review URL: https://codereview.chromium.org/300263005
git-svn-id: http://skia.googlecode.com/svn/trunk@14958 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/lazy')
-rw-r--r-- | src/lazy/SkDiscardablePixelRef.cpp | 19 | ||||
-rw-r--r-- | src/lazy/SkDiscardablePixelRef.h | 5 |
2 files changed, 18 insertions, 6 deletions
diff --git a/src/lazy/SkDiscardablePixelRef.cpp b/src/lazy/SkDiscardablePixelRef.cpp index ccf812ce6f..b0bbd27e3a 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 enough that this doesn't + // 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; } diff --git a/src/lazy/SkDiscardablePixelRef.h b/src/lazy/SkDiscardablePixelRef.h index e5e1c9f0e1..52a1d6ce37 100644 --- a/src/lazy/SkDiscardablePixelRef.h +++ b/src/lazy/SkDiscardablePixelRef.h @@ -17,10 +17,6 @@ * A PixelRef backed by SkDiscardableMemory, with the ability to * re-generate the pixels (via a SkImageGenerator) if the DM is * purged. - * - * Since SkColorTable is reference-counted, we do not support indexed - * color with this class; there would be no way for the discardable - * memory system to unref the color table. */ class SkDiscardablePixelRef : public SkPixelRef { public: @@ -46,6 +42,7 @@ private: // PixelRef, since the SkBitmap doesn't expect them to change. SkDiscardableMemory* fDiscardableMemory; + SkAutoTUnref<SkColorTable> fCTable; /* Takes ownership of SkImageGenerator. */ SkDiscardablePixelRef(const SkImageInfo&, SkImageGenerator*, |