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

Side by Side Diff: gm/textblobrandomfont.cpp

Issue 1316123003: Style Change: SkNEW->new; SkDELETE->delete (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-26 (Wednesday) 15:59:00 EDT Created 5 years, 3 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 | « gm/textblobmixedsizes.cpp ('k') | gm/textblobshader.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 2015 Google Inc. 2 * Copyright 2015 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 9
10 #include "Resources.h" 10 #include "Resources.h"
(...skipping 26 matching lines...) Expand all
37 SkPaint paint; 37 SkPaint paint;
38 paint.setTextSize(32); 38 paint.setTextSize(32);
39 paint.setLCDRenderText(true); 39 paint.setLCDRenderText(true);
40 40
41 // Setup our random scaler context 41 // Setup our random scaler context
42 SkAutoTUnref<SkTypeface> orig(sk_tool_utils::create_portable_typeface("s ans-serif", 42 SkAutoTUnref<SkTypeface> orig(sk_tool_utils::create_portable_typeface("s ans-serif",
43 Sk Typeface::kBold)); 43 Sk Typeface::kBold));
44 if (NULL == orig) { 44 if (NULL == orig) {
45 orig.reset(SkTypeface::RefDefault()); 45 orig.reset(SkTypeface::RefDefault());
46 } 46 }
47 SkAutoTUnref<SkTypeface> random(SkNEW_ARGS(SkRandomTypeface, (orig, pain t, false))); 47 SkAutoTUnref<SkTypeface> random(new SkRandomTypeface(orig, paint, false) );
48 paint.setTypeface(random); 48 paint.setTypeface(random);
49 49
50 SkRect bounds; 50 SkRect bounds;
51 paint.measureText(text, strlen(text), &bounds); 51 paint.measureText(text, strlen(text), &bounds);
52 sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, 0); 52 sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, 0);
53 53
54 // A8 54 // A8
55 const char* bigtext1 = "The quick brown fox"; 55 const char* bigtext1 = "The quick brown fox";
56 const char* bigtext2 = "jumps over the lazy dog."; 56 const char* bigtext2 = "jumps over the lazy dog.";
57 paint.setTextSize(160); 57 paint.setTextSize(160);
58 paint.setSubpixelText(false); 58 paint.setSubpixelText(false);
59 paint.setLCDRenderText(false); 59 paint.setLCDRenderText(false);
60 paint.measureText(bigtext1, strlen(bigtext1), &bounds); 60 paint.measureText(bigtext1, strlen(bigtext1), &bounds);
61 SkScalar offset = bounds.height(); 61 SkScalar offset = bounds.height();
62 sk_tool_utils::add_to_text_blob(&builder, bigtext1, paint, 0, offset); 62 sk_tool_utils::add_to_text_blob(&builder, bigtext1, paint, 0, offset);
63 63
64 paint.measureText(bigtext2, strlen(bigtext2), &bounds); 64 paint.measureText(bigtext2, strlen(bigtext2), &bounds);
65 offset += bounds.height(); 65 offset += bounds.height();
66 sk_tool_utils::add_to_text_blob(&builder, bigtext2, paint, 0, offset); 66 sk_tool_utils::add_to_text_blob(&builder, bigtext2, paint, 0, offset);
67 67
68 // color emoji 68 // color emoji
69 SkAutoTUnref<SkTypeface> origEmoji; 69 SkAutoTUnref<SkTypeface> origEmoji;
70 sk_tool_utils::emoji_typeface(&origEmoji); 70 sk_tool_utils::emoji_typeface(&origEmoji);
71 const char* osName = sk_tool_utils::platform_os_name(); 71 const char* osName = sk_tool_utils::platform_os_name();
72 // The mac emoji string will break us 72 // The mac emoji string will break us
73 if (origEmoji && (!strcmp(osName, "Android") || !strcmp(osName, "Ubuntu" ))) { 73 if (origEmoji && (!strcmp(osName, "Android") || !strcmp(osName, "Ubuntu" ))) {
74 const char* emojiText = sk_tool_utils::emoji_sample_text(); 74 const char* emojiText = sk_tool_utils::emoji_sample_text();
75 paint.measureText(emojiText, strlen(emojiText), &bounds); 75 paint.measureText(emojiText, strlen(emojiText), &bounds);
76 offset += bounds.height(); 76 offset += bounds.height();
77 SkAutoTUnref<SkTypeface> randomEmoji(SkNEW_ARGS(SkRandomTypeface, (o rig, paint, 77 SkAutoTUnref<SkTypeface> randomEmoji(new SkRandomTypeface(orig, pain t, false));
78 f alse)));
79 paint.setTypeface(randomEmoji); 78 paint.setTypeface(randomEmoji);
80 sk_tool_utils::add_to_text_blob(&builder, emojiText, paint, 0, offse t); 79 sk_tool_utils::add_to_text_blob(&builder, emojiText, paint, 0, offse t);
81 } 80 }
82 81
83 // build 82 // build
84 fBlob.reset(builder.build()); 83 fBlob.reset(builder.build());
85 } 84 }
86 85
87 SkString onShortName() override { 86 SkString onShortName() override {
88 return SkString("textblobrandomfont"); 87 return SkString("textblobrandomfont");
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 SkAutoTUnref<const SkTextBlob> fBlob; 141 SkAutoTUnref<const SkTextBlob> fBlob;
143 142
144 static const int kWidth = 2000; 143 static const int kWidth = 2000;
145 static const int kHeight = 1600; 144 static const int kHeight = 1600;
146 145
147 typedef GM INHERITED; 146 typedef GM INHERITED;
148 }; 147 };
149 148
150 ////////////////////////////////////////////////////////////////////////////// 149 //////////////////////////////////////////////////////////////////////////////
151 150
152 DEF_GM( return SkNEW(TextBlobRandomFont); ) 151 DEF_GM(return new TextBlobRandomFont;)
153 } 152 }
154 #endif 153 #endif
OLDNEW
« no previous file with comments | « gm/textblobmixedsizes.cpp ('k') | gm/textblobshader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698