From 57c29f7d6fe050838771f6b8d595d44919ace1a1 Mon Sep 17 00:00:00 2001 From: "djsollen@google.com" Date: Mon, 10 Dec 2012 13:55:02 +0000 Subject: Reapply r5364 (Update ARM and NEON optimizations for S32A_Opaque_BlitRow32) This reverts r5378. Review URL: https://codereview.appspot.com/6815056 git-svn-id: http://skia.googlecode.com/svn/trunk@6727 2bbb7eff-a529-9590-31e7-b0007b416f81 --- samplecode/SamplePictFile.cpp | 45 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) (limited to 'samplecode/SamplePictFile.cpp') diff --git a/samplecode/SamplePictFile.cpp b/samplecode/SamplePictFile.cpp index 22c81d1d94..b53ba83600 100644 --- a/samplecode/SamplePictFile.cpp +++ b/samplecode/SamplePictFile.cpp @@ -13,6 +13,7 @@ #include "SkGradientShader.h" #include "SkGraphics.h" #include "SkImageDecoder.h" +#include "SkOSFile.h" #include "SkPath.h" #include "SkPicture.h" #include "SkRandom.h" @@ -31,8 +32,10 @@ class PictFileView : public SampleView { SkString fFilename; SkPicture* fPicture; + SkPicture* fBBoxPicture; + bool fUseBBox; - static SkPicture* LoadPicture(const char path[]) { + static SkPicture* LoadPicture(const char path[], bool useBBox) { SkPicture* pic = NULL; SkBitmap bm; @@ -60,16 +63,30 @@ class PictFileView : public SampleView { p2.serialize(&writer); } } - return pic; + + if (useBBox) { + SkPicture* bboxPicture = SkNEW(SkPicture); + pic->draw(bboxPicture->beginRecording(pic->width(), pic->height(), + SkPicture::kOptimizeForClippedPlayback_RecordingFlag)); + bboxPicture->endRecording(); + SkDELETE(pic); + return bboxPicture; + + } else { + return pic; + } } public: PictFileView(const char name[] = NULL) : fFilename(name) { fPicture = NULL; + fBBoxPicture = NULL; + fUseBBox = false; } virtual ~PictFileView() { SkSafeUnref(fPicture); + SkSafeUnref(fBBoxPicture); } protected: @@ -77,19 +94,33 @@ protected: virtual bool onQuery(SkEvent* evt) { if (SampleCode::TitleQ(*evt)) { SkString name("P:"); - name.append(fFilename); + const char* basename = strrchr(fFilename.c_str(), SkPATH_SEPARATOR); + name.append(basename ? basename+1: fFilename.c_str()); + if (fUseBBox) { + name.append(" "); + } SampleCode::TitleR(evt, name.c_str()); return true; } return this->INHERITED::onQuery(evt); } + virtual bool onEvent(const SkEvent& evt) { + if (evt.isType("PictFileView::toggleBBox")) { + fUseBBox = !fUseBBox; + return true; + } + return this->INHERITED::onEvent(evt); + } + virtual void onDrawContent(SkCanvas* canvas) { - if (!fPicture) { - fPicture = LoadPicture(fFilename.c_str()); + SkPicture** picture = fUseBBox ? &fBBoxPicture : &fPicture; + + if (!*picture) { + *picture = LoadPicture(fFilename.c_str(), fUseBBox); } - if (fPicture) { - canvas->drawPicture(*fPicture); + if (*picture) { + canvas->drawPicture(**picture); } } -- cgit v1.2.3