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

Side by Side Diff: gm/dftext.cpp

Issue 630103003: Reduce sizes in dftext GM on Android to match desktop better. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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 "SkSurface.h" 8 #include "SkSurface.h"
9 #include "SkTypeface.h" 9 #include "SkTypeface.h"
10 10
(...skipping 23 matching lines...) Expand all
34 34
35 static void rotate_about(SkCanvas* canvas, 35 static void rotate_about(SkCanvas* canvas,
36 SkScalar degrees, 36 SkScalar degrees,
37 SkScalar px, SkScalar py) { 37 SkScalar px, SkScalar py) {
38 canvas->translate(px, py); 38 canvas->translate(px, py);
39 canvas->rotate(degrees); 39 canvas->rotate(degrees);
40 canvas->translate(-px, -py); 40 canvas->translate(-px, -py);
41 } 41 }
42 42
43 virtual void onDraw(SkCanvas* inputCanvas) { 43 virtual void onDraw(SkCanvas* inputCanvas) {
44 #if SK_BUILD_FOR_ANDROID
45 SkScalar textSizes[] = { 9.0f, 9.0f*2.0f, 9.0f*5.0f, 9.0f*2.0f*5.0f };
46 #else
44 SkScalar textSizes[] = { 11.0f, 11.0f*2.0f, 11.0f*5.0f, 11.0f*2.0f*5.0f }; 47 SkScalar textSizes[] = { 11.0f, 11.0f*2.0f, 11.0f*5.0f, 11.0f*2.0f*5.0f };
48 #endif
45 SkScalar scales[] = { 2.0f*5.0f, 5.0f, 2.0f, 1.0f }; 49 SkScalar scales[] = { 2.0f*5.0f, 5.0f, 2.0f, 1.0f };
46 50
47 // set up offscreen rendering with distance field text 51 // set up offscreen rendering with distance field text
48 #if SK_SUPPORT_GPU 52 #if SK_SUPPORT_GPU
49 GrContext* ctx = inputCanvas->getGrContext(); 53 GrContext* ctx = inputCanvas->getGrContext();
50 SkImageInfo info = SkImageInfo::MakeN32Premul(onISize()); 54 SkImageInfo info = SkImageInfo::MakeN32Premul(onISize());
51 SkSurfaceProps props(SkSurfaceProps::kUseDistanceFieldFonts_Flag, 55 SkSurfaceProps props(SkSurfaceProps::kUseDistanceFieldFonts_Flag,
52 SkSurfaceProps::kLegacyFontHost_InitType); 56 SkSurfaceProps::kLegacyFontHost_InitType);
53 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, info, 0, &props)); 57 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, info, 0, &props));
54 SkCanvas* canvas = surface.get() ? surface->getCanvas() : inputCanvas; 58 SkCanvas* canvas = surface.get() ? surface->getCanvas() : inputCanvas;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 147 0xFFFF0000, 0xFF00FF00, 0xFF0000FF,
144 0xFF000000, 148 0xFF000000,
145 }; 149 };
146 150
147 paint.setColor(0xFFF1F1F1); 151 paint.setColor(0xFFF1F1F1);
148 SkRect r = SkRect::MakeLTRB(670, 250, 820, 460); 152 SkRect r = SkRect::MakeLTRB(670, 250, 820, 460);
149 canvas->drawRect(r, paint); 153 canvas->drawRect(r, paint);
150 154
151 x = SkIntToScalar(680); 155 x = SkIntToScalar(680);
152 y = SkIntToScalar(270); 156 y = SkIntToScalar(270);
157 #if SK_BUILD_FOR_ANDROID
158 paint.setTextSize(SkIntToScalar(19));
159 #else
153 paint.setTextSize(SkIntToScalar(22)); 160 paint.setTextSize(SkIntToScalar(22));
161 #endif
154 for (size_t i = 0; i < SK_ARRAY_COUNT(fg); ++i) { 162 for (size_t i = 0; i < SK_ARRAY_COUNT(fg); ++i) {
155 paint.setColor(fg[i]); 163 paint.setColor(fg[i]);
156 164
157 canvas->drawText(text, textLen, x, y, paint); 165 canvas->drawText(text, textLen, x, y, paint);
158 y += paint.getFontMetrics(NULL); 166 y += paint.getFontMetrics(NULL);
159 } 167 }
160 168
161 paint.setColor(0xFF1F1F1F); 169 paint.setColor(0xFF1F1F1F);
162 r = SkRect::MakeLTRB(820, 250, 970, 460); 170 r = SkRect::MakeLTRB(820, 250, 970, 460);
163 canvas->drawRect(r, paint); 171 canvas->drawRect(r, paint);
164 172
165 x = SkIntToScalar(830); 173 x = SkIntToScalar(830);
166 y = SkIntToScalar(270); 174 y = SkIntToScalar(270);
175 #if SK_BUILD_FOR_ANDROID
176 paint.setTextSize(SkIntToScalar(19));
177 #else
167 paint.setTextSize(SkIntToScalar(22)); 178 paint.setTextSize(SkIntToScalar(22));
179 #endif
168 for (size_t i = 0; i < SK_ARRAY_COUNT(fg); ++i) { 180 for (size_t i = 0; i < SK_ARRAY_COUNT(fg); ++i) {
169 paint.setColor(fg[i]); 181 paint.setColor(fg[i]);
170 182
171 canvas->drawText(text, textLen, x, y, paint); 183 canvas->drawText(text, textLen, x, y, paint);
172 y += paint.getFontMetrics(NULL); 184 y += paint.getFontMetrics(NULL);
173 } 185 }
174 186
175 #if SK_SUPPORT_GPU 187 #if SK_SUPPORT_GPU
176 // render offscreen buffer 188 // render offscreen buffer
177 if (surface) { 189 if (surface) {
178 SkImage* image = surface->newImageSnapshot(); 190 SkImage* image = surface->newImageSnapshot();
179 inputCanvas->drawImage(image, 0, 0, NULL); 191 inputCanvas->drawImage(image, 0, 0, NULL);
180 image->unref(); 192 image->unref();
181 } 193 }
182 #endif 194 #endif
183 } 195 }
184 196
185 private: 197 private:
186 typedef GM INHERITED; 198 typedef GM INHERITED;
187 }; 199 };
188 200
189 ////////////////////////////////////////////////////////////////////////////// 201 //////////////////////////////////////////////////////////////////////////////
190 202
191 static GM* MyFactory(void*) { return new DFTextGM; } 203 static GM* MyFactory(void*) { return new DFTextGM; }
192 static GMRegistry reg(MyFactory); 204 static GMRegistry reg(MyFactory);
193 205
194 } 206 }
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