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

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

Issue 793013003: Remove the low hanging fruit with coord change matrices (Closed) Base URL: https://skia.googlesource.com/skia.git@more-ccm-cleanup
Patch Set: comment cleanup Created 6 years 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
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 "GrBitmapTextContext.h" 10 #include "GrBitmapTextContext.h"
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 SkScalarTruncToInt(dstRect.top()), 528 SkScalarTruncToInt(dstRect.top()),
529 SkScalarTruncToInt(dstRect.right()), 529 SkScalarTruncToInt(dstRect.right()),
530 SkScalarTruncToInt(dstRect.bottom()))) { 530 SkScalarTruncToInt(dstRect.bottom()))) {
531 // SkCLZ(3); // so we can set a break-point in the debugger 531 // SkCLZ(3); // so we can set a break-point in the debugger
532 return true; 532 return true;
533 } 533 }
534 534
535 if (NULL == glyph->fPlot) { 535 if (NULL == glyph->fPlot) {
536 // needs to be a separate conditional to avoid over-optimization 536 // needs to be a separate conditional to avoid over-optimization
537 // on Nexus 7 and Nexus 10 537 // on Nexus 7 and Nexus 10
538 // If the font is too large, we fall back to paths in SkGpuDevice. Howe ver, its possible
539 // for a corrupted font to have a super large glyph. We test for this b elow and fall back
540 // to paths.
538 if (!uploadGlyph(glyph, scaler)) { 541 if (!uploadGlyph(glyph, scaler)) {
539 if (NULL == glyph->fPath) { 542 if (NULL == glyph->fPath) {
540 SkPath* path = SkNEW(SkPath); 543 SkPath* path = SkNEW(SkPath);
541 if (!scaler->getGlyphPath(glyph->glyphID(), path)) { 544 if (!scaler->getGlyphPath(glyph->glyphID(), path)) {
542 // flag the glyph as being dead? 545 // flag the glyph as being dead?
543 delete path; 546 delete path;
544 return true; 547 return true;
545 } 548 }
546 glyph->fPath = path; 549 glyph->fPath = path;
547 } 550 }
548 551
549 // flush any accumulated draws before drawing this glyph as a path. 552 // flush any accumulated draws before drawing this glyph as a path.
550 this->flush(); 553 this->flush();
551 554
552 SkMatrix ctm; 555 SkMatrix ctm;
553 ctm.setScale(fTextRatio, fTextRatio); 556 ctm.setScale(fTextRatio, fTextRatio);
554 ctm.postTranslate(sx - dx, sy - dy); 557 ctm.postTranslate(sx - dx, sy - dy);
555 GrPaint tmpPaint(fPaint);
556 tmpPaint.localCoordChange(ctm);
557 558
558 SkMatrix viewM = fViewMatrix; 559 SkPath tmpPath(*glyph->fPath);
559 viewM.preConcat(ctm); 560 tmpPath.transform(ctm);
561
560 GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle); 562 GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle);
561 fContext->drawPath(tmpPaint, viewM, *glyph->fPath, strokeInfo); 563 fContext->drawPath(fPaint, fViewMatrix, tmpPath, strokeInfo);
562 564
563 // remove this glyph from the vertices we need to allocate 565 // remove this glyph from the vertices we need to allocate
564 fTotalVertexCount -= kVerticesPerGlyph; 566 fTotalVertexCount -= kVerticesPerGlyph;
565 return true; 567 return true;
566 } 568 }
567 } 569 }
568 570
569 SkASSERT(glyph->fPlot); 571 SkASSERT(glyph->fPlot);
570 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken(); 572 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken();
571 glyph->fPlot->setDrawToken(drawToken); 573 glyph->fPlot->setDrawToken(drawToken);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 } 680 }
679 } 681 }
680 682
681 inline void GrDistanceFieldTextContext::finish() { 683 inline void GrDistanceFieldTextContext::finish() {
682 this->flush(); 684 this->flush();
683 fTotalVertexCount = 0; 685 fTotalVertexCount = 0;
684 686
685 GrTextContext::finish(); 687 GrTextContext::finish();
686 } 688 }
687 689
OLDNEW
« src/gpu/GrBitmapTextContext.cpp ('K') | « src/gpu/GrBitmapTextContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698