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

Side by Side Diff: samplecode/GMSampleView.cpp

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 | « samplecode/GMSampleView.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "GMSampleView.h"
9
10 GMSampleView::GMSampleView(GM* gm) : fShowSize(false), fGM(gm) {}
11
12 GMSampleView::~GMSampleView() {
13 delete fGM;
14 }
15
16 SkEvent* GMSampleView::NewShowSizeEvt(bool doShowSize) {
17 SkEvent* evt = SkNEW_ARGS(SkEvent, ("GMSampleView::showSize"));
18 evt->setFast32(doShowSize);
19 return evt;
20 }
21
22 bool GMSampleView::onQuery(SkEvent* evt) {
23 if (SampleCode::TitleQ(*evt)) {
24 SkString name("GM:");
25 name.append(fGM->getName());
26 SampleCode::TitleR(evt, name.c_str());
27 return true;
28 }
29 return this->INHERITED::onQuery(evt);
30 }
31
32 bool GMSampleView::onEvent(const SkEvent& evt) {
33 if (evt.isType("GMSampleView::showSize")) {
34 fShowSize = SkToBool(evt.getFast32());
35 return true;
36 }
37 return this->INHERITED::onEvent(evt);
38 }
39
40 void GMSampleView::onDrawContent(SkCanvas* canvas) {
41 {
42 SkAutoCanvasRestore acr(canvas, fShowSize);
43 fGM->drawContent(canvas);
44 }
45 if (fShowSize) {
46 SkISize size = fGM->getISize();
47 SkRect r = SkRect::MakeWH(SkIntToScalar(size.width()),
48 SkIntToScalar(size.height()));
49 SkPaint paint;
50 paint.setColor(0x40FF8833);
51 canvas->drawRect(r, paint);
52 }
53 }
54
55 void GMSampleView::onDrawBackground(SkCanvas* canvas) {
56 fGM->drawBackground(canvas);
57 }
58
59 bool GMSampleView::onAnimate(const SkAnimTimer& timer) {
60 return fGM->animate(timer);
61 }
62
OLDNEW
« no previous file with comments | « samplecode/GMSampleView.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698