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 #include "GrInOrderDrawBuffer.h" | 8 #include "GrInOrderDrawBuffer.h" |
9 | 9 |
10 #include "GrBufferAllocPool.h" | 10 #include "GrBufferAllocPool.h" |
11 #include "GrDrawTargetCaps.h" | 11 #include "GrDrawTargetCaps.h" |
12 #include "GrTextStrike.h" | 12 #include "GrTextStrike.h" |
13 #include "GrGpu.h" | 13 #include "GrGpu.h" |
14 #include "GrTemplates.h" | 14 #include "GrTemplates.h" |
15 #include "GrTexture.h" | 15 #include "GrTexture.h" |
16 | 16 |
17 GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrGpu* gpu, | 17 GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrGpu* gpu, |
18 GrVertexBufferAllocPool* vertexPool, | 18 GrVertexBufferAllocPool* vertexPool, |
19 GrIndexBufferAllocPool* indexPool) | 19 GrIndexBufferAllocPool* indexPool) |
20 : INHERITED(gpu->getContext()) | 20 : INHERITED(gpu->getContext()) |
21 , fCmdBuffer(kCmdBufferInitialSizeInBytes) | 21 , fCmdBuffer(kCmdBufferInitialSizeInBytes) |
22 , fLastState(NULL) | 22 , fLastState(NULL) |
23 , fLastClip(NULL) | |
24 , fDstGpu(gpu) | 23 , fDstGpu(gpu) |
25 , fClipSet(true) | |
26 , fClipProxyState(kUnknown_ClipProxyState) | |
27 , fVertexPool(*vertexPool) | 24 , fVertexPool(*vertexPool) |
28 , fIndexPool(*indexPool) | 25 , fIndexPool(*indexPool) |
29 , fFlushing(false) | 26 , fFlushing(false) |
30 , fDrawID(0) { | 27 , fDrawID(0) { |
31 | 28 |
32 fDstGpu->ref(); | 29 fDstGpu->ref(); |
33 fCaps.reset(SkRef(fDstGpu->caps())); | 30 fCaps.reset(SkRef(fDstGpu->caps())); |
34 | 31 |
35 SkASSERT(vertexPool); | 32 SkASSERT(vertexPool); |
36 SkASSERT(indexPool); | 33 SkASSERT(indexPool); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 vertColor = (GrColor*) ((intptr_t) vertColor + vstride); | 166 vertColor = (GrColor*) ((intptr_t) vertColor + vstride); |
170 } | 167 } |
171 | 168 |
172 this->setIndexSourceToBuffer(this->getContext()->getQuadIndexBuffer()); | 169 this->setIndexSourceToBuffer(this->getContext()->getQuadIndexBuffer()); |
173 this->drawIndexedInstances(kTriangles_GrPrimitiveType, 1, 4, 6, &devBounds); | 170 this->drawIndexedInstances(kTriangles_GrPrimitiveType, 1, 4, 6, &devBounds); |
174 | 171 |
175 // to ensure that stashing the drawState ptr is valid | 172 // to ensure that stashing the drawState ptr is valid |
176 SkASSERT(this->drawState() == drawState); | 173 SkASSERT(this->drawState() == drawState); |
177 } | 174 } |
178 | 175 |
179 bool GrInOrderDrawBuffer::quickInsideClip(const SkRect& devBounds) { | 176 int GrInOrderDrawBuffer::concatInstancedDraw(const DrawInfo& info, |
bsalomon
2014/11/05 19:13:43
It'll be interesting to see what happens w.r.t. to
joshualitt
2014/11/05 19:55:47
was there a place we were actually calling this?
bsalomon
2014/11/05 20:00:22
void GrInOrderDrawBuffer::onDraw(const DrawInfo& i
| |
180 if (!this->getDrawState().isClipState()) { | 177 const GrClipMaskManager::ScissorSta te& scissorState) { |
181 return true; | |
182 } | |
183 if (kUnknown_ClipProxyState == fClipProxyState) { | |
184 SkIRect rect; | |
185 bool iior; | |
186 this->getClip()->getConservativeBounds(this->getDrawState().getRenderTar get(), &rect, &iior); | |
187 if (iior) { | |
188 // The clip is a rect. We will remember that in fProxyClip. It is co mmon for an edge (or | |
189 // all edges) of the clip to be at the edge of the RT. However, we g et that clipping for | |
190 // free via the viewport. We don't want to think that clipping must be enabled in this | |
191 // case. So we extend the clip outward from the edge to avoid these false negatives. | |
192 fClipProxyState = kValid_ClipProxyState; | |
193 fClipProxy = SkRect::Make(rect); | |
194 | |
195 if (fClipProxy.fLeft <= 0) { | |
196 fClipProxy.fLeft = SK_ScalarMin; | |
197 } | |
198 if (fClipProxy.fTop <= 0) { | |
199 fClipProxy.fTop = SK_ScalarMin; | |
200 } | |
201 if (fClipProxy.fRight >= this->getDrawState().getRenderTarget()->wid th()) { | |
202 fClipProxy.fRight = SK_ScalarMax; | |
203 } | |
204 if (fClipProxy.fBottom >= this->getDrawState().getRenderTarget()->he ight()) { | |
205 fClipProxy.fBottom = SK_ScalarMax; | |
206 } | |
207 } else { | |
208 fClipProxyState = kInvalid_ClipProxyState; | |
209 } | |
210 } | |
211 if (kValid_ClipProxyState == fClipProxyState) { | |
212 return fClipProxy.contains(devBounds); | |
213 } | |
214 SkPoint originOffset = {SkIntToScalar(this->getClip()->fOrigin.fX), | |
215 SkIntToScalar(this->getClip()->fOrigin.fY)}; | |
216 SkRect clipSpaceBounds = devBounds; | |
217 clipSpaceBounds.offset(originOffset); | |
218 return this->getClip()->fClipStack->quickContains(clipSpaceBounds); | |
219 } | |
220 | |
221 int GrInOrderDrawBuffer::concatInstancedDraw(const DrawInfo& info) { | |
222 SkASSERT(!fCmdBuffer.empty()); | 178 SkASSERT(!fCmdBuffer.empty()); |
223 SkASSERT(info.isInstanced()); | 179 SkASSERT(info.isInstanced()); |
224 | 180 |
225 const GeometrySrcState& geomSrc = this->getGeomSrc(); | 181 const GeometrySrcState& geomSrc = this->getGeomSrc(); |
226 const GrDrawState& drawState = this->getDrawState(); | 182 const GrDrawState& drawState = this->getDrawState(); |
227 | 183 |
228 // we only attempt to concat the case when reserved verts are used with a cl ient-specified index | 184 // we only attempt to concat the case when reserved verts are used with a cl ient-specified index |
229 // buffer. To make this work with client-specified VBs we'd need to know if the VB was updated | 185 // buffer. To make this work with client-specified VBs we'd need to know if the VB was updated |
230 // between draws. | 186 // between draws. |
231 if (kReserved_GeometrySrcType != geomSrc.fVertexSrc || | 187 if (kReserved_GeometrySrcType != geomSrc.fVertexSrc || |
232 kBuffer_GeometrySrcType != geomSrc.fIndexSrc) { | 188 kBuffer_GeometrySrcType != geomSrc.fIndexSrc) { |
233 return 0; | 189 return 0; |
234 } | 190 } |
235 // Check if there is a draw info that is compatible that uses the same VB fr om the pool and | 191 // Check if there is a draw info that is compatible that uses the same VB fr om the pool and |
236 // the same IB | 192 // the same IB |
237 if (kDraw_Cmd != strip_trace_bit(fCmdBuffer.back().fType)) { | 193 if (kDraw_Cmd != strip_trace_bit(fCmdBuffer.back().fType)) { |
238 return 0; | 194 return 0; |
239 } | 195 } |
240 | 196 |
241 Draw* draw = static_cast<Draw*>(&fCmdBuffer.back()); | 197 Draw* draw = static_cast<Draw*>(&fCmdBuffer.back()); |
242 GeometryPoolState& poolState = fGeoPoolStateStack.back(); | 198 GeometryPoolState& poolState = fGeoPoolStateStack.back(); |
243 const GrVertexBuffer* vertexBuffer = poolState.fPoolVertexBuffer; | 199 const GrVertexBuffer* vertexBuffer = poolState.fPoolVertexBuffer; |
244 | 200 |
245 if (!draw->fInfo.isInstanced() || | 201 if (!draw->fInfo.isInstanced() || |
246 draw->fInfo.verticesPerInstance() != info.verticesPerInstance() || | 202 draw->fInfo.verticesPerInstance() != info.verticesPerInstance() || |
247 draw->fInfo.indicesPerInstance() != info.indicesPerInstance() || | 203 draw->fInfo.indicesPerInstance() != info.indicesPerInstance() || |
248 draw->vertexBuffer() != vertexBuffer || | 204 draw->vertexBuffer() != vertexBuffer || |
249 draw->indexBuffer() != geomSrc.fIndexBuffer) { | 205 draw->indexBuffer() != geomSrc.fIndexBuffer || |
206 draw->fScissorState != scissorState) { | |
250 return 0; | 207 return 0; |
251 } | 208 } |
252 // info does not yet account for the offset from the start of the pool's VB while the previous | 209 // info does not yet account for the offset from the start of the pool's VB while the previous |
253 // draw record does. | 210 // draw record does. |
254 int adjustedStartVertex = poolState.fPoolStartVertex + info.startVertex(); | 211 int adjustedStartVertex = poolState.fPoolStartVertex + info.startVertex(); |
255 if (draw->fInfo.startVertex() + draw->fInfo.vertexCount() != adjustedStartVe rtex) { | 212 if (draw->fInfo.startVertex() + draw->fInfo.vertexCount() != adjustedStartVe rtex) { |
256 return 0; | 213 return 0; |
257 } | 214 } |
258 | 215 |
259 SkASSERT(poolState.fPoolStartVertex == draw->fInfo.startVertex() + draw->fIn fo.vertexCount()); | 216 SkASSERT(poolState.fPoolStartVertex == draw->fInfo.startVertex() + draw->fIn fo.vertexCount()); |
(...skipping 16 matching lines...) Expand all Loading... | |
276 fGpuCmdMarkers.back().addSet(this->getActiveTraceMarkers()); | 233 fGpuCmdMarkers.back().addSet(this->getActiveTraceMarkers()); |
277 } else { | 234 } else { |
278 fGpuCmdMarkers.push_back(this->getActiveTraceMarkers()); | 235 fGpuCmdMarkers.push_back(this->getActiveTraceMarkers()); |
279 draw->fType = add_trace_bit(draw->fType); | 236 draw->fType = add_trace_bit(draw->fType); |
280 } | 237 } |
281 } | 238 } |
282 | 239 |
283 return instancesToConcat; | 240 return instancesToConcat; |
284 } | 241 } |
285 | 242 |
286 class AutoClipReenable { | 243 void GrInOrderDrawBuffer::onDraw(const DrawInfo& info, |
287 public: | 244 const GrClipMaskManager::ScissorState& scissorS tate) { |
288 AutoClipReenable() : fDrawState(NULL) {} | |
289 ~AutoClipReenable() { | |
290 if (fDrawState) { | |
291 fDrawState->enableState(GrDrawState::kClip_StateBit); | |
292 } | |
293 } | |
294 void set(GrDrawState* drawState) { | |
295 if (drawState->isClipState()) { | |
296 fDrawState = drawState; | |
297 drawState->disableState(GrDrawState::kClip_StateBit); | |
298 } | |
299 } | |
300 private: | |
301 GrDrawState* fDrawState; | |
302 }; | |
303 | |
304 void GrInOrderDrawBuffer::onDraw(const DrawInfo& info) { | |
305 | 245 |
306 GeometryPoolState& poolState = fGeoPoolStateStack.back(); | 246 GeometryPoolState& poolState = fGeoPoolStateStack.back(); |
307 const GrDrawState& drawState = this->getDrawState(); | 247 const GrDrawState& drawState = this->getDrawState(); |
308 AutoClipReenable acr; | |
309 | 248 |
310 if (drawState.isClipState() && | |
311 info.getDevBounds() && | |
312 this->quickInsideClip(*info.getDevBounds())) { | |
313 acr.set(this->drawState()); | |
314 } | |
315 | |
316 this->recordClipIfNecessary(); | |
317 this->recordStateIfNecessary(); | 249 this->recordStateIfNecessary(); |
318 | 250 |
319 const GrVertexBuffer* vb; | 251 const GrVertexBuffer* vb; |
320 if (kBuffer_GeometrySrcType == this->getGeomSrc().fVertexSrc) { | 252 if (kBuffer_GeometrySrcType == this->getGeomSrc().fVertexSrc) { |
321 vb = this->getGeomSrc().fVertexBuffer; | 253 vb = this->getGeomSrc().fVertexBuffer; |
322 } else { | 254 } else { |
323 vb = poolState.fPoolVertexBuffer; | 255 vb = poolState.fPoolVertexBuffer; |
324 } | 256 } |
325 | 257 |
326 const GrIndexBuffer* ib = NULL; | 258 const GrIndexBuffer* ib = NULL; |
327 if (info.isIndexed()) { | 259 if (info.isIndexed()) { |
328 if (kBuffer_GeometrySrcType == this->getGeomSrc().fIndexSrc) { | 260 if (kBuffer_GeometrySrcType == this->getGeomSrc().fIndexSrc) { |
329 ib = this->getGeomSrc().fIndexBuffer; | 261 ib = this->getGeomSrc().fIndexBuffer; |
330 } else { | 262 } else { |
331 ib = poolState.fPoolIndexBuffer; | 263 ib = poolState.fPoolIndexBuffer; |
332 } | 264 } |
333 } | 265 } |
334 | 266 |
335 Draw* draw; | 267 Draw* draw; |
336 if (info.isInstanced()) { | 268 if (info.isInstanced()) { |
337 int instancesConcated = this->concatInstancedDraw(info); | 269 int instancesConcated = this->concatInstancedDraw(info, scissorState); |
338 if (info.instanceCount() > instancesConcated) { | 270 if (info.instanceCount() > instancesConcated) { |
339 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info, vb, ib)); | 271 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info, scissorStat e, vb, ib)); |
340 draw->fInfo.adjustInstanceCount(-instancesConcated); | 272 draw->fInfo.adjustInstanceCount(-instancesConcated); |
341 } else { | 273 } else { |
342 return; | 274 return; |
343 } | 275 } |
344 } else { | 276 } else { |
345 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info, vb, ib)); | 277 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info, scissorState, v b, ib)); |
346 } | 278 } |
347 this->recordTraceMarkersIfNecessary(); | 279 this->recordTraceMarkersIfNecessary(); |
348 | 280 |
349 // Adjust the starting vertex and index when we are using reserved or array sources to | 281 // Adjust the starting vertex and index when we are using reserved or array sources to |
350 // compensate for the fact that the data was inserted into a larger vb/ib ow ned by the pool. | 282 // compensate for the fact that the data was inserted into a larger vb/ib ow ned by the pool. |
351 if (kBuffer_GeometrySrcType != this->getGeomSrc().fVertexSrc) { | 283 if (kBuffer_GeometrySrcType != this->getGeomSrc().fVertexSrc) { |
352 size_t bytes = (info.vertexCount() + info.startVertex()) * drawState.get VertexStride(); | 284 size_t bytes = (info.vertexCount() + info.startVertex()) * drawState.get VertexStride(); |
353 poolState.fUsedPoolVertexBytes = SkTMax(poolState.fUsedPoolVertexBytes, bytes); | 285 poolState.fUsedPoolVertexBytes = SkTMax(poolState.fUsedPoolVertexBytes, bytes); |
354 draw->fInfo.adjustStartVertex(poolState.fPoolStartVertex); | 286 draw->fInfo.adjustStartVertex(poolState.fPoolStartVertex); |
355 } | 287 } |
356 | 288 |
357 if (info.isIndexed() && kBuffer_GeometrySrcType != this->getGeomSrc().fIndex Src) { | 289 if (info.isIndexed() && kBuffer_GeometrySrcType != this->getGeomSrc().fIndex Src) { |
358 size_t bytes = (info.indexCount() + info.startIndex()) * sizeof(uint16_t ); | 290 size_t bytes = (info.indexCount() + info.startIndex()) * sizeof(uint16_t ); |
359 poolState.fUsedPoolIndexBytes = SkTMax(poolState.fUsedPoolIndexBytes, by tes); | 291 poolState.fUsedPoolIndexBytes = SkTMax(poolState.fUsedPoolIndexBytes, by tes); |
360 draw->fInfo.adjustStartIndex(poolState.fPoolStartIndex); | 292 draw->fInfo.adjustStartIndex(poolState.fPoolStartIndex); |
361 } | 293 } |
362 } | 294 } |
363 | 295 |
364 void GrInOrderDrawBuffer::onStencilPath(const GrPath* path, GrPathRendering::Fil lType fill) { | 296 void GrInOrderDrawBuffer::onStencilPath(const GrPath* path, |
365 this->recordClipIfNecessary(); | 297 const GrClipMaskManager::ScissorState& s cissorState, |
298 const GrStencilSettings& stencilSettings ) { | |
366 // Only compare the subset of GrDrawState relevant to path stenciling? | 299 // Only compare the subset of GrDrawState relevant to path stenciling? |
367 this->recordStateIfNecessary(); | 300 this->recordStateIfNecessary(); |
368 StencilPath* sp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, StencilPath, (path)); | 301 StencilPath* sp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, StencilPath, (path)); |
369 sp->fFill = fill; | 302 sp->fStencilSettings = stencilSettings; |
303 sp->fScissorState = scissorState; | |
370 this->recordTraceMarkersIfNecessary(); | 304 this->recordTraceMarkersIfNecessary(); |
371 } | 305 } |
372 | 306 |
373 void GrInOrderDrawBuffer::onDrawPath(const GrPath* path, | 307 void GrInOrderDrawBuffer::onDrawPath(const GrPath* path, |
374 GrPathRendering::FillType fill, | 308 const GrClipMaskManager::ScissorState& scis sorState, |
309 const GrStencilSettings& stencilSettings, | |
375 const GrDeviceCoordTexture* dstCopy) { | 310 const GrDeviceCoordTexture* dstCopy) { |
376 this->recordClipIfNecessary(); | |
377 // TODO: Only compare the subset of GrDrawState relevant to path covering? | 311 // TODO: Only compare the subset of GrDrawState relevant to path covering? |
378 this->recordStateIfNecessary(); | 312 this->recordStateIfNecessary(); |
379 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path)); | 313 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path)); |
380 dp->fFill = fill; | |
381 if (dstCopy) { | 314 if (dstCopy) { |
382 dp->fDstCopy = *dstCopy; | 315 dp->fDstCopy = *dstCopy; |
383 } | 316 } |
317 dp->fStencilSettings = stencilSettings; | |
318 dp->fScissorState = scissorState; | |
384 this->recordTraceMarkersIfNecessary(); | 319 this->recordTraceMarkersIfNecessary(); |
385 } | 320 } |
386 | 321 |
387 void GrInOrderDrawBuffer::onDrawPaths(const GrPathRange* pathRange, | 322 void GrInOrderDrawBuffer::onDrawPaths(const GrPathRange* pathRange, |
388 const uint32_t indices[], int count, | 323 const uint32_t indices[], |
389 const float transforms[], PathTransformTyp e transformsType, | 324 int count, |
390 GrPathRendering::FillType fill, | 325 const float transforms[], |
326 PathTransformType transformsType, | |
327 const GrClipMaskManager::ScissorState& sci ssorState, | |
328 const GrStencilSettings& stencilSettings, | |
391 const GrDeviceCoordTexture* dstCopy) { | 329 const GrDeviceCoordTexture* dstCopy) { |
392 SkASSERT(pathRange); | 330 SkASSERT(pathRange); |
393 SkASSERT(indices); | 331 SkASSERT(indices); |
394 SkASSERT(transforms); | 332 SkASSERT(transforms); |
395 | 333 |
396 this->recordClipIfNecessary(); | |
397 this->recordStateIfNecessary(); | 334 this->recordStateIfNecessary(); |
398 | 335 |
399 int sizeOfIndices = sizeof(uint32_t) * count; | 336 int sizeOfIndices = sizeof(uint32_t) * count; |
400 int sizeOfTransforms = sizeof(float) * count * | 337 int sizeOfTransforms = sizeof(float) * count * |
401 GrPathRendering::PathTransformSize(transformsType); | 338 GrPathRendering::PathTransformSize(transformsType); |
402 | 339 |
403 DrawPaths* dp = GrNEW_APPEND_WITH_DATA_TO_RECORDER(fCmdBuffer, DrawPaths, (p athRange), | 340 DrawPaths* dp = GrNEW_APPEND_WITH_DATA_TO_RECORDER(fCmdBuffer, DrawPaths, (p athRange), |
404 sizeOfIndices + sizeOfTra nsforms); | 341 sizeOfIndices + sizeOfTra nsforms); |
405 memcpy(dp->indices(), indices, sizeOfIndices); | 342 memcpy(dp->indices(), indices, sizeOfIndices); |
406 dp->fCount = count; | 343 dp->fCount = count; |
407 memcpy(dp->transforms(), transforms, sizeOfTransforms); | 344 memcpy(dp->transforms(), transforms, sizeOfTransforms); |
408 dp->fTransformsType = transformsType; | 345 dp->fTransformsType = transformsType; |
409 dp->fFill = fill; | 346 dp->fStencilSettings = stencilSettings; |
347 dp->fScissorState = scissorState; | |
410 if (dstCopy) { | 348 if (dstCopy) { |
411 dp->fDstCopy = *dstCopy; | 349 dp->fDstCopy = *dstCopy; |
412 } | 350 } |
413 | 351 |
414 this->recordTraceMarkersIfNecessary(); | 352 this->recordTraceMarkersIfNecessary(); |
415 } | 353 } |
416 | 354 |
417 void GrInOrderDrawBuffer::clear(const SkIRect* rect, GrColor color, | 355 void GrInOrderDrawBuffer::clear(const SkIRect* rect, GrColor color, |
418 bool canIgnoreRect, GrRenderTarget* renderTarget ) { | 356 bool canIgnoreRect, GrRenderTarget* renderTarget ) { |
419 SkIRect r; | 357 SkIRect r; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
459 this->recordTraceMarkersIfNecessary(); | 397 this->recordTraceMarkersIfNecessary(); |
460 } | 398 } |
461 | 399 |
462 void GrInOrderDrawBuffer::reset() { | 400 void GrInOrderDrawBuffer::reset() { |
463 SkASSERT(1 == fGeoPoolStateStack.count()); | 401 SkASSERT(1 == fGeoPoolStateStack.count()); |
464 this->resetVertexSource(); | 402 this->resetVertexSource(); |
465 this->resetIndexSource(); | 403 this->resetIndexSource(); |
466 | 404 |
467 fCmdBuffer.reset(); | 405 fCmdBuffer.reset(); |
468 fLastState = NULL; | 406 fLastState = NULL; |
469 fLastClip = NULL; | |
470 fVertexPool.reset(); | 407 fVertexPool.reset(); |
471 fIndexPool.reset(); | 408 fIndexPool.reset(); |
472 fGpuCmdMarkers.reset(); | 409 fGpuCmdMarkers.reset(); |
473 fClipSet = true; | |
474 } | 410 } |
475 | 411 |
476 void GrInOrderDrawBuffer::flush() { | 412 void GrInOrderDrawBuffer::flush() { |
477 if (fFlushing) { | 413 if (fFlushing) { |
478 return; | 414 return; |
479 } | 415 } |
480 | 416 |
481 this->getContext()->getFontCache()->updateTextures(); | 417 this->getContext()->getFontCache()->updateTextures(); |
482 | 418 |
483 SkASSERT(kReserved_GeometrySrcType != this->getGeomSrc().fVertexSrc); | 419 SkASSERT(kReserved_GeometrySrcType != this->getGeomSrc().fVertexSrc); |
484 SkASSERT(kReserved_GeometrySrcType != this->getGeomSrc().fIndexSrc); | 420 SkASSERT(kReserved_GeometrySrcType != this->getGeomSrc().fIndexSrc); |
485 | 421 |
486 if (fCmdBuffer.empty()) { | 422 if (fCmdBuffer.empty()) { |
487 return; | 423 return; |
488 } | 424 } |
489 | 425 |
490 GrAutoTRestore<bool> flushRestore(&fFlushing); | 426 GrAutoTRestore<bool> flushRestore(&fFlushing); |
491 fFlushing = true; | 427 fFlushing = true; |
492 | 428 |
493 fVertexPool.unmap(); | 429 fVertexPool.unmap(); |
494 fIndexPool.unmap(); | 430 fIndexPool.unmap(); |
495 | 431 |
496 GrDrawTarget::AutoClipRestore acr(fDstGpu); | |
497 AutoGeometryAndStatePush agasp(fDstGpu, kPreserve_ASRInit); | 432 AutoGeometryAndStatePush agasp(fDstGpu, kPreserve_ASRInit); |
498 | 433 |
499 GrDrawState* prevDrawState = SkRef(fDstGpu->drawState()); | 434 GrDrawState* prevDrawState = SkRef(fDstGpu->drawState()); |
500 | 435 |
501 CmdBuffer::Iter iter(fCmdBuffer); | 436 CmdBuffer::Iter iter(fCmdBuffer); |
502 | 437 |
503 int currCmdMarker = 0; | 438 int currCmdMarker = 0; |
504 fDstGpu->saveActiveTraceMarkers(); | 439 fDstGpu->saveActiveTraceMarkers(); |
505 | 440 |
506 while (iter.next()) { | 441 while (iter.next()) { |
(...skipping 26 matching lines...) Expand all Loading... | |
533 prevDrawState->unref(); | 468 prevDrawState->unref(); |
534 this->reset(); | 469 this->reset(); |
535 ++fDrawID; | 470 ++fDrawID; |
536 } | 471 } |
537 | 472 |
538 void GrInOrderDrawBuffer::Draw::execute(GrClipTarget* gpu) { | 473 void GrInOrderDrawBuffer::Draw::execute(GrClipTarget* gpu) { |
539 gpu->setVertexSourceToBuffer(this->vertexBuffer()); | 474 gpu->setVertexSourceToBuffer(this->vertexBuffer()); |
540 if (fInfo.isIndexed()) { | 475 if (fInfo.isIndexed()) { |
541 gpu->setIndexSourceToBuffer(this->indexBuffer()); | 476 gpu->setIndexSourceToBuffer(this->indexBuffer()); |
542 } | 477 } |
543 gpu->executeDraw(fInfo); | 478 gpu->executeDraw(fInfo, fScissorState); |
544 } | 479 } |
545 | 480 |
546 void GrInOrderDrawBuffer::StencilPath::execute(GrClipTarget* gpu) { | 481 void GrInOrderDrawBuffer::StencilPath::execute(GrClipTarget* gpu) { |
547 gpu->stencilPath(this->path(), fFill); | 482 gpu->executeStencilPath(this->path(), fScissorState, fStencilSettings); |
548 } | 483 } |
549 | 484 |
550 void GrInOrderDrawBuffer::DrawPath::execute(GrClipTarget* gpu) { | 485 void GrInOrderDrawBuffer::DrawPath::execute(GrClipTarget* gpu) { |
551 gpu->executeDrawPath(this->path(), fFill, fDstCopy.texture() ? &fDstCopy : N ULL); | 486 gpu->executeDrawPath(this->path(), fScissorState, fStencilSettings, |
487 fDstCopy.texture() ? &fDstCopy : NULL); | |
552 } | 488 } |
553 | 489 |
554 void GrInOrderDrawBuffer::DrawPaths::execute(GrClipTarget* gpu) { | 490 void GrInOrderDrawBuffer::DrawPaths::execute(GrClipTarget* gpu) { |
555 gpu->executeDrawPaths(this->pathRange(), this->indices(), fCount, this->tran sforms(), | 491 gpu->executeDrawPaths(this->pathRange(), this->indices(), fCount, this->tran sforms(), |
556 fTransformsType, fFill, fDstCopy.texture() ? &fDstCopy : NULL); | 492 fTransformsType, fScissorState, fStencilSettings, |
493 fDstCopy.texture() ? &fDstCopy : NULL); | |
557 } | 494 } |
558 | 495 |
559 void GrInOrderDrawBuffer::SetState::execute(GrClipTarget* gpu) { | 496 void GrInOrderDrawBuffer::SetState::execute(GrClipTarget* gpu) { |
560 gpu->setDrawState(&fState); | 497 gpu->setDrawState(&fState); |
561 } | 498 } |
562 | 499 |
563 void GrInOrderDrawBuffer::SetClip::execute(GrClipTarget* gpu) { | |
564 // Our fClipData is referenced directly, so we must remain alive for the ent ire | |
565 // duration of the flush (after which the gpu's previous clip is restored). | |
566 gpu->setClip(&fClipData); | |
567 } | |
568 | |
569 void GrInOrderDrawBuffer::Clear::execute(GrClipTarget* gpu) { | 500 void GrInOrderDrawBuffer::Clear::execute(GrClipTarget* gpu) { |
570 if (GrColor_ILLEGAL == fColor) { | 501 if (GrColor_ILLEGAL == fColor) { |
571 gpu->discard(this->renderTarget()); | 502 gpu->discard(this->renderTarget()); |
572 } else { | 503 } else { |
573 gpu->clear(&fRect, fColor, fCanIgnoreRect, this->renderTarget()); | 504 gpu->clear(&fRect, fColor, fCanIgnoreRect, this->renderTarget()); |
574 } | 505 } |
575 } | 506 } |
576 | 507 |
577 void GrInOrderDrawBuffer::ClearStencilClip::execute(GrClipTarget* gpu) { | 508 void GrInOrderDrawBuffer::ClearStencilClip::execute(GrClipTarget* gpu) { |
578 gpu->clearStencilClip(fRect, fInsideClip, this->renderTarget()); | 509 gpu->clearStencilClip(fRect, fInsideClip, this->renderTarget()); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
835 // So here we just destruct the previous state and reinit with a new copy of curr. | 766 // So here we just destruct the previous state and reinit with a new copy of curr. |
836 // Note that this goes away when we move GrIODB over to taking optim ized snapshots | 767 // Note that this goes away when we move GrIODB over to taking optim ized snapshots |
837 // of draw states. | 768 // of draw states. |
838 fLastState->~GrDrawState(); | 769 fLastState->~GrDrawState(); |
839 SkNEW_PLACEMENT_ARGS(fLastState, GrDrawState, (curr)); | 770 SkNEW_PLACEMENT_ARGS(fLastState, GrDrawState, (curr)); |
840 this->convertDrawStateToPendingExec(fLastState); | 771 this->convertDrawStateToPendingExec(fLastState); |
841 break; | 772 break; |
842 } | 773 } |
843 } | 774 } |
844 | 775 |
845 void GrInOrderDrawBuffer::recordClipIfNecessary() { | |
846 if (this->getDrawState().isClipState() && | |
847 fClipSet && | |
848 (!fLastClip || *fLastClip != *this->getClip())) { | |
849 fLastClip = &GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetClip, (this->getCli p()))->fClipData; | |
850 this->recordTraceMarkersIfNecessary(); | |
851 fClipSet = false; | |
852 } | |
853 } | |
854 | |
855 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() { | 776 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() { |
856 SkASSERT(!fCmdBuffer.empty()); | 777 SkASSERT(!fCmdBuffer.empty()); |
857 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType)); | 778 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType)); |
858 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); | 779 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); |
859 if (activeTraceMarkers.count() > 0) { | 780 if (activeTraceMarkers.count() > 0) { |
860 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); | 781 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); |
861 fGpuCmdMarkers.push_back(activeTraceMarkers); | 782 fGpuCmdMarkers.push_back(activeTraceMarkers); |
862 } | 783 } |
863 } | 784 } |
864 | |
865 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) { | |
866 INHERITED::clipWillBeSet(newClipData); | |
867 fClipSet = true; | |
868 fClipProxyState = kUnknown_ClipProxyState; | |
869 } | |
OLD | NEW |