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

Unified Diff: src/lazy/SkDiscardablePixelRef.cpp

Issue 111713002: Sk_API for SkImageGenerator and SkInstallDiscardablePixelRef (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase 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') | tests/CachedDecodingPixelRefTest.cpp » ('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 e614db37e98589678919002432f1d9feb687f6d5..6a9507c8c76a713bba3c7a85388e3f8e4c78d702 100644
--- a/src/lazy/SkDiscardablePixelRef.cpp
+++ b/src/lazy/SkDiscardablePixelRef.cpp
@@ -7,6 +7,7 @@
#include "SkDiscardablePixelRef.h"
#include "SkDiscardableMemory.h"
+#include "SkImageGenerator.h"
SkDiscardablePixelRef::SkDiscardablePixelRef(SkImageGenerator* generator,
const SkImageInfo& info,
@@ -62,18 +63,22 @@ void SkDiscardablePixelRef::onUnlockPixels() {
}
}
-bool SkDiscardablePixelRef::Install(SkImageGenerator* generator,
- SkBitmap* dst,
- SkDiscardableMemory::Factory* factory) {
+bool SkInstallDiscardablePixelRef(SkImageGenerator* generator,
+ SkBitmap* dst,
+ SkDiscardableMemory::Factory* factory) {
SkImageInfo info;
SkASSERT(generator != NULL);
if ((NULL == generator)
|| (!generator->getInfo(&info))
- || (!dst->setConfig(info, 0))
- || (0 == dst->getSize())) { // dst->getSize=0 Probably a bad config
+ || (!dst->setConfig(info, 0))) {
SkDELETE(generator);
return false;
}
+ SkASSERT(dst->config() != SkBitmap::kNo_Config);
+ if (dst->empty()) { // Use a normal pixelref.
+ SkDELETE(generator); // Do not need this anymore.
+ return dst->allocPixels(NULL, NULL);
+ }
SkAutoTUnref<SkDiscardablePixelRef> ref(SkNEW_ARGS(SkDiscardablePixelRef,
(generator, info,
dst->getSize(),
« no previous file with comments | « src/lazy/SkDiscardablePixelRef.h ('k') | tests/CachedDecodingPixelRefTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698