OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "gm.h" | 8 #include "gm.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 canvas->drawText(text, len, 0, 0, paint); | 50 canvas->drawText(text, len, 0, 0, paint); |
51 paint.getTextPath(text, len, 0, 0, &path); | 51 paint.getTextPath(text, len, 0, 0, &path); |
52 strokePath(canvas, path); | 52 strokePath(canvas, path); |
53 path.reset(); | 53 path.reset(); |
54 | 54 |
55 SkAutoTArray<SkPoint> pos(len); | 55 SkAutoTArray<SkPoint> pos(len); |
56 SkAutoTArray<SkScalar> widths(len); | 56 SkAutoTArray<SkScalar> widths(len); |
57 paint.getTextWidths(text, len, &widths[0]); | 57 paint.getTextWidths(text, len, &widths[0]); |
58 | 58 |
59 SkLCGRandom rand; | 59 SkRandom rand; |
60 SkScalar x = SkIntToScalar(20); | 60 SkScalar x = SkIntToScalar(20); |
61 SkScalar y = SkIntToScalar(100); | 61 SkScalar y = SkIntToScalar(100); |
62 for (int i = 0; i < len; ++i) { | 62 for (int i = 0; i < len; ++i) { |
63 pos[i].set(x, y + rand.nextSScalar1() * 24); | 63 pos[i].set(x, y + rand.nextSScalar1() * 24); |
64 x += widths[i]; | 64 x += widths[i]; |
65 } | 65 } |
66 | 66 |
67 canvas->translate(0, SkIntToScalar(64)); | 67 canvas->translate(0, SkIntToScalar(64)); |
68 | 68 |
69 canvas->drawPosText(text, len, &pos[0], paint); | 69 canvas->drawPosText(text, len, &pos[0], paint); |
70 paint.getPosTextPath(text, len, &pos[0], &path); | 70 paint.getPosTextPath(text, len, &pos[0], &path); |
71 strokePath(canvas, path); | 71 strokePath(canvas, path); |
72 } | 72 } |
73 }; | 73 }; |
74 | 74 |
75 ////////////////////////////////////////////////////////////////////////////// | 75 ////////////////////////////////////////////////////////////////////////////// |
76 | 76 |
77 static skiagm::GM* F(void*) { return new GetPosTextPathGM; } | 77 static skiagm::GM* F(void*) { return new GetPosTextPathGM; } |
78 static skiagm::GMRegistry gR(F); | 78 static skiagm::GMRegistry gR(F); |
OLD | NEW |