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

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: rebase + vulkan 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
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 = flushInfo->fIndexBuffer->gpuMemorySize() / sizeof(uin t16_t) / 6;
jvanverth1 2016/03/24 19:21:01 needs a cast to int
Chris Dalton 2016/03/24 21:12:06 Done.
185 mesh.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer, 185 mesh.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer,
186 flushInfo->fIndexBuffer, flushInfo->fVertexOffset, 186 flushInfo->fIndexBuffer, flushInfo->fVertexOffset,
187 kVerticesPerGlyph, kIndicesPerGlyph, flushInfo->fGlyphsTo Flush, 187 kVerticesPerGlyph, kIndicesPerGlyph, flushInfo->fGlyphsTo Flush,
188 maxGlyphsPerDraw); 188 maxGlyphsPerDraw);
189 target->draw(mesh); 189 target->draw(mesh);
190 flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush; 190 flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush;
191 flushInfo->fGlyphsToFlush = 0; 191 flushInfo->fGlyphsToFlush = 0;
192 } 192 }
193 193
194 bool GrAtlasTextBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) { 194 bool GrAtlasTextBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 this->usesLocalCoords()); 308 this->usesLocalCoords());
309 #endif 309 #endif
310 } 310 }
311 311
312 } 312 }
313 313
314 void GrBlobRegenHelper::flush() { 314 void GrBlobRegenHelper::flush() {
315 fBatch->flush(fTarget, fFlushInfo); 315 fBatch->flush(fTarget, fFlushInfo);
316 fTarget->initDraw(fGP); 316 fTarget->initDraw(fGP);
317 } 317 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698