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

Side by Side Diff: samplecode/SampleArc.cpp

Issue 1037793002: C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: git cl web Created 5 years, 9 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/SampleApp.cpp ('k') | samplecode/SampleBitmapRect.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 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * 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
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkAnimTimer.h" 9 #include "SkAnimTimer.h"
10 #include "SkView.h" 10 #include "SkView.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 public: 45 public:
46 MyDrawable(const SkRect& r) : fR(r), fSweep(0) {} 46 MyDrawable(const SkRect& r) : fR(r), fSweep(0) {}
47 47
48 void setSweep(SkScalar sweep) { 48 void setSweep(SkScalar sweep) {
49 if (fSweep != sweep) { 49 if (fSweep != sweep) {
50 fSweep = sweep; 50 fSweep = sweep;
51 this->notifyDrawingChanged(); 51 this->notifyDrawingChanged();
52 } 52 }
53 } 53 }
54 54
55 void onDraw(SkCanvas* canvas) SK_OVERRIDE { 55 void onDraw(SkCanvas* canvas) override {
56 SkPaint paint; 56 SkPaint paint;
57 paint.setAntiAlias(true); 57 paint.setAntiAlias(true);
58 paint.setStrokeWidth(SkIntToScalar(2)); 58 paint.setStrokeWidth(SkIntToScalar(2));
59 59
60 paint.setStyle(SkPaint::kFill_Style); 60 paint.setStyle(SkPaint::kFill_Style);
61 paint.setColor(0x800000FF); 61 paint.setColor(0x800000FF);
62 canvas->drawArc(fR, 0, fSweep, true, paint); 62 canvas->drawArc(fR, 0, fSweep, true, paint);
63 63
64 paint.setColor(0x800FF000); 64 paint.setColor(0x800FF000);
65 canvas->drawArc(fR, 0, fSweep, false, paint); 65 canvas->drawArc(fR, 0, fSweep, false, paint);
66 66
67 paint.setStyle(SkPaint::kStroke_Style); 67 paint.setStyle(SkPaint::kStroke_Style);
68 paint.setColor(SK_ColorRED); 68 paint.setColor(SK_ColorRED);
69 canvas->drawArc(fR, 0, fSweep, true, paint); 69 canvas->drawArc(fR, 0, fSweep, true, paint);
70 70
71 paint.setStrokeWidth(0); 71 paint.setStrokeWidth(0);
72 paint.setColor(SK_ColorBLUE); 72 paint.setColor(SK_ColorBLUE);
73 canvas->drawArc(fR, 0, fSweep, false, paint); 73 canvas->drawArc(fR, 0, fSweep, false, paint);
74 } 74 }
75 75
76 SkRect onGetBounds() SK_OVERRIDE { 76 SkRect onGetBounds() override {
77 SkRect r(fR); 77 SkRect r(fR);
78 r.outset(2, 2); 78 r.outset(2, 2);
79 return r; 79 return r;
80 } 80 }
81 }; 81 };
82 82
83 public: 83 public:
84 SkRect fRect; 84 SkRect fRect;
85 MyDrawable* fAnimatingDrawable; 85 MyDrawable* fAnimatingDrawable;
86 SkDrawable* fRootDrawable; 86 SkDrawable* fRootDrawable;
87 87
88 ArcsView() { 88 ArcsView() {
89 testparse(); 89 testparse();
90 fSweep = SkIntToScalar(100); 90 fSweep = SkIntToScalar(100);
91 this->setBGColor(0xFFDDDDDD); 91 this->setBGColor(0xFFDDDDDD);
92 92
93 fRect.set(0, 0, SkIntToScalar(200), SkIntToScalar(200)); 93 fRect.set(0, 0, SkIntToScalar(200), SkIntToScalar(200));
94 fRect.offset(SkIntToScalar(20), SkIntToScalar(20)); 94 fRect.offset(SkIntToScalar(20), SkIntToScalar(20));
95 fAnimatingDrawable = SkNEW_ARGS(MyDrawable, (fRect)); 95 fAnimatingDrawable = SkNEW_ARGS(MyDrawable, (fRect));
96 96
97 SkPictureRecorder recorder; 97 SkPictureRecorder recorder;
98 this->drawRoot(recorder.beginRecording(SkRect::MakeWH(800, 500))); 98 this->drawRoot(recorder.beginRecording(SkRect::MakeWH(800, 500)));
99 fRootDrawable = recorder.endRecordingAsDrawable(); 99 fRootDrawable = recorder.endRecordingAsDrawable();
100 } 100 }
101 101
102 ~ArcsView() SK_OVERRIDE { 102 ~ArcsView() override {
103 fAnimatingDrawable->unref(); 103 fAnimatingDrawable->unref();
104 fRootDrawable->unref(); 104 fRootDrawable->unref();
105 } 105 }
106 106
107 protected: 107 protected:
108 // overrides from SkEventSink 108 // overrides from SkEventSink
109 bool onQuery(SkEvent* evt) SK_OVERRIDE { 109 bool onQuery(SkEvent* evt) override {
110 if (SampleCode::TitleQ(*evt)) { 110 if (SampleCode::TitleQ(*evt)) {
111 SampleCode::TitleR(evt, "Arcs"); 111 SampleCode::TitleR(evt, "Arcs");
112 return true; 112 return true;
113 } 113 }
114 return this->INHERITED::onQuery(evt); 114 return this->INHERITED::onQuery(evt);
115 } 115 }
116 116
117 static void DrawRectWithLines(SkCanvas* canvas, const SkRect& r, const SkPai nt& p) { 117 static void DrawRectWithLines(SkCanvas* canvas, const SkRect& r, const SkPai nt& p) {
118 canvas->drawRect(r, p); 118 canvas->drawRect(r, p);
119 canvas->drawLine(r.fLeft, r.fTop, r.fRight, r.fBottom, p); 119 canvas->drawLine(r.fLeft, r.fTop, r.fRight, r.fBottom, p);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 paint.setStrokeWidth(SkIntToScalar(2)); 185 paint.setStrokeWidth(SkIntToScalar(2));
186 paint.setStyle(SkPaint::kStroke_Style); 186 paint.setStyle(SkPaint::kStroke_Style);
187 187
188 DrawRectWithLines(canvas, fRect, paint); 188 DrawRectWithLines(canvas, fRect, paint);
189 189
190 canvas->drawDrawable(fAnimatingDrawable); 190 canvas->drawDrawable(fAnimatingDrawable);
191 191
192 DrawArcs(canvas); 192 DrawArcs(canvas);
193 } 193 }
194 194
195 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { 195 void onDrawContent(SkCanvas* canvas) override {
196 canvas->drawDrawable(fRootDrawable); 196 canvas->drawDrawable(fRootDrawable);
197 } 197 }
198 198
199 bool onAnimate(const SkAnimTimer& timer) SK_OVERRIDE { 199 bool onAnimate(const SkAnimTimer& timer) override {
200 SkScalar angle = SkDoubleToScalar(fmod(timer.secs() * 360 / 24, 360)); 200 SkScalar angle = SkDoubleToScalar(fmod(timer.secs() * 360 / 24, 360));
201 fAnimatingDrawable->setSweep(angle); 201 fAnimatingDrawable->setSweep(angle);
202 return true; 202 return true;
203 } 203 }
204 204
205 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) SK_ OVERRIDE { 205 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove rride {
206 // fSweep += SK_Scalar1; 206 // fSweep += SK_Scalar1;
207 this->inval(NULL); 207 this->inval(NULL);
208 return this->INHERITED::onFindClickHandler(x, y, modi); 208 return this->INHERITED::onFindClickHandler(x, y, modi);
209 } 209 }
210 210
211 private: 211 private:
212 SkScalar fSweep; 212 SkScalar fSweep;
213 213
214 typedef SampleView INHERITED; 214 typedef SampleView INHERITED;
215 }; 215 };
216 216
217 ////////////////////////////////////////////////////////////////////////////// 217 //////////////////////////////////////////////////////////////////////////////
218 218
219 static SkView* MyFactory() { return new ArcsView; } 219 static SkView* MyFactory() { return new ArcsView; }
220 static SkViewRegister reg(MyFactory); 220 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | samplecode/SampleBitmapRect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698