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

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

Issue 1116943004: Move instanced index buffer creation to flush time (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix missing assignment of keys to index buffers 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/GrAddPathRenderers_default.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"
11 #include "GrBatchTarget.h" 11 #include "GrBatchTarget.h"
12 #include "GrDefaultGeoProcFactory.h" 12 #include "GrDefaultGeoProcFactory.h"
13 #include "GrDrawTarget.h" 13 #include "GrDrawTarget.h"
14 #include "GrFontScaler.h" 14 #include "GrFontScaler.h"
15 #include "GrIndexBuffer.h" 15 #include "GrIndexBuffer.h"
16 #include "GrResourceProvider.h"
16 #include "GrStrokeInfo.h" 17 #include "GrStrokeInfo.h"
17 #include "GrTextBlobCache.h" 18 #include "GrTextBlobCache.h"
18 #include "GrTexturePriv.h" 19 #include "GrTexturePriv.h"
19 #include "GrVertexBuffer.h" 20 #include "GrVertexBuffer.h"
20 21
21 #include "SkAutoKern.h" 22 #include "SkAutoKern.h"
22 #include "SkColorPriv.h" 23 #include "SkColorPriv.h"
23 #include "SkColorFilter.h" 24 #include "SkColorFilter.h"
24 #include "SkDistanceFieldGen.h" 25 #include "SkDistanceFieldGen.h"
25 #include "SkDraw.h" 26 #include "SkDraw.h"
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 1508
1508 size_t vertexStride = gp->getVertexStride(); 1509 size_t vertexStride = gp->getVertexStride();
1509 SkASSERT(vertexStride == (fUseDistanceFields ? 1510 SkASSERT(vertexStride == (fUseDistanceFields ?
1510 get_vertex_stride_df(fMaskFormat, fUseLCDText) : 1511 get_vertex_stride_df(fMaskFormat, fUseLCDText) :
1511 get_vertex_stride(fMaskFormat))); 1512 get_vertex_stride(fMaskFormat)));
1512 1513
1513 this->initDraw(batchTarget, gp, pipeline); 1514 this->initDraw(batchTarget, gp, pipeline);
1514 1515
1515 int glyphCount = this->numGlyphs(); 1516 int glyphCount = this->numGlyphs();
1516 int instanceCount = fInstanceCount; 1517 int instanceCount = fInstanceCount;
1518 SkAutoTUnref<const GrIndexBuffer> indexBuffer(
1519 batchTarget->resourceProvider()->refQuadIndexBuffer());
1520
1517 const GrVertexBuffer* vertexBuffer; 1521 const GrVertexBuffer* vertexBuffer;
1518 int firstVertex; 1522 int firstVertex;
1519
1520 void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, 1523 void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride,
1521 glyphCount * kVert icesPerGlyph, 1524 glyphCount * kVert icesPerGlyph,
1522 &vertexBuffer, 1525 &vertexBuffer,
1523 &firstVertex); 1526 &firstVertex);
1524 if (!vertices) { 1527 if (!vertices || !indexBuffer) {
1525 SkDebugf("Could not allocate vertices\n"); 1528 SkDebugf("Could not allocate vertices\n");
1526 return; 1529 return;
1527 } 1530 }
1528 1531
1529 unsigned char* currVertex = reinterpret_cast<unsigned char*>(vertices); 1532 unsigned char* currVertex = reinterpret_cast<unsigned char*>(vertices);
1530 1533
1531 // setup drawinfo 1534 // setup drawinfo
1532 const GrIndexBuffer* quadIndexBuffer = batchTarget->quadIndexBuffer(); 1535 int maxInstancesPerDraw = indexBuffer->maxQuads();
1533 int maxInstancesPerDraw = quadIndexBuffer->maxQuads();
1534 1536
1535 GrDrawTarget::DrawInfo drawInfo; 1537 GrDrawTarget::DrawInfo drawInfo;
1536 drawInfo.setPrimitiveType(kTriangles_GrPrimitiveType); 1538 drawInfo.setPrimitiveType(kTriangles_GrPrimitiveType);
1537 drawInfo.setStartVertex(0); 1539 drawInfo.setStartVertex(0);
1538 drawInfo.setStartIndex(0); 1540 drawInfo.setStartIndex(0);
1539 drawInfo.setVerticesPerInstance(kVerticesPerGlyph); 1541 drawInfo.setVerticesPerInstance(kVerticesPerGlyph);
1540 drawInfo.setIndicesPerInstance(kIndicesPerGlyph); 1542 drawInfo.setIndicesPerInstance(kIndicesPerGlyph);
1541 drawInfo.adjustStartVertex(firstVertex); 1543 drawInfo.adjustStartVertex(firstVertex);
1542 drawInfo.setVertexBuffer(vertexBuffer); 1544 drawInfo.setVertexBuffer(vertexBuffer);
1543 drawInfo.setIndexBuffer(quadIndexBuffer); 1545 drawInfo.setIndexBuffer(indexBuffer);
1544 1546
1545 // We cache some values to avoid going to the glyphcache for the same fo ntScaler twice 1547 // We cache some values to avoid going to the glyphcache for the same fo ntScaler twice
1546 // in a row 1548 // in a row
1547 const SkDescriptor* desc = NULL; 1549 const SkDescriptor* desc = NULL;
1548 SkGlyphCache* cache = NULL; 1550 SkGlyphCache* cache = NULL;
1549 GrFontScaler* scaler = NULL; 1551 GrFontScaler* scaler = NULL;
1550 SkTypeface* typeface = NULL; 1552 SkTypeface* typeface = NULL;
1551 1553
1552 int instancesToFlush = 0; 1554 int instancesToFlush = 0;
1553 for (int i = 0; i < instanceCount; i++) { 1555 for (int i = 0; i < instanceCount; i++) {
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
2159 pipelineBuilder.setFromPaint(grPaint, rt, clip); 2161 pipelineBuilder.setFromPaint(grPaint, rt, clip);
2160 2162
2161 GrColor color = grPaint.getColor(); 2163 GrColor color = grPaint.getColor();
2162 for (int run = 0; run < cacheBlob->fRunCount; run++) { 2164 for (int run = 0; run < cacheBlob->fRunCount; run++) {
2163 this->flushRun(target, &pipelineBuilder, cacheBlob, run, color, 0, 0, sk Paint); 2165 this->flushRun(target, &pipelineBuilder, cacheBlob, run, color, 0, 0, sk Paint);
2164 } 2166 }
2165 2167
2166 // Now flush big glyphs 2168 // Now flush big glyphs
2167 this->flushBigGlyphs(cacheBlob, rt, grPaint, clip, 0, 0); 2169 this->flushBigGlyphs(cacheBlob, rt, grPaint, clip, 0, 0);
2168 } 2170 }
OLDNEW
« no previous file with comments | « src/gpu/GrAddPathRenderers_default.cpp ('k') | src/gpu/GrBatchTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698