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

Side by Side Diff: gm/typeface.cpp

Issue 2140863002: Use hintgasp font when testing rendering. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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 | resources/fonts/hintgasp.ttf » ('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 2012 Google Inc. 2 * Copyright 2012 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 #include "Resources.h" 9 #include "Resources.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 fFace = MakeResourceAsTypeface("/fonts/hintgasp.ttf"); 173 fFace = MakeResourceAsTypeface("/fonts/hintgasp.ttf");
174 } 174 }
175 175
176 SkString onShortName() override { 176 SkString onShortName() override {
177 SkString name("typefacerendering"); 177 SkString name("typefacerendering");
178 name.append(sk_tool_utils::major_platform_os_name()); 178 name.append(sk_tool_utils::major_platform_os_name());
179 return name; 179 return name;
180 } 180 }
181 181
182 SkISize onISize() override { 182 SkISize onISize() override {
183 return SkISize::Make(640, 480); 183 return SkISize::Make(640, 680);
184 } 184 }
185 185
186 void onDraw(SkCanvas* canvas) override { 186 void onDraw(SkCanvas* canvas) override {
187 struct AliasType { 187 struct AliasType {
188 bool antiAlias; 188 bool antiAlias;
189 bool subpixelAntitalias; 189 bool subpixelAntitalias;
190 bool inLayer; 190 bool inLayer;
191 } constexpr aliasTypes[] { 191 } constexpr aliasTypes[] {
192 { false, false, false }, // aliased 192 { false, false, false }, // aliased
193 { true, false, false }, // anti-aliased 193 { true, false, false }, // anti-aliased
194 { true, true , false }, // subpixel anti-aliased 194 { true, true , false }, // subpixel anti-aliased
195 { true, false, true }, // anti-aliased in layer (flat pixel geome try) 195 { true, false, true }, // anti-aliased in layer (flat pixel geome try)
196 { true, true , true }, // subpixel anti-aliased in layer (flat pi xel geometry) 196 { true, true , true }, // subpixel anti-aliased in layer (flat pi xel geometry)
197 }; 197 };
198 198
199 // The hintgasp.ttf is designed for the following sizes to be different. 199 // The hintgasp.ttf is designed for the following sizes to be different.
200 // GASP_DOGRAY 0x0002 0<=ppem<=10 200 // GASP_DOGRAY 0x0002 0<=ppem<=10
201 // GASP_SYMMETRIC_SMOOTHING 0x0008 0<=ppem<=10 201 // GASP_SYMMETRIC_SMOOTHING 0x0008 0<=ppem<=10
202 // GASP_GRIDFIT 0x0001 11<=ppem<=12 202 // GASP_GRIDFIT 0x0001 11<=ppem<=12
203 // GASP_SYMMETRIC_GRIDFIT 0x0004 11<=ppem<=12 203 // GASP_SYMMETRIC_GRIDFIT 0x0004 11<=ppem<=12
204 // GASP_DOGRAY|GASP_GRIDFIT 0x0003 13<=ppem<=14 204 // GASP_DOGRAY|GASP_GRIDFIT 0x0003 13<=ppem<=14
205 // GASP_SYMMETRIC_SMOOTHING|GASP_SYMMETRIC_GRIDFIT 0x000C 13<=ppem<=14 205 // GASP_SYMMETRIC_SMOOTHING|GASP_SYMMETRIC_GRIDFIT 0x000C 13<=ppem<=14
206 // (neither) 0x0000 15<=ppem 206 // (neither) 0x0000 15<=ppem
207 constexpr SkScalar textSizes[] = { 10, 12, 14, 16 }; 207 // Odd sizes have embedded bitmaps.
208 constexpr SkScalar textSizes[] = { 9, 10, 11, 12, 13, 14, 15, 16 };
208 209
209 constexpr SkPaint::Hinting hintingTypes[] = { SkPaint::kNo_Hinting, 210 constexpr SkPaint::Hinting hintingTypes[] = { SkPaint::kNo_Hinting,
210 SkPaint::kSlight_Hinting, 211 SkPaint::kSlight_Hinting,
211 SkPaint::kNormal_Hinting, 212 SkPaint::kNormal_Hinting,
212 SkPaint::kFull_Hinting }; 213 SkPaint::kFull_Hinting };
213 214
214 struct SubpixelType { 215 struct SubpixelType {
215 bool requested; 216 bool requested;
216 SkVector offset; 217 SkVector offset;
217 } constexpr subpixelTypes[] = { 218 } constexpr subpixelTypes[] = {
218 { false, { 0.00, 0.00 } }, 219 { false, { 0.00, 0.00 } },
219 { true , { 0.00, 0.00 } }, 220 { true , { 0.00, 0.00 } },
220 { true , { 0.25, 0.00 } }, 221 { true , { 0.25, 0.00 } },
221 { true , { 0.25, 0.25 } }, 222 { true , { 0.25, 0.25 } },
222 }; 223 };
223 224
224 constexpr bool rotateABitTypes[] = { false, true }; 225 constexpr bool rotateABitTypes[] = { false, true };
225 226
226 SkPaint paint; 227 SkPaint paint;
228 paint.setTypeface(fFace);
229 paint.setEmbeddedBitmapText(true);
230
227 SkScalar x = 0; 231 SkScalar x = 0;
228 SkScalar xMax = x; 232 SkScalar xMax = x;
229 SkScalar xBase = 0; 233 SkScalar xBase = 0;
230 SkScalar y = 0; // The baseline of the previous output 234 SkScalar y = 0; // The baseline of the previous output
231 for (const SubpixelType subpixel : subpixelTypes) { 235 for (const SubpixelType subpixel : subpixelTypes) {
232 y = 0; 236 y = 0;
233 paint.setSubpixelText(subpixel.requested); 237 paint.setSubpixelText(subpixel.requested);
234 238
235 for (const AliasType& alias : aliasTypes) { 239 for (const AliasType& alias : aliasTypes) {
236 paint.setAntiAlias(alias.antiAlias); 240 paint.setAntiAlias(alias.antiAlias);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 276
273 private: 277 private:
274 typedef skiagm::GM INHERITED; 278 typedef skiagm::GM INHERITED;
275 }; 279 };
276 280
277 /////////////////////////////////////////////////////////////////////////////// 281 ///////////////////////////////////////////////////////////////////////////////
278 282
279 DEF_GM( return new TypefaceStylesGM(false); ) 283 DEF_GM( return new TypefaceStylesGM(false); )
280 DEF_GM( return new TypefaceStylesGM(true); ) 284 DEF_GM( return new TypefaceStylesGM(true); )
281 DEF_GM( return new TypefaceRenderingGM(); ) 285 DEF_GM( return new TypefaceRenderingGM(); )
OLDNEW
« no previous file with comments | « no previous file | resources/fonts/hintgasp.ttf » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698