Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Side by Side Diff: samplecode/GMSampleView.h

Issue 947733002: move GMSampleView into its own cpp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gyp/SampleApp.gyp ('k') | samplecode/GMSampleView.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1
2 /* 1 /*
3 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
4 * 3 *
5 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
8 7
9
10 #ifndef GMSampleView_DEFINED 8 #ifndef GMSampleView_DEFINED
11 #define GMSampleView_DEFINED 9 #define GMSampleView_DEFINED
12 10
13 #include "SampleCode.h" 11 #include "SampleCode.h"
14 #include "gm.h" 12 #include "gm.h"
15 13
16 class GMSampleView : public SampleView { 14 class GMSampleView : public SampleView {
17 private: 15 private:
18 bool fShowSize; 16 bool fShowSize;
19 typedef skiagm::GM GM; 17 typedef skiagm::GM GM;
20 18
21 public: 19 public:
22 GMSampleView(GM* gm) 20 GMSampleView(GM*);
23 : fShowSize(false), fGM(gm) {} 21 virtual ~GMSampleView();
24 22
25 virtual ~GMSampleView() { 23 static SkEvent* NewShowSizeEvt(bool doShowSize);
26 delete fGM;
27 }
28
29 static SkEvent* NewShowSizeEvt(bool doShowSize) {
30 SkEvent* evt = SkNEW_ARGS(SkEvent, ("GMSampleView::showSize"));
31 evt->setFast32(doShowSize);
32 return evt;
33 }
34 24
35 protected: 25 protected:
36 virtual bool onQuery(SkEvent* evt) { 26 bool onQuery(SkEvent*) SK_OVERRIDE;
37 if (SampleCode::TitleQ(*evt)) { 27 bool onEvent(const SkEvent&) SK_OVERRIDE;
38 SkString name("GM:"); 28 void onDrawContent(SkCanvas*) SK_OVERRIDE;
39 name.append(fGM->getName()); 29 void onDrawBackground(SkCanvas*) SK_OVERRIDE;
40 SampleCode::TitleR(evt, name.c_str()); 30 bool onAnimate(const SkAnimTimer&) SK_OVERRIDE;
41 return true;
42 }
43 return this->INHERITED::onQuery(evt);
44 }
45
46 bool onEvent(const SkEvent& evt) SK_OVERRIDE {
47 if (evt.isType("GMSampleView::showSize")) {
48 fShowSize = SkToBool(evt.getFast32());
49 return true;
50 }
51 return this->INHERITED::onEvent(evt);
52 }
53
54 virtual void onDrawContent(SkCanvas* canvas) {
55 {
56 SkAutoCanvasRestore acr(canvas, fShowSize);
57 fGM->drawContent(canvas);
58 }
59 if (fShowSize) {
60 SkISize size = fGM->getISize();
61 SkRect r = SkRect::MakeWH(SkIntToScalar(size.width()),
62 SkIntToScalar(size.height()));
63 SkPaint paint;
64 paint.setColor(0x40FF8833);
65 canvas->drawRect(r, paint);
66 }
67 }
68
69 virtual void onDrawBackground(SkCanvas* canvas) {
70 fGM->drawBackground(canvas);
71 }
72
73 bool onAnimate(const SkAnimTimer& timer) SK_OVERRIDE {
74 return fGM->animate(timer);
75 }
76 31
77 private: 32 private:
78 GM* fGM; 33 GM* fGM;
79 typedef SampleView INHERITED; 34 typedef SampleView INHERITED;
80 }; 35 };
81 36
82 #endif 37 #endif
OLDNEW
« no previous file with comments | « gyp/SampleApp.gyp ('k') | samplecode/GMSampleView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698