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

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

Issue 876673002: Hairline batch (Closed) Base URL: https://skia.googlesource.com/skia.git@2_defer
Patch Set: update 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
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 #ifndef GrBatchBuffer_DEFINED 8 #ifndef GrBatchBuffer_DEFINED
9 #define GrBatchBuffer_DEFINED 9 #define GrBatchBuffer_DEFINED
10 10
11 #include "GrPendingProgramElement.h" 11 #include "GrPendingProgramElement.h"
12 #include "GrGpu.h" 12 #include "GrGpu.h"
13 #include "GrTRecorder.h" 13 #include "GrTRecorder.h"
14 14
15 /* 15 /*
16 * GrBatch instances use this object to allocate space for their geometry and to issue the draws 16 * GrBatch instances use this object to allocate space for their geometry and to issue the draws
17 * that render their batch. 17 * that render their batch.
18 */ 18 */
19 19
20 class GrIndexBufferAllocPool;
21 class GrVertexBufferAllocPool;
22
20 class GrBatchTarget : public SkNoncopyable { 23 class GrBatchTarget : public SkNoncopyable {
21 public: 24 public:
22 GrBatchTarget(GrGpu* gpu, 25 GrBatchTarget(GrGpu* gpu,
23 GrVertexBufferAllocPool* vpool, 26 GrVertexBufferAllocPool* vpool,
24 GrIndexBufferAllocPool* ipool) 27 GrIndexBufferAllocPool* ipool)
25 : fGpu(gpu) 28 : fGpu(gpu)
26 , fVertexPool(vpool) 29 , fVertexPool(vpool)
27 , fIndexPool(ipool) 30 , fIndexPool(ipool)
28 , fFlushBuffer(kFlushBufferInitialSizeInBytes) 31 , fFlushBuffer(kFlushBufferInitialSizeInBytes)
29 , fIter(fFlushBuffer) {} 32 , fIter(fFlushBuffer) {}
30 33
31 typedef GrDrawTarget::DrawInfo DrawInfo; 34 typedef GrDrawTarget::DrawInfo DrawInfo;
32 void initDraw(const GrPrimitiveProcessor* primProc, const GrPipeline* pipeli ne) { 35 void initDraw(const GrPrimitiveProcessor* primProc, const GrPipeline* pipeli ne) {
33 GrNEW_APPEND_TO_RECORDER(fFlushBuffer, BufferedFlush, (primProc, pipelin e)); 36 GrNEW_APPEND_TO_RECORDER(fFlushBuffer, BufferedFlush, (primProc, pipelin e));
34 } 37 }
35 38
36 void draw(const GrDrawTarget::DrawInfo& draw) { 39 void draw(const GrDrawTarget::DrawInfo& draw) {
37 fFlushBuffer.back().fDraws.push_back(draw); 40 fFlushBuffer.back().fDraws.push_back(draw);
38 } 41 }
39 42
40 // TODO this is temporary until batch is everywhere 43 // TODO this is temporary until batch is everywhere
41 //void flush(); 44 //void flush();
42 void preFlush() { fIter = FlushBuffer::Iter(fFlushBuffer); } 45 void preFlush() { fIter = FlushBuffer::Iter(fFlushBuffer); }
43 void flushNext(); 46 void flushNext(int n);
44 void postFlush() { SkASSERT(!fIter.next()); fFlushBuffer.reset(); } 47 void postFlush() { SkASSERT(!fIter.next()); fFlushBuffer.reset(); }
45 48
46 // TODO This goes away when everything uses batch 49 // TODO This goes away when everything uses batch
47 GrBatchTracker* currentBatchTracker() { 50 GrBatchTracker* currentBatchTracker() {
48 SkASSERT(!fFlushBuffer.empty()); 51 SkASSERT(!fFlushBuffer.empty());
49 return &fFlushBuffer.back().fBatchTracker; 52 return &fFlushBuffer.back().fBatchTracker;
50 } 53 }
51 54
55 const GrDrawTargetCaps& caps() const { return *fGpu->caps(); }
56
52 GrVertexBufferAllocPool* vertexPool() { return fVertexPool; } 57 GrVertexBufferAllocPool* vertexPool() { return fVertexPool; }
53 GrIndexBufferAllocPool* indexPool() { return fIndexPool; } 58 GrIndexBufferAllocPool* indexPool() { return fIndexPool; }
54 59
55 private: 60 private:
56 GrGpu* fGpu; 61 GrGpu* fGpu;
57 GrVertexBufferAllocPool* fVertexPool; 62 GrVertexBufferAllocPool* fVertexPool;
58 GrIndexBufferAllocPool* fIndexPool; 63 GrIndexBufferAllocPool* fIndexPool;
59 64
60 typedef void* TBufferAlign; // This wouldn't be enough align if a command us ed long double. 65 typedef void* TBufferAlign; // This wouldn't be enough align if a command us ed long double.
61 66
(...skipping 15 matching lines...) Expand all
77 }; 82 };
78 83
79 typedef GrTRecorder<BufferedFlush, TBufferAlign> FlushBuffer; 84 typedef GrTRecorder<BufferedFlush, TBufferAlign> FlushBuffer;
80 85
81 FlushBuffer fFlushBuffer; 86 FlushBuffer fFlushBuffer;
82 // TODO this is temporary 87 // TODO this is temporary
83 FlushBuffer::Iter fIter; 88 FlushBuffer::Iter fIter;
84 }; 89 };
85 90
86 #endif 91 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698