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