Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "GrBlurUtils.h" | 9 #include "GrBlurUtils.h" |
| 10 #include "GrDrawContext.h" | 10 #include "GrDrawContext.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 GrAtlasTextContext* GrAtlasTextContext::Create(GrContext* context, | 147 GrAtlasTextContext* GrAtlasTextContext::Create(GrContext* context, |
| 148 const SkSurfaceProps& surfaceProp s) { | 148 const SkSurfaceProps& surfaceProp s) { |
| 149 return new GrAtlasTextContext(context, surfaceProps); | 149 return new GrAtlasTextContext(context, surfaceProps); |
| 150 } | 150 } |
| 151 | 151 |
| 152 bool GrAtlasTextContext::canDraw(const GrRenderTarget*, | 152 bool GrAtlasTextContext::canDraw(const SkPaint& skPaint, const SkMatrix& viewMat rix) { |
| 153 const GrClip&, | |
| 154 const GrPaint&, | |
| 155 const SkPaint& skPaint, | |
| 156 const SkMatrix& viewMatrix) { | |
| 157 return this->canDrawAsDistanceFields(skPaint, viewMatrix) || | 153 return this->canDrawAsDistanceFields(skPaint, viewMatrix) || |
| 158 !SkDraw::ShouldDrawTextAsPaths(skPaint, viewMatrix); | 154 !SkDraw::ShouldDrawTextAsPaths(skPaint, viewMatrix); |
| 159 } | 155 } |
| 160 | 156 |
| 161 GrColor GrAtlasTextContext::ComputeCanonicalColor(const SkPaint& paint, bool lcd ) { | 157 GrColor GrAtlasTextContext::ComputeCanonicalColor(const SkPaint& paint, bool lcd ) { |
| 162 GrColor canonicalColor = paint.computeLuminanceColor(); | 158 GrColor canonicalColor = paint.computeLuminanceColor(); |
| 163 if (lcd) { | 159 if (lcd) { |
| 164 // This is the correct computation, but there are tons of cases where LC D can be overridden. | 160 // This is the correct computation, but there are tons of cases where LC D can be overridden. |
| 165 // For now we just regenerate if any run in a textblob has LCD. | 161 // For now we just regenerate if any run in a textblob has LCD. |
| 166 // TODO figure out where all of these overrides are and see if we can in corporate that logic | 162 // TODO figure out where all of these overrides are and see if we can in corporate that logic |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 case SkTextBlob::kFull_Positioning: { | 510 case SkTextBlob::kFull_Positioning: { |
| 515 dfOffset = SkPoint::Make(x, y); | 511 dfOffset = SkPoint::Make(x, y); |
| 516 this->internalDrawDFPosText(cacheBlob, run, dfPaint, color, viewMatrix, | 512 this->internalDrawDFPosText(cacheBlob, run, dfPaint, color, viewMatrix, |
| 517 (const char*)it.glyphs(), textLe n, it.pos(), | 513 (const char*)it.glyphs(), textLe n, it.pos(), |
| 518 scalarsPerPosition, dfOffset, cl ipRect, textRatio, | 514 scalarsPerPosition, dfOffset, cl ipRect, textRatio, |
| 519 &fallbackTxt, &fallbackPos); | 515 &fallbackTxt, &fallbackPos); |
| 520 break; | 516 break; |
| 521 } | 517 } |
| 522 } | 518 } |
| 523 if (fallbackTxt.count()) { | 519 if (fallbackTxt.count()) { |
| 524 this->fallbackDrawPosText(cacheBlob, run, rt, clip, color, runPa int, viewMatrix, | 520 this->fallbackDrawPosText(cacheBlob, run, clip, color, runPaint, viewMatrix, |
| 525 fallbackTxt, fallbackPos, scalarsPerPo sition, dfOffset, | 521 fallbackTxt, fallbackPos, scalarsPerPo sition, dfOffset, |
| 526 clipRect); | 522 clipRect); |
| 527 } | 523 } |
| 528 } else if (SkDraw::ShouldDrawTextAsPaths(runPaint, viewMatrix)) { | 524 } else if (SkDraw::ShouldDrawTextAsPaths(runPaint, viewMatrix)) { |
| 529 cacheBlob->fRuns[run].fDrawAsPaths = true; | 525 cacheBlob->fRuns[run].fDrawAsPaths = true; |
| 530 } else { | 526 } else { |
| 531 cacheBlob->setHasBitmap(); | 527 cacheBlob->setHasBitmap(); |
| 532 SkGlyphCache* cache = this->setupCache(&cacheBlob->fRuns[run], runPa int, &viewMatrix, | 528 SkGlyphCache* cache = this->setupCache(&cacheBlob->fRuns[run], runPa int, &viewMatrix, |
| 533 false); | 529 false); |
| 534 switch (it.positioning()) { | 530 switch (it.positioning()) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 607 blob->fMinMaxScale = SkMinScalar(dfMaskScaleCeil / scaledTextSize, blob->fMi nMaxScale); | 603 blob->fMinMaxScale = SkMinScalar(dfMaskScaleCeil / scaledTextSize, blob->fMi nMaxScale); |
| 608 | 604 |
| 609 skPaint->setLCDRenderText(false); | 605 skPaint->setLCDRenderText(false); |
| 610 skPaint->setAutohinted(false); | 606 skPaint->setAutohinted(false); |
| 611 skPaint->setHinting(SkPaint::kNormal_Hinting); | 607 skPaint->setHinting(SkPaint::kNormal_Hinting); |
| 612 skPaint->setSubpixelText(true); | 608 skPaint->setSubpixelText(true); |
| 613 } | 609 } |
| 614 | 610 |
| 615 inline void GrAtlasTextContext::fallbackDrawPosText(GrAtlasTextBlob* blob, | 611 inline void GrAtlasTextContext::fallbackDrawPosText(GrAtlasTextBlob* blob, |
| 616 int runIndex, | 612 int runIndex, |
| 617 GrRenderTarget* rt, const Gr Clip& clip, | 613 const GrClip& clip, |
| 618 GrColor color, | 614 GrColor color, |
| 619 const SkPaint& skPaint, | 615 const SkPaint& skPaint, |
| 620 const SkMatrix& viewMatrix, | 616 const SkMatrix& viewMatrix, |
| 621 const SkTDArray<char>& fallb ackTxt, | 617 const SkTDArray<char>& fallb ackTxt, |
| 622 const SkTDArray<SkScalar>& f allbackPos, | 618 const SkTDArray<SkScalar>& f allbackPos, |
| 623 int scalarsPerPosition, | 619 int scalarsPerPosition, |
| 624 const SkPoint& offset, | 620 const SkPoint& offset, |
| 625 const SkIRect& clipRect) { | 621 const SkIRect& clipRect) { |
| 626 SkASSERT(fallbackTxt.count()); | 622 SkASSERT(fallbackTxt.count()); |
| 627 blob->setHasBitmap(); | 623 blob->setHasBitmap(); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 650 blob->fViewMatrix = viewMatrix; | 646 blob->fViewMatrix = viewMatrix; |
| 651 Run& run = blob->fRuns[0]; | 647 Run& run = blob->fRuns[0]; |
| 652 PerSubRunInfo& subRun = run.fSubRunInfo.back(); | 648 PerSubRunInfo& subRun = run.fSubRunInfo.back(); |
| 653 subRun.fUseLCDText = origPaint.isLCDRenderText(); | 649 subRun.fUseLCDText = origPaint.isLCDRenderText(); |
| 654 subRun.fDrawAsDistanceFields = true; | 650 subRun.fDrawAsDistanceFields = true; |
| 655 | 651 |
| 656 return blob; | 652 return blob; |
| 657 } | 653 } |
| 658 | 654 |
| 659 inline GrAtlasTextBlob* | 655 inline GrAtlasTextBlob* |
| 660 GrAtlasTextContext::createDrawTextBlob(GrRenderTarget* rt, const GrClip& clip, | 656 GrAtlasTextContext::createDrawTextBlob(GrDrawContext* dc, const GrClip& clip, |
| 661 const GrPaint& paint, const SkPaint& skPa int, | 657 const GrPaint& paint, const SkPaint& skPa int, |
| 662 const SkMatrix& viewMatrix, | 658 const SkMatrix& viewMatrix, |
| 663 const char text[], size_t byteLength, | 659 const char text[], size_t byteLength, |
| 664 SkScalar x, SkScalar y, const SkIRect& re gionClipBounds) { | 660 SkScalar x, SkScalar y, const SkIRect& re gionClipBounds) { |
| 665 int glyphCount = skPaint.countText(text, byteLength); | 661 int glyphCount = skPaint.countText(text, byteLength); |
| 666 SkIRect clipRect; | 662 SkIRect clipRect; |
| 667 clip.getConservativeBounds(rt->width(), rt->height(), &clipRect); | 663 clip.getConservativeBounds(dc->width(), dc->height(), &clipRect); |
| 668 | 664 |
| 669 GrAtlasTextBlob* blob; | 665 GrAtlasTextBlob* blob; |
| 670 if (this->canDrawAsDistanceFields(skPaint, viewMatrix)) { | 666 if (this->canDrawAsDistanceFields(skPaint, viewMatrix)) { |
| 671 SkPaint dfPaint; | 667 SkPaint dfPaint; |
| 672 SkScalar textRatio; | 668 SkScalar textRatio; |
| 673 blob = this->setupDFBlob(glyphCount, skPaint, viewMatrix, &dfPaint, &tex tRatio); | 669 blob = this->setupDFBlob(glyphCount, skPaint, viewMatrix, &dfPaint, &tex tRatio); |
| 674 | 670 |
| 675 SkTDArray<char> fallbackTxt; | 671 SkTDArray<char> fallbackTxt; |
| 676 SkTDArray<SkScalar> fallbackPos; | 672 SkTDArray<SkScalar> fallbackPos; |
| 677 SkPoint offset; | 673 SkPoint offset; |
| 678 this->internalDrawDFText(blob, 0, dfPaint, paint.getColor(), viewMatrix, text, | 674 this->internalDrawDFText(blob, 0, dfPaint, paint.getColor(), viewMatrix, text, |
| 679 byteLength, x, y, clipRect, textRatio, &fallbac kTxt, &fallbackPos, | 675 byteLength, x, y, clipRect, textRatio, &fallbac kTxt, &fallbackPos, |
| 680 &offset, skPaint); | 676 &offset, skPaint); |
| 681 if (fallbackTxt.count()) { | 677 if (fallbackTxt.count()) { |
| 682 this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPai nt, viewMatrix, | 678 this->fallbackDrawPosText(blob, 0, clip, paint.getColor(), skPaint, viewMatrix, |
| 683 fallbackTxt, fallbackPos, 2, offset, clipR ect); | 679 fallbackTxt, fallbackPos, 2, offset, clipR ect); |
| 684 } | 680 } |
| 685 } else { | 681 } else { |
| 686 blob = fCache->createBlob(glyphCount, 1, GrAtlasTextBatch::kGrayTextVASi ze); | 682 blob = fCache->createBlob(glyphCount, 1, GrAtlasTextBatch::kGrayTextVASi ze); |
| 687 blob->fViewMatrix = viewMatrix; | 683 blob->fViewMatrix = viewMatrix; |
| 688 | 684 |
| 689 SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], skPaint, &viewMa trix, false); | 685 SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], skPaint, &viewMa trix, false); |
| 690 this->internalDrawBMPText(blob, 0, cache, skPaint, paint.getColor(), vie wMatrix, text, | 686 this->internalDrawBMPText(blob, 0, cache, skPaint, paint.getColor(), vie wMatrix, text, |
| 691 byteLength, x, y, clipRect); | 687 byteLength, x, y, clipRect); |
| 692 SkGlyphCache::AttachCache(cache); | 688 SkGlyphCache::AttachCache(cache); |
| 693 } | 689 } |
| 694 return blob; | 690 return blob; |
| 695 } | 691 } |
| 696 | 692 |
| 697 inline GrAtlasTextBlob* | 693 inline GrAtlasTextBlob* |
| 698 GrAtlasTextContext::createDrawPosTextBlob(GrRenderTarget* rt, const GrClip& clip , | 694 GrAtlasTextContext::createDrawPosTextBlob(GrDrawContext* dc, const GrClip& clip, |
| 699 const GrPaint& paint, const SkPaint& s kPaint, | 695 const GrPaint& paint, const SkPaint& s kPaint, |
| 700 const SkMatrix& viewMatrix, | 696 const SkMatrix& viewMatrix, |
| 701 const char text[], size_t byteLength, | 697 const char text[], size_t byteLength, |
| 702 const SkScalar pos[], int scalarsPerPo sition, | 698 const SkScalar pos[], int scalarsPerPo sition, |
| 703 const SkPoint& offset, const SkIRect& regionClipBounds) { | 699 const SkPoint& offset, const SkIRect& regionClipBounds) { |
| 704 int glyphCount = skPaint.countText(text, byteLength); | 700 int glyphCount = skPaint.countText(text, byteLength); |
| 705 | 701 |
| 706 SkIRect clipRect; | 702 SkIRect clipRect; |
| 707 clip.getConservativeBounds(rt->width(), rt->height(), &clipRect); | 703 clip.getConservativeBounds(dc->width(), dc->height(), &clipRect); |
| 708 | 704 |
| 709 GrAtlasTextBlob* blob; | 705 GrAtlasTextBlob* blob; |
| 710 if (this->canDrawAsDistanceFields(skPaint, viewMatrix)) { | 706 if (this->canDrawAsDistanceFields(skPaint, viewMatrix)) { |
| 711 SkPaint dfPaint; | 707 SkPaint dfPaint; |
| 712 SkScalar textRatio; | 708 SkScalar textRatio; |
| 713 blob = this->setupDFBlob(glyphCount, skPaint, viewMatrix, &dfPaint, &tex tRatio); | 709 blob = this->setupDFBlob(glyphCount, skPaint, viewMatrix, &dfPaint, &tex tRatio); |
| 714 | 710 |
| 715 SkTDArray<char> fallbackTxt; | 711 SkTDArray<char> fallbackTxt; |
| 716 SkTDArray<SkScalar> fallbackPos; | 712 SkTDArray<SkScalar> fallbackPos; |
| 717 this->internalDrawDFPosText(blob, 0, dfPaint, paint.getColor(), viewMatr ix, text, | 713 this->internalDrawDFPosText(blob, 0, dfPaint, paint.getColor(), viewMatr ix, text, |
| 718 byteLength, pos, scalarsPerPosition, offset, clipRect, | 714 byteLength, pos, scalarsPerPosition, offset, clipRect, |
| 719 textRatio, &fallbackTxt, &fallbackPos); | 715 textRatio, &fallbackTxt, &fallbackPos); |
| 720 if (fallbackTxt.count()) { | 716 if (fallbackTxt.count()) { |
| 721 this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPai nt, viewMatrix, | 717 this->fallbackDrawPosText(blob, 0, clip, paint.getColor(), skPaint, viewMatrix, |
| 722 fallbackTxt, fallbackPos, scalarsPerPositi on, offset, | 718 fallbackTxt, fallbackPos, scalarsPerPositi on, offset, |
| 723 clipRect); | 719 clipRect); |
| 724 } | 720 } |
| 725 } else { | 721 } else { |
| 726 blob = fCache->createBlob(glyphCount, 1, GrAtlasTextBatch::kGrayTextVASi ze); | 722 blob = fCache->createBlob(glyphCount, 1, GrAtlasTextBatch::kGrayTextVASi ze); |
| 727 blob->fViewMatrix = viewMatrix; | 723 blob->fViewMatrix = viewMatrix; |
| 728 SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], skPaint, &viewMa trix, false); | 724 SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], skPaint, &viewMa trix, false); |
| 729 this->internalDrawBMPPosText(blob, 0, cache, skPaint, paint.getColor(), viewMatrix, text, | 725 this->internalDrawBMPPosText(blob, 0, cache, skPaint, paint.getColor(), viewMatrix, text, |
| 730 byteLength, pos, scalarsPerPosition, offset , clipRect); | 726 byteLength, pos, scalarsPerPosition, offset , clipRect); |
| 731 SkGlyphCache::AttachCache(cache); | 727 SkGlyphCache::AttachCache(cache); |
| 732 } | 728 } |
| 733 return blob; | 729 return blob; |
| 734 } | 730 } |
| 735 | 731 |
| 736 void GrAtlasTextContext::onDrawText(GrDrawContext* dc, GrRenderTarget* rt, | 732 void GrAtlasTextContext::onDrawText(GrDrawContext* dc, GrRenderTarget* rt, |
| 737 const GrClip& clip, | 733 const GrClip& clip, |
| 738 const GrPaint& paint, const SkPaint& skPaint , | 734 const GrPaint& paint, const SkPaint& skPaint , |
| 739 const SkMatrix& viewMatrix, | 735 const SkMatrix& viewMatrix, |
| 740 const char text[], size_t byteLength, | 736 const char text[], size_t byteLength, |
| 741 SkScalar x, SkScalar y, const SkIRect& regio nClipBounds) { | 737 SkScalar x, SkScalar y, const SkIRect& regio nClipBounds) { |
| 742 SkAutoTUnref<GrAtlasTextBlob> blob( | 738 SkAutoTUnref<GrAtlasTextBlob> blob( |
| 743 this->createDrawTextBlob(rt, clip, paint, skPaint, viewMatrix, | 739 this->createDrawTextBlob(dc, clip, paint, skPaint, viewMatrix, |
| 744 text, byteLength, x, y, regionClipBounds)); | 740 text, byteLength, x, y, regionClipBounds)); |
| 745 this->flush(blob, dc, rt, skPaint, paint, clip, regionClipBounds); | 741 this->flush(blob, dc, rt, skPaint, paint, clip, regionClipBounds); |
| 746 } | 742 } |
| 747 | 743 |
| 748 void GrAtlasTextContext::onDrawPosText(GrDrawContext* dc, GrRenderTarget* rt, | 744 void GrAtlasTextContext::onDrawPosText(GrDrawContext* dc, GrRenderTarget* rt, |
| 749 const GrClip& clip, | 745 const GrClip& clip, |
| 750 const GrPaint& paint, const SkPaint& skPa int, | 746 const GrPaint& paint, const SkPaint& skPa int, |
| 751 const SkMatrix& viewMatrix, | 747 const SkMatrix& viewMatrix, |
| 752 const char text[], size_t byteLength, | 748 const char text[], size_t byteLength, |
| 753 const SkScalar pos[], int scalarsPerPosit ion, | 749 const SkScalar pos[], int scalarsPerPosit ion, |
| 754 const SkPoint& offset, const SkIRect& reg ionClipBounds) { | 750 const SkPoint& offset, const SkIRect& reg ionClipBounds) { |
| 755 SkAutoTUnref<GrAtlasTextBlob> blob( | 751 SkAutoTUnref<GrAtlasTextBlob> blob( |
| 756 this->createDrawPosTextBlob(rt, clip, paint, skPaint, viewMatrix, | 752 this->createDrawPosTextBlob(dc, clip, paint, skPaint, viewMatrix, |
| 757 text, byteLength, | 753 text, byteLength, |
| 758 pos, scalarsPerPosition, | 754 pos, scalarsPerPosition, |
| 759 offset, regionClipBounds)); | 755 offset, regionClipBounds)); |
| 760 | 756 |
| 761 this->flush(blob, dc, rt, skPaint, paint, clip, regionClipBounds); | 757 this->flush(blob, dc, rt, skPaint, paint, clip, regionClipBounds); |
| 762 } | 758 } |
| 763 | 759 |
| 764 void GrAtlasTextContext::internalDrawBMPText(GrAtlasTextBlob* blob, int runIndex , | 760 void GrAtlasTextContext::internalDrawBMPText(GrAtlasTextBlob* blob, int runIndex , |
| 765 SkGlyphCache* cache, const SkPaint& skPaint, | 761 SkGlyphCache* cache, const SkPaint& skPaint, |
| 766 GrColor color, | 762 GrColor color, |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1404 gTextContext = GrAtlasTextContext::Create(context, gSurfaceProps); | 1400 gTextContext = GrAtlasTextContext::Create(context, gSurfaceProps); |
| 1405 } | 1401 } |
| 1406 | 1402 |
| 1407 // create dummy render target | 1403 // create dummy render target |
| 1408 GrSurfaceDesc desc; | 1404 GrSurfaceDesc desc; |
| 1409 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 1405 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 1410 desc.fWidth = 1024; | 1406 desc.fWidth = 1024; |
| 1411 desc.fHeight = 1024; | 1407 desc.fHeight = 1024; |
| 1412 desc.fConfig = kRGBA_8888_GrPixelConfig; | 1408 desc.fConfig = kRGBA_8888_GrPixelConfig; |
| 1413 desc.fSampleCnt = 0; | 1409 desc.fSampleCnt = 0; |
| 1414 SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(de sc, true, nullptr, 0)); | 1410 SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(de sc, true, nullptr, 0)); |
|
joshualitt
2015/12/02 17:41:32
line wrap
robertphillips
2015/12/02 17:48:29
Done (deleted in the other patch).
| |
| 1415 SkASSERT(texture); | 1411 SkASSERT(texture); |
| 1416 SkASSERT(nullptr != texture->asRenderTarget()); | 1412 SkASSERT(nullptr != texture->asRenderTarget()); |
| 1417 GrRenderTarget* rt = texture->asRenderTarget(); | 1413 GrRenderTarget* rt = texture->asRenderTarget(); |
| 1418 | 1414 |
| 1415 SkAutoTUnref<GrDrawContext> dc(context->drawContext(rt)); | |
| 1416 | |
| 1419 // Setup dummy SkPaint / GrPaint | 1417 // Setup dummy SkPaint / GrPaint |
| 1420 GrColor color = GrRandomColor(random); | 1418 GrColor color = GrRandomColor(random); |
| 1421 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); | 1419 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); |
| 1422 SkPaint skPaint; | 1420 SkPaint skPaint; |
| 1423 skPaint.setColor(color); | 1421 skPaint.setColor(color); |
| 1424 skPaint.setLCDRenderText(random->nextBool()); | 1422 skPaint.setLCDRenderText(random->nextBool()); |
| 1425 skPaint.setAntiAlias(skPaint.isLCDRenderText() ? true : random->nextBool()); | 1423 skPaint.setAntiAlias(skPaint.isLCDRenderText() ? true : random->nextBool()); |
| 1426 skPaint.setSubpixelText(random->nextBool()); | 1424 skPaint.setSubpixelText(random->nextBool()); |
| 1427 | 1425 |
| 1428 GrPaint grPaint; | 1426 GrPaint grPaint; |
| 1429 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, &grPaint)) { | 1427 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, &grPaint)) { |
| 1430 SkFAIL("couldn't convert paint\n"); | 1428 SkFAIL("couldn't convert paint\n"); |
| 1431 } | 1429 } |
| 1432 | 1430 |
| 1433 const char* text = "The quick brown fox jumps over the lazy dog."; | 1431 const char* text = "The quick brown fox jumps over the lazy dog."; |
| 1434 int textLen = (int)strlen(text); | 1432 int textLen = (int)strlen(text); |
| 1435 | 1433 |
| 1436 // Setup clip | 1434 // Setup clip |
| 1437 GrClip clip; | 1435 GrClip clip; |
| 1438 SkIRect noClip = SkIRect::MakeLargest(); | 1436 SkIRect noClip = SkIRect::MakeLargest(); |
| 1439 | 1437 |
| 1440 // right now we don't handle textblobs, nor do we handle drawPosText. Since we only | 1438 // right now we don't handle textblobs, nor do we handle drawPosText. Since we only |
| 1441 // intend to test the batch with this unit test, that is okay. | 1439 // intend to test the batch with this unit test, that is okay. |
| 1442 SkAutoTUnref<GrAtlasTextBlob> blob( | 1440 SkAutoTUnref<GrAtlasTextBlob> blob( |
| 1443 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text, | 1441 gTextContext->createDrawTextBlob(dc, clip, grPaint, skPaint, viewMat rix, text, |
| 1444 static_cast<size_t>(textLen), 0, 0, noClip)); | 1442 static_cast<size_t>(textLen), 0, 0, noClip)); |
| 1445 | 1443 |
| 1446 SkScalar transX = static_cast<SkScalar>(random->nextU()); | 1444 SkScalar transX = static_cast<SkScalar>(random->nextU()); |
| 1447 SkScalar transY = static_cast<SkScalar>(random->nextU()); | 1445 SkScalar transY = static_cast<SkScalar>(random->nextU()); |
| 1448 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ; | 1446 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ; |
| 1449 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint); | 1447 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint); |
| 1450 } | 1448 } |
| 1451 | 1449 |
| 1452 #endif | 1450 #endif |
| OLD | NEW |