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

Unified Diff: src/lazy/SkDiscardablePixelRef.cpp

Issue 103033002: Big Cleanup: SkBitmapFactory, SkLazyPixelRef, SkImageCache (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase one last time Created 7 years 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 | « src/lazy/SkDiscardablePixelRef.h ('k') | src/lazy/SkLazyPixelRef.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/lazy/SkDiscardablePixelRef.cpp
diff --git a/src/lazy/SkDiscardablePixelRef.cpp b/src/lazy/SkDiscardablePixelRef.cpp
index 4e19c7f65b9c011e6e2ab424a5e05a67218f2986..e614db37e98589678919002432f1d9feb687f6d5 100644
--- a/src/lazy/SkDiscardablePixelRef.cpp
+++ b/src/lazy/SkDiscardablePixelRef.cpp
@@ -11,8 +11,10 @@
SkDiscardablePixelRef::SkDiscardablePixelRef(SkImageGenerator* generator,
const SkImageInfo& info,
size_t size,
- size_t rowBytes)
+ size_t rowBytes,
+ SkDiscardableMemory::Factory* fact)
: fGenerator(generator)
+ , fDMFactory(fact)
, fInfo(info)
, fSize(size)
, fRowBytes(rowBytes)
@@ -23,9 +25,12 @@ SkDiscardablePixelRef::SkDiscardablePixelRef(SkImageGenerator* generator,
// The SkImageGenerator contract requires fGenerator to always
// decode the same image on each call to getPixels().
this->setImmutable();
+ SkSafeRef(fDMFactory);
}
SkDiscardablePixelRef::~SkDiscardablePixelRef() {
+ SkDELETE(fDiscardableMemory);
+ SkSafeUnref(fDMFactory);
SkDELETE(fGenerator);
}
@@ -34,9 +39,14 @@ void* SkDiscardablePixelRef::onLockPixels(SkColorTable**) {
if (fDiscardableMemory->lock()) {
return fDiscardableMemory->data();
}
+ SkDELETE(fDiscardableMemory);
fDiscardableMemory = NULL;
}
- fDiscardableMemory = SkDiscardableMemory::Create(fSize);
+ if (fDMFactory != NULL) {
+ fDiscardableMemory = fDMFactory->create(fSize);
+ } else {
+ fDiscardableMemory = SkDiscardableMemory::Create(fSize);
+ }
if (NULL == fDiscardableMemory) {
return NULL; // Memory allocation failed.
}
@@ -53,19 +63,22 @@ void SkDiscardablePixelRef::onUnlockPixels() {
}
bool SkDiscardablePixelRef::Install(SkImageGenerator* generator,
- SkBitmap* dst) {
+ SkBitmap* dst,
+ SkDiscardableMemory::Factory* factory) {
SkImageInfo info;
SkASSERT(generator != NULL);
if ((NULL == generator)
|| (!generator->getInfo(&info))
- || (!dst->setConfig(info, 0))) {
+ || (!dst->setConfig(info, 0))
+ || (0 == dst->getSize())) { // dst->getSize=0 Probably a bad config
SkDELETE(generator);
return false;
}
SkAutoTUnref<SkDiscardablePixelRef> ref(SkNEW_ARGS(SkDiscardablePixelRef,
(generator, info,
dst->getSize(),
- dst->rowBytes())));
+ dst->rowBytes(),
+ factory)));
dst->setPixelRef(ref);
return true;
}
« no previous file with comments | « src/lazy/SkDiscardablePixelRef.h ('k') | src/lazy/SkLazyPixelRef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698