Samples: add name() virtual

Change-Id: I9b6e39bc7e35346bb73dfe014de1c8daa5a92f2a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/225428
Auto-Submit: Hal Canary <halcanary@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
This commit is contained in:
Hal Canary 2019-07-03 10:55:44 -04:00 committed by Skia Commit-Bot
parent 1e371e548e
commit 8a027312cd
91 changed files with 154 additions and 730 deletions

View File

@ -150,12 +150,9 @@ protected:
this->updatePaddleStrategy();
}
bool onQuery(Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "SGPong");
return true;
}
SkString name() override { return SkString("SGPong"); }
bool onQuery(Event* evt) override {
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
switch (uni) {

View File

@ -110,11 +110,9 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "PerlinPatch");
return true;
}
SkString name() override { return SkString("PerlinPatch"); }
bool onQuery(Sample::Event* evt) override {
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
switch (uni) {

View File

@ -34,7 +34,6 @@ bool Sample::Event::isType(const char type[]) const {
}
const char* Sample::kCharEvtName = "SampleCode_Char_Event";
const char* Sample::kTitleEvtName = "SampleCode_Title_Event";
bool Sample::CharQ(const Event& evt, SkUnichar* outUni) {
if (evt.isType(kCharEvtName)) {
@ -46,24 +45,6 @@ bool Sample::CharQ(const Event& evt, SkUnichar* outUni) {
return false;
}
bool Sample::TitleQ(const Event& evt) {
return evt.isType(kTitleEvtName);
}
void Sample::TitleR(Event* evt, const char title[]) {
SkASSERT(evt && TitleQ(*evt));
evt->setString(kTitleEvtName, title);
}
bool Sample::RequestTitle(Sample* view, SkString* title) {
Event evt(kTitleEvtName);
if (view->doQuery(&evt)) {
title->set(evt.findString(kTitleEvtName));
return true;
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
bool Sample::doEvent(const Event& evt) {

View File

@ -83,6 +83,8 @@ public:
void setBGColor(SkColor color) { fBGColor = color; }
bool animate(const AnimTimer& timer) { return this->onAnimate(timer); }
virtual SkString name() = 0;
class Event {
public:
Event();
@ -189,7 +191,6 @@ public:
static bool CharQ(const Event&, SkUnichar* outUni);
static bool TitleQ(const Event&);
static void TitleR(Event*, const char title[]);
static bool RequestTitle(Sample* view, SkString* title);
protected:
/** Override to handle events in your subclass.

View File

@ -14,13 +14,7 @@ public:
TwoPtConicalView() {}
protected:
virtual bool onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "2PtConical");
return true;
}
return this->INHERITED::onQuery(evt);
}
virtual SkString name() { return SkString("2PtConical"); }
virtual void onDrawContent(SkCanvas* canvas) {
canvas->translate(SkIntToScalar(10), SkIntToScalar(20));

View File

@ -61,13 +61,7 @@ public:
}
protected:
virtual bool onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "AAClip");
return true;
}
return this->INHERITED::onQuery(evt);
}
virtual SkString name() { return SkString("AAClip"); }
virtual void onDrawContent(SkCanvas* canvas) {
#if 1

View File

@ -970,6 +970,8 @@ public:
#undef SET_BUTTON
SkString name() override { return SkString("AAGeometry"); }
bool onQuery(Sample::Event* evt) override;
void onSizeChange() override {
@ -1820,10 +1822,6 @@ void AAGeometryView::draw_legend(SkCanvas* canvas) {
}
bool AAGeometryView::onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "AAGeometry");
return true;
}
SkUnichar uni;
if (false) {
return this->INHERITED::onQuery(evt);

View File

@ -76,13 +76,7 @@ public:
}
protected:
virtual bool onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "AARectsModes");
return true;
}
return this->INHERITED::onQuery(evt);
}
virtual SkString name() { return SkString("AARectsModes"); }
virtual void onDrawContent(SkCanvas* canvas) {
const SkRect bounds = SkRect::MakeWH(W, H);

View File

@ -45,13 +45,7 @@ protected:
fWidth = N;
}
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "AA Rects");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("AA Rects"); }
void onDrawContent(SkCanvas* canvas) override {
canvas->translate(SkIntToScalar(10), SkIntToScalar(10));

View File

@ -106,12 +106,9 @@ protected:
fLightPos = SkPoint3::Make(350, 0, 600);
}
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "AndroidShadows");
return true;
}
SkString name() override { return SkString("AndroidShadows"); }
bool onQuery(Sample::Event* evt) override {
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
bool handled = false;

View File

@ -27,13 +27,7 @@ public:
AnimBlurView() : fBlurSigma(0), fCircleRadius(100) {}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "AnimBlur");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("AnimBlur"); }
void onDrawContent(SkCanvas* canvas) override {
static const SkBlurStyle gStyles[] = {

View File

@ -96,12 +96,9 @@ protected:
fDrawable = recorder.finishRecordingAsDrawable();
}
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "AnimatedImage");
return true;
}
SkString name() override { return SkString("AnimatedImage"); }
bool onQuery(Sample::Event* evt) override {
SkUnichar uni;
if (fImage && Sample::CharQ(*evt, &uni)) {
switch (uni) {

View File

@ -47,12 +47,9 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "AnimatedText");
return true;
}
SkString name() override { return SkString("AnimatedText"); }
bool onQuery(Sample::Event* evt) override {
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
if ('2' == uni) {

View File

@ -87,13 +87,7 @@ public:
ArcsView() { }
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Arcs");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Arcs"); }
static void DrawRectWithLines(SkCanvas* canvas, const SkRect& r, const SkPaint& p) {
canvas->drawRect(r, p);

View File

@ -211,11 +211,9 @@ public:
DrawAtlasView(const char name[], DrawAtlasProc proc) : fName(name), fProc(proc) { }
protected:
SkString name() override { return SkString(fName); }
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, fName);
return true;
}
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
switch (uni) {

View File

@ -99,13 +99,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "BitmapRect");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("BitmapRect"); }
void onDrawContent(SkCanvas* canvas) override {
SkRect srcR;
@ -194,13 +188,7 @@ public:
BitmapRectView2() { }
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "BigBitmapRect");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("BigBitmapRect"); }
void onOnceBeforeDraw() override {
make_big_bitmap(&fBitmap);

View File

@ -51,6 +51,7 @@ public:
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) override;
bool onClick(Sample::Click*) override;
bool onQuery(Sample::Event* evt) override;
SkString name() override { return SkString("CCPRGeometry"); }
private:
class Click;
@ -441,10 +442,6 @@ bool CCPRGeometryView::onClick(Sample::Click* click) {
}
bool CCPRGeometryView::onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "CCPRGeometry");
return true;
}
SkUnichar unichar;
if (Sample::CharQ(*evt, &unichar)) {
if (unichar >= '1' && unichar <= '4') {

View File

@ -48,13 +48,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Camera");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Camera"); }
void onDrawContent(SkCanvas* canvas) override {
canvas->translate(this->width()/2, this->height()/2);

View File

@ -88,13 +88,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Chart");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Chart"); }
void onDrawContent(SkCanvas* canvas) override {
bool sizeChanged = false;

View File

@ -42,13 +42,7 @@ public:
ChineseFlingView() : fBlobs(kNumBlobs) {}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "chinese-fling");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("chinese-fling"); }
void onDrawContent(SkCanvas* canvas) override {
if (!fInitialized) {
@ -128,11 +122,9 @@ public:
ChineseZoomView() : fBlobs(kNumBlobs), fScale(15.0f), fTranslate(0.0f) {}
protected:
SkString name() override { return SkString("chinese-zoom"); }
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "chinese-zoom");
return true;
}
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
if ('>' == uni) {

View File

@ -34,13 +34,7 @@ public:
}
protected:
virtual bool onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Circles");
return true;
}
return this->INHERITED::onQuery(evt);
}
virtual SkString name() { return SkString("Circles"); }
void circle(SkCanvas* canvas, int width, bool aa) {
SkPaint paint;

View File

@ -113,13 +113,7 @@ public:
}
protected:
virtual bool onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Clip");
return true;
}
return this->INHERITED::onQuery(evt);
}
virtual SkString name() { return SkString("Clip"); }
virtual void onDrawContent(SkCanvas* canvas) {
canvas->drawColor(SK_ColorWHITE);

View File

@ -133,11 +133,9 @@ public:
}
protected:
SkString name() override { return SkString("ClipDrawMatch"); }
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "ClipDrawMatch");
return true;
}
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
switch (uni) {

View File

@ -22,13 +22,7 @@ public:
ClockView() {}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Clock");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Clock"); }
void onDrawContent(SkCanvas* canvas) override {
SkPaint paintFill;

View File

@ -123,13 +123,7 @@ protected:
}
}
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "ColorFilter");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("ColorFilter"); }
void onDrawBackground(SkCanvas* canvas) override {
SkPaint paint;

View File

@ -18,13 +18,7 @@ public:
}
protected:
virtual bool onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "ComplexClip");
return true;
}
return this->INHERITED::onQuery(evt);
}
virtual SkString name() { return SkString("ComplexClip"); }
virtual void onDrawContent(SkCanvas* canvas) {
SkPath path;

View File

@ -96,14 +96,7 @@ protected:
this->INHERITED::onSizeChange();
}
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, fLabel.c_str());
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return fLabel; }
bool onAnimate(const AnimTimer& timer) override {
if (!fDom) {

View File

@ -103,13 +103,7 @@ class CuspView : public Sample {
public:
CuspView() {}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Cusp");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Cusp"); }
void onDrawContent(SkCanvas* canvas) override {
SkPaint p;

View File

@ -384,6 +384,7 @@ public:
unsigned) override;
bool onClick(Sample::Click*) override;
bool onQuery(Sample::Event* evt) override;
SkString name() override { return SkString("DegenerateQuad"); }
private:
class Click;
@ -496,10 +497,6 @@ bool DegenerateQuadSample::onClick(Sample::Click* click) {
}
bool DegenerateQuadSample::onQuery(Sample::Event* event) {
if (Sample::TitleQ(*event)) {
Sample::TitleR(event, "DegenerateQuad");
return true;
}
SkUnichar code;
if (Sample::CharQ(*event, &code)) {
switch(code) {

View File

@ -43,13 +43,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "DegenerateTwoPtRadials");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("DegenerateTwoPtRadials"); }
void onDrawContent(SkCanvas* canvas) override {
SkScalar delta = fTime / 15.f;

View File

@ -90,13 +90,7 @@ public:
}
protected:
virtual bool onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Effects");
return true;
}
return this->INHERITED::onQuery(evt);
}
virtual SkString name() { return SkString("Effects"); }
virtual void onDrawContent(SkCanvas* canvas) {
canvas->scale(3, 3);

View File

@ -33,13 +33,7 @@ public:
}
protected:
virtual bool onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Emboss");
return true;
}
return this->INHERITED::onQuery(evt);
}
virtual SkString name() { return SkString("Emboss"); }
virtual void onDrawContent(SkCanvas* canvas) {
SkPaint paint;

View File

@ -391,11 +391,9 @@ public:
}
protected:
SkString name() override { return SkString("FatBits"); }
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "FatBits");
return true;
}
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
switch (uni) {

View File

@ -25,13 +25,7 @@ public:
}
protected:
virtual bool onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "FillType");
return true;
}
return this->INHERITED::onQuery(evt);
}
virtual SkString name() { return SkString("FillType"); }
void showPath(SkCanvas* canvas, int x, int y, SkPath::FillType ft,
SkScalar scale, const SkPaint& paint) {

View File

@ -26,13 +26,13 @@ static const char* gNames[] = {
class Filter2View : public Sample {
public:
SkBitmap* fBitmaps;
int fBitmapCount;
int fCurrIndex;
std::unique_ptr<SkBitmap[]> fBitmaps;
int fBitmapCount;
int fCurrIndex;
Filter2View() {
fBitmapCount = SK_ARRAY_COUNT(gNames)*2;
fBitmaps = new SkBitmap[fBitmapCount];
fBitmaps.reset(new SkBitmap[fBitmapCount]);
for (int i = 0; i < fBitmapCount/2; i++) {
decode_file(gNames[i], &fBitmaps[i]);
@ -45,22 +45,10 @@ public:
this->setBGColor(SK_ColorGRAY);
}
virtual ~Filter2View() {
delete[] fBitmaps;
}
protected:
virtual bool onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
SkString str("Filter/Dither ");
str.append(gNames[fCurrIndex]);
Sample::TitleR(evt, str.c_str());
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkStringPrintf("Filter/Dither %s", gNames[fCurrIndex]); }
virtual void onDrawContent(SkCanvas* canvas) {
void onDrawContent(SkCanvas* canvas) override {
canvas->translate(SkIntToScalar(10), SkIntToScalar(50));
const SkScalar W = SkIntToScalar(fBitmaps[0].width() + 1);

View File

@ -166,11 +166,9 @@ public:
}
protected:
SkString name() override { return SkString("FilterQuality"); }
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "FilterQuality");
return true;
}
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
switch (uni) {

View File

@ -33,14 +33,7 @@ protected:
initChars();
}
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "FlutterAnimate");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("FlutterAnimate"); }
void onDrawContent(SkCanvas* canvas) override {
SkFont font(fTypeface, 50);

View File

@ -111,13 +111,7 @@ public:
}
protected:
virtual bool onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "FontCache");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("FontCache"); }
virtual void onDrawContent(SkCanvas* canvas) {
SkScalar x = 0;

View File

@ -30,13 +30,7 @@ protected:
fEmojiFont.fText = ToolUtils::emoji_sample_text();
}
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Glyph Transform");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Glyph Transform"); }
void onDrawContent(SkCanvas* canvas) override {
SkPaint paint;

View File

@ -118,13 +118,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Gradients");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Gradients"); }
void onDrawContent(SkCanvas* canvas) override {
SkPoint pts[2] = {

View File

@ -142,13 +142,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "HT");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("HT"); }
void onDrawContent(SkCanvas* canvas) override {
canvas->drawDrawable(fRoot.get());

View File

@ -15,16 +15,9 @@ public:
}
protected:
virtual bool onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "HairCurves");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("HairCurves"); }
virtual void onDrawContent(SkCanvas* canvas) {
void onDrawContent(SkCanvas* canvas) override {
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);

View File

@ -75,15 +75,9 @@ public:
}
protected:
virtual bool onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "HairlineModes");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("HairlineModes"); }
virtual void onDrawContent(SkCanvas* canvas) {
void onDrawContent(SkCanvas* canvas) override {
const SkRect bounds = SkRect::MakeWH(W, H);
static const SkAlpha gAlphaValue[] = { 0xFF, 0x88, 0x88 };

View File

@ -179,15 +179,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
SkString str;
str.printf("Hair-%s", gProcs[fProcIndex].fName);
Sample::TitleR(evt, str.c_str());
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkStringPrintf("Hair-%s", gProcs[fProcIndex].fName); }
void show_bitmaps(SkCanvas* canvas, const SkBitmap& b0, const SkBitmap& b1,
const SkIRect& inset) {

View File

@ -33,13 +33,7 @@ public:
protected:
SkBitmap fBM;
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "IdentityScale");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("IdentityScale"); }
void onDrawContent(SkCanvas* canvas) override {

View File

@ -15,13 +15,7 @@ public:
LCDView() {}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "LCD Text");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("LCD Text"); }
void drawBG(SkCanvas* canvas) {
canvas->drawColor(SK_ColorWHITE);

View File

@ -20,13 +20,7 @@ public:
}
protected:
virtual bool onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "LayerMask");
return true;
}
return this->INHERITED::onQuery(evt);
}
virtual SkString name() { return SkString("LayerMask"); }
void drawMask(SkCanvas* canvas, const SkRect& r) {
SkPaint paint;

View File

@ -100,13 +100,7 @@ public:
LayersView() {}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Layers");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Layers"); }
void drawBG(SkCanvas* canvas) {
canvas->drawColor(SK_ColorGRAY);
@ -201,13 +195,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Backdrop");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Backdrop"); }
void onDrawContent(SkCanvas* canvas) override {
canvas->drawImage(fImage.get(), 0, 0, nullptr);

View File

@ -51,13 +51,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Lighting");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Lighting"); }
void onDrawContent(SkCanvas* canvas) override {
sk_sp<SkLights> lights(create_lights(fLightAngle, fColorFactor));

View File

@ -28,13 +28,7 @@ public:
LinesView() {}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Lines");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Lines"); }
/*
0x1F * x + 0x1F * (32 - x)

View File

@ -447,11 +447,9 @@ public:
DrawLitAtlasView() : fDrawable(new DrawLitAtlasDrawable(SkRect::MakeWH(640, 480))) {}
protected:
SkString name() override { return SkString("DrawLitAtlas"); }
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "DrawLitAtlas");
return true;
}
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
switch (uni) {

View File

@ -68,11 +68,9 @@ public:
}
protected:
SkString name() override { return SkString("Lua"); }
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Lua");
return true;
}
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
lua_State* L = this->ensureLua();

View File

@ -23,13 +23,7 @@ public:
ManyRectsView() {}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "ManyRects");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("ManyRects"); }
void onDrawContent(SkCanvas* canvas) override {
SkISize dsize = canvas->getBaseLayerSize();

View File

@ -26,12 +26,9 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "MegaStroke");
return true;
}
SkString name() override { return SkString("MegaStroke"); }
bool onQuery(Sample::Event* evt) override {
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
fClip.set(0, 0, 950, 600);

View File

@ -35,13 +35,7 @@ public:
MixerView() {}
protected:
bool onQuery(Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Mixer");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Mixer"); }
void dodraw(SkCanvas* canvas, sk_sp<SkColorFilter> cf0, sk_sp<SkColorFilter> cf1, float gap) {
SkPaint paint;
@ -131,13 +125,7 @@ public:
}
protected:
bool onQuery(Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "ShaderMixer");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("ShaderMixer"); }
void onDrawContent(SkCanvas* canvas) override {
if (!fSurface) {

View File

@ -36,13 +36,7 @@ sk_sp<SkShader> setgrad(const SkRect& r, SkColor c0, SkColor c1) {
class ParagraphView1 : public Sample {
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Paragraph1");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Paragraph1"); }
void drawTest(SkCanvas* canvas, SkScalar w, SkScalar h, SkColor fg, SkColor bg) {
const std::vector<
@ -148,13 +142,7 @@ private:
class ParagraphView2 : public Sample {
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Paragraph2");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Paragraph2"); }
void drawCode(SkCanvas* canvas, SkScalar w, SkScalar h) {
SkPaint comment;
@ -391,13 +379,7 @@ private:
class ParagraphView3 : public Sample {
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Paragraph3");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Paragraph3"); }
void drawLine(SkCanvas* canvas, SkScalar w, SkScalar h, const std::string& text,
TextAlign align, size_t lineLimit = std::numeric_limits<size_t>::max(),
@ -518,13 +500,7 @@ private:
class ParagraphView4 : public Sample {
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Paragraph4");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Paragraph4"); }
void drawFlutter(SkCanvas* canvas, SkScalar w, SkScalar h,
const char* ff = "Google Sans", SkScalar fs = 30,
@ -662,13 +638,7 @@ private:
class ParagraphView5 : public Sample {
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Paragraph4");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Paragraph4"); }
void bidi(SkCanvas* canvas, SkScalar w, SkScalar h, const std::u16string& text,
const std::u16string& expected, size_t lineLimit = std::numeric_limits<size_t>::max(),
@ -789,13 +759,7 @@ private:
class ParagraphView6 : public Sample {
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Paragraph4");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Paragraph4"); }
void hangingS(SkCanvas* canvas, SkScalar w, SkScalar h, SkScalar fs = 60.0) {
auto ff = "HangingS";
@ -970,13 +934,7 @@ private:
class ParagraphView7 : public Sample {
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Paragraph7");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Paragraph7"); }
void drawText(SkCanvas* canvas, SkColor background, SkScalar letterSpace, SkScalar w,
SkScalar h) {
@ -1048,13 +1006,7 @@ private:
class ParagraphView8 : public Sample {
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Paragraph7");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Paragraph7"); }
void drawText(SkCanvas* canvas, SkColor background, SkScalar wordSpace, SkScalar w,
SkScalar h) {
@ -1126,12 +1078,9 @@ private:
class ParagraphView9 : public Sample {
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Paragraph9");
return true;
}
SkString name() override { return SkString("Paragraph9"); }
bool onQuery(Sample::Event* evt) override {
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
switch (uni) {
@ -1230,13 +1179,7 @@ private:
class ParagraphView10 : public Sample {
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Paragraph10");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Paragraph10"); }
void onDrawContent(SkCanvas* canvas) override {
canvas->drawColor(SK_ColorWHITE);
@ -1277,13 +1220,7 @@ private:
class ParagraphView11 : public Sample {
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Paragraph11");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Paragraph11"); }
void onDrawContent(SkCanvas* canvas) override {
canvas->drawColor(SK_ColorWHITE);

View File

@ -236,13 +236,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Patch");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Patch"); }
void onDrawContent(SkCanvas* canvas) override {
const int nu = 10;
@ -387,13 +381,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "PseudoInk");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("PseudoInk"); }
bool onAnimate(const AnimTimer& timer) override { return true; }
@ -458,13 +446,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "ManyStrokes");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("ManyStrokes"); }
bool onAnimate(const AnimTimer& timer) override { return true; }

View File

@ -130,13 +130,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Paths");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Paths"); }
void drawPath(SkCanvas* canvas, const SkPath& path, SkPaint::Join j) {
SkPaint paint;
@ -250,11 +244,9 @@ public:
}
protected:
SkString name() override { return SkString("ArcTo"); }
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "ArcTo");
return true;
}
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
switch (uni) {
@ -367,11 +359,9 @@ public:
}
protected:
SkString name() override { return SkString("FatStroke"); }
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "FatStroke");
return true;
}
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
switch (uni) {
@ -488,13 +478,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "CubicCurve");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("CubicCurve"); }
void onDrawContent(SkCanvas* canvas) override {
SkPaint paint;
@ -617,11 +601,9 @@ public:
}
protected:
SkString name() override { return SkString("CubicCurve2"); }
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "CubicCurve2");
return true;
}
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
switch (uni) {

View File

@ -29,13 +29,7 @@ public:
PathClipView() : fOval(SkRect::MakeWH(200, 50)), fCenter(SkPoint::Make(250, 250)) {}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "PathClip");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("PathClip"); }
void onDrawContent(SkCanvas* canvas) override {
const SkRect oval = fOval.makeOffset(fCenter.fX - fOval.centerX(),
@ -171,13 +165,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "EdgeClip");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("EdgeClip"); }
static SkScalar snap(SkScalar x) {
return SkScalarRoundToScalar(x * 0.5f) * 2;

View File

@ -108,13 +108,7 @@ protected:
this->setBGColor(0xFFDDDDDD);
}
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "PathEffects");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("PathEffects"); }
void onDrawContent(SkCanvas* canvas) override {
SkPaint paint;

View File

@ -32,11 +32,9 @@ class OverstrokeView : public Sample {
}
protected:
SkString name() override { return SkString("PathOverstroke"); }
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "PathOverstroke");
return true;
}
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
switch (uni) {

View File

@ -54,11 +54,9 @@ public:
}
void onSizeChange() final { this->INHERITED::onSizeChange(); this->reset(); }
bool onQuery(Sample::Event* evt) final {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, this->getName());
return true;
}
SkString name() override { return SkString(this->getName()); }
bool onQuery(Sample::Event* evt) override {
SkUnichar unichar;
if (Sample::CharQ(*evt, &unichar)) {
if (unichar == 'X') {

View File

@ -55,15 +55,11 @@ public:
}
protected:
virtual bool onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
SkString name("P:");
const char* basename = strrchr(fFilename.c_str(), SkPATH_SEPARATOR);
name.append(basename ? basename+1: fFilename.c_str());
Sample::TitleR(evt, name.c_str());
return true;
}
return this->INHERITED::onQuery(evt);
virtual SkString name() {
SkString name("P:");
const char* basename = strrchr(fFilename.c_str(), SkPATH_SEPARATOR);
name.append(basename ? basename+1: fFilename.c_str());
return name;
}
virtual bool onEvent(const SkEvent& evt) {

View File

@ -69,13 +69,7 @@ public:
}
protected:
virtual bool onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "PolyToPolyView");
return true;
}
return this->INHERITED::onQuery(evt);
}
virtual SkString name() { return SkString("PolyToPolyView"); }
static void doDraw(SkCanvas* canvas, SkPaint* paint, const SkFont& font, const int isrc[],
const int idst[], int count) {

View File

@ -209,11 +209,9 @@ public:
}
protected:
SkString name() override { return SkString("QuadStroker"); }
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "QuadStroker");
return true;
}
SkUnichar uni;
if (fTextButton.fEnabled && Sample::CharQ(*evt, &uni)) {
switch (uni) {

View File

@ -54,11 +54,9 @@ public:
}
protected:
SkString name() override { return SkString("Rectanizer"); }
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Rectanizer");
return true;
}
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
char utf8[SkUTF::kMaxBytesInUTF8Sequence];

View File

@ -176,13 +176,7 @@ public:
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Regions");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Regions"); }
static void drawstr(SkCanvas* canvas, const char text[], const SkPoint& loc,
bool hilite) {

View File

@ -45,13 +45,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "RepeatTile");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("RepeatTile"); }
void onDrawContent(SkCanvas* canvas) override {
SkPaint paint;

View File

@ -66,13 +66,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "SceneGraph");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("SceneGraph"); }
void onDrawContent(SkCanvas* canvas) override {
fScene->render(canvas);

View File

@ -59,14 +59,8 @@ protected:
this->INHERITED::onSizeChange();
}
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, fLabel.c_str());
return true;
}
SkString name() override { return fLabel; }
return this->INHERITED::onQuery(evt);
}
private:
sk_sp<SkSVGDOM> fDom;
SkString fPath;

View File

@ -61,13 +61,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Shaders");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Shaders"); }
void onDrawContent(SkCanvas* canvas) override {
canvas->drawBitmap(fBitmap, 0, 0);

View File

@ -44,12 +44,9 @@ protected:
fRectPath.addRect(SkRect::MakeXYWH(-50, -50, 100, 100));
}
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "ShadowColor");
return true;
}
SkString name() override { return SkString("ShadowColor"); }
bool onQuery(Sample::Event* evt) override {
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
bool handled = false;

View File

@ -38,12 +38,9 @@ protected:
fReferenceImage = GetResourceAsImage("images/shadowreference.png");
}
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "ShadowReference");
return true;
}
SkString name() override { return SkString("ShadowReference"); }
bool onQuery(Sample::Event* evt) override {
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
bool handled = false;

View File

@ -73,12 +73,9 @@ protected:
fConcavePaths.back().cubicTo(0, -25, 40, -50, 50, 0);
}
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "ShadowUtils");
return true;
}
SkString name() override { return SkString("ShadowUtils"); }
bool onQuery(Sample::Event* evt) override {
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
bool handled = false;

View File

@ -88,13 +88,7 @@ public:
~DrawShipView() override {}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, fName);
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString(fName); }
void onDrawContent(SkCanvas* canvas) override {
const float kCosDiff = 0.99984769515f;

View File

@ -436,13 +436,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Slides");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Slides"); }
void onDrawContent(SkCanvas* canvas) override {
this->init();

View File

@ -20,13 +20,7 @@ public:
StringArtView() : fAngle(0.305f) {}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "StringArt");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("StringArt"); }
void onDrawContent(SkCanvas* canvas) override {
SkScalar angle = fAngle*SK_ScalarPI + SkScalarHalf(SK_ScalarPI);

View File

@ -123,13 +123,7 @@ protected:
this->setBGColor(0xFFDDDDDD);
}
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "StrokePath");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("StrokePath"); }
SkRandom rand;

View File

@ -13,13 +13,7 @@ public:
StrokeRectSample() {}
protected:
virtual bool onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Stroke Rects");
return true;
}
return this->INHERITED::onQuery(evt);
}
virtual SkString name() { return SkString("Stroke Rects"); }
virtual void onDrawContent(SkCanvas* canvas) {
SkPaint paint;

View File

@ -42,13 +42,7 @@ protected:
SkPoint fCurPos;
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "SubpixelTranslate");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("SubpixelTranslate"); }
void onDrawContent(SkCanvas* canvas) override {

View File

@ -38,13 +38,7 @@ public:
TextBoxView() : fShaper(SkShaper::Make()) {}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "TextBox");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("TextBox"); }
void drawTest(SkCanvas* canvas, SkScalar w, SkScalar h, SkColor fg, SkColor bg) {
SkAutoCanvasRestore acr(canvas, true);

View File

@ -117,13 +117,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Text Effects");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Text Effects"); }
void drawBG(SkCanvas* canvas) {
canvas->drawColor(SK_ColorWHITE);

View File

@ -33,13 +33,7 @@ public:
}
protected:
virtual bool onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Texture Domain");
return true;
}
return this->INHERITED::onQuery(evt);
}
virtual SkString name() { return SkString("Texture Domain"); }
virtual void onDrawContent(SkCanvas* canvas) {
SkRect srcRect;

View File

@ -373,12 +373,9 @@ protected:
return true;
}
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Thin-AA");
return true;
}
SkString name() override { return SkString("Thin-AA"); }
bool onQuery(Sample::Event* evt) override {
SkUnichar key;
if (Sample::CharQ(*evt, &key)) {
switch(key) {

View File

@ -72,13 +72,7 @@ public:
SkBitmap fTexture[SK_ARRAY_COUNT(gColorTypes)];
protected:
virtual bool onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Tiling");
return true;
}
return this->INHERITED::onQuery(evt);
}
virtual SkString name() { return SkString("Tiling"); }
virtual void onDrawContent(SkCanvas* canvas) {
SkRect r = { 0, 0, SkIntToScalar(gWidth*2), SkIntToScalar(gHeight*2) };

View File

@ -42,11 +42,9 @@ public:
}
protected:
SkString name() override { return SkString("unpremul"); }
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "unpremul");
return true;
}
SkUnichar uni;
if (Sample::CharQ(*evt, &uni)) {
char utf8[SkUTF::kMaxBytesInUTF8Sequence];

View File

@ -66,13 +66,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "Vertices");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("Vertices"); }
SkScalar fScale;

View File

@ -32,13 +32,7 @@ public:
WritePixelsView() {}
protected:
virtual bool onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "WritePixels");
return true;
}
return this->INHERITED::onQuery(evt);
}
virtual SkString name() { return SkString("WritePixels"); }
virtual void onDrawContent(SkCanvas* canvas) {
SkBitmap bitmap;

View File

@ -137,13 +137,7 @@ public:
}
protected:
bool onQuery(Sample::Event* evt) override {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "XferDemo");
return true;
}
return this->INHERITED::onQuery(evt);
}
SkString name() override { return SkString("XferDemo"); }
void onDrawContent(SkCanvas* canvas) override {
for (int i = 0; i < N_Modes; ++i) {

View File

@ -73,13 +73,7 @@ public:
}
protected:
virtual bool onQuery(Sample::Event* evt) {
if (Sample::TitleQ(*evt)) {
Sample::TitleR(evt, "XfermodesBlur");
return true;
}
return this->INHERITED::onQuery(evt);
}
virtual SkString name() { return SkString("XfermodesBlur"); }
virtual void onDrawContent(SkCanvas* canvas) {
canvas->translate(SkIntToScalar(10), SkIntToScalar(20));

View File

@ -15,9 +15,10 @@ using namespace sk_app;
SampleSlide::SampleSlide(const SampleFactory factory)
: fSampleFactory(factory)
, fClick(nullptr) {
, fClick(nullptr)
{
sk_sp<Sample> sample(factory());
Sample::RequestTitle(sample.get(), &fName);
fName = sample->name();
}
SampleSlide::~SampleSlide() { delete fClick; }