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

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

Issue 1458193003: Move glyph choosing to the find and place glyph code. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Comments and fixes. Created 5 years, 1 month 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/SkFindAndPlaceGlyph.h ('k') | no next file » | 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 "GrBatchFontCache.h" 9 #include "GrBatchFontCache.h"
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 const char text[], size_t byteLengt h, 814 const char text[], size_t byteLengt h,
815 SkScalar x, SkScalar y, const SkIRe ct& clipRect) { 815 SkScalar x, SkScalar y, const SkIRe ct& clipRect) {
816 SkASSERT(byteLength == 0 || text != nullptr); 816 SkASSERT(byteLength == 0 || text != nullptr);
817 817
818 // nothing to draw 818 // nothing to draw
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();
825 824
826 // Get GrFontScaler from cache 825 // Get GrFontScaler from cache
827 GrFontScaler* fontScaler = GetGrFontScaler(cache); 826 GrFontScaler* fontScaler = GetGrFontScaler(cache);
828 827
829 SkFindAndPlaceGlyph::ProcessText( 828 SkFindAndPlaceGlyph::ProcessText(
830 text, byteLength, {x, y}, viewMatrix, skPaint.getTextAlign(), glyphCache Proc, cache, 829 skPaint.getTextEncoding(), text, byteLength,
830 {x, y}, viewMatrix, skPaint.getTextAlign(),
831 cache,
831 [&](const SkGlyph& glyph, SkPoint position, SkPoint rounding) { 832 [&](const SkGlyph& glyph, SkPoint position, SkPoint rounding) {
832 position += rounding; 833 position += rounding;
833 this->bmpAppendGlyph( 834 this->bmpAppendGlyph(
834 blob, runIndex, glyph, 835 blob, runIndex, glyph,
835 SkScalarFloorToInt(position.fX), SkScalarFloorToInt(position.fY) , 836 SkScalarFloorToInt(position.fX), SkScalarFloorToInt(position.fY) ,
836 color, fontScaler, clipRect); 837 color, fontScaler, clipRect);
837 } 838 }
838 ); 839 );
839 } 840 }
840 841
841 void GrAtlasTextContext::internalDrawBMPPosText(GrAtlasTextBlob* blob, int runIn dex, 842 void GrAtlasTextContext::internalDrawBMPPosText(GrAtlasTextBlob* blob, int runIn dex,
842 SkGlyphCache* cache, const SkPai nt& skPaint, 843 SkGlyphCache* cache, const SkPai nt& skPaint,
843 GrColor color, 844 GrColor color,
844 const SkMatrix& viewMatrix, 845 const SkMatrix& viewMatrix,
845 const char text[], size_t byteLe ngth, 846 const char text[], size_t byteLe ngth,
846 const SkScalar pos[], int scalar sPerPosition, 847 const SkScalar pos[], int scalar sPerPosition,
847 const SkPoint& offset, const SkI Rect& clipRect) { 848 const SkPoint& offset, const SkI Rect& clipRect) {
848 SkASSERT(byteLength == 0 || text != nullptr); 849 SkASSERT(byteLength == 0 || text != nullptr);
849 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition); 850 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
850 851
851 // nothing to draw 852 // nothing to draw
852 if (text == nullptr || byteLength == 0) { 853 if (text == nullptr || byteLength == 0) {
853 return; 854 return;
854 } 855 }
855 856
856 fCurrStrike = nullptr; 857 fCurrStrike = nullptr;
857 SkDrawCacheProc glyphCacheProc = skPaint.getDrawCacheProc();
858 858
859 // Get GrFontScaler from cache 859 // Get GrFontScaler from cache
860 GrFontScaler* fontScaler = GetGrFontScaler(cache); 860 GrFontScaler* fontScaler = GetGrFontScaler(cache);
861 861
862 SkFindAndPlaceGlyph::ProcessPosText( 862 SkFindAndPlaceGlyph::ProcessPosText(
863 text, byteLength, offset, viewMatrix, pos, scalarsPerPosition, 863 skPaint.getTextEncoding(), text, byteLength,
864 skPaint.getTextAlign(), glyphCacheProc, cache, 864 offset, viewMatrix, pos, scalarsPerPosition,
865 skPaint.getTextAlign(), cache,
865 [&](const SkGlyph& glyph, SkPoint position, SkPoint rounding) { 866 [&](const SkGlyph& glyph, SkPoint position, SkPoint rounding) {
866 position += rounding; 867 position += rounding;
867 this->bmpAppendGlyph( 868 this->bmpAppendGlyph(
868 blob, runIndex, glyph, 869 blob, runIndex, glyph,
869 SkScalarFloorToInt(position.fX), SkScalarFloorToInt(position.fY) , 870 SkScalarFloorToInt(position.fX), SkScalarFloorToInt(position.fY) ,
870 color, fontScaler, clipRect); 871 color, fontScaler, clipRect);
871 } 872 }
872 ); 873 );
873 } 874 }
874 875
(...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after
2107 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text, 2108 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text,
2108 static_cast<size_t>(textLen), 0, 0, noClip)); 2109 static_cast<size_t>(textLen), 0, 0, noClip));
2109 2110
2110 SkScalar transX = static_cast<SkScalar>(random->nextU()); 2111 SkScalar transX = static_cast<SkScalar>(random->nextU());
2111 SkScalar transY = static_cast<SkScalar>(random->nextU()); 2112 SkScalar transY = static_cast<SkScalar>(random->nextU());
2112 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ; 2113 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ;
2113 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint); 2114 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint);
2114 } 2115 }
2115 2116
2116 #endif 2117 #endif
OLDNEW
« no previous file with comments | « src/core/SkFindAndPlaceGlyph.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698