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

Side by Side Diff: gm/dftext.cpp

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 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/dcshader.cpp ('k') | gm/discard.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 2011 Google Inc. 2 * Copyright 2011 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 "gm.h" 7 #include "gm.h"
8 #include "Resources.h" 8 #include "Resources.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkStream.h" 10 #include "SkStream.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 // check scaling up 75 // check scaling up
76 SkScalar x = SkIntToScalar(0); 76 SkScalar x = SkIntToScalar(0);
77 SkScalar y = SkIntToScalar(78); 77 SkScalar y = SkIntToScalar(78);
78 for (size_t i = 0; i < SK_ARRAY_COUNT(textSizes); ++i) { 78 for (size_t i = 0; i < SK_ARRAY_COUNT(textSizes); ++i) {
79 SkAutoCanvasRestore acr(canvas, true); 79 SkAutoCanvasRestore acr(canvas, true);
80 canvas->translate(x, y); 80 canvas->translate(x, y);
81 canvas->scale(scales[i], scales[i]); 81 canvas->scale(scales[i], scales[i]);
82 paint.setTextSize(textSizes[i]); 82 paint.setTextSize(textSizes[i]);
83 canvas->drawText(text, textLen, 0, 0, paint); 83 canvas->drawText(text, textLen, 0, 0, paint);
84 y += paint.getFontMetrics(NULL)*scales[i]; 84 y += paint.getFontMetrics(nullptr)*scales[i];
85 } 85 }
86 86
87 // check rotation 87 // check rotation
88 for (size_t i = 0; i < 5; ++i) { 88 for (size_t i = 0; i < 5; ++i) {
89 SkScalar rotX = SkIntToScalar(10); 89 SkScalar rotX = SkIntToScalar(10);
90 SkScalar rotY = y; 90 SkScalar rotY = y;
91 91
92 SkAutoCanvasRestore acr(canvas, true); 92 SkAutoCanvasRestore acr(canvas, true);
93 canvas->translate(SkIntToScalar(10 + i * 200), -80); 93 canvas->translate(SkIntToScalar(10 + i * 200), -80);
94 rotate_about(canvas, SkIntToScalar(i * 5), rotX, rotY); 94 rotate_about(canvas, SkIntToScalar(i * 5), rotX, rotY);
95 for (int ps = 6; ps <= 32; ps += 3) { 95 for (int ps = 6; ps <= 32; ps += 3) {
96 paint.setTextSize(SkIntToScalar(ps)); 96 paint.setTextSize(SkIntToScalar(ps));
97 canvas->drawText(text, textLen, rotX, rotY, paint); 97 canvas->drawText(text, textLen, rotX, rotY, paint);
98 rotY += paint.getFontMetrics(NULL); 98 rotY += paint.getFontMetrics(nullptr);
99 } 99 }
100 } 100 }
101 101
102 // check scaling down 102 // check scaling down
103 paint.setLCDRenderText(true); 103 paint.setLCDRenderText(true);
104 x = SkIntToScalar(680); 104 x = SkIntToScalar(680);
105 y = SkIntToScalar(20); 105 y = SkIntToScalar(20);
106 size_t arraySize = SK_ARRAY_COUNT(textSizes); 106 size_t arraySize = SK_ARRAY_COUNT(textSizes);
107 for (size_t i = 0; i < arraySize; ++i) { 107 for (size_t i = 0; i < arraySize; ++i) {
108 SkAutoCanvasRestore acr(canvas, true); 108 SkAutoCanvasRestore acr(canvas, true);
109 canvas->translate(x, y); 109 canvas->translate(x, y);
110 SkScalar scaleFactor = SkScalarInvert(scales[arraySize - i - 1]); 110 SkScalar scaleFactor = SkScalarInvert(scales[arraySize - i - 1]);
111 canvas->scale(scaleFactor, scaleFactor); 111 canvas->scale(scaleFactor, scaleFactor);
112 paint.setTextSize(textSizes[i]); 112 paint.setTextSize(textSizes[i]);
113 canvas->drawText(text, textLen, 0, 0, paint); 113 canvas->drawText(text, textLen, 0, 0, paint);
114 y += paint.getFontMetrics(NULL)*scaleFactor; 114 y += paint.getFontMetrics(nullptr)*scaleFactor;
115 } 115 }
116 116
117 // check pos text 117 // check pos text
118 { 118 {
119 SkAutoCanvasRestore acr(canvas, true); 119 SkAutoCanvasRestore acr(canvas, true);
120 120
121 canvas->scale(2.0f, 2.0f); 121 canvas->scale(2.0f, 2.0f);
122 122
123 SkAutoTArray<SkPoint> pos(SkToInt(textLen)); 123 SkAutoTArray<SkPoint> pos(SkToInt(textLen));
124 SkAutoTArray<SkScalar> widths(SkToInt(textLen)); 124 SkAutoTArray<SkScalar> widths(SkToInt(textLen));
(...skipping 24 matching lines...) Expand all
149 SkRect r = SkRect::MakeLTRB(670, 215, 820, 397); 149 SkRect r = SkRect::MakeLTRB(670, 215, 820, 397);
150 canvas->drawRect(r, paint); 150 canvas->drawRect(r, paint);
151 151
152 x = SkIntToScalar(680); 152 x = SkIntToScalar(680);
153 y = SkIntToScalar(235); 153 y = SkIntToScalar(235);
154 paint.setTextSize(SkIntToScalar(19)); 154 paint.setTextSize(SkIntToScalar(19));
155 for (size_t i = 0; i < SK_ARRAY_COUNT(fg); ++i) { 155 for (size_t i = 0; i < SK_ARRAY_COUNT(fg); ++i) {
156 paint.setColor(fg[i]); 156 paint.setColor(fg[i]);
157 157
158 canvas->drawText(text, textLen, x, y, paint); 158 canvas->drawText(text, textLen, x, y, paint);
159 y += paint.getFontMetrics(NULL); 159 y += paint.getFontMetrics(nullptr);
160 } 160 }
161 161
162 paint.setColor(0xFF181C18); 162 paint.setColor(0xFF181C18);
163 r = SkRect::MakeLTRB(820, 215, 970, 397); 163 r = SkRect::MakeLTRB(820, 215, 970, 397);
164 canvas->drawRect(r, paint); 164 canvas->drawRect(r, paint);
165 165
166 x = SkIntToScalar(830); 166 x = SkIntToScalar(830);
167 y = SkIntToScalar(235); 167 y = SkIntToScalar(235);
168 paint.setTextSize(SkIntToScalar(19)); 168 paint.setTextSize(SkIntToScalar(19));
169 for (size_t i = 0; i < SK_ARRAY_COUNT(fg); ++i) { 169 for (size_t i = 0; i < SK_ARRAY_COUNT(fg); ++i) {
170 paint.setColor(fg[i]); 170 paint.setColor(fg[i]);
171 171
172 canvas->drawText(text, textLen, x, y, paint); 172 canvas->drawText(text, textLen, x, y, paint);
173 y += paint.getFontMetrics(NULL); 173 y += paint.getFontMetrics(nullptr);
174 } 174 }
175 175
176 // check skew 176 // check skew
177 { 177 {
178 paint.setLCDRenderText(false); 178 paint.setLCDRenderText(false);
179 SkAutoCanvasRestore acr(canvas, true); 179 SkAutoCanvasRestore acr(canvas, true);
180 canvas->skew(0.0f, 0.151515f); 180 canvas->skew(0.0f, 0.151515f);
181 paint.setTextSize(SkIntToScalar(32)); 181 paint.setTextSize(SkIntToScalar(32));
182 canvas->drawText(text, textLen, 745, 70, paint); 182 canvas->drawText(text, textLen, 745, 70, paint);
183 } 183 }
(...skipping 11 matching lines...) Expand all
195 paint.setTextSize(SkIntToScalar(19)); 195 paint.setTextSize(SkIntToScalar(19));
196 canvas->drawText(fEmojiText, strlen(fEmojiText), 670, 90, paint); 196 canvas->drawText(fEmojiText, strlen(fEmojiText), 670, 90, paint);
197 } 197 }
198 #if SK_SUPPORT_GPU 198 #if SK_SUPPORT_GPU
199 // render offscreen buffer 199 // render offscreen buffer
200 if (surface) { 200 if (surface) {
201 SkAutoCanvasRestore acr(inputCanvas, true); 201 SkAutoCanvasRestore acr(inputCanvas, true);
202 // since we prepended this matrix already, we blit using identity 202 // since we prepended this matrix already, we blit using identity
203 inputCanvas->resetMatrix(); 203 inputCanvas->resetMatrix();
204 SkImage* image = surface->newImageSnapshot(); 204 SkImage* image = surface->newImageSnapshot();
205 inputCanvas->drawImage(image, 0, 0, NULL); 205 inputCanvas->drawImage(image, 0, 0, nullptr);
206 image->unref(); 206 image->unref();
207 } 207 }
208 #endif 208 #endif
209 } 209 }
210 210
211 private: 211 private:
212 SkAutoTUnref<SkTypeface> fEmojiTypeface; 212 SkAutoTUnref<SkTypeface> fEmojiTypeface;
213 const char* fEmojiText; 213 const char* fEmojiText;
214 214
215 typedef skiagm::GM INHERITED; 215 typedef skiagm::GM INHERITED;
216 }; 216 };
217 217
218 DEF_GM(return new DFTextGM;) 218 DEF_GM(return new DFTextGM;)
OLDNEW
« no previous file with comments | « gm/dcshader.cpp ('k') | gm/discard.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698