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

Side by Side Diff: src/gpu/GrDistanceFieldTextContext.cpp

Issue 218613014: Add support for multiple base distance field sizes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Revert fontscaler Created 6 years, 8 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 2013 Google Inc. 2 * Copyright 2013 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 "GrDistanceFieldTextContext.h" 8 #include "GrDistanceFieldTextContext.h"
9 #include "GrAtlas.h" 9 #include "GrAtlas.h"
10 #include "GrDrawTarget.h" 10 #include "GrDrawTarget.h"
11 #include "GrDrawTargetCaps.h" 11 #include "GrDrawTargetCaps.h"
12 #include "GrFontScaler.h" 12 #include "GrFontScaler.h"
13 #include "SkGlyphCache.h" 13 #include "SkGlyphCache.h"
14 #include "GrIndexBuffer.h" 14 #include "GrIndexBuffer.h"
15 #include "GrTextStrike.h" 15 #include "GrTextStrike.h"
16 #include "GrTextStrike_impl.h" 16 #include "GrTextStrike_impl.h"
17 #include "SkDraw.h" 17 #include "SkDraw.h"
18 #include "SkGpuDevice.h" 18 #include "SkGpuDevice.h"
19 #include "SkPath.h" 19 #include "SkPath.h"
20 #include "SkRTConf.h" 20 #include "SkRTConf.h"
21 #include "SkStrokeRec.h" 21 #include "SkStrokeRec.h"
22 #include "effects/GrDistanceFieldTextureEffect.h" 22 #include "effects/GrDistanceFieldTextureEffect.h"
23 23
24 static const int kGlyphCoordsAttributeIndex = 1; 24 static const int kGlyphCoordsAttributeIndex = 1;
25 25
26 static const int kBaseDFFontSize = 32; 26 static const int kSmallDFFontSize = 32;
27 static const int kSmallDFFontLimit = 32;
28 static const int kMediumDFFontSize = 64;
29 static const int kMediumDFFontLimit = 64;
30 static const int kLargeDFFontSize = 128;
robertphillips 2014/04/01 17:55:43 Do we need kLargeDFFontLimit?
jvanverth1 2014/04/01 18:06:06 Done.
31 static const int kLargeDFFontLimit = 256; // 128 pt can scale up better than 32 or 64
27 32
28 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, 33 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false,
29 "Dump the contents of the font cache before every purge."); 34 "Dump the contents of the font cache before every purge.");
30 35
31 #if SK_FORCE_DISTANCEFIELD_FONTS 36 #if SK_FORCE_DISTANCEFIELD_FONTS
32 static const bool kForceDistanceFieldFonts = true; 37 static const bool kForceDistanceFieldFonts = true;
33 #else 38 #else
robertphillips 2014/04/01 17:55:43 Are we ready for this?
jvanverth1 2014/04/01 18:06:06 Whoops, reverted.
34 static const bool kForceDistanceFieldFonts = false; 39 static const bool kForceDistanceFieldFonts = true;
35 #endif 40 #endif
36 41
37 GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context, 42 GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context,
38 const SkDeviceProperties& properties) 43 const SkDeviceProperties& properties)
39 : GrTextContext(context, pro perties) { 44 : GrTextContext(context, pro perties) {
40 fStrike = NULL; 45 fStrike = NULL;
41 46
42 fCurrTexture = NULL; 47 fCurrTexture = NULL;
43 fCurrVertex = 0; 48 fCurrVertex = 0;
44 49
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 GrTextContext::init(paint, skPaint); 301 GrTextContext::init(paint, skPaint);
297 302
298 fStrike = NULL; 303 fStrike = NULL;
299 304
300 fCurrTexture = NULL; 305 fCurrTexture = NULL;
301 fCurrVertex = 0; 306 fCurrVertex = 0;
302 307
303 fVertices = NULL; 308 fVertices = NULL;
304 fMaxVertices = 0; 309 fMaxVertices = 0;
305 310
306 fTextRatio = fSkPaint.getTextSize()/kBaseDFFontSize; 311 if (fSkPaint.getTextSize() <= kSmallDFFontLimit) {
312 fTextRatio = fSkPaint.getTextSize()/kSmallDFFontSize;
313 fSkPaint.setTextSize(SkIntToScalar(kSmallDFFontSize));
314 } else if (fSkPaint.getTextSize() <= kMediumDFFontLimit) {
315 fTextRatio = fSkPaint.getTextSize()/kMediumDFFontSize;
316 fSkPaint.setTextSize(SkIntToScalar(kMediumDFFontSize));
317 } else {
318 fTextRatio = fSkPaint.getTextSize()/kLargeDFFontSize;
319 fSkPaint.setTextSize(SkIntToScalar(kLargeDFFontSize));
320 }
307 321
308 fSkPaint.setTextSize(SkIntToScalar(kBaseDFFontSize));
309 fSkPaint.setLCDRenderText(false); 322 fSkPaint.setLCDRenderText(false);
310 fSkPaint.setAutohinted(false); 323 fSkPaint.setAutohinted(false);
311 fSkPaint.setSubpixelText(true); 324 fSkPaint.setSubpixelText(true);
312 } 325 }
313 326
314 inline void GrDistanceFieldTextContext::finish() { 327 inline void GrDistanceFieldTextContext::finish() {
315 flushGlyphs(); 328 flushGlyphs();
316 329
317 GrTextContext::finish(); 330 GrTextContext::finish();
318 } 331 }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 SkScalarToFixed(y) - (glyph.fAdvanceY >> a lignShift) 462 SkScalarToFixed(y) - (glyph.fAdvanceY >> a lignShift)
450 + SK_FixedHalf, //d1g.fHalfSampleY, 463 + SK_FixedHalf, //d1g.fHalfSampleY,
451 fontScaler); 464 fontScaler);
452 } 465 }
453 pos += scalarsPerPosition; 466 pos += scalarsPerPosition;
454 } 467 }
455 } 468 }
456 469
457 this->finish(); 470 this->finish();
458 } 471 }
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