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

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

Issue 1806983002: Update how we send draws to gpu backend to reduce state setting. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit 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/GrAAStrokeRectBatch.cpp ('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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 maskFormat, 109 maskFormat,
110 localMatrix, 110 localMatrix,
111 this->usesLocalCoords())); 111 this->usesLocalCoords()));
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, this->pipeline()); 119 target->initDraw(gp);
120 120
121 int glyphCount = this->numGlyphs(); 121 int glyphCount = this->numGlyphs();
122 const GrVertexBuffer* vertexBuffer; 122 const GrVertexBuffer* 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( ));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 173 }
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 GrVertices vertices; 183 GrMesh mesh;
184 int maxGlyphsPerDraw = flushInfo->fIndexBuffer->maxQuads(); 184 int maxGlyphsPerDraw = flushInfo->fIndexBuffer->maxQuads();
185 vertices.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->fGlyp hsToFlush, 187 kVerticesPerGlyph, kIndicesPerGlyph, flushInfo->fGlyphsTo Flush,
188 maxGlyphsPerDraw); 188 maxGlyphsPerDraw);
189 target->draw(vertices); 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) {
195 GrAtlasTextBatch* that = t->cast<GrAtlasTextBatch>(); 195 GrAtlasTextBatch* that = t->cast<GrAtlasTextBatch>();
196 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeli ne(), 196 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeli ne(),
197 that->bounds(), caps)) { 197 that->bounds(), caps)) {
198 return false; 198 return false;
199 } 199 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 params, 306 params,
307 flags, 307 flags,
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, fBatch->pipeline()); 316 fTarget->initDraw(fGP);
317 } 317 }
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAAStrokeRectBatch.cpp ('k') | src/gpu/batches/GrDefaultPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698