Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(941)

Unified Diff: src/core/SkResourceCache.cpp

Issue 1426753006: SkResourceCache::GetAllocator() index8 and other color types handling (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/CachedDecodingPixelRefTest.cpp » ('j') | tests/CachedDecodingPixelRefTest.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkResourceCache.cpp
diff --git a/src/core/SkResourceCache.cpp b/src/core/SkResourceCache.cpp
index 240d1977e53968d417de449d84ff42c8e34f405e..d51cf927d4dbce3741464a7b14459f194c1e7516 100644
--- a/src/core/SkResourceCache.cpp
+++ b/src/core/SkResourceCache.cpp
@@ -79,7 +79,7 @@ class SkOneShotDiscardablePixelRef : public SkPixelRef {
public:
// Ownership of the discardablememory is transfered to the pixelref
- SkOneShotDiscardablePixelRef(const SkImageInfo&, SkDiscardableMemory*, size_t rowBytes);
+ SkOneShotDiscardablePixelRef(const SkImageInfo&, SkDiscardableMemory*, size_t rowBytes, SkColorTable* ctable);
~SkOneShotDiscardablePixelRef();
protected:
@@ -93,22 +93,29 @@ private:
SkDiscardableMemory* fDM;
size_t fRB;
bool fFirstTime;
+ SkColorTable* fCTable;
typedef SkPixelRef INHERITED;
};
SkOneShotDiscardablePixelRef::SkOneShotDiscardablePixelRef(const SkImageInfo& info,
SkDiscardableMemory* dm,
- size_t rowBytes)
+ size_t rowBytes,
+ SkColorTable* ctable)
: INHERITED(info)
, fDM(dm)
, fRB(rowBytes)
+ , fCTable(ctable)
{
SkASSERT(dm->data());
fFirstTime = true;
+ SkSafeRef(ctable);
}
-SkOneShotDiscardablePixelRef::~SkOneShotDiscardablePixelRef() { delete fDM; }
+SkOneShotDiscardablePixelRef::~SkOneShotDiscardablePixelRef() {
+ delete fDM;
+ SkSafeUnref(fCTable);
+}
bool SkOneShotDiscardablePixelRef::onNewLockPixels(LockRec* rec) {
if (fFirstTime) {
@@ -132,7 +139,7 @@ bool SkOneShotDiscardablePixelRef::onNewLockPixels(LockRec* rec) {
SUCCESS:
rec->fPixels = fDM->data();
- rec->fColorTable = nullptr;
+ rec->fColorTable = fCTable;
rec->fRowBytes = fRB;
return true;
}
@@ -171,13 +178,20 @@ bool SkResourceCacheDiscardableAllocator::allocPixelRef(SkBitmap* bitmap, SkColo
return false;
}
- // can we relax this?
- if (kN32_SkColorType != bitmap->colorType()) {
+ if (kIndex_8_SkColorType == bitmap->colorType()) {
+ if (ctable == nullptr) {
reed1 2015/11/09 14:14:19 1. nit: skia convention is either if (!ctable
aleksandar.stojiljkovic 2015/11/09 15:28:00 Good point. Fixing.
+ return false;
+ }
+ } else {
+ ctable = nullptr;
+ }
+
+ if ((unsigned)bitmap->colorType() > (unsigned)kLastEnum_SkColorType) {
reed1 2015/11/09 14:14:18 What is this actually testing, now that we're not
aleksandar.stojiljkovic 2015/11/09 15:28:00 Argh, I was some time ago, as customer, misusing c
return false;
}
SkImageInfo info = bitmap->info();
- bitmap->setPixelRef(new SkOneShotDiscardablePixelRef(info, dm, bitmap->rowBytes()))->unref();
+ bitmap->setPixelRef(new SkOneShotDiscardablePixelRef(info, dm, bitmap->rowBytes(), ctable))->unref();
bitmap->lockPixels();
return bitmap->readyToDraw();
}
« no previous file with comments | « no previous file | tests/CachedDecodingPixelRefTest.cpp » ('j') | tests/CachedDecodingPixelRefTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698