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

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

Issue 845103005: GrBatchPrototype (Closed) Base URL: https://skia.googlesource.com/skia.git@lc2
Patch Set: update devrect Created 5 years, 11 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
(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 * GrBatchBuffer is a simple class which lets GrDrawTarget subclasses defer flus hing of batched
17 * Geometry for performance reasons.
18 */
19
20 class GrBatchBuffer : public SkNoncopyable {
21 public:
22 GrBatchBuffer(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*, const GrOptDrawState*);
32 void draw(const GrDrawTarget::DrawInfo&);
33 void flush();
34
35 // TODO This goes away when everything uses batch
36 GrBatchTracker* currentBatchTracker() {
37 SkASSERT(!fFlushBuffer.empty());
38 return &fFlushBuffer.back().fBatchTracker;
39 }
40
41 GrVertexBufferAllocPool* vertexPool() { return fVertexPool; }
42 GrIndexBufferAllocPool* indexPool() { return fIndexPool; }
43
44 private:
45 GrGpu* fGpu;
46 GrVertexBufferAllocPool* fVertexPool;
47 GrIndexBufferAllocPool* fIndexPool;
48
49 typedef void* TBufferAlign; // This wouldn't be enough align if a command us ed long double.
50 typedef GrTRecorder<GrDrawTarget::DrawInfo, TBufferAlign> DrawRecorder;
51
52 struct BufferedFlush {
53 BufferedFlush(const GrPrimitiveProcessor* primProc, const GrOptDrawState * optState)
54 : fPrimitiveProcessor(primProc)
55 , fOptState(optState)
56 , fDraws(kDrawRecorderInitialSizeInBytes) {}
57 typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimi tiveProcessor;
58 ProgramPrimitiveProcessor fPrimitiveProcessor;
59 const GrOptDrawState* fOptState;
60 GrBatchTracker fBatchTracker;
61 DrawRecorder fDraws;
62 };
63
64 enum {
65 kFlushBufferInitialSizeInBytes = 8 * sizeof(BufferedFlush),
66 kDrawRecorderInitialSizeInBytes = 8 * sizeof(DrawInfo),
67 };
68
69 typedef GrTRecorder<BufferedFlush, TBufferAlign> FlushBuffer;
70
71 FlushBuffer fFlushBuffer;
72 };
73
74 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698