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

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

Issue 1315563003: GrPathRangeBatch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix init order warning Created 5 years, 3 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/GrStencilAndCoverTextContext.cpp ('k') | src/gpu/GrTargetCommands.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 #ifndef GrTargetCommands_DEFINED 8 #ifndef GrTargetCommands_DEFINED
9 #define GrTargetCommands_DEFINED 9 #define GrTargetCommands_DEFINED
10 10
(...skipping 12 matching lines...) Expand all
23 class GrBatchFlushState; 23 class GrBatchFlushState;
24 24
25 // TODO: Convert all commands into GrBatch and remove this class. 25 // TODO: Convert all commands into GrBatch and remove this class.
26 class GrTargetCommands : ::SkNoncopyable { 26 class GrTargetCommands : ::SkNoncopyable {
27 public: 27 public:
28 GrTargetCommands() : fCmdBuffer(kCmdBufferInitialSizeInBytes), fLastFlushTok en(0) {} 28 GrTargetCommands() : fCmdBuffer(kCmdBufferInitialSizeInBytes), fLastFlushTok en(0) {}
29 29
30 class Cmd : ::SkNoncopyable { 30 class Cmd : ::SkNoncopyable {
31 public: 31 public:
32 enum CmdType { 32 enum CmdType {
33 kDrawPath_CmdType = 2,
34 kDrawPaths_CmdType = 3,
35 kDrawBatch_CmdType = 4, 33 kDrawBatch_CmdType = 4,
36 }; 34 };
37 35
38 Cmd(CmdType type) 36 Cmd(CmdType type)
39 : fType(type) 37 : fType(type)
40 #if GR_BATCH_SPEW 38 #if GR_BATCH_SPEW
41 , fUniqueID(GenID(&gUniqueID)) 39 , fUniqueID(GenID(&gUniqueID))
42 #endif 40 #endif
43 {} 41 {}
44 virtual ~Cmd() {} 42 virtual ~Cmd() {}
(...skipping 21 matching lines...) Expand all
66 void reset(); 64 void reset();
67 void flush(GrGpu*, GrResourceProvider*); 65 void flush(GrGpu*, GrResourceProvider*);
68 66
69 private: 67 private:
70 friend class GrCommandBuilder; 68 friend class GrCommandBuilder;
71 friend class GrBufferedDrawTarget; // This goes away when State becomes just a pipeline 69 friend class GrBufferedDrawTarget; // This goes away when State becomes just a pipeline
72 friend class GrReorderCommandBuilder; 70 friend class GrReorderCommandBuilder;
73 71
74 typedef GrGpu::DrawArgs DrawArgs; 72 typedef GrGpu::DrawArgs DrawArgs;
75 73
76 // TODO: This can be just a pipeline once paths are in batch, and it should live elsewhere
77 struct StateForPathDraw : public SkNVRefCnt<StateForPathDraw> {
78 // TODO get rid of the prim proc parameter when we use batch everywhere
79 StateForPathDraw(const GrPrimitiveProcessor* primProc = nullptr)
80 : fPrimitiveProcessor(primProc)
81 , fCompiled(false) {}
82
83 ~StateForPathDraw() { reinterpret_cast<GrPipeline*>(fPipeline.get())->~G rPipeline(); }
84
85 // This function is only for getting the location in memory where we wil l create our
86 // pipeline object.
87 void* pipelineLocation() { return fPipeline.get(); }
88
89 const GrPipeline* getPipeline() const {
90 return reinterpret_cast<const GrPipeline*>(fPipeline.get());
91 }
92 GrRenderTarget* getRenderTarget() const {
93 return this->getPipeline()->getRenderTarget();
94 }
95 const GrXferProcessor* getXferProcessor() const {
96 return this->getPipeline()->getXferProcessor();
97 }
98
99 void operator delete(void* p) {}
100 void* operator new(size_t) {
101 SkFAIL("All States are created by placement new.");
102 return sk_malloc_throw(0);
103 }
104
105 void* operator new(size_t, void* p) { return p; }
106 void operator delete(void* target, void* placement) {
107 ::operator delete(target, placement);
108 }
109
110 typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimi tiveProcessor;
111 ProgramPrimitiveProcessor fPrimitiveProcessor;
112 SkAlignedSStorage<sizeof(GrPipeline)> fPipeline;
113 GrProgramDesc fDesc;
114 GrBatchTracker fBatchTracker;
115 bool fCompiled;
116 };
117 // TODO remove this when State is just a pipeline
118 friend SkNVRefCnt<StateForPathDraw>;
119
120 struct DrawPath : public Cmd {
121 DrawPath(StateForPathDraw* state, const GrPath* path)
122 : Cmd(kDrawPath_CmdType)
123 , fState(SkRef(state))
124 , fPath(path) {}
125
126 const GrPath* path() const { return fPath.get(); }
127
128 void execute(GrBatchFlushState*) override;
129
130 SkAutoTUnref<StateForPathDraw> fState;
131 GrStencilSettings fStencilSettings;
132 private:
133 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
134 };
135
136 struct DrawPaths : public Cmd {
137 DrawPaths(StateForPathDraw* state, const GrPathRange* pathRange)
138 : Cmd(kDrawPaths_CmdType)
139 , fState(SkRef(state))
140 , fPathRange(pathRange) {}
141
142 const GrPathRange* pathRange() const { return fPathRange.get(); }
143
144 void execute(GrBatchFlushState*) override;
145
146 SkAutoTUnref<StateForPathDraw> fState;
147 char* fIndices;
148 GrDrawTarget::PathIndexType fIndexType;
149 float* fTransforms;
150 GrDrawTarget::PathTransformType fTransformType;
151 int fCount;
152 GrStencilSettings fStencilSettings;
153
154 private:
155 GrPendingIOResource<const GrPathRange, kRead_GrIOType> fPathRange;
156 };
157
158 struct DrawBatch : public Cmd { 74 struct DrawBatch : public Cmd {
159 DrawBatch(GrBatch* batch) 75 DrawBatch(GrBatch* batch)
160 : Cmd(kDrawBatch_CmdType) 76 : Cmd(kDrawBatch_CmdType)
161 , fBatch(SkRef(batch)){ 77 , fBatch(SkRef(batch)){
162 SkASSERT(!batch->isUsed()); 78 SkASSERT(!batch->isUsed());
163 } 79 }
164 80
165 GrBatch* batch() { return fBatch; } 81 GrBatch* batch() { return fBatch; }
166 void execute(GrBatchFlushState*) override; 82 void execute(GrBatchFlushState*) override;
167 83
168 private: 84 private:
169 SkAutoTUnref<GrBatch> fBatch; 85 SkAutoTUnref<GrBatch> fBatch;
170 }; 86 };
171 87
172 static const int kCmdBufferInitialSizeInBytes = 8 * 1024; 88 static const int kCmdBufferInitialSizeInBytes = 8 * 1024;
173 89
174 typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double. 90 typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double.
175 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; 91 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer;
176 92
177 CmdBuffer* cmdBuffer() { return &fCmdBuffer; } 93 CmdBuffer* cmdBuffer() { return &fCmdBuffer; }
178 94
179 CmdBuffer fCmdBuffer; 95 CmdBuffer fCmdBuffer;
180 GrBatchToken fLastFlushToken; 96 GrBatchToken fLastFlushToken;
181 }; 97 };
182 98
183 #endif 99 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrStencilAndCoverTextContext.cpp ('k') | src/gpu/GrTargetCommands.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698