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

Side by Side Diff: src/gpu/text/GrStencilAndCoverTextContext.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/core/SkPaint.cpp ('k') | src/gpu/text/GrTextUtils.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 2014 Google Inc. 2 * Copyright 2014 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 "GrStencilAndCoverTextContext.h" 8 #include "GrStencilAndCoverTextContext.h"
9 #include "GrAtlasTextContext.h" 9 #include "GrAtlasTextContext.h"
10 #include "GrContext.h" 10 #include "GrContext.h"
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 462
463 GrStencilAndCoverTextContext::TextRun::~TextRun() { 463 GrStencilAndCoverTextContext::TextRun::~TextRun() {
464 this->releaseGlyphCache(); 464 this->releaseGlyphCache();
465 } 465 }
466 466
467 void GrStencilAndCoverTextContext::TextRun::setText(const char text[], size_t by teLength, 467 void GrStencilAndCoverTextContext::TextRun::setText(const char text[], size_t by teLength,
468 SkScalar x, SkScalar y) { 468 SkScalar x, SkScalar y) {
469 SkASSERT(byteLength == 0 || text != nullptr); 469 SkASSERT(byteLength == 0 || text != nullptr);
470 470
471 SkGlyphCache* glyphCache = this->getGlyphCache(); 471 SkGlyphCache* glyphCache = this->getGlyphCache();
472 SkPaint::GlyphCacheProc glyphCacheProc = fFont.getGlyphCacheProc(true); 472 SkPaint::GlyphCacheProc glyphCacheProc = SkPaint::GetGlyphCacheProc(fFont.ge tTextEncoding(),
473 fFont.is DevKernText(),
474 true);
473 475
474 fTotalGlyphCount = fFont.countText(text, byteLength); 476 fTotalGlyphCount = fFont.countText(text, byteLength);
475 fInstanceData.reset(InstanceData::Alloc(GrPathRendering::kTranslate_PathTran sformType, 477 fInstanceData.reset(InstanceData::Alloc(GrPathRendering::kTranslate_PathTran sformType,
476 fTotalGlyphCount)); 478 fTotalGlyphCount));
477 479
478 const char* stop = text + byteLength; 480 const char* stop = text + byteLength;
479 481
480 // Measure first if needed. 482 // Measure first if needed.
481 if (fFont.getTextAlign() != SkPaint::kLeft_Align) { 483 if (fFont.getTextAlign() != SkPaint::kLeft_Align) {
482 SkScalar stopX = 0; 484 SkScalar stopX = 0;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 fFallbackTextBlob.reset(fallback.buildIfNeeded(&fFallbackGlyphCount)); 524 fFallbackTextBlob.reset(fallback.buildIfNeeded(&fFallbackGlyphCount));
523 } 525 }
524 526
525 void GrStencilAndCoverTextContext::TextRun::setPosText(const char text[], size_t byteLength, 527 void GrStencilAndCoverTextContext::TextRun::setPosText(const char text[], size_t byteLength,
526 const SkScalar pos[], int scalarsPerPosition, 528 const SkScalar pos[], int scalarsPerPosition,
527 const SkPoint& offset) { 529 const SkPoint& offset) {
528 SkASSERT(byteLength == 0 || text != nullptr); 530 SkASSERT(byteLength == 0 || text != nullptr);
529 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition); 531 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
530 532
531 SkGlyphCache* glyphCache = this->getGlyphCache(); 533 SkGlyphCache* glyphCache = this->getGlyphCache();
532 SkPaint::GlyphCacheProc glyphCacheProc = fFont.getGlyphCacheProc(true); 534 SkPaint::GlyphCacheProc glyphCacheProc = SkPaint::GetGlyphCacheProc(fFont.ge tTextEncoding(),
535 fFont.is DevKernText(),
536 true);
533 537
534 fTotalGlyphCount = fFont.countText(text, byteLength); 538 fTotalGlyphCount = fFont.countText(text, byteLength);
535 fInstanceData.reset(InstanceData::Alloc(GrPathRendering::kTranslate_PathTran sformType, 539 fInstanceData.reset(InstanceData::Alloc(GrPathRendering::kTranslate_PathTran sformType,
536 fTotalGlyphCount)); 540 fTotalGlyphCount));
537 541
538 const char* stop = text + byteLength; 542 const char* stop = text + byteLength;
539 543
540 SkTextMapStateProc tmsProc(SkMatrix::I(), offset, scalarsPerPosition); 544 SkTextMapStateProc tmsProc(SkMatrix::I(), offset, scalarsPerPosition);
541 SkTextAlignProc alignProc(fFont.getTextAlign()); 545 SkTextAlignProc alignProc(fFont.getTextAlign());
542 FallbackBlobBuilder fallback; 546 FallbackBlobBuilder fallback;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 } 730 }
727 731
728 const SkTextBlob* GrStencilAndCoverTextContext::FallbackBlobBuilder::buildIfNeed ed(int *count) { 732 const SkTextBlob* GrStencilAndCoverTextContext::FallbackBlobBuilder::buildIfNeed ed(int *count) {
729 *count = fCount; 733 *count = fCount;
730 if (fCount) { 734 if (fCount) {
731 this->flush(); 735 this->flush();
732 return fBuilder->build(); 736 return fBuilder->build();
733 } 737 }
734 return nullptr; 738 return nullptr;
735 } 739 }
OLDNEW
« no previous file with comments | « src/core/SkPaint.cpp ('k') | src/gpu/text/GrTextUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698