blob: 0b224a53a77ac491a8da27437a3defd7bbd72cb9 [file] [log] [blame]
bsalomon@google.com48dd1a22011-10-31 14:18:20 +00001
2/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9
10#ifndef GMSampleView_DEFINED
11#define GMSampleView_DEFINED
12
13#include "SampleCode.h"
14#include "gm.h"
15
16class GMSampleView : public SampleView {
17private:
18 typedef skiagm::GM GM;
19
20public:
21 GMSampleView(GM* gm)
22 : fGM(gm) {}
rmistry@google.comae933ce2012-08-23 18:19:56 +000023
bsalomon@google.com48dd1a22011-10-31 14:18:20 +000024 virtual ~GMSampleView() {
25 delete fGM;
26 }
rmistry@google.comae933ce2012-08-23 18:19:56 +000027
bsalomon@google.com48dd1a22011-10-31 14:18:20 +000028protected:
29 virtual bool onQuery(SkEvent* evt) {
30 if (SampleCode::TitleQ(*evt)) {
bsalomon@google.come9f091d2011-12-09 19:50:48 +000031 SkString name("GM:");
reed@google.comac7aa1b2011-11-08 15:06:34 +000032 name.append(fGM->shortName());
33 SampleCode::TitleR(evt, name.c_str());
bsalomon@google.com48dd1a22011-10-31 14:18:20 +000034 return true;
35 }
36 return this->INHERITED::onQuery(evt);
37 }
rmistry@google.comae933ce2012-08-23 18:19:56 +000038
bsalomon@google.com48dd1a22011-10-31 14:18:20 +000039 virtual void onDrawContent(SkCanvas* canvas) {
40 fGM->drawContent(canvas);
41 }
42
43 virtual void onDrawBackground(SkCanvas* canvas) {
44 fGM->drawBackground(canvas);
45 }
46
47private:
48 GM* fGM;
49 typedef SampleView INHERITED;
50};
51
52#endif