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

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

Issue 1551563003: Reland of Make draw* lines responsible for cache management (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanuptext13reallytexutilsdf
Patch Set: Created 4 years, 11 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/GrAtlasTextContext.h ('k') | src/gpu/text/GrTextUtils.h » ('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 #include "GrAtlasTextContext.h" 7 #include "GrAtlasTextContext.h"
8 8
9 #include "GrDrawContext.h" 9 #include "GrDrawContext.h"
10 #include "GrDrawTarget.h" 10 #include "GrDrawTarget.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 bool GrAtlasTextContext::HasLCD(const SkTextBlob* blob) { 98 bool GrAtlasTextContext::HasLCD(const SkTextBlob* blob) {
99 SkTextBlobRunIterator it(blob); 99 SkTextBlobRunIterator it(blob);
100 for (; !it.done(); it.next()) { 100 for (; !it.done(); it.next()) {
101 if (it.isLCD()) { 101 if (it.isLCD()) {
102 return true; 102 return true;
103 } 103 }
104 } 104 }
105 return false; 105 return false;
106 } 106 }
107 107
108 inline SkGlyphCache* GrAtlasTextContext::setupCache(GrAtlasTextBlob::Run* run,
109 const SkPaint& skPaint,
110 const SkMatrix* viewMatrix,
111 bool noGamma) {
112 skPaint.getScalerContextDescriptor(&run->fDescriptor, fSurfaceProps, viewMat rix, noGamma);
113 run->fTypeface.reset(SkSafeRef(skPaint.getTypeface()));
114 return SkGlyphCache::DetachCache(run->fTypeface, run->fDescriptor.getDesc()) ;
115 }
116
117 void GrAtlasTextContext::drawTextBlob(GrDrawContext* dc, 108 void GrAtlasTextContext::drawTextBlob(GrDrawContext* dc,
118 const GrClip& clip, const SkPaint& skPaint , 109 const GrClip& clip, const SkPaint& skPaint ,
119 const SkMatrix& viewMatrix, const SkTextBl ob* blob, 110 const SkMatrix& viewMatrix, const SkTextBl ob* blob,
120 SkScalar x, SkScalar y, 111 SkScalar x, SkScalar y,
121 SkDrawFilter* drawFilter, const SkIRect& c lipBounds) { 112 SkDrawFilter* drawFilter, const SkIRect& c lipBounds) {
122 // If we have been abandoned, then don't draw 113 // If we have been abandoned, then don't draw
123 if (fContext->abandoned()) { 114 if (fContext->abandoned()) {
124 return; 115 return;
125 } 116 }
126 117
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 275
285 if (this->canDrawAsDistanceFields(runPaint, viewMatrix)) { 276 if (this->canDrawAsDistanceFields(runPaint, viewMatrix)) {
286 cacheBlob->setHasDistanceField(); 277 cacheBlob->setHasDistanceField();
287 SkPaint dfPaint = runPaint; 278 SkPaint dfPaint = runPaint;
288 SkScalar textRatio; 279 SkScalar textRatio;
289 this->initDistanceFieldPaint(cacheBlob, &dfPaint, &textRatio, viewMa trix); 280 this->initDistanceFieldPaint(cacheBlob, &dfPaint, &textRatio, viewMa trix);
290 Run& runIdx = cacheBlob->fRuns[run]; 281 Run& runIdx = cacheBlob->fRuns[run];
291 PerSubRunInfo& subRun = runIdx.fSubRunInfo.back(); 282 PerSubRunInfo& subRun = runIdx.fSubRunInfo.back();
292 subRun.setUseLCDText(runPaint.isLCDRenderText()); 283 subRun.setUseLCDText(runPaint.isLCDRenderText());
293 subRun.setDrawAsDistanceFields(); 284 subRun.setDrawAsDistanceFields();
294 SkGlyphCache* cache = this->setupCache(&cacheBlob->fRuns[run], dfPai nt, nullptr, true);
295 285
296 switch (it.positioning()) { 286 switch (it.positioning()) {
297 case SkTextBlob::kDefault_Positioning: { 287 case SkTextBlob::kDefault_Positioning: {
298 this->internalDrawDFText(cacheBlob, run, cache, dfPaint, col or, viewMatrix, 288 this->internalDrawDFText(cacheBlob, run, dfPaint, color, vie wMatrix,
299 (const char *)it.glyphs(), textLen, 289 (const char *)it.glyphs(), textLen,
300 x + offset.x(), y + offset.y(), tex tRatio, runPaint); 290 x + offset.x(), y + offset.y(), tex tRatio, runPaint);
301 break; 291 break;
302 } 292 }
303 case SkTextBlob::kHorizontal_Positioning: { 293 case SkTextBlob::kHorizontal_Positioning: {
304 SkPoint dfOffset = SkPoint::Make(x, y + offset.y()); 294 SkPoint dfOffset = SkPoint::Make(x, y + offset.y());
305 this->internalDrawDFPosText(cacheBlob, run, cache, dfPaint, color, viewMatrix, 295 this->internalDrawDFPosText(cacheBlob, run, dfPaint, color, viewMatrix,
306 (const char*)it.glyphs(), textLe n, it.pos(), 296 (const char*)it.glyphs(), textLe n, it.pos(),
307 1, dfOffset, textRatio, 297 1, dfOffset, textRatio,
308 runPaint); 298 runPaint);
309 break; 299 break;
310 } 300 }
311 case SkTextBlob::kFull_Positioning: { 301 case SkTextBlob::kFull_Positioning: {
312 SkPoint dfOffset = SkPoint::Make(x, y); 302 SkPoint dfOffset = SkPoint::Make(x, y);
313 this->internalDrawDFPosText(cacheBlob, run, cache, dfPaint, color, viewMatrix, 303 this->internalDrawDFPosText(cacheBlob, run, dfPaint, color, viewMatrix,
314 (const char*)it.glyphs(), textLe n, it.pos(), 304 (const char*)it.glyphs(), textLe n, it.pos(),
315 2, dfOffset, textRatio, runPaint ); 305 2, dfOffset, textRatio, runPaint );
316 break; 306 break;
317 } 307 }
318 } 308 }
319 SkGlyphCache::AttachCache(cache);
320 } else if (SkDraw::ShouldDrawTextAsPaths(runPaint, viewMatrix)) { 309 } else if (SkDraw::ShouldDrawTextAsPaths(runPaint, viewMatrix)) {
321 cacheBlob->fRuns[run].fDrawAsPaths = true; 310 cacheBlob->fRuns[run].fDrawAsPaths = true;
322 } else { 311 } else {
323 cacheBlob->setHasBitmap(); 312 cacheBlob->setHasBitmap();
324 SkGlyphCache* cache = this->setupCache(&cacheBlob->fRuns[run], runPa int, &viewMatrix,
325 false);
326 switch (it.positioning()) { 313 switch (it.positioning()) {
327 case SkTextBlob::kDefault_Positioning: 314 case SkTextBlob::kDefault_Positioning:
328 GrTextUtils::DrawBmpText(cacheBlob, run, fContext->getBatchF ontCache(), 315 GrTextUtils::DrawBmpText(cacheBlob, run, fContext->getBatchF ontCache(),
329 cache, runPaint, color, viewMatrix, 316 fSurfaceProps, runPaint, color, vie wMatrix,
330 (const char *)it.glyphs(), textLen, 317 (const char *)it.glyphs(), textLen,
331 x + offset.x(), y + offset.y()); 318 x + offset.x(), y + offset.y());
332 break; 319 break;
333 case SkTextBlob::kHorizontal_Positioning: 320 case SkTextBlob::kHorizontal_Positioning:
334 GrTextUtils::DrawBmpPosText(cacheBlob, run, fContext->getBat chFontCache(), 321 GrTextUtils::DrawBmpPosText(cacheBlob, run, fContext->getBat chFontCache(),
335 cache, runPaint, color, viewMatr ix, 322 fSurfaceProps, runPaint, color, viewMatrix,
336 (const char*)it.glyphs(), textLe n, it.pos(), 1, 323 (const char*)it.glyphs(), textLe n, it.pos(), 1,
337 SkPoint::Make(x, y + offset.y()) ); 324 SkPoint::Make(x, y + offset.y()) );
338 break; 325 break;
339 case SkTextBlob::kFull_Positioning: 326 case SkTextBlob::kFull_Positioning:
340 GrTextUtils::DrawBmpPosText(cacheBlob, run, fContext->getBat chFontCache(), 327 GrTextUtils::DrawBmpPosText(cacheBlob, run, fContext->getBat chFontCache(),
341 cache, runPaint, color, viewMatr ix, 328 fSurfaceProps, runPaint, color, viewMatrix,
342 (const char*)it.glyphs(), textLe n, it.pos(), 2, 329 (const char*)it.glyphs(), textLe n, it.pos(), 2,
343 SkPoint::Make(x, y)); 330 SkPoint::Make(x, y));
344 break; 331 break;
345 } 332 }
346 SkGlyphCache::AttachCache(cache);
347 } 333 }
348 334
349 if (drawFilter) { 335 if (drawFilter) {
350 // A draw filter may change the paint arbitrarily, so we must re-see d in this case. 336 // A draw filter may change the paint arbitrarily, so we must re-see d in this case.
351 runPaint = skPaint; 337 runPaint = skPaint;
352 } 338 }
353 } 339 }
354 } 340 }
355 341
356 inline void GrAtlasTextContext::initDistanceFieldPaint(GrAtlasTextBlob* blob, 342 inline void GrAtlasTextContext::initDistanceFieldPaint(GrAtlasTextBlob* blob,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 const SkTDArray<char>& fallb ackTxt, 401 const SkTDArray<char>& fallb ackTxt,
416 const SkTDArray<SkScalar>& f allbackPos, 402 const SkTDArray<SkScalar>& f allbackPos,
417 int scalarsPerPosition, 403 int scalarsPerPosition,
418 const SkPoint& offset) { 404 const SkPoint& offset) {
419 SkASSERT(fallbackTxt.count()); 405 SkASSERT(fallbackTxt.count());
420 blob->setHasBitmap(); 406 blob->setHasBitmap();
421 Run& run = blob->fRuns[runIndex]; 407 Run& run = blob->fRuns[runIndex];
422 // Push back a new subrun to fill and set the override descriptor 408 // Push back a new subrun to fill and set the override descriptor
423 run.push_back(); 409 run.push_back();
424 run.fOverrideDescriptor.reset(new SkAutoDescriptor); 410 run.fOverrideDescriptor.reset(new SkAutoDescriptor);
425 skPaint.getScalerContextDescriptor(run.fOverrideDescriptor, 411 GrTextUtils::DrawBmpPosText(blob, runIndex, fContext->getBatchFontCache(), f SurfaceProps,
426 fSurfaceProps, &viewMatrix, false); 412 skPaint, color, viewMatrix, fallbackTxt.begin(), fallbackTxt.count(),
427 SkGlyphCache* cache = SkGlyphCache::DetachCache(run.fTypeface,
428 run.fOverrideDescriptor->get Desc());
429 GrTextUtils::DrawBmpPosText(blob, runIndex, fContext->getBatchFontCache(), c ache, skPaint,
430 color, viewMatrix, fallbackTxt.begin(), fallback Txt.count(),
431 fallbackPos.begin(), scalarsPerPosition, offset) ; 413 fallbackPos.begin(), scalarsPerPosition, offset) ;
432 SkGlyphCache::AttachCache(cache);
433 } 414 }
434 415
435 inline GrAtlasTextBlob* 416 inline GrAtlasTextBlob*
436 GrAtlasTextContext::setupDFBlob(int glyphCount, const SkPaint& origPaint, 417 GrAtlasTextContext::setupDFBlob(int glyphCount, const SkPaint& origPaint,
437 const SkMatrix& viewMatrix, SkPaint* dfPaint, 418 const SkMatrix& viewMatrix, SkPaint* dfPaint,
438 SkScalar* textRatio) { 419 SkScalar* textRatio) {
439 GrAtlasTextBlob* blob = fCache->createBlob(glyphCount, 1, GrAtlasTextBlob::k GrayTextVASize); 420 GrAtlasTextBlob* blob = fCache->createBlob(glyphCount, 1, GrAtlasTextBlob::k GrayTextVASize);
440 421
441 *dfPaint = origPaint; 422 *dfPaint = origPaint;
442 this->initDistanceFieldPaint(blob, dfPaint, textRatio, viewMatrix); 423 this->initDistanceFieldPaint(blob, dfPaint, textRatio, viewMatrix);
(...skipping 11 matching lines...) Expand all
454 const SkMatrix& viewMatrix, 435 const SkMatrix& viewMatrix,
455 const char text[], size_t byteLength, 436 const char text[], size_t byteLength,
456 SkScalar x, SkScalar y) { 437 SkScalar x, SkScalar y) {
457 int glyphCount = skPaint.countText(text, byteLength); 438 int glyphCount = skPaint.countText(text, byteLength);
458 439
459 GrAtlasTextBlob* blob; 440 GrAtlasTextBlob* blob;
460 if (this->canDrawAsDistanceFields(skPaint, viewMatrix)) { 441 if (this->canDrawAsDistanceFields(skPaint, viewMatrix)) {
461 SkPaint dfPaint; 442 SkPaint dfPaint;
462 SkScalar textRatio; 443 SkScalar textRatio;
463 blob = this->setupDFBlob(glyphCount, skPaint, viewMatrix, &dfPaint, &tex tRatio); 444 blob = this->setupDFBlob(glyphCount, skPaint, viewMatrix, &dfPaint, &tex tRatio);
464 SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], dfPaint, nullptr , true);
465 445
466 this->internalDrawDFText(blob, 0, cache, dfPaint, paint.getColor(), view Matrix, text, 446 this->internalDrawDFText(blob, 0, dfPaint, paint.getColor(), viewMatrix, text,
467 byteLength, x, y, textRatio, skPaint); 447 byteLength, x, y, textRatio, skPaint);
468 SkGlyphCache::AttachCache(cache);
469 } else { 448 } else {
470 blob = fCache->createBlob(glyphCount, 1, GrAtlasTextBlob::kGrayTextVASiz e); 449 blob = fCache->createBlob(glyphCount, 1, GrAtlasTextBlob::kGrayTextVASiz e);
471 blob->fViewMatrix = viewMatrix; 450 blob->fViewMatrix = viewMatrix;
472 451
473 SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], skPaint, &viewMa trix, false); 452 GrTextUtils::DrawBmpText(blob, 0, fContext->getBatchFontCache(), fSurfac eProps, skPaint,
474 GrTextUtils::DrawBmpText(blob, 0, fContext->getBatchFontCache(), cache, skPaint,
475 paint.getColor(), viewMatrix, text, byteLength, x, y); 453 paint.getColor(), viewMatrix, text, byteLength, x, y);
476 SkGlyphCache::AttachCache(cache);
477 } 454 }
478 return blob; 455 return blob;
479 } 456 }
480 457
481 inline GrAtlasTextBlob* 458 inline GrAtlasTextBlob*
482 GrAtlasTextContext::createDrawPosTextBlob(const GrPaint& paint, const SkPaint& s kPaint, 459 GrAtlasTextContext::createDrawPosTextBlob(const GrPaint& paint, const SkPaint& s kPaint,
483 const SkMatrix& viewMatrix, 460 const SkMatrix& viewMatrix,
484 const char text[], size_t byteLength, 461 const char text[], size_t byteLength,
485 const SkScalar pos[], int scalarsPerPo sition, 462 const SkScalar pos[], int scalarsPerPo sition,
486 const SkPoint& offset) { 463 const SkPoint& offset) {
487 int glyphCount = skPaint.countText(text, byteLength); 464 int glyphCount = skPaint.countText(text, byteLength);
488 465
489 GrAtlasTextBlob* blob; 466 GrAtlasTextBlob* blob;
490 if (this->canDrawAsDistanceFields(skPaint, viewMatrix)) { 467 if (this->canDrawAsDistanceFields(skPaint, viewMatrix)) {
491 SkPaint dfPaint; 468 SkPaint dfPaint;
492 SkScalar textRatio; 469 SkScalar textRatio;
493 blob = this->setupDFBlob(glyphCount, skPaint, viewMatrix, &dfPaint, &tex tRatio); 470 blob = this->setupDFBlob(glyphCount, skPaint, viewMatrix, &dfPaint, &tex tRatio);
494 SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], dfPaint, nullptr , true);
495 471
496 this->internalDrawDFPosText(blob, 0, cache, dfPaint, paint.getColor(), v iewMatrix, text, 472 this->internalDrawDFPosText(blob, 0, dfPaint, paint.getColor(), viewMatr ix, text,
497 byteLength, pos, scalarsPerPosition, offset, textRatio, 473 byteLength, pos, scalarsPerPosition, offset, textRatio,
498 skPaint); 474 skPaint);
499 SkGlyphCache::AttachCache(cache);
500 } else { 475 } else {
501 blob = fCache->createBlob(glyphCount, 1, GrAtlasTextBlob::kGrayTextVASiz e); 476 blob = fCache->createBlob(glyphCount, 1, GrAtlasTextBlob::kGrayTextVASiz e);
502 blob->fViewMatrix = viewMatrix; 477 blob->fViewMatrix = viewMatrix;
503 SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], skPaint, &viewMa trix, false); 478 GrTextUtils::DrawBmpPosText(blob, 0, fContext->getBatchFontCache(), fSur faceProps, skPaint,
504 GrTextUtils::DrawBmpPosText(blob, 0, fContext->getBatchFontCache(), cach e, skPaint,
505 paint.getColor(), viewMatrix, text, 479 paint.getColor(), viewMatrix, text,
506 byteLength, pos, scalarsPerPosition, offset) ; 480 byteLength, pos, scalarsPerPosition, offset) ;
507 SkGlyphCache::AttachCache(cache);
508 } 481 }
509 return blob; 482 return blob;
510 } 483 }
511 484
512 void GrAtlasTextContext::onDrawText(GrDrawContext* dc, 485 void GrAtlasTextContext::onDrawText(GrDrawContext* dc,
513 const GrClip& clip, 486 const GrClip& clip,
514 const GrPaint& paint, const SkPaint& skPaint , 487 const GrPaint& paint, const SkPaint& skPaint ,
515 const SkMatrix& viewMatrix, 488 const SkMatrix& viewMatrix,
516 const char text[], size_t byteLength, 489 const char text[], size_t byteLength,
517 SkScalar x, SkScalar y, const SkIRect& regio nClipBounds) { 490 SkScalar x, SkScalar y, const SkIRect& regio nClipBounds) {
(...skipping 14 matching lines...) Expand all
532 this->createDrawPosTextBlob(paint, skPaint, viewMatrix, 505 this->createDrawPosTextBlob(paint, skPaint, viewMatrix,
533 text, byteLength, 506 text, byteLength,
534 pos, scalarsPerPosition, 507 pos, scalarsPerPosition,
535 offset)); 508 offset));
536 509
537 blob->flushThrowaway(fContext, dc, fSurfaceProps, fDistanceAdjustTable, skPa int, paint, clip, 510 blob->flushThrowaway(fContext, dc, fSurfaceProps, fDistanceAdjustTable, skPa int, paint, clip,
538 regionClipBounds); 511 regionClipBounds);
539 } 512 }
540 513
541 void GrAtlasTextContext::internalDrawDFText(GrAtlasTextBlob* blob, int runIndex, 514 void GrAtlasTextContext::internalDrawDFText(GrAtlasTextBlob* blob, int runIndex,
542 SkGlyphCache* cache,
543 const SkPaint& skPaint, GrColor colo r, 515 const SkPaint& skPaint, GrColor colo r,
544 const SkMatrix& viewMatrix, 516 const SkMatrix& viewMatrix,
545 const char text[], size_t byteLength , 517 const char text[], size_t byteLength ,
546 SkScalar x, SkScalar y, 518 SkScalar x, SkScalar y,
547 SkScalar textRatio, 519 SkScalar textRatio,
548 const SkPaint& origPaint) { 520 const SkPaint& origPaint) {
549 SkASSERT(byteLength == 0 || text != nullptr); 521 SkASSERT(byteLength == 0 || text != nullptr);
550 522
551 // nothing to draw 523 // nothing to draw
552 if (text == nullptr || byteLength == 0) { 524 if (text == nullptr || byteLength == 0) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 alignX = SkScalarHalf(alignX); 570 alignX = SkScalarHalf(alignX);
599 alignY = SkScalarHalf(alignY); 571 alignY = SkScalarHalf(alignY);
600 } else if (origPaint.getTextAlign() == SkPaint::kLeft_Align) { 572 } else if (origPaint.getTextAlign() == SkPaint::kLeft_Align) {
601 alignX = 0; 573 alignX = 0;
602 alignY = 0; 574 alignY = 0;
603 } 575 }
604 x -= alignX; 576 x -= alignX;
605 y -= alignY; 577 y -= alignY;
606 SkPoint offset = SkPoint::Make(x, y); 578 SkPoint offset = SkPoint::Make(x, y);
607 579
608 this->internalDrawDFPosText(blob, runIndex, cache, skPaint, color, viewMatri x, text, byteLength, 580 this->internalDrawDFPosText(blob, runIndex, skPaint, color, viewMatrix, text , byteLength,
609 positions.begin(), 2, offset, textRatio, origPai nt); 581 positions.begin(), 2, offset, textRatio, origPai nt);
610 } 582 }
611 583
612 void GrAtlasTextContext::internalDrawDFPosText(GrAtlasTextBlob* blob, int runInd ex, 584 void GrAtlasTextContext::internalDrawDFPosText(GrAtlasTextBlob* blob, int runInd ex,
613 SkGlyphCache* cache,
614 const SkPaint& skPaint, 585 const SkPaint& skPaint,
615 GrColor color, 586 GrColor color,
616 const SkMatrix& viewMatrix, 587 const SkMatrix& viewMatrix,
617 const char text[], size_t byteLen gth, 588 const char text[], size_t byteLen gth,
618 const SkScalar pos[], int scalars PerPosition, 589 const SkScalar pos[], int scalars PerPosition,
619 const SkPoint& offset, 590 const SkPoint& offset,
620 SkScalar textRatio, 591 SkScalar textRatio,
621 const SkPaint& origPaint) { 592 const SkPaint& origPaint) {
622 593
623 SkASSERT(byteLength == 0 || text != nullptr); 594 SkASSERT(byteLength == 0 || text != nullptr);
624 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition); 595 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
625 596
626 // nothing to draw 597 // nothing to draw
627 if (text == nullptr || byteLength == 0) { 598 if (text == nullptr || byteLength == 0) {
628 return; 599 return;
629 } 600 }
630 601
631 SkTDArray<char> fallbackTxt; 602 SkTDArray<char> fallbackTxt;
632 SkTDArray<SkScalar> fallbackPos; 603 SkTDArray<SkScalar> fallbackPos;
633 604
634 fCurrStrike = nullptr; 605 fCurrStrike = nullptr;
635 606
607 SkGlyphCache* cache = blob->setupCache(runIndex, fSurfaceProps, skPaint, nul lptr, true);
636 SkDrawCacheProc glyphCacheProc = skPaint.getDrawCacheProc(); 608 SkDrawCacheProc glyphCacheProc = skPaint.getDrawCacheProc();
637 GrFontScaler* fontScaler = GetGrFontScaler(cache); 609 GrFontScaler* fontScaler = GetGrFontScaler(cache);
638 610
639 const char* stop = text + byteLength; 611 const char* stop = text + byteLength;
640 612
641 if (SkPaint::kLeft_Align == skPaint.getTextAlign()) { 613 if (SkPaint::kLeft_Align == skPaint.getTextAlign()) {
642 while (text < stop) { 614 while (text < stop) {
643 const char* lastText = text; 615 const char* lastText = text;
644 // the last 2 parameters are ignored 616 // the last 2 parameters are ignored
645 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); 617 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 *fallbackPos.append() = pos[0]; 662 *fallbackPos.append() = pos[0];
691 if (2 == scalarsPerPosition) { 663 if (2 == scalarsPerPosition) {
692 *fallbackPos.append() = pos[1]; 664 *fallbackPos.append() = pos[1];
693 } 665 }
694 } 666 }
695 } 667 }
696 pos += scalarsPerPosition; 668 pos += scalarsPerPosition;
697 } 669 }
698 } 670 }
699 671
672 SkGlyphCache::AttachCache(cache);
700 if (fallbackTxt.count()) { 673 if (fallbackTxt.count()) {
701 this->fallbackDrawPosText(blob, runIndex, origPaint.getColor(), origPain t, viewMatrix, 674 this->fallbackDrawPosText(blob, runIndex, origPaint.getColor(), origPain t, viewMatrix,
702 fallbackTxt, fallbackPos, scalarsPerPosition, offset); 675 fallbackTxt, fallbackPos, scalarsPerPosition, offset);
703 } 676 }
704 } 677 }
705 678
706 bool GrAtlasTextContext::dfAppendGlyph(GrAtlasTextBlob* blob, int runIndex, 679 bool GrAtlasTextContext::dfAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
707 const SkGlyph& skGlyph, 680 const SkGlyph& skGlyph,
708 SkScalar sx, SkScalar sy, GrColor color, 681 SkScalar sx, SkScalar sy, GrColor color,
709 GrFontScaler* scaler, 682 GrFontScaler* scaler,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 765
793 SkScalar transX = static_cast<SkScalar>(random->nextU()); 766 SkScalar transX = static_cast<SkScalar>(random->nextU());
794 SkScalar transY = static_cast<SkScalar>(random->nextU()); 767 SkScalar transY = static_cast<SkScalar>(random->nextU());
795 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ; 768 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ;
796 return blob->createBatch(info, textLen, 0, 0, color, transX, transY, skPaint , 769 return blob->createBatch(info, textLen, 0, 0, color, transX, transY, skPaint ,
797 gSurfaceProps, gTextContext->dfAdjustTable(), 770 gSurfaceProps, gTextContext->dfAdjustTable(),
798 context->getBatchFontCache()); 771 context->getBatchFontCache());
799 } 772 }
800 773
801 #endif 774 #endif
OLDNEW
« no previous file with comments | « src/gpu/text/GrAtlasTextContext.h ('k') | src/gpu/text/GrTextUtils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698