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

Side by Side Diff: samplecode/SampleHT.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/SampleFilterQuality.cpp ('k') | samplecode/SampleHairline.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 2014 Google Inc. 2 * Copyright 2014 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 this->notifyDrawingChanged(); 77 this->notifyDrawingChanged();
78 } 78 }
79 79
80 bool hitTest(SkScalar x, SkScalar y) { 80 bool hitTest(SkScalar x, SkScalar y) {
81 return oval_contains(fR, x, y); 81 return oval_contains(fR, x, y);
82 } 82 }
83 83
84 void setTime(SkMSec time) { fTime = time; } 84 void setTime(SkMSec time) { fTime = time; }
85 85
86 void onDraw(SkCanvas* canvas) SK_OVERRIDE { 86 void onDraw(SkCanvas* canvas) override {
87 SkAutoCanvasRestore acr(canvas, false); 87 SkAutoCanvasRestore acr(canvas, false);
88 88
89 SkPaint paint; 89 SkPaint paint;
90 paint.setAntiAlias(true); 90 paint.setAntiAlias(true);
91 91
92 if (fInterp) { 92 if (fInterp) {
93 SkScalar values[5]; 93 SkScalar values[5];
94 SkInterpolator::Result res = fInterp->timeToValues(fTime, values); 94 SkInterpolator::Result res = fInterp->timeToValues(fTime, values);
95 fColor = floats_to_color(values); 95 fColor = floats_to_color(values);
96 96
97 canvas->save(); 97 canvas->save();
98 canvas->translate(fR.centerX(), fR.centerY()); 98 canvas->translate(fR.centerX(), fR.centerY());
99 canvas->rotate(values[4]); 99 canvas->rotate(values[4]);
100 canvas->translate(-fR.centerX(), -fR.centerY()); 100 canvas->translate(-fR.centerX(), -fR.centerY());
101 101
102 switch (res) { 102 switch (res) {
103 case SkInterpolator::kFreezeEnd_Result: 103 case SkInterpolator::kFreezeEnd_Result:
104 SkDELETE(fInterp); 104 SkDELETE(fInterp);
105 fInterp = NULL; 105 fInterp = NULL;
106 break; 106 break;
107 default: 107 default:
108 break; 108 break;
109 } 109 }
110 } 110 }
111 paint.setColor(fColor); 111 paint.setColor(fColor);
112 canvas->drawRect(fR, paint); 112 canvas->drawRect(fR, paint);
113 } 113 }
114 114
115 SkRect onGetBounds() SK_OVERRIDE { return fR; } 115 SkRect onGetBounds() override { return fR; }
116 }; 116 };
117 117
118 class HTView : public SampleView { 118 class HTView : public SampleView {
119 public: 119 public:
120 enum { 120 enum {
121 N = 50, 121 N = 50,
122 W = 640, 122 W = 640,
123 H = 480, 123 H = 480,
124 }; 124 };
125 125
(...skipping 11 matching lines...) Expand all
137 SkCanvas* canvas = recorder.beginRecording(SkRect::MakeWH(W, H)); 137 SkCanvas* canvas = recorder.beginRecording(SkRect::MakeWH(W, H));
138 for (int i = 0; i < N; ++i) { 138 for (int i = 0; i < N; ++i) {
139 fArray[i].fDrawable = new HTDrawable(rand); 139 fArray[i].fDrawable = new HTDrawable(rand);
140 canvas->drawDrawable(fArray[i].fDrawable); 140 canvas->drawDrawable(fArray[i].fDrawable);
141 fArray[i].fDrawable->unref(); 141 fArray[i].fDrawable->unref();
142 } 142 }
143 fRoot.reset(recorder.endRecordingAsDrawable()); 143 fRoot.reset(recorder.endRecordingAsDrawable());
144 } 144 }
145 145
146 protected: 146 protected:
147 bool onQuery(SkEvent* evt) SK_OVERRIDE { 147 bool onQuery(SkEvent* evt) override {
148 if (SampleCode::TitleQ(*evt)) { 148 if (SampleCode::TitleQ(*evt)) {
149 SampleCode::TitleR(evt, "HT"); 149 SampleCode::TitleR(evt, "HT");
150 return true; 150 return true;
151 } 151 }
152 return this->INHERITED::onQuery(evt); 152 return this->INHERITED::onQuery(evt);
153 } 153 }
154 154
155 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { 155 void onDrawContent(SkCanvas* canvas) override {
156 canvas->drawDrawable(fRoot); 156 canvas->drawDrawable(fRoot);
157 } 157 }
158 158
159 bool onAnimate(const SkAnimTimer& timer) SK_OVERRIDE { 159 bool onAnimate(const SkAnimTimer& timer) override {
160 fTime = timer.msec(); 160 fTime = timer.msec();
161 for (int i = 0; i < N; ++i) { 161 for (int i = 0; i < N; ++i) {
162 fArray[i].fDrawable->setTime(fTime); 162 fArray[i].fDrawable->setTime(fTime);
163 } 163 }
164 return true; 164 return true;
165 } 165 }
166 166
167 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) SK_ OVERRIDE { 167 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove rride {
168 // search backwards to find the top-most 168 // search backwards to find the top-most
169 for (int i = N - 1; i >= 0; --i) { 169 for (int i = N - 1; i >= 0; --i) {
170 if (fArray[i].fDrawable->hitTest(x, y)) { 170 if (fArray[i].fDrawable->hitTest(x, y)) {
171 fArray[i].fDrawable->spawnAnimation(fTime); 171 fArray[i].fDrawable->spawnAnimation(fTime);
172 break; 172 break;
173 } 173 }
174 } 174 }
175 this->inval(NULL); 175 this->inval(NULL);
176 return NULL; 176 return NULL;
177 } 177 }
178 178
179 private: 179 private:
180 typedef SampleView INHERITED; 180 typedef SampleView INHERITED;
181 }; 181 };
182 182
183 ////////////////////////////////////////////////////////////////////////////// 183 //////////////////////////////////////////////////////////////////////////////
184 184
185 static SkView* MyFactory() { return new HTView; } 185 static SkView* MyFactory() { return new HTView; }
186 static SkViewRegister reg(MyFactory); 186 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleFilterQuality.cpp ('k') | samplecode/SampleHairline.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698