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

Unified Diff: gm/factory.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 | « no previous file | gyp/SampleApp.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/factory.cpp
diff --git a/gm/factory.cpp b/gm/factory.cpp
index 6734235abb583aa66b5325feeca1ff1e5edefd1e..19eb63be0c87206ec54f262ea1e1326f6546da64 100644
--- a/gm/factory.cpp
+++ b/gm/factory.cpp
@@ -6,11 +6,12 @@
*/
#include "gm.h"
-#include "SkBitmapFactory.h"
#include "SkCanvas.h"
#include "SkData.h"
+#include "SkDecodingImageGenerator.h"
+#include "SkDiscardableMemoryPool.h"
+#include "SkDiscardablePixelRef.h"
#include "SkImageDecoder.h"
-#include "SkLruImageCache.h"
#include "SkOSFile.h"
#include "SkStream.h"
@@ -28,20 +29,14 @@ protected:
// Copyright-free file from http://openclipart.org/detail/29213/paper-plane-by-ddoo
SkString filename = SkOSPath::SkPathJoin(INHERITED::gResourcePath.c_str(),
"plane.png");
-
- SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(filename.c_str()));
- if (NULL != stream.get()) {
- stream->rewind();
- size_t length = stream->getLength();
- void* buffer = sk_malloc_throw(length);
- stream->read(buffer, length);
- SkAutoDataUnref data(SkData::NewFromMalloc(buffer, length));
- SkBitmapFactory factory(&SkImageDecoder::DecodeMemoryToTarget);
+ SkAutoDataUnref data(SkData::NewFromFileName(filename.c_str()));
+ if (NULL != data.get()) {
// Create a cache which will boot the pixels out anytime the
// bitmap is unlocked.
- SkAutoTUnref<SkLruImageCache> cache(SkNEW_ARGS(SkLruImageCache, (1)));
- factory.setImageCache(cache);
- factory.installPixelRef(data, &fBitmap);
+ SkAutoTUnref<SkDiscardableMemoryPool> pool(
+ SkNEW_ARGS(SkDiscardableMemoryPool, (1)));
+ SkAssertResult(SkDecodingImageGenerator::Install(data,
+ &fBitmap, pool));
}
}
« no previous file with comments | « no previous file | gyp/SampleApp.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698