OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkView.h" | 9 #include "SkView.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkGraphics.h" | 11 #include "SkGraphics.h" |
12 #include "SkRandom.h" | 12 #include "SkRandom.h" |
13 | 13 |
14 #include <pthread.h> | 14 #include <pthread.h> |
15 | 15 |
16 static void call_measure() { | 16 static void call_measure() { |
17 SkPaint paint; | 17 SkPaint paint; |
18 uint16_t text[32]; | 18 uint16_t text[32]; |
19 SkMWCRandom rand; | 19 SkRandom rand; |
20 | 20 |
21 paint.setAntiAlias(true); | 21 paint.setAntiAlias(true); |
22 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding); | 22 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding); |
23 for (int j = 0; j < SK_ARRAY_COUNT(text); j++) | 23 for (int j = 0; j < SK_ARRAY_COUNT(text); j++) |
24 text[j] = (uint16_t)((rand.nextU() & 0xFF) + 32); | 24 text[j] = (uint16_t)((rand.nextU() & 0xFF) + 32); |
25 | 25 |
26 for (int i = 9; i < 36; i++) { | 26 for (int i = 9; i < 36; i++) { |
27 SkPaint::FontMetrics m; | 27 SkPaint::FontMetrics m; |
28 | 28 |
29 paint.setTextSize(SkIntToScalar(i)); | 29 paint.setTextSize(SkIntToScalar(i)); |
30 paint.getFontMetrics(&m); | 30 paint.getFontMetrics(&m); |
31 paint.measureText(text, sizeof(text)); | 31 paint.measureText(text, sizeof(text)); |
32 } | 32 } |
33 } | 33 } |
34 | 34 |
35 static void call_draw(SkCanvas* canvas) { | 35 static void call_draw(SkCanvas* canvas) { |
36 SkPaint paint; | 36 SkPaint paint; |
37 uint16_t text[32]; | 37 uint16_t text[32]; |
38 SkMWCRandom rand; | 38 SkRandom rand; |
39 | 39 |
40 paint.setAntiAlias(true); | 40 paint.setAntiAlias(true); |
41 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding); | 41 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding); |
42 for (int j = 0; j < SK_ARRAY_COUNT(text); j++) | 42 for (int j = 0; j < SK_ARRAY_COUNT(text); j++) |
43 text[j] = (uint16_t)((rand.nextU() & 0xFF) + 32); | 43 text[j] = (uint16_t)((rand.nextU() & 0xFF) + 32); |
44 | 44 |
45 SkScalar x = SkIntToScalar(10); | 45 SkScalar x = SkIntToScalar(10); |
46 SkScalar y = SkIntToScalar(20); | 46 SkScalar y = SkIntToScalar(20); |
47 | 47 |
48 canvas->drawColor(SK_ColorWHITE); | 48 canvas->drawColor(SK_ColorWHITE); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 } | 132 } |
133 | 133 |
134 private: | 134 private: |
135 typedef SampleView INHERITED; | 135 typedef SampleView INHERITED; |
136 }; | 136 }; |
137 | 137 |
138 ////////////////////////////////////////////////////////////////////////////// | 138 ////////////////////////////////////////////////////////////////////////////// |
139 | 139 |
140 static SkView* MyFactory() { return new FontCacheView; } | 140 static SkView* MyFactory() { return new FontCacheView; } |
141 static SkViewRegister reg(MyFactory); | 141 static SkViewRegister reg(MyFactory); |
OLD | NEW |