From e2380570de11226a93362d017e93c4790641c027 Mon Sep 17 00:00:00 2001 From: "halcanary@google.com" Date: Wed, 18 Dec 2013 15:08:35 +0000 Subject: 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 --- samplecode/SamplePicture.cpp | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'samplecode') 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(); -- cgit v1.2.3