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

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: clean up Created 5 years, 7 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 "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)
21 , fFlushBuffer(kFlushBufferInitialSizeInBytes) 15 , fFlushBuffer(kFlushBufferInitialSizeInBytes)
22 , fIter(fFlushBuffer) 16 , fIter(fFlushBuffer)
23 , fNumberOfDraws(0) 17 , fNumberOfDraws(0)
24 , fCurrentToken(0) 18 , fCurrentToken(0)
25 , fLastFlushedToken(0) 19 , fLastFlushedToken(0)
26 , fInlineUpdatesIndex(0) { 20 , fInlineUpdatesIndex(0) {
27 21
28 fVertexPool.reset(SkNEW_ARGS(GrVertexBufferAllocPool, (fGpu, 22 fVertexPool.reset(SkNEW_ARGS(GrVertexBufferAllocPool, (fGpu)));
bsalomon 2015/05/13 16:24:07 need to be dynamic?
robertphillips 2015/05/13 16:56:14 Done.
29 DRAW_BUFFER_VBPOOL_BUFFER_SIZE, 23 fIndexPool.reset(SkNEW_ARGS(GrIndexBufferAllocPool, (fGpu)));
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 } 24 }
35 25
36 void GrBatchTarget::flushNext(int n) { 26 void GrBatchTarget::flushNext(int n) {
37 for (; n > 0; n--) { 27 for (; n > 0; n--) {
38 fLastFlushedToken++; 28 fLastFlushedToken++;
39 SkDEBUGCODE(bool verify =) fIter.next(); 29 SkDEBUGCODE(bool verify =) fIter.next();
40 SkASSERT(verify); 30 SkASSERT(verify);
41 31
42 BufferedFlush* bf = fIter.get(); 32 BufferedFlush* bf = fIter.get();
43 33
(...skipping 22 matching lines...) Expand all
66 void* GrBatchTarget::makeVertSpace(size_t vertexSize, int vertexCount, 56 void* GrBatchTarget::makeVertSpace(size_t vertexSize, int vertexCount,
67 const GrVertexBuffer** buffer, int* startVertex) { 57 const GrVertexBuffer** buffer, int* startVertex) {
68 return fVertexPool->makeSpace(vertexSize, vertexCount, buffer, startVertex); 58 return fVertexPool->makeSpace(vertexSize, vertexCount, buffer, startVertex);
69 } 59 }
70 60
71 uint16_t* GrBatchTarget::makeIndexSpace(int indexCount, 61 uint16_t* GrBatchTarget::makeIndexSpace(int indexCount,
72 const GrIndexBuffer** buffer, int* start Index) { 62 const GrIndexBuffer** buffer, int* start Index) {
73 return reinterpret_cast<uint16_t*>(fIndexPool->makeSpace(indexCount, buffer, startIndex)); 63 return reinterpret_cast<uint16_t*>(fIndexPool->makeSpace(indexCount, buffer, startIndex));
74 } 64 }
75 65
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698