aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode
diff options
context:
space:
mode:
authorGravatar halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-18 15:08:35 +0000
committerGravatar halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-18 15:08:35 +0000
commite2380570de11226a93362d017e93c4790641c027 (patch)
tree03454d2688c146874b86c9e437a6cc65f87aaf2f /samplecode
parent6cb74f2b86144803f6351c85f0c57ae386d6b66b (diff)
SamplePicture no longer uses SkImageRef
Motivation: in an attempt to simplify life, we are depricating SkImageRef and its subclasses. To that end, SamplePicture will now use SkDiscardablePixelRef. Also, fixed missing resource. BUG= R=scroggo@google.com Review URL: https://codereview.chromium.org/116423006 git-svn-id: http://skia.googlecode.com/svn/trunk@12737 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode')
-rw-r--r--samplecode/SamplePicture.cpp27
1 files changed, 11 insertions, 16 deletions
diff --git a/samplecode/SamplePicture.cpp b/samplecode/SamplePicture.cpp
index 2f7d691d17..af06e823b8 100644
--- a/samplecode/SamplePicture.cpp
+++ b/samplecode/SamplePicture.cpp
@@ -6,6 +6,8 @@
* found in the LICENSE file.
*/
#include "SampleCode.h"
+#include "SkData.h"
+#include "SkDecodingImageGenerator.h"
#include "SkDumpCanvas.h"
#include "SkView.h"
#include "SkCanvas.h"
@@ -13,6 +15,7 @@
#include "SkGradientShader.h"
#include "SkGraphics.h"
#include "SkImageDecoder.h"
+#include "SkOSFile.h"
#include "SkPath.h"
#include "SkPicture.h"
#include "SkRandom.h"
@@ -24,27 +27,20 @@
#include "SkTime.h"
#include "SkTypeface.h"
#include "SkXfermode.h"
-
#include "SkStream.h"
#include "SkXMLParser.h"
-///////////////////////////////////////////////////////////////////////////////
+#include "gm.h"
-#include "SkImageRef_GlobalPool.h"
+///////////////////////////////////////////////////////////////////////////////
static SkBitmap load_bitmap() {
SkBitmap bm;
- SkStreamAsset* stream = SkStream::NewFromFile("/skimages/sesame_street_ensemble-hp.jpg");
- if (stream) {
- SkAutoUnref aur(stream);
-
- if (SkImageDecoder::DecodeStream(stream, &bm, SkBitmap::kNo_Config,
- SkImageDecoder::kDecodeBounds_Mode)) {
- SkImageInfo info;
- bm.asImageInfo(&info);
- SkPixelRef* pr = new SkImageRef_GlobalPool(info, stream, 1);
- bm.setPixelRef(pr)->unref();
- }
+ SkString directory = skiagm::GM::GetResourcePath();
+ SkString path = SkOSPath::SkPathJoin(directory.c_str(), "mandrill_512.png");
+ SkAutoDataUnref data(SkData::NewFromFileName(path.c_str()));
+ if (data.get() != NULL) {
+ SkDecodingImageGenerator::Install(data.get(), &bm);
}
return bm;
}
@@ -61,8 +57,7 @@ static void drawCircle(SkCanvas* canvas, int r, SkColor color) {
class PictureView : public SampleView {
SkBitmap fBitmap;
public:
- PictureView() {
- SkImageRef_GlobalPool::SetRAMBudget(16 * 1024);
+ PictureView() {
fBitmap = load_bitmap();