| OLD | NEW |
| 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 Loading... |
| 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 GrBuffer* 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(
)); |
| 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 Loading... |
| 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 = | 184 int maxGlyphsPerDraw = flushInfo->fIndexBuffer->maxQuads(); |
| 185 static_cast<int>(flushInfo->fIndexBuffer->gpuMemorySize() / sizeof(uint1
6_t) / 6); | |
| 186 mesh.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer, | 185 mesh.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer, |
| 187 flushInfo->fIndexBuffer, flushInfo->fVertexOffset, | 186 flushInfo->fIndexBuffer, flushInfo->fVertexOffset, |
| 188 kVerticesPerGlyph, kIndicesPerGlyph, flushInfo->fGlyphsTo
Flush, | 187 kVerticesPerGlyph, kIndicesPerGlyph, flushInfo->fGlyphsTo
Flush, |
| 189 maxGlyphsPerDraw); | 188 maxGlyphsPerDraw); |
| 190 target->draw(mesh); | 189 target->draw(mesh); |
| 191 flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush; | 190 flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush; |
| 192 flushInfo->fGlyphsToFlush = 0; | 191 flushInfo->fGlyphsToFlush = 0; |
| 193 } | 192 } |
| 194 | 193 |
| 195 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 Loading... |
| 309 this->usesLocalCoords()); | 308 this->usesLocalCoords()); |
| 310 #endif | 309 #endif |
| 311 } | 310 } |
| 312 | 311 |
| 313 } | 312 } |
| 314 | 313 |
| 315 void GrBlobRegenHelper::flush() { | 314 void GrBlobRegenHelper::flush() { |
| 316 fBatch->flush(fTarget, fFlushInfo); | 315 fBatch->flush(fTarget, fFlushInfo); |
| 317 fTarget->initDraw(fGP); | 316 fTarget->initDraw(fGP); |
| 318 } | 317 } |
| OLD | NEW |