OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #include "SampleCode.h" | 7 #include "SampleCode.h" |
8 | 8 |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
11 #include "SkRRect.h" | 11 #include "SkRRect.h" |
12 #include "SkTime.h" | 12 #include "SkTime.h" |
13 | 13 |
14 // Implementation in C++ of Mozilla Canvas2D benchmark Canvas Clock Test | 14 // Implementation in C++ of Mozilla Canvas2D benchmark Canvas Clock Test |
15 // See https://code.google.com/p/skia/issues/detail?id=1626 | 15 // See https://code.google.com/p/skia/issues/detail?id=1626 |
16 | 16 |
17 #define USE_PATH 1 | 17 #define USE_PATH 1 |
18 | 18 |
19 class ClockView : public SampleView { | 19 class ClockView : public SampleView { |
20 public: | 20 public: |
21 ClockView() {} | 21 ClockView() {} |
22 | 22 |
23 protected: | 23 protected: |
24 // overrides from SkEventSink | 24 // overrides from SkEventSink |
25 virtual bool onQuery(SkEvent* evt) SK_OVERRIDE { | 25 bool onQuery(SkEvent* evt) SK_OVERRIDE { |
26 if (SampleCode::TitleQ(*evt)) { | 26 if (SampleCode::TitleQ(*evt)) { |
27 SampleCode::TitleR(evt, "Clock"); | 27 SampleCode::TitleR(evt, "Clock"); |
28 return true; | 28 return true; |
29 } | 29 } |
30 return this->INHERITED::onQuery(evt); | 30 return this->INHERITED::onQuery(evt); |
31 } | 31 } |
32 | 32 |
33 virtual void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { | 33 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { |
34 SkPaint paintFill; | 34 SkPaint paintFill; |
35 SkPaint paintStroke; | 35 SkPaint paintStroke; |
36 SkPath path; | 36 SkPath path; |
37 | 37 |
38 canvas->save(); | 38 canvas->save(); |
39 canvas->translate(150, 150); | 39 canvas->translate(150, 150); |
40 canvas->scale(0.4f, 0.4f); | 40 canvas->scale(0.4f, 0.4f); |
41 canvas->rotate(-180.f/2.f); | 41 canvas->rotate(-180.f/2.f); |
42 | 42 |
43 paintFill.setAntiAlias(true); | 43 paintFill.setAntiAlias(true); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 220 |
221 private: | 221 private: |
222 | 222 |
223 typedef SampleView INHERITED; | 223 typedef SampleView INHERITED; |
224 }; | 224 }; |
225 | 225 |
226 ////////////////////////////////////////////////////////////////////////////// | 226 ////////////////////////////////////////////////////////////////////////////// |
227 | 227 |
228 static SkView* MyFactory() { return new ClockView; } | 228 static SkView* MyFactory() { return new ClockView; } |
229 static SkViewRegister reg(MyFactory); | 229 static SkViewRegister reg(MyFactory); |
OLD | NEW |