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

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

Issue 862823004: Revert of GrBatchPrototype (Closed) Base URL: https://skia.googlesource.com/skia.git@lc2
Patch Set: Created 5 years, 10 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/GrBatch.cpp ('k') | src/gpu/GrBatchTarget.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef GrBatchBuffer_DEFINED
9 #define GrBatchBuffer_DEFINED
10
11 #include "GrPendingProgramElement.h"
12 #include "GrGpu.h"
13 #include "GrTRecorder.h"
14
15 /*
16 * GrBatch instances use this object to allocate space for their geometry and to issue the draws
17 * that render their batch.
18 */
19
20 class GrBatchTarget : public SkNoncopyable {
21 public:
22 GrBatchTarget(GrGpu* gpu,
23 GrVertexBufferAllocPool* vpool,
24 GrIndexBufferAllocPool* ipool)
25 : fGpu(gpu)
26 , fVertexPool(vpool)
27 , fIndexPool(ipool)
28 , fFlushBuffer(kFlushBufferInitialSizeInBytes) {}
29
30 typedef GrDrawTarget::DrawInfo DrawInfo;
31 void initDraw(const GrPrimitiveProcessor* primProc, const GrPipeline* pipeli ne) {
32 GrNEW_APPEND_TO_RECORDER(fFlushBuffer, BufferedFlush, (primProc, pipelin e));
33 }
34
35 void draw(const GrDrawTarget::DrawInfo& draw) {
36 fFlushBuffer.back().fDraws.push_back(draw);
37 }
38 void flush();
39
40 // TODO This goes away when everything uses batch
41 GrBatchTracker* currentBatchTracker() {
42 SkASSERT(!fFlushBuffer.empty());
43 return &fFlushBuffer.back().fBatchTracker;
44 }
45
46 GrVertexBufferAllocPool* vertexPool() { return fVertexPool; }
47 GrIndexBufferAllocPool* indexPool() { return fIndexPool; }
48
49 private:
50 GrGpu* fGpu;
51 GrVertexBufferAllocPool* fVertexPool;
52 GrIndexBufferAllocPool* fIndexPool;
53
54 typedef void* TBufferAlign; // This wouldn't be enough align if a command us ed long double.
55
56 struct BufferedFlush {
57 BufferedFlush(const GrPrimitiveProcessor* primProc, const GrPipeline* pi peline)
58 : fPrimitiveProcessor(primProc)
59 , fPipeline(pipeline)
60 , fDraws(kDrawRecorderInitialSizeInBytes) {}
61 typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimi tiveProcessor;
62 ProgramPrimitiveProcessor fPrimitiveProcessor;
63 const GrPipeline* fPipeline;
64 GrBatchTracker fBatchTracker;
65 SkSTArray<4, DrawInfo, true> fDraws;
66 };
67
68 enum {
69 kFlushBufferInitialSizeInBytes = 8 * sizeof(BufferedFlush),
70 kDrawRecorderInitialSizeInBytes = 8 * sizeof(DrawInfo),
71 };
72
73 typedef GrTRecorder<BufferedFlush, TBufferAlign> FlushBuffer;
74
75 FlushBuffer fFlushBuffer;
76 };
77
78 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrBatch.cpp ('k') | src/gpu/GrBatchTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698