| 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 "GrBatchFontCache.h" | 9 #include "GrBatchFontCache.h" |
| 10 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 | 480 |
| 481 return true; | 481 return true; |
| 482 } | 482 } |
| 483 | 483 |
| 484 void GrAtlasTextContext::regenerateTextBlob(GrAtlasTextBlob* cacheBlob, | 484 void GrAtlasTextContext::regenerateTextBlob(GrAtlasTextBlob* cacheBlob, |
| 485 const SkPaint& skPaint, GrColor colo
r, | 485 const SkPaint& skPaint, GrColor colo
r, |
| 486 const SkMatrix& viewMatrix, | 486 const SkMatrix& viewMatrix, |
| 487 const SkTextBlob* blob, SkScalar x,
SkScalar y, | 487 const SkTextBlob* blob, SkScalar x,
SkScalar y, |
| 488 SkDrawFilter* drawFilter, const SkIR
ect& clipRect, | 488 SkDrawFilter* drawFilter, const SkIR
ect& clipRect, |
| 489 GrRenderTarget* rt, const GrClip& cl
ip) { | 489 GrRenderTarget* rt, const GrClip& cl
ip) { |
| 490 // The color here is the GrPaint color, and it is used to determine whether
we | 490 // The color here is the GrPaint color, and it is used to determine whether
we |
| 491 // have to regenerate LCD text blobs. | 491 // have to regenerate LCD text blobs. |
| 492 // We use this color vs the SkPaint color because it has the colorfilter app
lied. | 492 // We use this color vs the SkPaint color because it has the colorfilter app
lied. |
| 493 cacheBlob->fPaintColor = color; | 493 cacheBlob->fPaintColor = color; |
| 494 cacheBlob->fViewMatrix = viewMatrix; | 494 cacheBlob->fViewMatrix = viewMatrix; |
| 495 cacheBlob->fX = x; | 495 cacheBlob->fX = x; |
| 496 cacheBlob->fY = y; | 496 cacheBlob->fY = y; |
| 497 | 497 |
| 498 // Regenerate textblob | 498 // Regenerate textblob |
| 499 SkPaint runPaint = skPaint; | 499 SkPaint runPaint = skPaint; |
| 500 SkTextBlobRunIterator it(blob); | 500 SkTextBlobRunIterator it(blob); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 fSurfaceProps, &viewMatrix, false); | 679 fSurfaceProps, &viewMatrix, false); |
| 680 SkGlyphCache* cache = SkGlyphCache::DetachCache(run.fTypeface, | 680 SkGlyphCache* cache = SkGlyphCache::DetachCache(run.fTypeface, |
| 681 run.fOverrideDescriptor->get
Desc()); | 681 run.fOverrideDescriptor->get
Desc()); |
| 682 this->internalDrawBMPPosText(blob, runIndex, cache, skPaint, color, viewMatr
ix, | 682 this->internalDrawBMPPosText(blob, runIndex, cache, skPaint, color, viewMatr
ix, |
| 683 fallbackTxt.begin(), fallbackTxt.count(), | 683 fallbackTxt.begin(), fallbackTxt.count(), |
| 684 fallbackPos.begin(), scalarsPerPosition, offset
, clipRect); | 684 fallbackPos.begin(), scalarsPerPosition, offset
, clipRect); |
| 685 SkGlyphCache::AttachCache(cache); | 685 SkGlyphCache::AttachCache(cache); |
| 686 } | 686 } |
| 687 | 687 |
| 688 inline GrAtlasTextBlob* | 688 inline GrAtlasTextBlob* |
| 689 GrAtlasTextContext::setupDFBlob(int glyphCount, const SkPaint& origPaint, | 689 GrAtlasTextContext::setupDFBlob(int glyphCount, const SkPaint& origPaint, |
| 690 const SkMatrix& viewMatrix, SkPaint* dfPaint, | 690 const SkMatrix& viewMatrix, SkPaint* dfPaint, |
| 691 SkScalar* textRatio) { | 691 SkScalar* textRatio) { |
| 692 GrAtlasTextBlob* blob = fCache->createBlob(glyphCount, 1, kGrayTextVASize); | 692 GrAtlasTextBlob* blob = fCache->createBlob(glyphCount, 1, kGrayTextVASize); |
| 693 | 693 |
| 694 *dfPaint = origPaint; | 694 *dfPaint = origPaint; |
| 695 this->initDistanceFieldPaint(blob, dfPaint, textRatio, viewMatrix); | 695 this->initDistanceFieldPaint(blob, dfPaint, textRatio, viewMatrix); |
| 696 blob->fViewMatrix = viewMatrix; | 696 blob->fViewMatrix = viewMatrix; |
| 697 Run& run = blob->fRuns[0]; | 697 Run& run = blob->fRuns[0]; |
| 698 PerSubRunInfo& subRun = run.fSubRunInfo.back(); | 698 PerSubRunInfo& subRun = run.fSubRunInfo.back(); |
| 699 subRun.fUseLCDText = origPaint.isLCDRenderText(); | 699 subRun.fUseLCDText = origPaint.isLCDRenderText(); |
| 700 subRun.fDrawAsDistanceFields = true; | 700 subRun.fDrawAsDistanceFields = true; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 718 SkScalar textRatio; | 718 SkScalar textRatio; |
| 719 blob = this->setupDFBlob(glyphCount, skPaint, viewMatrix, &dfPaint, &tex
tRatio); | 719 blob = this->setupDFBlob(glyphCount, skPaint, viewMatrix, &dfPaint, &tex
tRatio); |
| 720 | 720 |
| 721 SkTDArray<char> fallbackTxt; | 721 SkTDArray<char> fallbackTxt; |
| 722 SkTDArray<SkScalar> fallbackPos; | 722 SkTDArray<SkScalar> fallbackPos; |
| 723 SkPoint offset; | 723 SkPoint offset; |
| 724 this->internalDrawDFText(blob, 0, dfPaint, paint.getColor(), viewMatrix,
text, | 724 this->internalDrawDFText(blob, 0, dfPaint, paint.getColor(), viewMatrix,
text, |
| 725 byteLength, x, y, clipRect, textRatio, &fallbac
kTxt, &fallbackPos, | 725 byteLength, x, y, clipRect, textRatio, &fallbac
kTxt, &fallbackPos, |
| 726 &offset, skPaint); | 726 &offset, skPaint); |
| 727 if (fallbackTxt.count()) { | 727 if (fallbackTxt.count()) { |
| 728 this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPai
nt, viewMatrix, | 728 this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPai
nt, viewMatrix, |
| 729 fallbackTxt, fallbackPos, 2, offset, clipR
ect); | 729 fallbackTxt, fallbackPos, 2, offset, clipR
ect); |
| 730 } | 730 } |
| 731 } else { | 731 } else { |
| 732 blob = fCache->createBlob(glyphCount, 1, kGrayTextVASize); | 732 blob = fCache->createBlob(glyphCount, 1, kGrayTextVASize); |
| 733 blob->fViewMatrix = viewMatrix; | 733 blob->fViewMatrix = viewMatrix; |
| 734 | 734 |
| 735 SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], skPaint, &viewMa
trix, false); | 735 SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], skPaint, &viewMa
trix, false); |
| 736 this->internalDrawBMPText(blob, 0, cache, skPaint, paint.getColor(), vie
wMatrix, text, | 736 this->internalDrawBMPText(blob, 0, cache, skPaint, paint.getColor(), vie
wMatrix, text, |
| 737 byteLength, x, y, clipRect); | 737 byteLength, x, y, clipRect); |
| 738 SkGlyphCache::AttachCache(cache); | 738 SkGlyphCache::AttachCache(cache); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 757 SkPaint dfPaint; | 757 SkPaint dfPaint; |
| 758 SkScalar textRatio; | 758 SkScalar textRatio; |
| 759 blob = this->setupDFBlob(glyphCount, skPaint, viewMatrix, &dfPaint, &tex
tRatio); | 759 blob = this->setupDFBlob(glyphCount, skPaint, viewMatrix, &dfPaint, &tex
tRatio); |
| 760 | 760 |
| 761 SkTDArray<char> fallbackTxt; | 761 SkTDArray<char> fallbackTxt; |
| 762 SkTDArray<SkScalar> fallbackPos; | 762 SkTDArray<SkScalar> fallbackPos; |
| 763 this->internalDrawDFPosText(blob, 0, dfPaint, paint.getColor(), viewMatr
ix, text, | 763 this->internalDrawDFPosText(blob, 0, dfPaint, paint.getColor(), viewMatr
ix, text, |
| 764 byteLength, pos, scalarsPerPosition, offset,
clipRect, | 764 byteLength, pos, scalarsPerPosition, offset,
clipRect, |
| 765 textRatio, &fallbackTxt, &fallbackPos); | 765 textRatio, &fallbackTxt, &fallbackPos); |
| 766 if (fallbackTxt.count()) { | 766 if (fallbackTxt.count()) { |
| 767 this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPai
nt, viewMatrix, | 767 this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPai
nt, viewMatrix, |
| 768 fallbackTxt, fallbackPos, scalarsPerPositi
on, offset, | 768 fallbackTxt, fallbackPos, scalarsPerPositi
on, offset, |
| 769 clipRect); | 769 clipRect); |
| 770 } | 770 } |
| 771 } else { | 771 } else { |
| 772 blob = fCache->createBlob(glyphCount, 1, kGrayTextVASize); | 772 blob = fCache->createBlob(glyphCount, 1, kGrayTextVASize); |
| 773 blob->fViewMatrix = viewMatrix; | 773 blob->fViewMatrix = viewMatrix; |
| 774 SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], skPaint, &viewMa
trix, false); | 774 SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], skPaint, &viewMa
trix, false); |
| 775 this->internalDrawBMPPosText(blob, 0, cache, skPaint, paint.getColor(),
viewMatrix, text, | 775 this->internalDrawBMPPosText(blob, 0, cache, skPaint, paint.getColor(),
viewMatrix, text, |
| 776 byteLength, pos, scalarsPerPosition, offset
, clipRect); | 776 byteLength, pos, scalarsPerPosition, offset
, clipRect); |
| 777 SkGlyphCache::AttachCache(cache); | 777 SkGlyphCache::AttachCache(cache); |
| 778 } | 778 } |
| 779 return blob; | 779 return blob; |
| 780 } | 780 } |
| 781 | 781 |
| 782 void GrAtlasTextContext::onDrawText(GrDrawContext* dc, GrRenderTarget* rt, | 782 void GrAtlasTextContext::onDrawText(GrDrawContext* dc, GrRenderTarget* rt, |
| 783 const GrClip& clip, | 783 const GrClip& clip, |
| 784 const GrPaint& paint, const SkPaint& skPaint
, | 784 const GrPaint& paint, const SkPaint& skPaint
, |
| 785 const SkMatrix& viewMatrix, | 785 const SkMatrix& viewMatrix, |
| 786 const char text[], size_t byteLength, | 786 const char text[], size_t byteLength, |
| 787 SkScalar x, SkScalar y, const SkIRect& regio
nClipBounds) { | 787 SkScalar x, SkScalar y, const SkIRect& regio
nClipBounds) { |
| 788 SkAutoTUnref<GrAtlasTextBlob> blob( | 788 SkAutoTUnref<GrAtlasTextBlob> blob( |
| 789 this->createDrawTextBlob(rt, clip, paint, skPaint, viewMatrix, | 789 this->createDrawTextBlob(rt, clip, paint, skPaint, viewMatrix, |
| 790 text, byteLength, x, y, regionClipBounds)); | 790 text, byteLength, x, y, regionClipBounds)); |
| 791 this->flush(blob, dc, rt, skPaint, paint, clip, regionClipBounds); | 791 this->flush(blob, dc, rt, skPaint, paint, clip, regionClipBounds); |
| 792 } | 792 } |
| 793 | 793 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 819 if (text == nullptr || byteLength == 0) { | 819 if (text == nullptr || byteLength == 0) { |
| 820 return; | 820 return; |
| 821 } | 821 } |
| 822 | 822 |
| 823 fCurrStrike = nullptr; | 823 fCurrStrike = nullptr; |
| 824 SkDrawCacheProc glyphCacheProc = skPaint.getDrawCacheProc(); | 824 SkDrawCacheProc glyphCacheProc = skPaint.getDrawCacheProc(); |
| 825 | 825 |
| 826 // Get GrFontScaler from cache | 826 // Get GrFontScaler from cache |
| 827 GrFontScaler* fontScaler = GetGrFontScaler(cache); | 827 GrFontScaler* fontScaler = GetGrFontScaler(cache); |
| 828 | 828 |
| 829 // transform our starting point | 829 SkFindAndPlaceGlyph::ProcessText( |
| 830 { | 830 text, byteLength, {x, y}, viewMatrix, skPaint.getTextAlign(), glyphCache
Proc, cache, |
| 831 SkPoint loc; | 831 [&](const SkGlyph& glyph, SkPoint position, SkPoint rounding) { |
| 832 viewMatrix.mapXY(x, y, &loc); | 832 position += rounding; |
| 833 x = loc.fX; | 833 this->bmpAppendGlyph( |
| 834 y = loc.fY; | 834 blob, runIndex, glyph, |
| 835 } | 835 SkScalarFloorToInt(position.fX), SkScalarFloorToInt(position.fY)
, |
| 836 | 836 color, fontScaler, clipRect); |
| 837 // need to measure first | |
| 838 if (skPaint.getTextAlign() != SkPaint::kLeft_Align) { | |
| 839 SkVector stopVector; | |
| 840 MeasureText(cache, glyphCacheProc, text, byteLength, &stopVector); | |
| 841 | |
| 842 SkScalar stopX = stopVector.fX; | |
| 843 SkScalar stopY = stopVector.fY; | |
| 844 | |
| 845 if (skPaint.getTextAlign() == SkPaint::kCenter_Align) { | |
| 846 stopX = SkScalarHalf(stopX); | |
| 847 stopY = SkScalarHalf(stopY); | |
| 848 } | 837 } |
| 849 x -= stopX; | 838 ); |
| 850 y -= stopY; | |
| 851 } | |
| 852 | |
| 853 const char* stop = text + byteLength; | |
| 854 | |
| 855 SkAutoKern autokern; | |
| 856 | |
| 857 SkFixed fxMask = ~0; | |
| 858 SkFixed fyMask = ~0; | |
| 859 SkScalar halfSampleX, halfSampleY; | |
| 860 if (cache->isSubpixel()) { | |
| 861 halfSampleX = halfSampleY = SkFixedToScalar(SkGlyph::kSubpixelRound); | |
| 862 SkAxisAlignment baseline = SkComputeAxisAlignmentForHText(viewMatrix); | |
| 863 if (kX_SkAxisAlignment == baseline) { | |
| 864 fyMask = 0; | |
| 865 halfSampleY = SK_ScalarHalf; | |
| 866 } else if (kY_SkAxisAlignment == baseline) { | |
| 867 fxMask = 0; | |
| 868 halfSampleX = SK_ScalarHalf; | |
| 869 } | |
| 870 } else { | |
| 871 halfSampleX = halfSampleY = SK_ScalarHalf; | |
| 872 } | |
| 873 | |
| 874 Sk48Dot16 fx = SkScalarTo48Dot16(x + halfSampleX); | |
| 875 Sk48Dot16 fy = SkScalarTo48Dot16(y + halfSampleY); | |
| 876 | |
| 877 while (text < stop) { | |
| 878 const SkGlyph& glyph = glyphCacheProc(cache, &text, fx & fxMask, fy & fy
Mask); | |
| 879 | |
| 880 fx += autokern.adjust(glyph); | |
| 881 | |
| 882 if (glyph.fWidth) { | |
| 883 this->bmpAppendGlyph(blob, | |
| 884 runIndex, | |
| 885 glyph, | |
| 886 Sk48Dot16FloorToInt(fx), | |
| 887 Sk48Dot16FloorToInt(fy), | |
| 888 color, | |
| 889 fontScaler, | |
| 890 clipRect); | |
| 891 } | |
| 892 | |
| 893 fx += glyph.fAdvanceX; | |
| 894 fy += glyph.fAdvanceY; | |
| 895 } | |
| 896 } | 839 } |
| 897 | 840 |
| 898 void GrAtlasTextContext::internalDrawBMPPosText(GrAtlasTextBlob* blob, int runIn
dex, | 841 void GrAtlasTextContext::internalDrawBMPPosText(GrAtlasTextBlob* blob, int runIn
dex, |
| 899 SkGlyphCache* cache, const SkPai
nt& skPaint, | 842 SkGlyphCache* cache, const SkPai
nt& skPaint, |
| 900 GrColor color, | 843 GrColor color, |
| 901 const SkMatrix& viewMatrix, | 844 const SkMatrix& viewMatrix, |
| 902 const char text[], size_t byteLe
ngth, | 845 const char text[], size_t byteLe
ngth, |
| 903 const SkScalar pos[], int scalar
sPerPosition, | 846 const SkScalar pos[], int scalar
sPerPosition, |
| 904 const SkPoint& offset, const SkI
Rect& clipRect) { | 847 const SkPoint& offset, const SkI
Rect& clipRect) { |
| 905 SkASSERT(byteLength == 0 || text != nullptr); | 848 SkASSERT(byteLength == 0 || text != nullptr); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 SkASSERT(byteLength == 0 || text != nullptr); | 885 SkASSERT(byteLength == 0 || text != nullptr); |
| 943 | 886 |
| 944 // nothing to draw | 887 // nothing to draw |
| 945 if (text == nullptr || byteLength == 0) { | 888 if (text == nullptr || byteLength == 0) { |
| 946 return; | 889 return; |
| 947 } | 890 } |
| 948 | 891 |
| 949 SkDrawCacheProc glyphCacheProc = origPaint.getDrawCacheProc(); | 892 SkDrawCacheProc glyphCacheProc = origPaint.getDrawCacheProc(); |
| 950 SkAutoDescriptor desc; | 893 SkAutoDescriptor desc; |
| 951 origPaint.getScalerContextDescriptor(&desc, fSurfaceProps, nullptr, true); | 894 origPaint.getScalerContextDescriptor(&desc, fSurfaceProps, nullptr, true); |
| 952 SkGlyphCache* origPaintCache = SkGlyphCache::DetachCache(origPaint.getTypefa
ce(), | 895 SkGlyphCache* origPaintCache = SkGlyphCache::DetachCache(origPaint.getTypefa
ce(), |
| 953 desc.getDesc()); | 896 desc.getDesc()); |
| 954 | 897 |
| 955 SkTArray<SkScalar> positions; | 898 SkTArray<SkScalar> positions; |
| 956 | 899 |
| 957 const char* textPtr = text; | 900 const char* textPtr = text; |
| 958 SkFixed stopX = 0; | 901 SkFixed stopX = 0; |
| 959 SkFixed stopY = 0; | 902 SkFixed stopY = 0; |
| 960 SkFixed origin = 0; | 903 SkFixed origin = 0; |
| 961 switch (origPaint.getTextAlign()) { | 904 switch (origPaint.getTextAlign()) { |
| 962 case SkPaint::kRight_Align: origin = SK_Fixed1; break; | 905 case SkPaint::kRight_Align: origin = SK_Fixed1; break; |
| (...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1925 GrBatchFontCache* fFontCache; | 1868 GrBatchFontCache* fFontCache; |
| 1926 | 1869 |
| 1927 // Distance field properties | 1870 // Distance field properties |
| 1928 SkAutoTUnref<const DistanceAdjustTable> fDistanceAdjustTable; | 1871 SkAutoTUnref<const DistanceAdjustTable> fDistanceAdjustTable; |
| 1929 SkColor fFilteredColor; | 1872 SkColor fFilteredColor; |
| 1930 | 1873 |
| 1931 typedef GrVertexBatch INHERITED; | 1874 typedef GrVertexBatch INHERITED; |
| 1932 }; | 1875 }; |
| 1933 | 1876 |
| 1934 void GrAtlasTextContext::flushRunAsPaths(GrDrawContext* dc, GrRenderTarget* rt, | 1877 void GrAtlasTextContext::flushRunAsPaths(GrDrawContext* dc, GrRenderTarget* rt, |
| 1935 const SkTextBlobRunIterator& it, | 1878 const SkTextBlobRunIterator& it, |
| 1936 const GrClip& clip, const SkPaint& skPa
int, | 1879 const GrClip& clip, const SkPaint& skPa
int, |
| 1937 SkDrawFilter* drawFilter, const SkMatri
x& viewMatrix, | 1880 SkDrawFilter* drawFilter, const SkMatri
x& viewMatrix, |
| 1938 const SkIRect& clipBounds, SkScalar x,
SkScalar y) { | 1881 const SkIRect& clipBounds, SkScalar x,
SkScalar y) { |
| 1939 SkPaint runPaint = skPaint; | 1882 SkPaint runPaint = skPaint; |
| 1940 | 1883 |
| 1941 size_t textLen = it.glyphCount() * sizeof(uint16_t); | 1884 size_t textLen = it.glyphCount() * sizeof(uint16_t); |
| 1942 const SkPoint& offset = it.offset(); | 1885 const SkPoint& offset = it.offset(); |
| 1943 | 1886 |
| 1944 it.applyFontToPaint(&runPaint); | 1887 it.applyFontToPaint(&runPaint); |
| 1945 | 1888 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2022 continue; | 1965 continue; |
| 2023 } | 1966 } |
| 2024 | 1967 |
| 2025 SkAutoTUnref<GrDrawBatch> batch(this->createBatch(cacheBlob, info, glyph
Count, run, | 1968 SkAutoTUnref<GrDrawBatch> batch(this->createBatch(cacheBlob, info, glyph
Count, run, |
| 2026 subRun, color, transX,
transY, | 1969 subRun, color, transX,
transY, |
| 2027 skPaint)); | 1970 skPaint)); |
| 2028 dc->drawBatch(pipelineBuilder, batch); | 1971 dc->drawBatch(pipelineBuilder, batch); |
| 2029 } | 1972 } |
| 2030 } | 1973 } |
| 2031 | 1974 |
| 2032 inline void GrAtlasTextContext::flushBigGlyphs(GrAtlasTextBlob* cacheBlob, | 1975 inline void GrAtlasTextContext::flushBigGlyphs(GrAtlasTextBlob* cacheBlob, |
| 2033 GrDrawContext* dc, GrRenderTarget
* rt, | 1976 GrDrawContext* dc, GrRenderTarget
* rt, |
| 2034 const GrClip& clip, const SkPaint
& skPaint, | 1977 const GrClip& clip, const SkPaint
& skPaint, |
| 2035 SkScalar transX, SkScalar transY, | 1978 SkScalar transX, SkScalar transY, |
| 2036 const SkIRect& clipBounds) { | 1979 const SkIRect& clipBounds) { |
| 2037 if (!cacheBlob->fBigGlyphs.count()) { | 1980 if (!cacheBlob->fBigGlyphs.count()) { |
| 2038 return; | 1981 return; |
| 2039 } | 1982 } |
| 2040 | 1983 |
| 2041 for (int i = 0; i < cacheBlob->fBigGlyphs.count(); i++) { | 1984 for (int i = 0; i < cacheBlob->fBigGlyphs.count(); i++) { |
| 2042 GrAtlasTextBlob::BigGlyph& bigGlyph = cacheBlob->fBigGlyphs[i]; | 1985 GrAtlasTextBlob::BigGlyph& bigGlyph = cacheBlob->fBigGlyphs[i]; |
| 2043 bigGlyph.fVx += transX; | 1986 bigGlyph.fVx += transX; |
| 2044 bigGlyph.fVy += transY; | 1987 bigGlyph.fVy += transY; |
| 2045 SkMatrix ctm; | 1988 SkMatrix ctm; |
| 2046 ctm.setScale(bigGlyph.fScale, bigGlyph.fScale); | 1989 ctm.setScale(bigGlyph.fScale, bigGlyph.fScale); |
| 2047 ctm.postTranslate(bigGlyph.fVx, bigGlyph.fVy); | 1990 ctm.postTranslate(bigGlyph.fVx, bigGlyph.fVy); |
| 2048 if (bigGlyph.fApplyVM) { | 1991 if (bigGlyph.fApplyVM) { |
| 2049 ctm.postConcat(cacheBlob->fViewMatrix); | 1992 ctm.postConcat(cacheBlob->fViewMatrix); |
| 2050 } | 1993 } |
| 2051 | 1994 |
| 2052 GrBlurUtils::drawPathWithMaskFilter(fContext, dc, rt, clip, bigGlyph.fPa
th, | 1995 GrBlurUtils::drawPathWithMaskFilter(fContext, dc, rt, clip, bigGlyph.fPa
th, |
| 2053 skPaint, ctm, nullptr, clipBounds, f
alse); | 1996 skPaint, ctm, nullptr, clipBounds, f
alse); |
| 2054 } | 1997 } |
| 2055 } | 1998 } |
| 2056 | 1999 |
| 2057 void GrAtlasTextContext::flush(const SkTextBlob* blob, | 2000 void GrAtlasTextContext::flush(const SkTextBlob* blob, |
| 2058 GrAtlasTextBlob* cacheBlob, | 2001 GrAtlasTextBlob* cacheBlob, |
| 2059 GrDrawContext* dc, | 2002 GrDrawContext* dc, |
| 2060 GrRenderTarget* rt, | 2003 GrRenderTarget* rt, |
| 2061 const SkPaint& skPaint, | 2004 const SkPaint& skPaint, |
| 2062 const GrPaint& grPaint, | 2005 const GrPaint& grPaint, |
| 2063 SkDrawFilter* drawFilter, | 2006 SkDrawFilter* drawFilter, |
| 2064 const GrClip& clip, | 2007 const GrClip& clip, |
| 2065 const SkMatrix& viewMatrix, | 2008 const SkMatrix& viewMatrix, |
| 2066 const SkIRect& clipBounds, | 2009 const SkIRect& clipBounds, |
| 2067 SkScalar x, SkScalar y, | 2010 SkScalar x, SkScalar y, |
| 2068 SkScalar transX, SkScalar transY) { | 2011 SkScalar transX, SkScalar transY) { |
| 2069 // We loop through the runs of the blob, flushing each. If any run is too l
arge, then we flush | 2012 // We loop through the runs of the blob, flushing each. If any run is too l
arge, then we flush |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2164 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat
rix, text, | 2107 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat
rix, text, |
| 2165 static_cast<size_t>(textLen), 0, 0,
noClip)); | 2108 static_cast<size_t>(textLen), 0, 0,
noClip)); |
| 2166 | 2109 |
| 2167 SkScalar transX = static_cast<SkScalar>(random->nextU()); | 2110 SkScalar transX = static_cast<SkScalar>(random->nextU()); |
| 2168 SkScalar transY = static_cast<SkScalar>(random->nextU()); | 2111 SkScalar transY = static_cast<SkScalar>(random->nextU()); |
| 2169 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0]
; | 2112 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0]
; |
| 2170 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t
ransY, skPaint); | 2113 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t
ransY, skPaint); |
| 2171 } | 2114 } |
| 2172 | 2115 |
| 2173 #endif | 2116 #endif |
| OLD | NEW |