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

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

Issue 1266253002: Revert of Move strike to subrun in GrAtlasTextContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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/GrAtlasTextBlob.h ('k') | src/gpu/GrBatchAtlas.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 "GrBatch.h" 9 #include "GrBatch.h"
10 #include "GrBatchFontCache.h" 10 #include "GrBatchFontCache.h"
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 } 1214 }
1215 } 1215 }
1216 1216
1217 void GrAtlasTextContext::bmpAppendGlyph(GrAtlasTextBlob* blob, int runIndex, 1217 void GrAtlasTextContext::bmpAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
1218 const SkGlyph& skGlyph, 1218 const SkGlyph& skGlyph,
1219 int vx, int vy, GrColor color, GrFontSca ler* scaler, 1219 int vx, int vy, GrColor color, GrFontSca ler* scaler,
1220 const SkIRect& clipRect) { 1220 const SkIRect& clipRect) {
1221 Run& run = blob->fRuns[runIndex]; 1221 Run& run = blob->fRuns[runIndex];
1222 if (!fCurrStrike) { 1222 if (!fCurrStrike) {
1223 fCurrStrike = fContext->getBatchFontCache()->getStrike(scaler); 1223 fCurrStrike = fContext->getBatchFontCache()->getStrike(scaler);
1224 run.fStrike.reset(SkRef(fCurrStrike));
1224 } 1225 }
1225 1226
1226 GrGlyph::PackedID id = GrGlyph::Pack(skGlyph.getGlyphID(), 1227 GrGlyph::PackedID id = GrGlyph::Pack(skGlyph.getGlyphID(),
1227 skGlyph.getSubXFixed(), 1228 skGlyph.getSubXFixed(),
1228 skGlyph.getSubYFixed(), 1229 skGlyph.getSubYFixed(),
1229 GrGlyph::kCoverage_MaskStyle); 1230 GrGlyph::kCoverage_MaskStyle);
1230 GrGlyph* glyph = fCurrStrike->getGlyph(skGlyph, id, scaler); 1231 GrGlyph* glyph = fCurrStrike->getGlyph(skGlyph, id, scaler);
1231 if (!glyph) { 1232 if (!glyph) {
1232 return; 1233 return;
1233 } 1234 }
(...skipping 21 matching lines...) Expand all
1255 if (glyph->fTooLargeForAtlas) { 1256 if (glyph->fTooLargeForAtlas) {
1256 this->appendGlyphPath(blob, glyph, scaler, skGlyph, SkIntToScalar(vx), S kIntToScalar(vy)); 1257 this->appendGlyphPath(blob, glyph, scaler, skGlyph, SkIntToScalar(vx), S kIntToScalar(vy));
1257 return; 1258 return;
1258 } 1259 }
1259 1260
1260 GrMaskFormat format = glyph->fMaskFormat; 1261 GrMaskFormat format = glyph->fMaskFormat;
1261 1262
1262 PerSubRunInfo* subRun = &run.fSubRunInfo.back(); 1263 PerSubRunInfo* subRun = &run.fSubRunInfo.back();
1263 if (run.fInitialized && subRun->fMaskFormat != format) { 1264 if (run.fInitialized && subRun->fMaskFormat != format) {
1264 subRun = &run.push_back(); 1265 subRun = &run.push_back();
1265 subRun->fStrike.reset(SkRef(fCurrStrike));
1266 } else if (!run.fInitialized) {
1267 subRun->fStrike.reset(SkRef(fCurrStrike));
1268 } 1266 }
1269 1267
1270 run.fInitialized = true; 1268 run.fInitialized = true;
1271 1269
1272 size_t vertexStride = get_vertex_stride(format); 1270 size_t vertexStride = get_vertex_stride(format);
1273 1271
1274 SkRect r; 1272 SkRect r;
1275 r.fLeft = SkIntToScalar(x); 1273 r.fLeft = SkIntToScalar(x);
1276 r.fTop = SkIntToScalar(y); 1274 r.fTop = SkIntToScalar(y);
1277 r.fRight = r.fLeft + SkIntToScalar(width); 1275 r.fRight = r.fLeft + SkIntToScalar(width);
1278 r.fBottom = r.fTop + SkIntToScalar(height); 1276 r.fBottom = r.fTop + SkIntToScalar(height);
1279 subRun->fMaskFormat = format; 1277 subRun->fMaskFormat = format;
1280 this->appendGlyphCommon(blob, &run, subRun, r, color, vertexStride, kA8_GrMa skFormat == format, 1278 this->appendGlyphCommon(blob, &run, subRun, r, color, vertexStride, kA8_GrMa skFormat == format,
1281 glyph); 1279 glyph);
1282 } 1280 }
1283 1281
1284 bool GrAtlasTextContext::dfAppendGlyph(GrAtlasTextBlob* blob, int runIndex, 1282 bool GrAtlasTextContext::dfAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
1285 const SkGlyph& skGlyph, 1283 const SkGlyph& skGlyph,
1286 SkScalar sx, SkScalar sy, GrColor color, 1284 SkScalar sx, SkScalar sy, GrColor color,
1287 GrFontScaler* scaler, 1285 GrFontScaler* scaler,
1288 const SkIRect& clipRect, 1286 const SkIRect& clipRect,
1289 SkScalar textRatio, const SkMatrix& viewM atrix) { 1287 SkScalar textRatio, const SkMatrix& viewM atrix) {
1290 Run& run = blob->fRuns[runIndex]; 1288 Run& run = blob->fRuns[runIndex];
1291 if (!fCurrStrike) { 1289 if (!fCurrStrike) {
1292 fCurrStrike = fContext->getBatchFontCache()->getStrike(scaler); 1290 fCurrStrike = fContext->getBatchFontCache()->getStrike(scaler);
1291 run.fStrike.reset(SkRef(fCurrStrike));
1293 } 1292 }
1294 1293
1295 GrGlyph::PackedID id = GrGlyph::Pack(skGlyph.getGlyphID(), 1294 GrGlyph::PackedID id = GrGlyph::Pack(skGlyph.getGlyphID(),
1296 skGlyph.getSubXFixed(), 1295 skGlyph.getSubXFixed(),
1297 skGlyph.getSubYFixed(), 1296 skGlyph.getSubYFixed(),
1298 GrGlyph::kDistance_MaskStyle); 1297 GrGlyph::kDistance_MaskStyle);
1299 GrGlyph* glyph = fCurrStrike->getGlyph(skGlyph, id, scaler); 1298 GrGlyph* glyph = fCurrStrike->getGlyph(skGlyph, id, scaler);
1300 if (!glyph) { 1299 if (!glyph) {
1301 return true; 1300 return true;
1302 } 1301 }
(...skipping 30 matching lines...) Expand all
1333 #endif 1332 #endif
1334 1333
1335 // TODO combine with the above 1334 // TODO combine with the above
1336 // If the glyph is too large we fall back to paths 1335 // If the glyph is too large we fall back to paths
1337 if (glyph->fTooLargeForAtlas) { 1336 if (glyph->fTooLargeForAtlas) {
1338 this->appendGlyphPath(blob, glyph, scaler, skGlyph, sx - dx, sy - dy); 1337 this->appendGlyphPath(blob, glyph, scaler, skGlyph, sx - dx, sy - dy);
1339 return true; 1338 return true;
1340 } 1339 }
1341 1340
1342 PerSubRunInfo* subRun = &run.fSubRunInfo.back(); 1341 PerSubRunInfo* subRun = &run.fSubRunInfo.back();
1343 if (!run.fInitialized) {
1344 subRun->fStrike.reset(SkRef(fCurrStrike));
1345 }
1346 run.fInitialized = true;
1347 SkASSERT(glyph->fMaskFormat == kA8_GrMaskFormat); 1342 SkASSERT(glyph->fMaskFormat == kA8_GrMaskFormat);
1348 subRun->fMaskFormat = kA8_GrMaskFormat; 1343 subRun->fMaskFormat = kA8_GrMaskFormat;
1349 1344
1350 size_t vertexStride = get_vertex_stride_df(kA8_GrMaskFormat, subRun->fUseLCD Text); 1345 size_t vertexStride = get_vertex_stride_df(kA8_GrMaskFormat, subRun->fUseLCD Text);
1351 1346
1352 bool useColorVerts = !subRun->fUseLCDText; 1347 bool useColorVerts = !subRun->fUseLCDText;
1353 this->appendGlyphCommon(blob, &run, subRun, glyphRect, color, vertexStride, useColorVerts, 1348 this->appendGlyphCommon(blob, &run, subRun, glyphRect, color, vertexStride, useColorVerts,
1354 glyph); 1349 glyph);
1355 return true; 1350 return true;
1356 } 1351 }
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 SkTypeface* typeface = NULL; 1596 SkTypeface* typeface = NULL;
1602 1597
1603 for (int i = 0; i < fGeoCount; i++) { 1598 for (int i = 0; i < fGeoCount; i++) {
1604 Geometry& args = fGeoData[i]; 1599 Geometry& args = fGeoData[i];
1605 Blob* blob = args.fBlob; 1600 Blob* blob = args.fBlob;
1606 Run& run = blob->fRuns[args.fRun]; 1601 Run& run = blob->fRuns[args.fRun];
1607 TextInfo& info = run.fSubRunInfo[args.fSubRun]; 1602 TextInfo& info = run.fSubRunInfo[args.fSubRun];
1608 1603
1609 uint64_t currentAtlasGen = fFontCache->atlasGeneration(maskFormat); 1604 uint64_t currentAtlasGen = fFontCache->atlasGeneration(maskFormat);
1610 bool regenerateTextureCoords = info.fAtlasGeneration != currentAtlas Gen || 1605 bool regenerateTextureCoords = info.fAtlasGeneration != currentAtlas Gen ||
1611 info.fStrike->isAbandoned(); 1606 run.fStrike->isAbandoned();
1612 bool regenerateColors; 1607 bool regenerateColors;
1613 if (usesDistanceFields) { 1608 if (usesDistanceFields) {
1614 regenerateColors = !isLCD && run.fColor != args.fColor; 1609 regenerateColors = !isLCD && run.fColor != args.fColor;
1615 } else { 1610 } else {
1616 regenerateColors = kA8_GrMaskFormat == maskFormat && run.fColor != args.fColor; 1611 regenerateColors = kA8_GrMaskFormat == maskFormat && run.fColor != args.fColor;
1617 } 1612 }
1618 bool regeneratePositions = args.fTransX != 0.f || args.fTransY != 0. f; 1613 bool regeneratePositions = args.fTransX != 0.f || args.fTransY != 0. f;
1619 int glyphCount = info.fGlyphEndIndex - info.fGlyphStartIndex; 1614 int glyphCount = info.fGlyphEndIndex - info.fGlyphStartIndex;
1620 1615
1621 // We regenerate both texture coords and colors in the blob itself, and update the 1616 // We regenerate both texture coords and colors in the blob itself, and update the
(...skipping 27 matching lines...) Expand all
1649 run.fOverrideDescriptor->getDe sc() : 1644 run.fOverrideDescriptor->getDe sc() :
1650 run.fDescriptor.getDesc(); 1645 run.fDescriptor.getDesc();
1651 if (!cache || !SkTypeface::Equal(typeface, run.fTypeface) || 1646 if (!cache || !SkTypeface::Equal(typeface, run.fTypeface) ||
1652 !(desc->equals(*newDesc))) { 1647 !(desc->equals(*newDesc))) {
1653 if (cache) { 1648 if (cache) {
1654 SkGlyphCache::AttachCache(cache); 1649 SkGlyphCache::AttachCache(cache);
1655 } 1650 }
1656 desc = newDesc; 1651 desc = newDesc;
1657 cache = SkGlyphCache::DetachCache(run.fTypeface, desc); 1652 cache = SkGlyphCache::DetachCache(run.fTypeface, desc);
1658 scaler = GrTextContext::GetGrFontScaler(cache); 1653 scaler = GrTextContext::GetGrFontScaler(cache);
1659 strike = info.fStrike; 1654 strike = run.fStrike;
1660 typeface = run.fTypeface; 1655 typeface = run.fTypeface;
1661 } 1656 }
1662 1657
1663 if (info.fStrike->isAbandoned()) { 1658 if (run.fStrike->isAbandoned()) {
1664 regenerateGlyphs = true; 1659 regenerateGlyphs = true;
1665 strike = fFontCache->getStrike(scaler); 1660 strike = fFontCache->getStrike(scaler);
1666 } else { 1661 } else {
1667 strike = info.fStrike; 1662 strike = run.fStrike;
1668 } 1663 }
1669 } 1664 }
1670 1665
1671 for (int glyphIdx = 0; glyphIdx < glyphCount; glyphIdx++) { 1666 for (int glyphIdx = 0; glyphIdx < glyphCount; glyphIdx++) {
1672 if (regenerateTextureCoords) { 1667 if (regenerateTextureCoords) {
1673 size_t glyphOffset = glyphIdx + info.fGlyphStartIndex; 1668 size_t glyphOffset = glyphIdx + info.fGlyphStartIndex;
1674 1669
1675 GrGlyph* glyph = blob->fGlyphs[glyphOffset]; 1670 GrGlyph* glyph = blob->fGlyphs[glyphOffset];
1676 GrGlyph::PackedID id = glyph->fPackedID; 1671 GrGlyph::PackedID id = glyph->fPackedID;
1677 const SkGlyph& skGlyph = scaler->grToSkGlyph(id); 1672 const SkGlyph& skGlyph = scaler->grToSkGlyph(id);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 SkScalar transY = args.fTransY; 1725 SkScalar transY = args.fTransY;
1731 this->regeneratePositions(vertex, vertexStride, transX, transY); 1726 this->regeneratePositions(vertex, vertexStride, transX, transY);
1732 } 1727 }
1733 flushInfo.fGlyphsToFlush++; 1728 flushInfo.fGlyphsToFlush++;
1734 } 1729 }
1735 1730
1736 // We my have changed the color so update it here 1731 // We my have changed the color so update it here
1737 run.fColor = args.fColor; 1732 run.fColor = args.fColor;
1738 if (regenerateTextureCoords) { 1733 if (regenerateTextureCoords) {
1739 if (regenerateGlyphs) { 1734 if (regenerateGlyphs) {
1740 info.fStrike.reset(SkRef(strike)); 1735 run.fStrike.reset(SkRef(strike));
1741 } 1736 }
1742 info.fAtlasGeneration = brokenRun ? GrBatchAtlas::kInvalidAt lasGeneration : 1737 info.fAtlasGeneration = brokenRun ? GrBatchAtlas::kInvalidAt lasGeneration :
1743 fFontCache->atlasGenerat ion(maskFormat); 1738 fFontCache->atlasGenerat ion(maskFormat);
1744 } 1739 }
1745 } else { 1740 } else {
1746 flushInfo.fGlyphsToFlush += glyphCount; 1741 flushInfo.fGlyphsToFlush += glyphCount;
1747 1742
1748 // set use tokens for all of the glyphs in our subrun. This is only valid if we 1743 // set use tokens for all of the glyphs in our subrun. This is only valid if we
1749 // have a valid atlas generation 1744 // have a valid atlas generation
1750 fFontCache->setUseTokenBulk(info.fBulkUseToken, 1745 fFontCache->setUseTokenBulk(info.fBulkUseToken,
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
2282 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text, 2277 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text,
2283 static_cast<size_t>(textLen), 0, 0, noClip)); 2278 static_cast<size_t>(textLen), 0, 0, noClip));
2284 2279
2285 SkScalar transX = static_cast<SkScalar>(random->nextU()); 2280 SkScalar transX = static_cast<SkScalar>(random->nextU());
2286 SkScalar transY = static_cast<SkScalar>(random->nextU()); 2281 SkScalar transY = static_cast<SkScalar>(random->nextU());
2287 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ; 2282 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ;
2288 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint); 2283 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint);
2289 } 2284 }
2290 2285
2291 #endif 2286 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrAtlasTextBlob.h ('k') | src/gpu/GrBatchAtlas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698