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

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

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