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

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

Issue 1139753002: Refactor GrBufferAllocPools to use resource cache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix merge issue Created 5 years, 6 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/GrBatchTarget.h ('k') | src/gpu/GrBufferAllocPool.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 7
8 #include "GrBatchTarget.h" 8 #include "GrBatchTarget.h"
9 9
10 #include "GrBatchAtlas.h" 10 #include "GrBatchAtlas.h"
11 #include "GrPipeline.h" 11 #include "GrPipeline.h"
12 12
13 static const size_t DRAW_BUFFER_VBPOOL_BUFFER_SIZE = 1 << 15;
14 static const int DRAW_BUFFER_VBPOOL_PREALLOC_BUFFERS = 4;
15
16 static const size_t DRAW_BUFFER_IBPOOL_BUFFER_SIZE = 1 << 11;
17 static const int DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS = 4;
18
19 GrBatchTarget::GrBatchTarget(GrGpu* gpu) 13 GrBatchTarget::GrBatchTarget(GrGpu* gpu)
20 : fGpu(gpu) 14 : fGpu(gpu)
15 , fVertexPool(gpu)
16 , fIndexPool(gpu)
21 , fFlushBuffer(kFlushBufferInitialSizeInBytes) 17 , fFlushBuffer(kFlushBufferInitialSizeInBytes)
22 , fIter(fFlushBuffer) 18 , fIter(fFlushBuffer)
23 , fNumberOfDraws(0) 19 , fNumberOfDraws(0)
24 , fCurrentToken(0) 20 , fCurrentToken(0)
25 , fLastFlushedToken(0) 21 , fLastFlushedToken(0)
26 , fInlineUpdatesIndex(0) { 22 , fInlineUpdatesIndex(0) {
27
28 fVertexPool.reset(SkNEW_ARGS(GrVertexBufferAllocPool, (fGpu,
29 DRAW_BUFFER_VBPOOL_BUFFER_SIZE,
30 DRAW_BUFFER_VBPOOL_PREALLOC_BUFFERS )));
31 fIndexPool.reset(SkNEW_ARGS(GrIndexBufferAllocPool, (fGpu,
32 DRAW_BUFFER_IBPOOL_BUFFER_SIZE,
33 DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS) ));
34 } 23 }
35 24
36 void GrBatchTarget::flushNext(int n) { 25 void GrBatchTarget::flushNext(int n) {
37 for (; n > 0; n--) { 26 for (; n > 0; n--) {
38 fLastFlushedToken++; 27 fLastFlushedToken++;
39 SkDEBUGCODE(bool verify =) fIter.next(); 28 SkDEBUGCODE(bool verify =) fIter.next();
40 SkASSERT(verify); 29 SkASSERT(verify);
41 30
42 BufferedFlush* bf = fIter.get(); 31 BufferedFlush* bf = fIter.get();
43 32
(...skipping 14 matching lines...) Expand all
58 int drawCount = bf->fVertexDraws.count(); 47 int drawCount = bf->fVertexDraws.count();
59 const SkSTArray<1, GrVertices, true>& vertexDraws = bf->fVertexDraws; 48 const SkSTArray<1, GrVertices, true>& vertexDraws = bf->fVertexDraws;
60 for (int i = 0; i < drawCount; i++) { 49 for (int i = 0; i < drawCount; i++) {
61 fGpu->draw(args, vertexDraws[i]); 50 fGpu->draw(args, vertexDraws[i]);
62 } 51 }
63 } 52 }
64 } 53 }
65 54
66 void* GrBatchTarget::makeVertSpace(size_t vertexSize, int vertexCount, 55 void* GrBatchTarget::makeVertSpace(size_t vertexSize, int vertexCount,
67 const GrVertexBuffer** buffer, int* startVertex) { 56 const GrVertexBuffer** buffer, int* startVertex) {
68 return fVertexPool->makeSpace(vertexSize, vertexCount, buffer, startVertex); 57 return fVertexPool.makeSpace(vertexSize, vertexCount, buffer, startVertex);
69 } 58 }
70 59
71 uint16_t* GrBatchTarget::makeIndexSpace(int indexCount, 60 uint16_t* GrBatchTarget::makeIndexSpace(int indexCount,
72 const GrIndexBuffer** buffer, int* start Index) { 61 const GrIndexBuffer** buffer, int* start Index) {
73 return reinterpret_cast<uint16_t*>(fIndexPool->makeSpace(indexCount, buffer, startIndex)); 62 return reinterpret_cast<uint16_t*>(fIndexPool.makeSpace(indexCount, buffer, startIndex));
74 } 63 }
75 64
OLDNEW
« no previous file with comments | « src/gpu/GrBatchTarget.h ('k') | src/gpu/GrBufferAllocPool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698