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

Side by Side Diff: gm/getpostextpath.cpp

Issue 147683003: fix more 64bit warnings (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | gm/nonclosedpaths.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 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 15 matching lines...) Expand all
26 SkPaint paint; 26 SkPaint paint;
27 paint.setAntiAlias(true); 27 paint.setAntiAlias(true);
28 paint.setColor(SK_ColorRED); 28 paint.setColor(SK_ColorRED);
29 paint.setStyle(SkPaint::kStroke_Style); 29 paint.setStyle(SkPaint::kStroke_Style);
30 canvas->drawPath(path, paint); 30 canvas->drawPath(path, paint);
31 } 31 }
32 32
33 virtual void onDraw(SkCanvas* canvas) { 33 virtual void onDraw(SkCanvas* canvas) {
34 // explicitly add spaces, to test a prev. bug 34 // explicitly add spaces, to test a prev. bug
35 const char* text = "Ham bur ge fons"; 35 const char* text = "Ham bur ge fons";
36 size_t len = strlen(text); 36 int len = SkToInt(strlen(text));
37 SkPath path; 37 SkPath path;
38 38
39 SkPaint paint; 39 SkPaint paint;
40 paint.setAntiAlias(true); 40 paint.setAntiAlias(true);
41 paint.setTextSize(SkIntToScalar(48)); 41 paint.setTextSize(SkIntToScalar(48));
42 42
43 canvas->translate(SkIntToScalar(10), SkIntToScalar(64)); 43 canvas->translate(SkIntToScalar(10), SkIntToScalar(64));
44 44
45 canvas->drawText(text, len, 0, 0, paint); 45 canvas->drawText(text, len, 0, 0, paint);
46 paint.getTextPath(text, len, 0, 0, &path); 46 paint.getTextPath(text, len, 0, 0, &path);
47 strokePath(canvas, path); 47 strokePath(canvas, path);
48 path.reset(); 48 path.reset();
49 49
50 SkAutoTArray<SkPoint> pos(len); 50 SkAutoTArray<SkPoint> pos(len);
51 SkAutoTArray<SkScalar> widths(len); 51 SkAutoTArray<SkScalar> widths(len);
52 paint.getTextWidths(text, len, &widths[0]); 52 paint.getTextWidths(text, len, &widths[0]);
53 53
54 SkLCGRandom rand; 54 SkLCGRandom rand;
55 SkScalar x = SkIntToScalar(20); 55 SkScalar x = SkIntToScalar(20);
56 SkScalar y = SkIntToScalar(100); 56 SkScalar y = SkIntToScalar(100);
57 for (size_t i = 0; i < len; ++i) { 57 for (int i = 0; i < len; ++i) {
58 pos[i].set(x, y + rand.nextSScalar1() * 24); 58 pos[i].set(x, y + rand.nextSScalar1() * 24);
59 x += widths[i]; 59 x += widths[i];
60 } 60 }
61 61
62 canvas->translate(0, SkIntToScalar(64)); 62 canvas->translate(0, SkIntToScalar(64));
63 63
64 canvas->drawPosText(text, len, &pos[0], paint); 64 canvas->drawPosText(text, len, &pos[0], paint);
65 paint.getPosTextPath(text, len, &pos[0], &path); 65 paint.getPosTextPath(text, len, &pos[0], &path);
66 strokePath(canvas, path); 66 strokePath(canvas, path);
67 } 67 }
68 }; 68 };
69 69
70 ////////////////////////////////////////////////////////////////////////////// 70 //////////////////////////////////////////////////////////////////////////////
71 71
72 static skiagm::GM* F(void*) { return new GetPosTextPathGM; } 72 static skiagm::GM* F(void*) { return new GetPosTextPathGM; }
73 static skiagm::GMRegistry gR(F); 73 static skiagm::GMRegistry gR(F);
OLDNEW
« no previous file with comments | « no previous file | gm/nonclosedpaths.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698