OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 GrInOrderDrawBuffer_DEFINED | 8 #ifndef GrInOrderDrawBuffer_DEFINED |
9 #define GrInOrderDrawBuffer_DEFINED | 9 #define GrInOrderDrawBuffer_DEFINED |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 kClear_Cmd = 4, | 59 kClear_Cmd = 4, |
60 kCopySurface_Cmd = 5, | 60 kCopySurface_Cmd = 5, |
61 kDrawPath_Cmd = 6, | 61 kDrawPath_Cmd = 6, |
62 kDrawPaths_Cmd = 7, | 62 kDrawPaths_Cmd = 7, |
63 }; | 63 }; |
64 | 64 |
65 struct Cmd : ::SkNoncopyable { | 65 struct Cmd : ::SkNoncopyable { |
66 Cmd(uint8_t type) : fType(type) {} | 66 Cmd(uint8_t type) : fType(type) {} |
67 virtual ~Cmd() {} | 67 virtual ~Cmd() {} |
68 | 68 |
69 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) = 0; | 69 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*, const GrProgramDesc*) = 0; |
70 | 70 |
71 uint8_t fType; | 71 uint8_t fType; |
72 }; | 72 }; |
73 | 73 |
74 struct Draw : public Cmd { | 74 struct Draw : public Cmd { |
75 Draw(const DrawInfo& info) : Cmd(kDraw_Cmd), fInfo(info) {} | 75 Draw(const DrawInfo& info) : Cmd(kDraw_Cmd), fInfo(info) {} |
76 | 76 |
77 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; | 77 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*, const GrProgra mDesc*) SK_OVERRIDE; |
78 | 78 |
79 DrawInfo fInfo; | 79 DrawInfo fInfo; |
80 }; | 80 }; |
81 | 81 |
82 struct StencilPath : public Cmd { | 82 struct StencilPath : public Cmd { |
83 StencilPath(const GrPath* path) : Cmd(kStencilPath_Cmd), fPath(path) {} | 83 StencilPath(const GrPath* path) : Cmd(kStencilPath_Cmd), fPath(path) {} |
84 | 84 |
85 const GrPath* path() const { return fPath.get(); } | 85 const GrPath* path() const { return fPath.get(); } |
86 | 86 |
87 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; | 87 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*, const GrProgra mDesc*) SK_OVERRIDE; |
88 | 88 |
89 GrStencilSettings fStencilSettings; | 89 GrStencilSettings fStencilSettings; |
90 | 90 |
91 private: | 91 private: |
92 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; | 92 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; |
93 }; | 93 }; |
94 | 94 |
95 struct DrawPath : public Cmd { | 95 struct DrawPath : public Cmd { |
96 DrawPath(const GrPath* path) : Cmd(kDrawPath_Cmd), fPath(path) {} | 96 DrawPath(const GrPath* path) : Cmd(kDrawPath_Cmd), fPath(path) {} |
97 | 97 |
98 const GrPath* path() const { return fPath.get(); } | 98 const GrPath* path() const { return fPath.get(); } |
99 | 99 |
100 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; | 100 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*, const GrProgra mDesc*) SK_OVERRIDE; |
101 | 101 |
102 GrStencilSettings fStencilSettings; | 102 GrStencilSettings fStencilSettings; |
103 | 103 |
104 private: | 104 private: |
105 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; | 105 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; |
106 }; | 106 }; |
107 | 107 |
108 struct DrawPaths : public Cmd { | 108 struct DrawPaths : public Cmd { |
109 DrawPaths(const GrPathRange* pathRange) : Cmd(kDrawPaths_Cmd), fPathRang e(pathRange) {} | 109 DrawPaths(const GrPathRange* pathRange) : Cmd(kDrawPaths_Cmd), fPathRang e(pathRange) {} |
110 | 110 |
111 const GrPathRange* pathRange() const { return fPathRange.get(); } | 111 const GrPathRange* pathRange() const { return fPathRange.get(); } |
112 | 112 |
113 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; | 113 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*, const GrProgra mDesc*) SK_OVERRIDE; |
114 | 114 |
115 int fIndicesLocation; | 115 int fIndicesLocation; |
116 PathIndexType fIndexType; | 116 PathIndexType fIndexType; |
117 int fTransformsLocation; | 117 int fTransformsLocation; |
118 PathTransformType fTransformType; | 118 PathTransformType fTransformType; |
119 int fCount; | 119 int fCount; |
120 GrStencilSettings fStencilSettings; | 120 GrStencilSettings fStencilSettings; |
121 | 121 |
122 private: | 122 private: |
123 GrPendingIOResource<const GrPathRange, kRead_GrIOType> fPathRange; | 123 GrPendingIOResource<const GrPathRange, kRead_GrIOType> fPathRange; |
124 }; | 124 }; |
125 | 125 |
126 // This is also used to record a discard by setting the color to GrColor_ILL EGAL | 126 // This is also used to record a discard by setting the color to GrColor_ILL EGAL |
127 struct Clear : public Cmd { | 127 struct Clear : public Cmd { |
128 Clear(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt) {} | 128 Clear(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt) {} |
129 | 129 |
130 GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } | 130 GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } |
131 | 131 |
132 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; | 132 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*, const GrProgra mDesc*) SK_OVERRIDE; |
133 | 133 |
134 SkIRect fRect; | 134 SkIRect fRect; |
135 GrColor fColor; | 135 GrColor fColor; |
136 bool fCanIgnoreRect; | 136 bool fCanIgnoreRect; |
137 | 137 |
138 private: | 138 private: |
139 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | 139 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; |
140 }; | 140 }; |
141 | 141 |
142 // This command is ONLY used by the clip mask manager to clear the stencil c lip bits | 142 // This command is ONLY used by the clip mask manager to clear the stencil c lip bits |
143 struct ClearStencilClip : public Cmd { | 143 struct ClearStencilClip : public Cmd { |
144 ClearStencilClip(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt ) {} | 144 ClearStencilClip(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt ) {} |
145 | 145 |
146 GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } | 146 GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } |
147 | 147 |
148 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; | 148 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*, const GrProgra mDesc*) SK_OVERRIDE; |
149 | 149 |
150 SkIRect fRect; | 150 SkIRect fRect; |
151 bool fInsideClip; | 151 bool fInsideClip; |
152 | 152 |
153 private: | 153 private: |
154 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | 154 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; |
155 }; | 155 }; |
156 | 156 |
157 struct CopySurface : public Cmd { | 157 struct CopySurface : public Cmd { |
158 CopySurface(GrSurface* dst, GrSurface* src) : Cmd(kCopySurface_Cmd), fDs t(dst), fSrc(src) {} | 158 CopySurface(GrSurface* dst, GrSurface* src) : Cmd(kCopySurface_Cmd), fDs t(dst), fSrc(src) {} |
159 | 159 |
160 GrSurface* dst() const { return fDst.get(); } | 160 GrSurface* dst() const { return fDst.get(); } |
161 GrSurface* src() const { return fSrc.get(); } | 161 GrSurface* src() const { return fSrc.get(); } |
162 | 162 |
163 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; | 163 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*, const GrProgra mDesc*) SK_OVERRIDE; |
164 | 164 |
165 SkIPoint fDstPoint; | 165 SkIPoint fDstPoint; |
166 SkIRect fSrcRect; | 166 SkIRect fSrcRect; |
167 | 167 |
168 private: | 168 private: |
169 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; | 169 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; |
170 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; | 170 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; |
171 }; | 171 }; |
172 | 172 |
173 struct SetState : public Cmd { | 173 struct SetState : public Cmd { |
174 SetState(const GrDrawState& drawState, GrGpu* gpu, const ScissorState& s cissor, | 174 SetState(const GrDrawState& drawState, const GrDrawTargetCaps& caps, |
175 const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType drawType) | 175 const ScissorState& scissor, const GrDeviceCoordTexture* dstCop y, |
176 GrGpu::DrawType drawType) | |
176 : Cmd(kSetState_Cmd) | 177 : Cmd(kSetState_Cmd) |
177 , fState(drawState, gpu, scissor, dstCopy, drawType) {} | 178 , fState(drawState, caps, scissor, dstCopy, drawType) |
179 , fDrawType(drawType) {} | |
178 | 180 |
179 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; | 181 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*, const GrProgra mDesc*) SK_OVERRIDE; |
180 | 182 |
181 const GrOptDrawState fState; | 183 const GrOptDrawState fState; |
182 GrGpu::DrawType fDrawType; | 184 GrGpu::DrawType fDrawType; |
183 }; | 185 }; |
184 | 186 |
185 typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double. | 187 typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double. |
186 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; | 188 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; |
187 | 189 |
188 void onReset() SK_OVERRIDE; | 190 void onReset() SK_OVERRIDE; |
189 void onFlush() SK_OVERRIDE; | 191 void onFlush() SK_OVERRIDE; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 | 248 |
247 // TODO: Use a single allocator for commands and records | 249 // TODO: Use a single allocator for commands and records |
248 enum { | 250 enum { |
249 kCmdBufferInitialSizeInBytes = 8 * 1024, | 251 kCmdBufferInitialSizeInBytes = 8 * 1024, |
250 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's | 252 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's |
251 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms | 253 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms |
252 }; | 254 }; |
253 | 255 |
254 CmdBuffer fCmdBuffer; | 256 CmdBuffer fCmdBuffer; |
255 const GrOptDrawState* fPrevState; | 257 const GrOptDrawState* fPrevState; |
258 GrProgramDesc fDesc; | |
bsalomon
2014/12/03 18:41:07
shouldn't this be a local in onflush()?
| |
256 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; | 259 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; |
257 SkTDArray<char> fPathIndexBuffer; | 260 SkTDArray<char> fPathIndexBuffer; |
258 SkTDArray<float> fPathTransformBuffer; | 261 SkTDArray<float> fPathTransformBuffer; |
259 uint32_t fDrawID; | 262 uint32_t fDrawID; |
260 | 263 |
261 typedef GrFlushToGpuDrawTarget INHERITED; | 264 typedef GrFlushToGpuDrawTarget INHERITED; |
262 }; | 265 }; |
263 | 266 |
264 #endif | 267 #endif |
OLD | NEW |