diff options
| author | reed <reed@chromium.org> | 2015-08-04 18:46:38 -0700 |
|---|---|---|
| committer | Commit bot <commit-bot@chromium.org> | 2015-08-04 18:46:38 -0700 |
| commit | 093b4e8f51ab3432cc22ae506a2bd036d5716c98 (patch) | |
| tree | fb90570216ab64003870957a8faa7aa78ecff6a7 /samplecode/SamplePictFile.cpp | |
| parent | fb8c1fcab19c99b56d2fdcf6234751d6f0465142 (diff) | |
- allow for stepping through a picture with 'n' and 'p'
- save current slide as .skp with 'K'
BUG=skia:
TBR=
Review URL: https://codereview.chromium.org/1272063002
Diffstat (limited to 'samplecode/SamplePictFile.cpp')
| -rw-r--r-- | samplecode/SamplePictFile.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/samplecode/SamplePictFile.cpp b/samplecode/SamplePictFile.cpp index a0bab7da4e..c0973a5042 100644 --- a/samplecode/SamplePictFile.cpp +++ b/samplecode/SamplePictFile.cpp @@ -32,6 +32,18 @@ #include "SkGlyphCache.h" +#include "SkDrawFilter.h" +class SkCounterDrawFilter : public SkDrawFilter { +public: + SkCounterDrawFilter(int count) : fCount(count) {} + + bool filter(SkPaint*, Type t) override { + return --fCount >= 0; + } + + int fCount; +}; + class PictFileView : public SampleView { public: PictFileView(const char name[] = NULL) @@ -41,6 +53,7 @@ public: for (int i = 0; i < kBBoxTypeCount; ++i) { fPictures[i] = NULL; } + fCount = 0; } virtual ~PictFileView() { @@ -76,6 +89,15 @@ protected: SampleCode::TitleR(evt, name.c_str()); return true; } + SkUnichar uni; + if (SampleCode::CharQ(*evt, &uni)) { + switch (uni) { + case 'n': fCount += 1; this->inval(nullptr); return true; + case 'p': fCount -= 1; this->inval(nullptr); return true; + case 's': fCount = 0; this->inval(nullptr); return true; + default: break; + } + } return this->INHERITED::onQuery(evt); } @@ -99,7 +121,12 @@ protected: *picture = LoadPicture(fFilename.c_str(), fBBox); } if (*picture) { + SkCounterDrawFilter filter(fCount); + if (fCount > 0) { + canvas->setDrawFilter(&filter); + } canvas->drawPicture(*picture); + canvas->setDrawFilter(NULL); } #ifdef SK_GLYPHCACHE_TRACK_HASH_STATS @@ -121,6 +148,7 @@ private: SkPicture* fPictures[kBBoxTypeCount]; BBoxType fBBox; SkSize fTileSize; + int fCount; SkPicture* LoadPicture(const char path[], BBoxType bbox) { SkAutoTUnref<SkPicture> pic; |
