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

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

Issue 1517563002: Move appending of large glyphs into GrAtlasTextBlob (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanuptext6
Patch Set: rebase Created 5 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
« no previous file with comments | « src/gpu/GrAtlasTextContext.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 "GrBlurUtils.h" 9 #include "GrBlurUtils.h"
10 #include "GrDrawContext.h" 10 #include "GrDrawContext.h"
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 return; 882 return;
883 } 883 }
884 884
885 int x = vx + glyph->fBounds.fLeft; 885 int x = vx + glyph->fBounds.fLeft;
886 int y = vy + glyph->fBounds.fTop; 886 int y = vy + glyph->fBounds.fTop;
887 887
888 // keep them as ints until we've done the clip-test 888 // keep them as ints until we've done the clip-test
889 int width = glyph->fBounds.width(); 889 int width = glyph->fBounds.width();
890 int height = glyph->fBounds.height(); 890 int height = glyph->fBounds.height();
891 891
892 // If the glyph is too large we fall back to paths
893 if (glyph->fTooLargeForAtlas) {
894 this->appendGlyphPath(blob, glyph, scaler, skGlyph, SkIntToScalar(vx), S kIntToScalar(vy));
895 return;
896 }
897
898 SkRect r; 892 SkRect r;
899 r.fLeft = SkIntToScalar(x); 893 r.fLeft = SkIntToScalar(x);
900 r.fTop = SkIntToScalar(y); 894 r.fTop = SkIntToScalar(y);
901 r.fRight = r.fLeft + SkIntToScalar(width); 895 r.fRight = r.fLeft + SkIntToScalar(width);
902 r.fBottom = r.fTop + SkIntToScalar(height); 896 r.fBottom = r.fTop + SkIntToScalar(height);
903 897
904 blob->appendGlyph(runIndex, r, color, fCurrStrike, glyph); 898 blob->appendGlyph(runIndex, r, color, fCurrStrike, glyph, scaler, skGlyph,
899 SkIntToScalar(vx), SkIntToScalar(vy), 1.0f, false);
905 } 900 }
906 901
907 bool GrAtlasTextContext::dfAppendGlyph(GrAtlasTextBlob* blob, int runIndex, 902 bool GrAtlasTextContext::dfAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
908 const SkGlyph& skGlyph, 903 const SkGlyph& skGlyph,
909 SkScalar sx, SkScalar sy, GrColor color, 904 SkScalar sx, SkScalar sy, GrColor color,
910 GrFontScaler* scaler, 905 GrFontScaler* scaler,
911 SkScalar textRatio, const SkMatrix& viewM atrix) { 906 SkScalar textRatio, const SkMatrix& viewM atrix) {
912 if (!fCurrStrike) { 907 if (!fCurrStrike) {
913 fCurrStrike = fContext->getBatchFontCache()->getStrike(scaler); 908 fCurrStrike = fContext->getBatchFontCache()->getStrike(scaler);
914 } 909 }
(...skipping 19 matching lines...) Expand all
934 929
935 SkScalar scale = textRatio; 930 SkScalar scale = textRatio;
936 dx *= scale; 931 dx *= scale;
937 dy *= scale; 932 dy *= scale;
938 width *= scale; 933 width *= scale;
939 height *= scale; 934 height *= scale;
940 sx += dx; 935 sx += dx;
941 sy += dy; 936 sy += dy;
942 SkRect glyphRect = SkRect::MakeXYWH(sx, sy, width, height); 937 SkRect glyphRect = SkRect::MakeXYWH(sx, sy, width, height);
943 938
944 // TODO combine with the above 939 blob->appendGlyph(runIndex, glyphRect, color, fCurrStrike, glyph, scaler, sk Glyph,
945 // If the glyph is too large we fall back to paths 940 sx - dx, sy - dy, scale, true);
946 if (glyph->fTooLargeForAtlas) {
947 this->appendGlyphPath(blob, glyph, scaler, skGlyph, sx - dx, sy - dy, sc ale, true);
948 return true;
949 }
950
951 blob->appendGlyph(runIndex, glyphRect, color, fCurrStrike, glyph);
952 return true; 941 return true;
953 } 942 }
954 943
955 inline void GrAtlasTextContext::appendGlyphPath(GrAtlasTextBlob* blob, GrGlyph* glyph,
956 GrFontScaler* scaler, const SkGl yph& skGlyph,
957 SkScalar x, SkScalar y, SkScalar scale,
958 bool applyVM) {
959 if (nullptr == glyph->fPath) {
960 const SkPath* glyphPath = scaler->getGlyphPath(skGlyph);
961 if (!glyphPath) {
962 return;
963 }
964
965 glyph->fPath = new SkPath(*glyphPath);
966 }
967 blob->fBigGlyphs.push_back(GrAtlasTextBlob::BigGlyph(*glyph->fPath, x, y, sc ale, applyVM));
968 }
969
970 void GrAtlasTextContext::flushRunAsPaths(GrDrawContext* dc, 944 void GrAtlasTextContext::flushRunAsPaths(GrDrawContext* dc,
971 const SkTextBlobRunIterator& it, 945 const SkTextBlobRunIterator& it,
972 const GrClip& clip, const SkPaint& skPa int, 946 const GrClip& clip, const SkPaint& skPa int,
973 SkDrawFilter* drawFilter, const SkMatri x& viewMatrix, 947 SkDrawFilter* drawFilter, const SkMatri x& viewMatrix,
974 const SkIRect& clipBounds, SkScalar x, SkScalar y) { 948 const SkIRect& clipBounds, SkScalar x, SkScalar y) {
975 SkPaint runPaint = skPaint; 949 SkPaint runPaint = skPaint;
976 950
977 size_t textLen = it.glyphCount() * sizeof(uint16_t); 951 size_t textLen = it.glyphCount() * sizeof(uint16_t);
978 const SkPoint& offset = it.offset(); 952 const SkPoint& offset = it.offset();
979 953
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 gTextContext->createDrawTextBlob(clip, grPaint, skPaint, viewMatrix, text, 1160 gTextContext->createDrawTextBlob(clip, grPaint, skPaint, viewMatrix, text,
1187 static_cast<size_t>(textLen), 0, 0, noClip)); 1161 static_cast<size_t>(textLen), 0, 0, noClip));
1188 1162
1189 SkScalar transX = static_cast<SkScalar>(random->nextU()); 1163 SkScalar transX = static_cast<SkScalar>(random->nextU());
1190 SkScalar transY = static_cast<SkScalar>(random->nextU()); 1164 SkScalar transY = static_cast<SkScalar>(random->nextU());
1191 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ; 1165 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ;
1192 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint); 1166 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint);
1193 } 1167 }
1194 1168
1195 #endif 1169 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrAtlasTextContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698