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

Side by Side Diff: src/gpu/batches/GrAtlasTextBatch.cpp

Issue 1825393002: Consolidate GPU buffer implementations (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: asserts Created 4 years, 9 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/batches/GrAtlasTextBatch.h ('k') | src/gpu/batches/GrDefaultPathRenderer.cpp » ('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 7
8 #include "GrAtlasTextBatch.h" 8 #include "GrAtlasTextBatch.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 112 }
113 113
114 FlushInfo flushInfo; 114 FlushInfo flushInfo;
115 flushInfo.fGlyphsToFlush = 0; 115 flushInfo.fGlyphsToFlush = 0;
116 size_t vertexStride = gp->getVertexStride(); 116 size_t vertexStride = gp->getVertexStride();
117 SkASSERT(vertexStride == GrAtlasTextBlob::GetVertexStride(maskFormat)); 117 SkASSERT(vertexStride == GrAtlasTextBlob::GetVertexStride(maskFormat));
118 118
119 target->initDraw(gp); 119 target->initDraw(gp);
120 120
121 int glyphCount = this->numGlyphs(); 121 int glyphCount = this->numGlyphs();
122 const GrVertexBuffer* vertexBuffer; 122 const GrBuffer* vertexBuffer;
123 123
124 void* vertices = target->makeVertexSpace(vertexStride, 124 void* vertices = target->makeVertexSpace(vertexStride,
125 glyphCount * kVerticesPerGlyph, 125 glyphCount * kVerticesPerGlyph,
126 &vertexBuffer, 126 &vertexBuffer,
127 &flushInfo.fVertexOffset); 127 &flushInfo.fVertexOffset);
128 flushInfo.fVertexBuffer.reset(SkRef(vertexBuffer)); 128 flushInfo.fVertexBuffer.reset(SkRef(vertexBuffer));
129 flushInfo.fIndexBuffer.reset(target->resourceProvider()->refQuadIndexBuffer( )); 129 flushInfo.fIndexBuffer.reset(target->resourceProvider()->refQuadIndexBuffer( ));
130 if (!vertices || !flushInfo.fVertexBuffer) { 130 if (!vertices || !flushInfo.fVertexBuffer) {
131 SkDebugf("Could not allocate vertices\n"); 131 SkDebugf("Could not allocate vertices\n");
132 return; 132 return;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 // Make sure to attach the last cache if applicable 175 // Make sure to attach the last cache if applicable
176 if (cache) { 176 if (cache) {
177 SkGlyphCache::AttachCache(cache); 177 SkGlyphCache::AttachCache(cache);
178 } 178 }
179 this->flush(target, &flushInfo); 179 this->flush(target, &flushInfo);
180 } 180 }
181 181
182 void GrAtlasTextBatch::flush(GrVertexBatch::Target* target, FlushInfo* flushInfo ) const { 182 void GrAtlasTextBatch::flush(GrVertexBatch::Target* target, FlushInfo* flushInfo ) const {
183 GrMesh mesh; 183 GrMesh mesh;
184 int maxGlyphsPerDraw = flushInfo->fIndexBuffer->maxQuads(); 184 int maxGlyphsPerDraw =
185 static_cast<int>(flushInfo->fIndexBuffer->gpuMemorySize() / sizeof(uint1 6_t) / 6);
185 mesh.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer, 186 mesh.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer,
186 flushInfo->fIndexBuffer, flushInfo->fVertexOffset, 187 flushInfo->fIndexBuffer, flushInfo->fVertexOffset,
187 kVerticesPerGlyph, kIndicesPerGlyph, flushInfo->fGlyphsTo Flush, 188 kVerticesPerGlyph, kIndicesPerGlyph, flushInfo->fGlyphsTo Flush,
188 maxGlyphsPerDraw); 189 maxGlyphsPerDraw);
189 target->draw(mesh); 190 target->draw(mesh);
190 flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush; 191 flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush;
191 flushInfo->fGlyphsToFlush = 0; 192 flushInfo->fGlyphsToFlush = 0;
192 } 193 }
193 194
194 bool GrAtlasTextBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) { 195 bool GrAtlasTextBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 this->usesLocalCoords()); 309 this->usesLocalCoords());
309 #endif 310 #endif
310 } 311 }
311 312
312 } 313 }
313 314
314 void GrBlobRegenHelper::flush() { 315 void GrBlobRegenHelper::flush() {
315 fBatch->flush(fTarget, fFlushInfo); 316 fBatch->flush(fTarget, fFlushInfo);
316 fTarget->initDraw(fGP); 317 fTarget->initDraw(fGP);
317 } 318 }
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAtlasTextBatch.h ('k') | src/gpu/batches/GrDefaultPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698