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 GrDrawTargetCaps& caps, | 174 SetState(const GrDrawState& drawState, GrColor color, uint8_t coverage, |
175 const ScissorState& scissor, const GrDeviceCoordTexture* dstCop
y, | 175 const GrDrawTargetCaps& caps, const ScissorState& scissor, |
176 GrGpu::DrawType drawType) | 176 const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType drawType) |
177 : Cmd(kSetState_Cmd) | 177 : Cmd(kSetState_Cmd) |
178 , fState(drawState, caps, scissor, dstCopy, drawType) {} | 178 , fState(drawState, color, coverage, caps, scissor, dstCopy, drawType) {
} |
179 | 179 |
180 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; | 180 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; |
181 | 181 |
182 GrOptDrawState fState; | 182 GrOptDrawState fState; |
183 }; | 183 }; |
184 | 184 |
185 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. |
186 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; | 186 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; |
187 | 187 |
188 void onReset() SK_OVERRIDE; | 188 void onReset() SK_OVERRIDE; |
189 void onFlush() SK_OVERRIDE; | 189 void onFlush() SK_OVERRIDE; |
190 | 190 |
191 // overrides from GrDrawTarget | 191 // overrides from GrDrawTarget |
192 void onDraw(const GrDrawState&, | 192 void onDraw(const GrDrawState&, |
193 const DrawInfo&, | 193 const DrawInfo&, |
194 const ScissorState&, | 194 const ScissorState&, |
195 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; | 195 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; |
196 void onDrawRect(GrDrawState*, | 196 void onDrawRect(GrDrawState*, |
| 197 GrColor, |
197 const SkRect& rect, | 198 const SkRect& rect, |
198 const SkRect* localRect, | 199 const SkRect* localRect, |
199 const SkMatrix* localMatrix) SK_OVERRIDE; | 200 const SkMatrix* localMatrix) SK_OVERRIDE; |
200 | 201 |
201 void onStencilPath(const GrDrawState&, | 202 void onStencilPath(const GrDrawState&, |
202 const GrPath*, | 203 const GrPath*, |
203 const ScissorState&, | 204 const ScissorState&, |
204 const GrStencilSettings&) SK_OVERRIDE; | 205 const GrStencilSettings&) SK_OVERRIDE; |
205 void onDrawPath(const GrDrawState&, | 206 void onDrawPath(const GrDrawState&, |
| 207 GrColor, |
206 const GrPath*, | 208 const GrPath*, |
207 const ScissorState&, | 209 const ScissorState&, |
208 const GrStencilSettings&, | 210 const GrStencilSettings&, |
209 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; | 211 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; |
210 void onDrawPaths(const GrDrawState&, | 212 void onDrawPaths(const GrDrawState&, |
| 213 GrColor, |
211 const GrPathRange*, | 214 const GrPathRange*, |
212 const void* indices, | 215 const void* indices, |
213 PathIndexType, | 216 PathIndexType, |
214 const float transformValues[], | 217 const float transformValues[], |
215 PathTransformType, | 218 PathTransformType, |
216 int count, | 219 int count, |
217 const ScissorState&, | 220 const ScissorState&, |
218 const GrStencilSettings&, | 221 const GrStencilSettings&, |
219 const GrDeviceCoordTexture*) SK_OVERRIDE; | 222 const GrDeviceCoordTexture*) SK_OVERRIDE; |
220 void onClear(const SkIRect* rect, | 223 void onClear(const SkIRect* rect, |
221 GrColor color, | 224 GrColor color, |
222 bool canIgnoreRect, | 225 bool canIgnoreRect, |
223 GrRenderTarget* renderTarget) SK_OVERRIDE; | 226 GrRenderTarget* renderTarget) SK_OVERRIDE; |
224 bool onCopySurface(GrSurface* dst, | 227 bool onCopySurface(GrSurface* dst, |
225 GrSurface* src, | 228 GrSurface* src, |
226 const SkIRect& srcRect, | 229 const SkIRect& srcRect, |
227 const SkIPoint& dstPoint) SK_OVERRIDE; | 230 const SkIPoint& dstPoint) SK_OVERRIDE; |
228 | 231 |
229 // 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 |
230 // 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. |
231 int concatInstancedDraw(const GrDrawState&, const DrawInfo&); | 234 int concatInstancedDraw(const GrDrawState&, const DrawInfo&); |
232 | 235 |
233 // 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 |
234 // 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 |
235 // recorded. | 238 // recorded. |
236 bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrDrawState&, | 239 bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrDrawState&, |
| 240 GrColor, |
| 241 uint8_t coverage, |
237 GrGpu::DrawType, | 242 GrGpu::DrawType, |
238 const GrClipMaskManager:
:ScissorState&, | 243 const GrClipMaskManager:
:ScissorState&, |
239 const GrDeviceCoordTextu
re*); | 244 const GrDeviceCoordTextu
re*); |
240 // 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. |
241 void recordClipIfNecessary(); | 246 void recordClipIfNecessary(); |
242 // 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. |
243 void recordTraceMarkersIfNecessary(); | 248 void recordTraceMarkersIfNecessary(); |
244 | 249 |
245 virtual bool isIssued(uint32_t drawID) { return drawID != fDrawID; } | 250 virtual bool isIssued(uint32_t drawID) { return drawID != fDrawID; } |
246 | 251 |
247 // TODO: Use a single allocator for commands and records | 252 // TODO: Use a single allocator for commands and records |
248 enum { | 253 enum { |
249 kCmdBufferInitialSizeInBytes = 8 * 1024, | 254 kCmdBufferInitialSizeInBytes = 8 * 1024, |
250 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's | 255 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's |
251 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms | 256 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms |
252 }; | 257 }; |
253 | 258 |
254 CmdBuffer fCmdBuffer; | 259 CmdBuffer fCmdBuffer; |
255 const GrOptDrawState* fPrevState; | 260 const GrOptDrawState* fPrevState; |
256 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; | 261 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; |
257 SkTDArray<char> fPathIndexBuffer; | 262 SkTDArray<char> fPathIndexBuffer; |
258 SkTDArray<float> fPathTransformBuffer; | 263 SkTDArray<float> fPathTransformBuffer; |
259 uint32_t fDrawID; | 264 uint32_t fDrawID; |
260 | 265 |
261 typedef GrFlushToGpuDrawTarget INHERITED; | 266 typedef GrFlushToGpuDrawTarget INHERITED; |
262 }; | 267 }; |
263 | 268 |
264 #endif | 269 #endif |
OLD | NEW |