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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, GrColor color, uint8_t coverage, | 174 SetState(const GrDrawState& drawState, const GrGeometryProcessor* gp, |
175 const GrDrawTargetCaps& caps, const ScissorState& scissor, | 175 const GrPathProcessor* pp, const GrDrawTargetCaps& caps, |
176 const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType drawType) | 176 const ScissorState& scissor, const GrDeviceCoordTexture* dstCop
y, |
| 177 GrGpu::DrawType drawType) |
177 : Cmd(kSetState_Cmd) | 178 : Cmd(kSetState_Cmd) |
178 , fState(drawState, color, coverage, caps, scissor, dstCopy, drawType) {
} | 179 , fState(drawState, gp, pp, caps, scissor, dstCopy, drawType) {} |
179 | 180 |
180 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; | 181 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; |
181 | 182 |
182 GrOptDrawState fState; | 183 GrOptDrawState fState; |
183 }; | 184 }; |
184 | 185 |
185 typedef void* TCmdAlign; // This wouldn't be enough align if a command used
long double. | 186 typedef void* TCmdAlign; // This wouldn't be enough align if a command used
long double. |
186 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; | 187 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; |
187 | 188 |
188 void onReset() SK_OVERRIDE; | 189 void onReset() SK_OVERRIDE; |
189 void onFlush() SK_OVERRIDE; | 190 void onFlush() SK_OVERRIDE; |
190 | 191 |
191 // overrides from GrDrawTarget | 192 // overrides from GrDrawTarget |
192 void onDraw(const GrDrawState&, | 193 void onDraw(const GrDrawState&, |
| 194 const GrGeometryProcessor*, |
193 const DrawInfo&, | 195 const DrawInfo&, |
194 const ScissorState&, | 196 const ScissorState&, |
195 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; | 197 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; |
196 void onDrawRect(GrDrawState*, | 198 void onDrawRect(GrDrawState*, |
197 GrColor, | 199 GrColor, |
198 const SkRect& rect, | 200 const SkRect& rect, |
199 const SkRect* localRect, | 201 const SkRect* localRect, |
200 const SkMatrix* localMatrix) SK_OVERRIDE; | 202 const SkMatrix* localMatrix) SK_OVERRIDE; |
201 | 203 |
202 void onStencilPath(const GrDrawState&, | 204 void onStencilPath(const GrDrawState&, |
| 205 const GrPathProcessor*, |
203 const GrPath*, | 206 const GrPath*, |
204 const ScissorState&, | 207 const ScissorState&, |
205 const GrStencilSettings&) SK_OVERRIDE; | 208 const GrStencilSettings&) SK_OVERRIDE; |
206 void onDrawPath(const GrDrawState&, | 209 void onDrawPath(const GrDrawState&, |
207 GrColor, | 210 const GrPathProcessor*, |
208 const GrPath*, | 211 const GrPath*, |
209 const ScissorState&, | 212 const ScissorState&, |
210 const GrStencilSettings&, | 213 const GrStencilSettings&, |
211 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; | 214 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; |
212 void onDrawPaths(const GrDrawState&, | 215 void onDrawPaths(const GrDrawState&, |
213 GrColor, | 216 const GrPathProcessor*, |
214 const GrPathRange*, | 217 const GrPathRange*, |
215 const void* indices, | 218 const void* indices, |
216 PathIndexType, | 219 PathIndexType, |
217 const float transformValues[], | 220 const float transformValues[], |
218 PathTransformType, | 221 PathTransformType, |
219 int count, | 222 int count, |
220 const ScissorState&, | 223 const ScissorState&, |
221 const GrStencilSettings&, | 224 const GrStencilSettings&, |
222 const GrDeviceCoordTexture*) SK_OVERRIDE; | 225 const GrDeviceCoordTexture*) SK_OVERRIDE; |
223 void onClear(const SkIRect* rect, | 226 void onClear(const SkIRect* rect, |
224 GrColor color, | 227 GrColor color, |
225 bool canIgnoreRect, | 228 bool canIgnoreRect, |
226 GrRenderTarget* renderTarget) SK_OVERRIDE; | 229 GrRenderTarget* renderTarget) SK_OVERRIDE; |
227 bool onCopySurface(GrSurface* dst, | 230 bool onCopySurface(GrSurface* dst, |
228 GrSurface* src, | 231 GrSurface* src, |
229 const SkIRect& srcRect, | 232 const SkIRect& srcRect, |
230 const SkIPoint& dstPoint) SK_OVERRIDE; | 233 const SkIPoint& dstPoint) SK_OVERRIDE; |
231 | 234 |
232 // Attempts to concat instances from info onto the previous draw. info must
represent an | 235 // Attempts to concat instances from info onto the previous draw. info must
represent an |
233 // instanced draw. The caller must have already recorded a new draw state an
d clip if necessary. | 236 // instanced draw. The caller must have already recorded a new draw state an
d clip if necessary. |
234 int concatInstancedDraw(const GrDrawState&, const DrawInfo&); | 237 int concatInstancedDraw(const GrDrawState&, const DrawInfo&); |
235 | 238 |
236 // Determines whether the current draw operation requires a new GrOptDrawSta
te and if so | 239 // Determines whether the current draw operation requires a new GrOptDrawSta
te and if so |
237 // records it. If the draw can be skipped false is returned and no new GrOpt
DrawState is | 240 // records it. If the draw can be skipped false is returned and no new GrOpt
DrawState is |
238 // recorded. | 241 // recorded. |
239 bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrDrawState&, | 242 bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrDrawState&, |
240 GrColor, | 243 const GrGeometryProcesso
r*, |
241 uint8_t coverage, | 244 const GrPathProcessor*, |
242 GrGpu::DrawType, | 245 GrGpu::DrawType, |
243 const GrClipMaskManager:
:ScissorState&, | 246 const GrClipMaskManager:
:ScissorState&, |
244 const GrDeviceCoordTextu
re*); | 247 const GrDeviceCoordTextu
re*); |
245 // We lazily record clip changes in order to skip clips that have no effect. | 248 // We lazily record clip changes in order to skip clips that have no effect. |
246 void recordClipIfNecessary(); | 249 void recordClipIfNecessary(); |
247 // Records any trace markers for a command after adding it to the buffer. | 250 // Records any trace markers for a command after adding it to the buffer. |
248 void recordTraceMarkersIfNecessary(); | 251 void recordTraceMarkersIfNecessary(); |
249 | 252 |
250 virtual bool isIssued(uint32_t drawID) { return drawID != fDrawID; } | 253 virtual bool isIssued(uint32_t drawID) { return drawID != fDrawID; } |
251 | 254 |
252 // TODO: Use a single allocator for commands and records | 255 // TODO: Use a single allocator for commands and records |
253 enum { | 256 enum { |
254 kCmdBufferInitialSizeInBytes = 8 * 1024, | 257 kCmdBufferInitialSizeInBytes = 8 * 1024, |
255 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's | 258 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's |
256 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms | 259 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms |
257 }; | 260 }; |
258 | 261 |
259 CmdBuffer fCmdBuffer; | 262 CmdBuffer fCmdBuffer; |
260 const GrOptDrawState* fPrevState; | 263 const GrOptDrawState* fPrevState; |
261 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; | 264 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; |
262 SkTDArray<char> fPathIndexBuffer; | 265 SkTDArray<char> fPathIndexBuffer; |
263 SkTDArray<float> fPathTransformBuffer; | 266 SkTDArray<float> fPathTransformBuffer; |
264 uint32_t fDrawID; | 267 uint32_t fDrawID; |
265 | 268 |
266 typedef GrFlushToGpuDrawTarget INHERITED; | 269 typedef GrFlushToGpuDrawTarget INHERITED; |
267 }; | 270 }; |
268 | 271 |
269 #endif | 272 #endif |
OLD | NEW |