fMagnify = false;
fSaveToPdf = false;
-
- fTransitionNext = 6;
- fTransitionPrev = 2;
+ fSaveToSKP = false;
int sinkID = this->getSinkID();
fAppMenu = new SkOSMenu;
fAppMenu->assignKeyEquivalentToItem(itemID, 'z');
itemID = fAppMenu->appendSwitch("Magnify", "Magnify" , sinkID, fMagnify);
fAppMenu->assignKeyEquivalentToItem(itemID, 'm');
- itemID =fAppMenu->appendList("Transition-Next", "Transition-Next", sinkID,
- fTransitionNext, "Up", "Up and Right", "Right",
- "Down and Right", "Down", "Down and Left",
- "Left", "Up and Left", NULL);
- fAppMenu->assignKeyEquivalentToItem(itemID, 'j');
- itemID =fAppMenu->appendList("Transition-Prev", "Transition-Prev", sinkID,
- fTransitionPrev, "Up", "Up and Right", "Right",
- "Down and Right", "Down", "Down and Left",
- "Left", "Up and Left", NULL);
- fAppMenu->assignKeyEquivalentToItem(itemID, 'k');
+
itemID = fAppMenu->appendAction("Save to PDF", sinkID);
fAppMenu->assignKeyEquivalentToItem(itemID, 'e');
if (kPicture_DeviceType == fDeviceType) {
SkAutoTUnref<const SkPicture> picture(fRecorder.endRecording());
+ if (fSaveToSKP) {
+ SkFILEWStream stream("sample_app.skp");
+ picture->serialize(&stream);
+ fSaveToSKP = false;
+ }
+
if (true) {
if (true) {
SkImageInfo info;
SkOSMenu::FindListIndex(evt, "Hinting", &fHintingState) ||
SkOSMenu::FindSwitchState(evt, "Clip", &fUseClip) ||
SkOSMenu::FindSwitchState(evt, "Zoomer", &fShowZoomer) ||
- SkOSMenu::FindSwitchState(evt, "Magnify", &fMagnify) ||
- SkOSMenu::FindListIndex(evt, "Transition-Next", &fTransitionNext) ||
- SkOSMenu::FindListIndex(evt, "Transition-Prev", &fTransitionPrev)) {
+ SkOSMenu::FindSwitchState(evt, "Magnify", &fMagnify))
+ {
this->inval(NULL);
this->updateTitle();
return true;
this->inval(NULL);
this->updateTitle();
return true;
+ case 'K':
+ fSaveToSKP = true;
+ this->inval(NULL);
+ return true;
#if SK_SUPPORT_GPU
case 'p':
{
#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)
for (int i = 0; i < kBBoxTypeCount; ++i) {
fPictures[i] = NULL;
}
+ fCount = 0;
}
virtual ~PictFileView() {
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);
}
*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
SkPicture* fPictures[kBBoxTypeCount];
BBoxType fBBox;
SkSize fTileSize;
+ int fCount;
SkPicture* LoadPicture(const char path[], BBoxType bbox) {
SkAutoTUnref<SkPicture> pic;