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

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

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

Powered by Google App Engine
This is Rietveld 408576698