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

Side by Side Diff: src/gpu/text/GrTextUtils.cpp

Issue 2163633002: Make SkFont a bit more useable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix bug 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 | « src/gpu/text/GrStencilAndCoverTextContext.cpp ('k') | src/pdf/SkPDFDevice.cpp » ('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 2015 Google Inc. 2 * Copyright 2015 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 "GrTextUtils.h" 8 #include "GrTextUtils.h"
9 9
10 #include "GrAtlasTextBlob.h" 10 #include "GrAtlasTextBlob.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 const SkMatrix& viewMatrix, 246 const SkMatrix& viewMatrix,
247 const char text[], size_t byteLength, 247 const char text[], size_t byteLength,
248 SkScalar x, SkScalar y) { 248 SkScalar x, SkScalar y) {
249 SkASSERT(byteLength == 0 || text != nullptr); 249 SkASSERT(byteLength == 0 || text != nullptr);
250 250
251 // nothing to draw 251 // nothing to draw
252 if (text == nullptr || byteLength == 0) { 252 if (text == nullptr || byteLength == 0) {
253 return; 253 return;
254 } 254 }
255 255
256 SkPaint::GlyphCacheProc glyphCacheProc = skPaint.getGlyphCacheProc(true); 256 SkPaint::GlyphCacheProc glyphCacheProc = SkPaint::GetGlyphCacheProc(skPaint. getTextEncoding(),
257 skPaint. isDevKernText(),
258 true);
257 SkAutoDescriptor desc; 259 SkAutoDescriptor desc;
258 SkScalerContextEffects effects; 260 SkScalerContextEffects effects;
259 // We apply the fake-gamma by altering the distance in the shader, so we ign ore the 261 // We apply the fake-gamma by altering the distance in the shader, so we ign ore the
260 // passed-in scaler context flags. (It's only used when we fall-back to bitm ap text). 262 // passed-in scaler context flags. (It's only used when we fall-back to bitm ap text).
261 skPaint.getScalerContextDescriptor(&effects, &desc, props, SkPaint::kNone_Sc alerContextFlags, 263 skPaint.getScalerContextDescriptor(&effects, &desc, props, SkPaint::kNone_Sc alerContextFlags,
262 nullptr); 264 nullptr);
263 SkGlyphCache* origPaintCache = SkGlyphCache::DetachCache(skPaint.getTypeface (), effects, 265 SkGlyphCache* origPaintCache = SkGlyphCache::DetachCache(skPaint.getTypeface (), effects,
264 desc.getDesc()); 266 desc.getDesc());
265 267
266 SkTArray<SkScalar> positions; 268 SkTArray<SkScalar> positions;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 GrTextUtils::InitDistanceFieldPaint(blob, &dfPaint, &textRatio, viewMatrix); 340 GrTextUtils::InitDistanceFieldPaint(blob, &dfPaint, &textRatio, viewMatrix);
339 blob->setHasDistanceField(); 341 blob->setHasDistanceField();
340 blob->setSubRunHasDistanceFields(runIndex, origPaint.isLCDRenderText()); 342 blob->setSubRunHasDistanceFields(runIndex, origPaint.isLCDRenderText());
341 343
342 GrBatchTextStrike* currStrike = nullptr; 344 GrBatchTextStrike* currStrike = nullptr;
343 345
344 // We apply the fake-gamma by altering the distance in the shader, so we ign ore the 346 // We apply the fake-gamma by altering the distance in the shader, so we ign ore the
345 // passed-in scaler context flags. (It's only used when we fall-back to bitm ap text). 347 // passed-in scaler context flags. (It's only used when we fall-back to bitm ap text).
346 SkGlyphCache* cache = blob->setupCache(runIndex, props, SkPaint::kNone_Scale rContextFlags, 348 SkGlyphCache* cache = blob->setupCache(runIndex, props, SkPaint::kNone_Scale rContextFlags,
347 dfPaint, nullptr); 349 dfPaint, nullptr);
348 SkPaint::GlyphCacheProc glyphCacheProc = dfPaint.getGlyphCacheProc(true); 350 SkPaint::GlyphCacheProc glyphCacheProc = SkPaint::GetGlyphCacheProc(dfPaint. getTextEncoding(),
351 dfPaint. isDevKernText(),
352 true);
349 353
350 const char* stop = text + byteLength; 354 const char* stop = text + byteLength;
351 355
352 if (SkPaint::kLeft_Align == dfPaint.getTextAlign()) { 356 if (SkPaint::kLeft_Align == dfPaint.getTextAlign()) {
353 while (text < stop) { 357 while (text < stop) {
354 const char* lastText = text; 358 const char* lastText = text;
355 // the last 2 parameters are ignored 359 // the last 2 parameters are ignored
356 const SkGlyph& glyph = glyphCacheProc(cache, &text); 360 const SkGlyph& glyph = glyphCacheProc(cache, &text);
357 361
358 if (glyph.fWidth) { 362 if (glyph.fWidth) {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 SkPaint paint(origPaint); 505 SkPaint paint(origPaint);
502 SkScalar matrixScale = paint.setupForAsPaths(); 506 SkScalar matrixScale = paint.setupForAsPaths();
503 507
504 SkMatrix matrix; 508 SkMatrix matrix;
505 matrix.setScale(matrixScale, matrixScale); 509 matrix.setScale(matrixScale, matrixScale);
506 510
507 // Temporarily jam in kFill, so we only ever ask for the raw outline from th e cache. 511 // Temporarily jam in kFill, so we only ever ask for the raw outline from th e cache.
508 paint.setStyle(SkPaint::kFill_Style); 512 paint.setStyle(SkPaint::kFill_Style);
509 paint.setPathEffect(nullptr); 513 paint.setPathEffect(nullptr);
510 514
511 SkPaint::GlyphCacheProc glyphCacheProc = paint.getGlyphCacheProc(true); 515 SkPaint::GlyphCacheProc glyphCacheProc = SkPaint::GetGlyphCacheProc(paint .getTextEncoding(),
516 paint .isDevKernText(),
517 true) ;
512 SkAutoGlyphCache autoCache(paint, &props, nullptr); 518 SkAutoGlyphCache autoCache(paint, &props, nullptr);
513 SkGlyphCache* cache = autoCache.getCache(); 519 SkGlyphCache* cache = autoCache.getCache();
514 520
515 const char* stop = text + byteLength; 521 const char* stop = text + byteLength;
516 SkTextAlignProc alignProc(paint.getTextAlign()); 522 SkTextAlignProc alignProc(paint.getTextAlign());
517 SkTextMapStateProc tmsProc(SkMatrix::I(), offset, scalarsPerPosition); 523 SkTextMapStateProc tmsProc(SkMatrix::I(), offset, scalarsPerPosition);
518 524
519 // Now restore the original settings, so we "draw" with whatever style/strok ing. 525 // Now restore the original settings, so we "draw" with whatever style/strok ing.
520 paint.setStyle(origPaint.getStyle()); 526 paint.setStyle(origPaint.getStyle());
521 paint.setPathEffect(sk_ref_sp(origPaint.getPathEffect())); 527 paint.setPathEffect(sk_ref_sp(origPaint.getPathEffect()));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 return flags; 562 return flags;
557 } 563 }
558 564
559 if (kUnknown_SkPixelGeometry == surfaceProps.pixelGeometry() || ShouldDisabl eLCD(paint)) { 565 if (kUnknown_SkPixelGeometry == surfaceProps.pixelGeometry() || ShouldDisabl eLCD(paint)) {
560 flags &= ~SkPaint::kLCDRenderText_Flag; 566 flags &= ~SkPaint::kLCDRenderText_Flag;
561 flags |= SkPaint::kGenA8FromLCD_Flag; 567 flags |= SkPaint::kGenA8FromLCD_Flag;
562 } 568 }
563 569
564 return flags; 570 return flags;
565 } 571 }
OLDNEW
« no previous file with comments | « src/gpu/text/GrStencilAndCoverTextContext.cpp ('k') | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698