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

Side by Side Diff: gm/dftext.cpp

Issue 1253643004: make dftext gm not overlap itself (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: move emoji up slightly Created 5 years, 5 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 | « no previous file | no next file » | 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 139
140 // check gamma-corrected blending 140 // check gamma-corrected blending
141 const SkColor fg[] = { 141 const SkColor fg[] = {
142 0xFFFFFFFF, 142 0xFFFFFFFF,
143 0xFFFFFF00, 0xFFFF00FF, 0xFF00FFFF, 143 0xFFFFFF00, 0xFFFF00FF, 0xFF00FFFF,
144 0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 144 0xFFFF0000, 0xFF00FF00, 0xFF0000FF,
145 0xFF000000, 145 0xFF000000,
146 }; 146 };
147 147
148 paint.setColor(0xFFF7F3F7); 148 paint.setColor(0xFFF7F3F7);
149 SkRect r = SkRect::MakeLTRB(670, 250, 820, 460); 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(270); 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(NULL);
160 } 160 }
161 161
162 paint.setColor(0xFF181C18); 162 paint.setColor(0xFF181C18);
163 r = SkRect::MakeLTRB(820, 250, 970, 460); 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(270); 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(NULL);
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 }
184 { 184 {
185 paint.setLCDRenderText(true); 185 paint.setLCDRenderText(true);
186 SkAutoCanvasRestore acr(canvas, true); 186 SkAutoCanvasRestore acr(canvas, true);
187 canvas->skew(0.5f, 0.0f); 187 canvas->skew(0.5f, 0.0f);
188 paint.setTextSize(SkIntToScalar(32)); 188 paint.setTextSize(SkIntToScalar(32));
189 canvas->drawText(text, textLen, 580, 230, paint); 189 canvas->drawText(text, textLen, 580, 125, paint);
190 } 190 }
191 191
192 // check color emoji 192 // check color emoji
193 if (fEmojiTypeface) { 193 if (fEmojiTypeface) {
194 paint.setTypeface(fEmojiTypeface); 194 paint.setTypeface(fEmojiTypeface);
195 paint.setTextSize(SkIntToScalar(19)); 195 paint.setTextSize(SkIntToScalar(19));
196 canvas->drawText(fEmojiText, strlen(fEmojiText), 670, 100, 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, NULL);
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 SkNEW(DFTextGM); ) 218 DEF_GM( return SkNEW(DFTextGM); )
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698