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

Side by Side Diff: gm/dftext.cpp

Issue 1253573006: make dftext the same on Linux and Android (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 24 matching lines...) Expand all
35 35
36 static void rotate_about(SkCanvas* canvas, 36 static void rotate_about(SkCanvas* canvas,
37 SkScalar degrees, 37 SkScalar degrees,
38 SkScalar px, SkScalar py) { 38 SkScalar px, SkScalar py) {
39 canvas->translate(px, py); 39 canvas->translate(px, py);
40 canvas->rotate(degrees); 40 canvas->rotate(degrees);
41 canvas->translate(-px, -py); 41 canvas->translate(-px, -py);
42 } 42 }
43 43
44 virtual void onDraw(SkCanvas* inputCanvas) override { 44 virtual void onDraw(SkCanvas* inputCanvas) override {
45 #ifdef SK_BUILD_FOR_ANDROID
46 SkScalar textSizes[] = { 9.0f, 9.0f*2.0f, 9.0f*5.0f, 9.0f*2.0f*5.0f }; 45 SkScalar textSizes[] = { 9.0f, 9.0f*2.0f, 9.0f*5.0f, 9.0f*2.0f*5.0f };
47 #else
48 SkScalar textSizes[] = { 11.0f, 11.0f*2.0f, 11.0f*5.0f, 11.0f*2.0f*5.0f };
49 #endif
50 SkScalar scales[] = { 2.0f*5.0f, 5.0f, 2.0f, 1.0f }; 46 SkScalar scales[] = { 2.0f*5.0f, 5.0f, 2.0f, 1.0f };
51 47
52 // set up offscreen rendering with distance field text 48 // set up offscreen rendering with distance field text
53 #if SK_SUPPORT_GPU 49 #if SK_SUPPORT_GPU
54 GrContext* ctx = inputCanvas->getGrContext(); 50 GrContext* ctx = inputCanvas->getGrContext();
55 SkImageInfo info = SkImageInfo::MakeN32Premul(onISize()); 51 SkImageInfo info = SkImageInfo::MakeN32Premul(onISize());
56 SkSurfaceProps props(SkSurfaceProps::kUseDistanceFieldFonts_Flag, 52 SkSurfaceProps props(SkSurfaceProps::kUseDistanceFieldFonts_Flag,
57 SkSurfaceProps::kLegacyFontHost_InitType); 53 SkSurfaceProps::kLegacyFontHost_InitType);
58 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkSurfac e::kNo_Budgeted, 54 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkSurfac e::kNo_Budgeted,
59 info, 0, &pro ps)); 55 info, 0, &pro ps));
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 144 0xFFFF0000, 0xFF00FF00, 0xFF0000FF,
149 0xFF000000, 145 0xFF000000,
150 }; 146 };
151 147
152 paint.setColor(0xFFF7F3F7); 148 paint.setColor(0xFFF7F3F7);
153 SkRect r = SkRect::MakeLTRB(670, 250, 820, 460); 149 SkRect r = SkRect::MakeLTRB(670, 250, 820, 460);
154 canvas->drawRect(r, paint); 150 canvas->drawRect(r, paint);
155 151
156 x = SkIntToScalar(680); 152 x = SkIntToScalar(680);
157 y = SkIntToScalar(270); 153 y = SkIntToScalar(270);
158 #ifdef SK_BUILD_FOR_ANDROID
159 paint.setTextSize(SkIntToScalar(19)); 154 paint.setTextSize(SkIntToScalar(19));
160 #else
161 paint.setTextSize(SkIntToScalar(22));
162 #endif
163 for (size_t i = 0; i < SK_ARRAY_COUNT(fg); ++i) { 155 for (size_t i = 0; i < SK_ARRAY_COUNT(fg); ++i) {
164 paint.setColor(fg[i]); 156 paint.setColor(fg[i]);
165 157
166 canvas->drawText(text, textLen, x, y, paint); 158 canvas->drawText(text, textLen, x, y, paint);
167 y += paint.getFontMetrics(NULL); 159 y += paint.getFontMetrics(NULL);
168 } 160 }
169 161
170 paint.setColor(0xFF181C18); 162 paint.setColor(0xFF181C18);
171 r = SkRect::MakeLTRB(820, 250, 970, 460); 163 r = SkRect::MakeLTRB(820, 250, 970, 460);
172 canvas->drawRect(r, paint); 164 canvas->drawRect(r, paint);
173 165
174 x = SkIntToScalar(830); 166 x = SkIntToScalar(830);
175 y = SkIntToScalar(270); 167 y = SkIntToScalar(270);
176 #ifdef SK_BUILD_FOR_ANDROID
177 paint.setTextSize(SkIntToScalar(19)); 168 paint.setTextSize(SkIntToScalar(19));
178 #else
179 paint.setTextSize(SkIntToScalar(22));
180 #endif
181 for (size_t i = 0; i < SK_ARRAY_COUNT(fg); ++i) { 169 for (size_t i = 0; i < SK_ARRAY_COUNT(fg); ++i) {
182 paint.setColor(fg[i]); 170 paint.setColor(fg[i]);
183 171
184 canvas->drawText(text, textLen, x, y, paint); 172 canvas->drawText(text, textLen, x, y, paint);
185 y += paint.getFontMetrics(NULL); 173 y += paint.getFontMetrics(NULL);
186 } 174 }
187 175
188 // check skew 176 // check skew
189 { 177 {
190 paint.setLCDRenderText(false); 178 paint.setLCDRenderText(false);
(...skipping 30 matching lines...) Expand all
221 } 209 }
222 210
223 private: 211 private:
224 SkAutoTUnref<SkTypeface> fEmojiTypeface; 212 SkAutoTUnref<SkTypeface> fEmojiTypeface;
225 const char* fEmojiText; 213 const char* fEmojiText;
226 214
227 typedef skiagm::GM INHERITED; 215 typedef skiagm::GM INHERITED;
228 }; 216 };
229 217
230 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