• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
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 
16 class GMSampleView : public SampleView {
17 private:
18     typedef skiagm::GM GM;
19 
20 public:
GMSampleView(GM * gm)21     GMSampleView(GM* gm)
22     : fGM(gm) {}
23 
~GMSampleView()24     virtual ~GMSampleView() {
25         delete fGM;
26     }
27 
28 protected:
onQuery(SkEvent * evt)29     virtual bool onQuery(SkEvent* evt) {
30         if (SampleCode::TitleQ(*evt)) {
31             SkString name("GM:");
32             name.append(fGM->shortName());
33             SampleCode::TitleR(evt, name.c_str());
34             return true;
35         }
36         return this->INHERITED::onQuery(evt);
37     }
38 
onDrawContent(SkCanvas * canvas)39     virtual void onDrawContent(SkCanvas* canvas) {
40         fGM->drawContent(canvas);
41     }
42 
onDrawBackground(SkCanvas * canvas)43     virtual void onDrawBackground(SkCanvas* canvas) {
44         fGM->drawBackground(canvas);
45     }
46 
47 private:
48     GM* fGM;
49     typedef SampleView INHERITED;
50 };
51 
52 #endif
53