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

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

Issue 1139723004: Preliminary attempt to remove batch tracker (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanup5
Patch Set: tweaks Created 5 years, 7 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/GrAARectRenderer.cpp ('k') | src/gpu/GrBatchTarget.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 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 SkAutoTUnref<const GrGeometryProcessor> gp; 1530 SkAutoTUnref<const GrGeometryProcessor> gp;
1531 if (fUseDistanceFields) { 1531 if (fUseDistanceFields) {
1532 gp.reset(this->setupDfProcessor(this->viewMatrix(), fFilteredColor, this->color(), 1532 gp.reset(this->setupDfProcessor(this->viewMatrix(), fFilteredColor, this->color(),
1533 texture)); 1533 texture));
1534 } else { 1534 } else {
1535 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::k None_FilterMode); 1535 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::k None_FilterMode);
1536 gp.reset(GrBitmapTextGeoProc::Create(this->color(), 1536 gp.reset(GrBitmapTextGeoProc::Create(this->color(),
1537 texture, 1537 texture,
1538 params, 1538 params,
1539 fMaskFormat, 1539 fMaskFormat,
1540 localMatrix)); 1540 localMatrix,
1541 this->usesLocalCoords()));
1541 } 1542 }
1542 1543
1543 FlushInfo flushInfo; 1544 FlushInfo flushInfo;
1544 flushInfo.fGlyphsToFlush = 0; 1545 flushInfo.fGlyphsToFlush = 0;
1545 size_t vertexStride = gp->getVertexStride(); 1546 size_t vertexStride = gp->getVertexStride();
1546 SkASSERT(vertexStride == (fUseDistanceFields ? 1547 SkASSERT(vertexStride == (fUseDistanceFields ?
1547 get_vertex_stride_df(fMaskFormat, fUseLCDText) : 1548 get_vertex_stride_df(fMaskFormat, fUseLCDText) :
1548 get_vertex_stride(fMaskFormat))); 1549 get_vertex_stride(fMaskFormat)));
1549 1550
1550 this->initDraw(batchTarget, gp, pipeline); 1551 batchTarget->initDraw(gp, pipeline);
1551 1552
1552 int glyphCount = this->numGlyphs(); 1553 int glyphCount = this->numGlyphs();
1553 int instanceCount = fInstanceCount; 1554 int instanceCount = fInstanceCount;
1554 const GrVertexBuffer* vertexBuffer; 1555 const GrVertexBuffer* vertexBuffer;
1555 1556
1556 void* vertices = batchTarget->makeVertSpace(vertexStride, 1557 void* vertices = batchTarget->makeVertSpace(vertexStride,
1557 glyphCount * kVerticesPerGly ph, 1558 glyphCount * kVerticesPerGly ph,
1558 &vertexBuffer, 1559 &vertexBuffer,
1559 &flushInfo.fVertexOffset); 1560 &flushInfo.fVertexOffset);
1560 flushInfo.fVertexBuffer.reset(SkRef(vertexBuffer)); 1561 flushInfo.fVertexBuffer.reset(SkRef(vertexBuffer));
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 glyph = blob->fGlyphs[glyphOffset]; 1651 glyph = blob->fGlyphs[glyphOffset];
1651 blob->fGlyphs[glyphOffset] = strike->getGlyph(glyph- >fPackedID, 1652 blob->fGlyphs[glyphOffset] = strike->getGlyph(glyph- >fPackedID,
1652 scaler ); 1653 scaler );
1653 } 1654 }
1654 glyph = blob->fGlyphs[glyphOffset]; 1655 glyph = blob->fGlyphs[glyphOffset];
1655 SkASSERT(glyph); 1656 SkASSERT(glyph);
1656 1657
1657 if (!fFontCache->hasGlyph(glyph) && 1658 if (!fFontCache->hasGlyph(glyph) &&
1658 !strike->addGlyphToAtlas(batchTarget, glyph, scaler) ) { 1659 !strike->addGlyphToAtlas(batchTarget, glyph, scaler) ) {
1659 this->flush(batchTarget, &flushInfo); 1660 this->flush(batchTarget, &flushInfo);
1660 this->initDraw(batchTarget, gp, pipeline); 1661 batchTarget->initDraw(gp, pipeline);
1661 brokenRun = glyphIdx > 0; 1662 brokenRun = glyphIdx > 0;
1662 1663
1663 SkDEBUGCODE(bool success =) strike->addGlyphToAtlas( batchTarget, 1664 SkDEBUGCODE(bool success =) strike->addGlyphToAtlas( batchTarget,
1664 glyph, 1665 glyph,
1665 scaler); 1666 scaler);
1666 SkASSERT(success); 1667 SkASSERT(success);
1667 } 1668 }
1668 fFontCache->addGlyphToBulkAndSetUseToken(&info.fBulkUseT oken, glyph, 1669 fFontCache->addGlyphToBulkAndSetUseToken(&info.fBulkUseT oken, glyph,
1669 batchTarget->cu rrentToken()); 1670 batchTarget->cu rrentToken());
1670 1671
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1842 void regeneratePositions(intptr_t vertex, size_t vertexStride, SkScalar tran sX, 1843 void regeneratePositions(intptr_t vertex, size_t vertexStride, SkScalar tran sX,
1843 SkScalar transY) { 1844 SkScalar transY) {
1844 for (int i = 0; i < kVerticesPerGlyph; i++) { 1845 for (int i = 0; i < kVerticesPerGlyph; i++) {
1845 SkPoint* point = reinterpret_cast<SkPoint*>(vertex); 1846 SkPoint* point = reinterpret_cast<SkPoint*>(vertex);
1846 point->fX += transX; 1847 point->fX += transX;
1847 point->fY += transY; 1848 point->fY += transY;
1848 vertex += vertexStride; 1849 vertex += vertexStride;
1849 } 1850 }
1850 } 1851 }
1851 1852
1852 void initDraw(GrBatchTarget* batchTarget,
1853 const GrGeometryProcessor* gp,
1854 const GrPipeline* pipeline) {
1855 batchTarget->initDraw(gp, pipeline);
1856
1857 // TODO remove this when batch is everywhere
1858 GrPipelineInfo init;
1859 init.fColorIgnored = fBatch.fColorIgnored;
1860 init.fOverrideColor = GrColor_ILLEGAL;
1861 init.fCoverageIgnored = fBatch.fCoverageIgnored;
1862 init.fUsesLocalCoords = this->usesLocalCoords();
1863 gp->initBatchTracker(batchTarget->currentBatchTracker(), init);
1864 }
1865
1866 void flush(GrBatchTarget* batchTarget, FlushInfo* flushInfo) { 1853 void flush(GrBatchTarget* batchTarget, FlushInfo* flushInfo) {
1867 GrVertices vertices; 1854 GrVertices vertices;
1868 int maxGlyphsPerDraw = flushInfo->fIndexBuffer->maxQuads(); 1855 int maxGlyphsPerDraw = flushInfo->fIndexBuffer->maxQuads();
1869 vertices.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuf fer, 1856 vertices.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuf fer,
1870 flushInfo->fIndexBuffer, flushInfo->fVertexOffset , 1857 flushInfo->fIndexBuffer, flushInfo->fVertexOffset ,
1871 kVerticesPerGlyph, kIndicesPerGlyph, flushInfo->f GlyphsToFlush, 1858 kVerticesPerGlyph, kIndicesPerGlyph, flushInfo->f GlyphsToFlush,
1872 maxGlyphsPerDraw); 1859 maxGlyphsPerDraw);
1873 batchTarget->draw(vertices); 1860 batchTarget->draw(vertices);
1874 flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlus h; 1861 flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlus h;
1875 flushInfo->fGlyphsToFlush = 0; 1862 flushInfo->fGlyphsToFlush = 0;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1985 GrDistanceFieldLCDTextGeoProc::DistanceAdjust widthAdjust = 1972 GrDistanceFieldLCDTextGeoProc::DistanceAdjust widthAdjust =
1986 GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(redCorrectio n, 1973 GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(redCorrectio n,
1987 greenCorrect ion, 1974 greenCorrect ion,
1988 blueCorrecti on); 1975 blueCorrecti on);
1989 1976
1990 return GrDistanceFieldLCDTextGeoProc::Create(color, 1977 return GrDistanceFieldLCDTextGeoProc::Create(color,
1991 viewMatrix, 1978 viewMatrix,
1992 texture, 1979 texture,
1993 params, 1980 params,
1994 widthAdjust, 1981 widthAdjust,
1995 flags); 1982 flags,
1983 this->usesLocalCoords() );
1996 } else { 1984 } else {
1997 flags |= kColorAttr_DistanceFieldEffectFlag; 1985 flags |= kColorAttr_DistanceFieldEffectFlag;
1998 #ifdef SK_GAMMA_APPLY_TO_A8 1986 #ifdef SK_GAMMA_APPLY_TO_A8
1999 U8CPU lum = SkColorSpaceLuminance::computeLuminance(fGamma, filtered Color); 1987 U8CPU lum = SkColorSpaceLuminance::computeLuminance(fGamma, filtered Color);
2000 float correction = (*fDistanceAdjustTable)[lum >> kDistanceAdjustLum Shift]; 1988 float correction = (*fDistanceAdjustTable)[lum >> kDistanceAdjustLum Shift];
2001 return GrDistanceFieldA8TextGeoProc::Create(color, 1989 return GrDistanceFieldA8TextGeoProc::Create(color,
2002 viewMatrix, 1990 viewMatrix,
2003 texture, 1991 texture,
2004 params, 1992 params,
2005 correction, 1993 correction,
2006 flags); 1994 flags,
1995 this->usesLocalCoords()) ;
2007 #else 1996 #else
2008 return GrDistanceFieldA8TextGeoProc::Create(color, 1997 return GrDistanceFieldA8TextGeoProc::Create(color,
2009 viewMatrix, 1998 viewMatrix,
2010 texture, 1999 texture,
2011 params, 2000 params,
2012 flags); 2001 flags,
2002 this->usesLocalCoords()) ;
2013 #endif 2003 #endif
2014 } 2004 }
2015 2005
2016 } 2006 }
2017 2007
2018 struct BatchTracker { 2008 struct BatchTracker {
2019 GrColor fColor; 2009 GrColor fColor;
2020 SkMatrix fViewMatrix; 2010 SkMatrix fViewMatrix;
2021 bool fUsesLocalCoords; 2011 bool fUsesLocalCoords;
2022 bool fColorIgnored; 2012 bool fColorIgnored;
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
2272 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text, 2262 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text,
2273 static_cast<size_t>(textLen), 0, 0, noClip)); 2263 static_cast<size_t>(textLen), 0, 0, noClip));
2274 2264
2275 SkScalar transX = static_cast<SkScalar>(random->nextU()); 2265 SkScalar transX = static_cast<SkScalar>(random->nextU());
2276 SkScalar transY = static_cast<SkScalar>(random->nextU()); 2266 SkScalar transY = static_cast<SkScalar>(random->nextU());
2277 const GrAtlasTextContext::BitmapTextBlob::Run::SubRunInfo& info = blob->fRun s[0].fSubRunInfo[0]; 2267 const GrAtlasTextContext::BitmapTextBlob::Run::SubRunInfo& info = blob->fRun s[0].fSubRunInfo[0];
2278 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint); 2268 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint);
2279 } 2269 }
2280 2270
2281 #endif 2271 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrAARectRenderer.cpp ('k') | src/gpu/GrBatchTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698