Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: src/gpu/GrInOrderDrawBuffer.cpp

Issue 581123002: Make GrIODB keep pending IO refs on all resources it records into its cmd stream. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix param init order warning Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "GrIndexBuffer.h"
15 #include "GrPath.h"
16 #include "GrPathRange.h"
17 #include "GrRenderTarget.h"
18 #include "GrTemplates.h" 14 #include "GrTemplates.h"
19 #include "GrTexture.h" 15 #include "GrTexture.h"
20 #include "GrVertexBuffer.h"
21 16
22 GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrGpu* gpu, 17 GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrGpu* gpu,
23 GrVertexBufferAllocPool* vertexPool, 18 GrVertexBufferAllocPool* vertexPool,
24 GrIndexBufferAllocPool* indexPool) 19 GrIndexBufferAllocPool* indexPool)
25 : GrDrawTarget(gpu->getContext()) 20 : GrDrawTarget(gpu->getContext())
26 , fDstGpu(gpu) 21 , fDstGpu(gpu)
27 , fClipSet(true) 22 , fClipSet(true)
28 , fClipProxyState(kUnknown_ClipProxyState) 23 , fClipProxyState(kUnknown_ClipProxyState)
29 , fVertexPool(*vertexPool) 24 , fVertexPool(*vertexPool)
30 , fIndexPool(*indexPool) 25 , fIndexPool(*indexPool)
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 if (kReserved_GeometrySrcType != geomSrc.fVertexSrc || 227 if (kReserved_GeometrySrcType != geomSrc.fVertexSrc ||
233 kBuffer_GeometrySrcType != geomSrc.fIndexSrc) { 228 kBuffer_GeometrySrcType != geomSrc.fIndexSrc) {
234 return 0; 229 return 0;
235 } 230 }
236 // Check if there is a draw info that is compatible that uses the same VB fr om the pool and 231 // Check if there is a draw info that is compatible that uses the same VB fr om the pool and
237 // the same IB 232 // the same IB
238 if (kDraw_Cmd != strip_trace_bit(fCmds.back())) { 233 if (kDraw_Cmd != strip_trace_bit(fCmds.back())) {
239 return 0; 234 return 0;
240 } 235 }
241 236
242 DrawRecord* draw = &fDraws.back(); 237 Draw* draw = &fDraws.back();
243 GeometryPoolState& poolState = fGeoPoolStateStack.back(); 238 GeometryPoolState& poolState = fGeoPoolStateStack.back();
244 const GrVertexBuffer* vertexBuffer = poolState.fPoolVertexBuffer; 239 const GrVertexBuffer* vertexBuffer = poolState.fPoolVertexBuffer;
245 240
246 if (!draw->isInstanced() || 241 if (!draw->isInstanced() ||
247 draw->verticesPerInstance() != info.verticesPerInstance() || 242 draw->verticesPerInstance() != info.verticesPerInstance() ||
248 draw->indicesPerInstance() != info.indicesPerInstance() || 243 draw->indicesPerInstance() != info.indicesPerInstance() ||
249 draw->fVertexBuffer != vertexBuffer || 244 draw->vertexBuffer() != vertexBuffer ||
250 draw->fIndexBuffer != geomSrc.fIndexBuffer) { 245 draw->indexBuffer() != geomSrc.fIndexBuffer) {
251 return 0; 246 return 0;
252 } 247 }
253 // info does not yet account for the offset from the start of the pool's VB while the previous 248 // info does not yet account for the offset from the start of the pool's VB while the previous
254 // draw record does. 249 // draw record does.
255 int adjustedStartVertex = poolState.fPoolStartVertex + info.startVertex(); 250 int adjustedStartVertex = poolState.fPoolStartVertex + info.startVertex();
256 if (draw->startVertex() + draw->vertexCount() != adjustedStartVertex) { 251 if (draw->startVertex() + draw->vertexCount() != adjustedStartVertex) {
257 return 0; 252 return 0;
258 } 253 }
259 254
260 SkASSERT(poolState.fPoolStartVertex == draw->startVertex() + draw->vertexCou nt()); 255 SkASSERT(poolState.fPoolStartVertex == draw->startVertex() + draw->vertexCou nt());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 info.getDevBounds() && 307 info.getDevBounds() &&
313 this->quickInsideClip(*info.getDevBounds())) { 308 this->quickInsideClip(*info.getDevBounds())) {
314 acr.set(this->drawState()); 309 acr.set(this->drawState());
315 } 310 }
316 311
317 if (this->needsNewClip()) { 312 if (this->needsNewClip()) {
318 this->recordClip(); 313 this->recordClip();
319 } 314 }
320 this->recordStateIfNecessary(); 315 this->recordStateIfNecessary();
321 316
322 DrawRecord* draw; 317 const GrVertexBuffer* vb;
318 if (kBuffer_GeometrySrcType == this->getGeomSrc().fVertexSrc) {
319 vb = this->getGeomSrc().fVertexBuffer;
320 } else {
321 vb = poolState.fPoolVertexBuffer;
322 }
323
324 const GrIndexBuffer* ib = NULL;
325 if (info.isIndexed()) {
326 if (kBuffer_GeometrySrcType == this->getGeomSrc().fIndexSrc) {
327 ib = this->getGeomSrc().fIndexBuffer;
328 } else {
329 ib = poolState.fPoolIndexBuffer;
330 }
331 }
332
333 Draw* draw;
323 if (info.isInstanced()) { 334 if (info.isInstanced()) {
324 int instancesConcated = this->concatInstancedDraw(info); 335 int instancesConcated = this->concatInstancedDraw(info);
325 if (info.instanceCount() > instancesConcated) { 336 if (info.instanceCount() > instancesConcated) {
326 draw = this->recordDraw(info); 337 draw = this->recordDraw(info, vb, ib);
327 draw->adjustInstanceCount(-instancesConcated); 338 draw->adjustInstanceCount(-instancesConcated);
328 } else { 339 } else {
329 return; 340 return;
330 } 341 }
331 } else { 342 } else {
332 draw = this->recordDraw(info); 343 draw = this->recordDraw(info, vb, ib);
333 } 344 }
334 345
335 switch (this->getGeomSrc().fVertexSrc) { 346 // Adjust the starting vertex and index when we are using reserved or array sources to
336 case kBuffer_GeometrySrcType: 347 // compensate for the fact that the data was inserted into a larger vb/ib ow ned by the pool.
337 draw->fVertexBuffer = this->getGeomSrc().fVertexBuffer; 348 if (kBuffer_GeometrySrcType != this->getGeomSrc().fVertexSrc) {
338 break; 349 size_t bytes = (info.vertexCount() + info.startVertex()) * drawState.get VertexStride();
339 case kReserved_GeometrySrcType: // fallthrough 350 poolState.fUsedPoolVertexBytes = SkTMax(poolState.fUsedPoolVertexBytes, bytes);
340 case kArray_GeometrySrcType: { 351 draw->adjustStartVertex(poolState.fPoolStartVertex);
341 size_t vertexBytes = (info.vertexCount() + info.startVertex()) *
342 drawState.getVertexStride();
343 poolState.fUsedPoolVertexBytes = SkTMax(poolState.fUsedPoolVertexByt es, vertexBytes);
344 draw->fVertexBuffer = poolState.fPoolVertexBuffer;
345 draw->adjustStartVertex(poolState.fPoolStartVertex);
346 break;
347 }
348 default:
349 SkFAIL("unknown geom src type");
350 } 352 }
351 draw->fVertexBuffer->ref(); 353
352 354 if (info.isIndexed() && kBuffer_GeometrySrcType != this->getGeomSrc().fIndex Src) {
353 if (info.isIndexed()) { 355 size_t bytes = (info.indexCount() + info.startIndex()) * sizeof(uint16_t );
354 switch (this->getGeomSrc().fIndexSrc) { 356 poolState.fUsedPoolIndexBytes = SkTMax(poolState.fUsedPoolIndexBytes, by tes);
355 case kBuffer_GeometrySrcType: 357 draw->adjustStartIndex(poolState.fPoolStartIndex);
356 draw->fIndexBuffer = this->getGeomSrc().fIndexBuffer;
357 break;
358 case kReserved_GeometrySrcType: // fallthrough
359 case kArray_GeometrySrcType: {
360 size_t indexBytes = (info.indexCount() + info.startIndex()) * si zeof(uint16_t);
361 poolState.fUsedPoolIndexBytes = SkTMax(poolState.fUsedPoolIndexB ytes, indexBytes);
362 draw->fIndexBuffer = poolState.fPoolIndexBuffer;
363 draw->adjustStartIndex(poolState.fPoolStartIndex);
364 break;
365 }
366 default:
367 SkFAIL("unknown geom src type");
368 }
369 draw->fIndexBuffer->ref();
370 } else {
371 draw->fIndexBuffer = NULL;
372 } 358 }
373 } 359 }
374 360
375 GrInOrderDrawBuffer::StencilPath::StencilPath() {}
376 GrInOrderDrawBuffer::DrawPath::DrawPath() {}
377 GrInOrderDrawBuffer::DrawPaths::DrawPaths() {}
378 GrInOrderDrawBuffer::DrawPaths::~DrawPaths() {
379 if (fTransforms) {
380 SkDELETE_ARRAY(fTransforms);
381 }
382 if (fIndices) {
383 SkDELETE_ARRAY(fIndices);
384 }
385 }
386
387 void GrInOrderDrawBuffer::onStencilPath(const GrPath* path, SkPath::FillType fil l) { 361 void GrInOrderDrawBuffer::onStencilPath(const GrPath* path, SkPath::FillType fil l) {
388 if (this->needsNewClip()) { 362 if (this->needsNewClip()) {
389 this->recordClip(); 363 this->recordClip();
390 } 364 }
391 // Only compare the subset of GrDrawState relevant to path stenciling? 365 // Only compare the subset of GrDrawState relevant to path stenciling?
392 this->recordStateIfNecessary(); 366 this->recordStateIfNecessary();
393 StencilPath* sp = this->recordStencilPath(); 367 StencilPath* sp = this->recordStencilPath(path);
394 sp->fPath.reset(path);
395 path->ref();
396 sp->fFill = fill; 368 sp->fFill = fill;
397 } 369 }
398 370
399 void GrInOrderDrawBuffer::onDrawPath(const GrPath* path, 371 void GrInOrderDrawBuffer::onDrawPath(const GrPath* path,
400 SkPath::FillType fill, const GrDeviceCoordT exture* dstCopy) { 372 SkPath::FillType fill, const GrDeviceCoordT exture* dstCopy) {
401 if (this->needsNewClip()) { 373 if (this->needsNewClip()) {
402 this->recordClip(); 374 this->recordClip();
403 } 375 }
404 // TODO: Only compare the subset of GrDrawState relevant to path covering? 376 // TODO: Only compare the subset of GrDrawState relevant to path covering?
405 this->recordStateIfNecessary(); 377 this->recordStateIfNecessary();
406 DrawPath* cp = this->recordDrawPath(); 378 DrawPath* cp = this->recordDrawPath(path);
407 cp->fPath.reset(path);
408 path->ref();
409 cp->fFill = fill; 379 cp->fFill = fill;
410 if (dstCopy) { 380 if (dstCopy) {
411 cp->fDstCopy = *dstCopy; 381 cp->fDstCopy = *dstCopy;
412 } 382 }
413 } 383 }
414 384
415 void GrInOrderDrawBuffer::onDrawPaths(const GrPathRange* pathRange, 385 void GrInOrderDrawBuffer::onDrawPaths(const GrPathRange* pathRange,
416 const uint32_t indices[], int count, 386 const uint32_t indices[], int count,
417 const float transforms[], PathTransformTyp e transformsType, 387 const float transforms[], PathTransformTyp e transformsType,
418 SkPath::FillType fill, const GrDeviceCoord Texture* dstCopy) { 388 SkPath::FillType fill, const GrDeviceCoord Texture* dstCopy) {
419 SkASSERT(pathRange); 389 SkASSERT(pathRange);
420 SkASSERT(indices); 390 SkASSERT(indices);
421 SkASSERT(transforms); 391 SkASSERT(transforms);
422 392
423 if (this->needsNewClip()) { 393 if (this->needsNewClip()) {
424 this->recordClip(); 394 this->recordClip();
425 } 395 }
426 this->recordStateIfNecessary(); 396 this->recordStateIfNecessary();
427 DrawPaths* dp = this->recordDrawPaths(); 397 DrawPaths* dp = this->recordDrawPaths(pathRange);
428 dp->fPathRange.reset(SkRef(pathRange));
429 dp->fIndices = SkNEW_ARRAY(uint32_t, count); // TODO: Accomplish this withou t a malloc 398 dp->fIndices = SkNEW_ARRAY(uint32_t, count); // TODO: Accomplish this withou t a malloc
430 memcpy(dp->fIndices, indices, sizeof(uint32_t) * count); 399 memcpy(dp->fIndices, indices, sizeof(uint32_t) * count);
431 dp->fCount = count; 400 dp->fCount = count;
432 401
433 const int transformsLength = GrPathRendering::PathTransformSize(transformsTy pe) * count; 402 const int transformsLength = GrPathRendering::PathTransformSize(transformsTy pe) * count;
434 dp->fTransforms = SkNEW_ARRAY(float, transformsLength); 403 dp->fTransforms = SkNEW_ARRAY(float, transformsLength);
435 memcpy(dp->fTransforms, transforms, sizeof(float) * transformsLength); 404 memcpy(dp->fTransforms, transforms, sizeof(float) * transformsLength);
436 dp->fTransformsType = transformsType; 405 dp->fTransformsType = transformsType;
437 406
438 dp->fFill = fill; 407 dp->fFill = fill;
(...skipping 10 matching lines...) Expand all
449 renderTarget = this->drawState()->getRenderTarget(); 418 renderTarget = this->drawState()->getRenderTarget();
450 SkASSERT(renderTarget); 419 SkASSERT(renderTarget);
451 } 420 }
452 if (NULL == rect) { 421 if (NULL == rect) {
453 // We could do something smart and remove previous draws and clears to 422 // We could do something smart and remove previous draws and clears to
454 // the current render target. If we get that smart we have to make sure 423 // the current render target. If we get that smart we have to make sure
455 // those draws aren't read before this clear (render-to-texture). 424 // those draws aren't read before this clear (render-to-texture).
456 r.setLTRB(0, 0, renderTarget->width(), renderTarget->height()); 425 r.setLTRB(0, 0, renderTarget->width(), renderTarget->height());
457 rect = &r; 426 rect = &r;
458 } 427 }
459 Clear* clr = this->recordClear(); 428 Clear* clr = this->recordClear(renderTarget);
460 GrColorIsPMAssert(color); 429 GrColorIsPMAssert(color);
461 clr->fColor = color; 430 clr->fColor = color;
462 clr->fRect = *rect; 431 clr->fRect = *rect;
463 clr->fCanIgnoreRect = canIgnoreRect; 432 clr->fCanIgnoreRect = canIgnoreRect;
464 clr->fRenderTarget = renderTarget;
465 renderTarget->ref();
466 } 433 }
467 434
468 void GrInOrderDrawBuffer::discard(GrRenderTarget* renderTarget) { 435 void GrInOrderDrawBuffer::discard(GrRenderTarget* renderTarget) {
469 if (!this->caps()->discardRenderTargetSupport()) { 436 if (!this->caps()->discardRenderTargetSupport()) {
470 return; 437 return;
471 } 438 }
472 if (NULL == renderTarget) { 439 if (NULL == renderTarget) {
473 renderTarget = this->drawState()->getRenderTarget(); 440 renderTarget = this->drawState()->getRenderTarget();
474 SkASSERT(renderTarget); 441 SkASSERT(renderTarget);
475 } 442 }
476 Clear* clr = this->recordClear(); 443 Clear* clr = this->recordClear(renderTarget);
477 clr->fColor = GrColor_ILLEGAL; 444 clr->fColor = GrColor_ILLEGAL;
478 clr->fRenderTarget = renderTarget;
479 renderTarget->ref();
480 } 445 }
481 446
482 void GrInOrderDrawBuffer::reset() { 447 void GrInOrderDrawBuffer::reset() {
483 SkASSERT(1 == fGeoPoolStateStack.count()); 448 SkASSERT(1 == fGeoPoolStateStack.count());
484 this->resetVertexSource(); 449 this->resetVertexSource();
485 this->resetIndexSource(); 450 this->resetIndexSource();
486 451
487 DrawAllocator::Iter drawIter(&fDraws);
488 while (drawIter.next()) {
489 // we always have a VB, but not always an IB
490 SkASSERT(drawIter->fVertexBuffer);
491 drawIter->fVertexBuffer->unref();
492 SkSafeUnref(drawIter->fIndexBuffer);
493 }
494 fCmds.reset(); 452 fCmds.reset();
495 fDraws.reset(); 453 fDraws.reset();
496 fStencilPaths.reset(); 454 fStencilPaths.reset();
497 fDrawPath.reset(); 455 fDrawPath.reset();
498 fDrawPaths.reset(); 456 fDrawPaths.reset();
499 fStates.reset(); 457 fStates.reset();
500 fClears.reset(); 458 fClears.reset();
501 fVertexPool.reset(); 459 fVertexPool.reset();
502 fIndexPool.reset(); 460 fIndexPool.reset();
503 fClips.reset(); 461 fClips.reset();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 if (cmd_has_trace_marker(fCmds[c])) { 510 if (cmd_has_trace_marker(fCmds[c])) {
553 traceString = fGpuCmdMarkers[currCmdMarker].toString(); 511 traceString = fGpuCmdMarkers[currCmdMarker].toString();
554 newMarker.fMarker = traceString.c_str(); 512 newMarker.fMarker = traceString.c_str();
555 fDstGpu->addGpuTraceMarker(&newMarker); 513 fDstGpu->addGpuTraceMarker(&newMarker);
556 ++currCmdMarker; 514 ++currCmdMarker;
557 } 515 }
558 switch (strip_trace_bit(fCmds[c])) { 516 switch (strip_trace_bit(fCmds[c])) {
559 case kDraw_Cmd: { 517 case kDraw_Cmd: {
560 SkASSERT(fDstGpu->drawState() != prevDrawState); 518 SkASSERT(fDstGpu->drawState() != prevDrawState);
561 SkAssertResult(drawIter.next()); 519 SkAssertResult(drawIter.next());
562 fDstGpu->setVertexSourceToBuffer(drawIter->fVertexBuffer); 520 fDstGpu->setVertexSourceToBuffer(drawIter->vertexBuffer());
563 if (drawIter->isIndexed()) { 521 if (drawIter->isIndexed()) {
564 fDstGpu->setIndexSourceToBuffer(drawIter->fIndexBuffer); 522 fDstGpu->setIndexSourceToBuffer(drawIter->indexBuffer());
565 } 523 }
566 fDstGpu->executeDraw(*drawIter); 524 fDstGpu->executeDraw(*drawIter);
567 break; 525 break;
568 } 526 }
569 case kStencilPath_Cmd: { 527 case kStencilPath_Cmd: {
570 SkASSERT(fDstGpu->drawState() != prevDrawState); 528 SkASSERT(fDstGpu->drawState() != prevDrawState);
571 SkAssertResult(stencilPathIter.next()); 529 SkAssertResult(stencilPathIter.next());
572 fDstGpu->stencilPath(stencilPathIter->fPath.get(), stencilPathIt er->fFill); 530 fDstGpu->stencilPath(stencilPathIter->path(), stencilPathIter->f Fill);
573 break; 531 break;
574 } 532 }
575 case kDrawPath_Cmd: { 533 case kDrawPath_Cmd: {
576 SkASSERT(fDstGpu->drawState() != prevDrawState); 534 SkASSERT(fDstGpu->drawState() != prevDrawState);
577 SkAssertResult(drawPathIter.next()); 535 SkAssertResult(drawPathIter.next());
578 fDstGpu->executeDrawPath(drawPathIter->fPath.get(), drawPathIter ->fFill, 536 fDstGpu->executeDrawPath(drawPathIter->path(), drawPathIter->fFi ll,
579 drawPathIter->fDstCopy.texture() ? 537 drawPathIter->fDstCopy.texture() ?
580 &drawPathIter->fDstCopy : 538 &drawPathIter->fDstCopy :
581 NULL); 539 NULL);
582 break; 540 break;
583 } 541 }
584 case kDrawPaths_Cmd: { 542 case kDrawPaths_Cmd: {
585 SkASSERT(fDstGpu->drawState() != prevDrawState); 543 SkASSERT(fDstGpu->drawState() != prevDrawState);
586 SkAssertResult(drawPathsIter.next()); 544 SkAssertResult(drawPathsIter.next());
587 const GrDeviceCoordTexture* dstCopy = 545 const GrDeviceCoordTexture* dstCopy =
588 drawPathsIter->fDstCopy.texture() ? &drawPathsIter->fDstCopy : NULL; 546 drawPathsIter->fDstCopy.texture() ? &drawPathsIter->fDstCopy : NULL;
589 fDstGpu->executeDrawPaths(drawPathsIter->fPathRange.get(), 547 fDstGpu->executeDrawPaths(drawPathsIter->pathRange(),
590 drawPathsIter->fIndices, 548 drawPathsIter->fIndices,
591 drawPathsIter->fCount, 549 drawPathsIter->fCount,
592 drawPathsIter->fTransforms, 550 drawPathsIter->fTransforms,
593 drawPathsIter->fTransformsType, 551 drawPathsIter->fTransformsType,
594 drawPathsIter->fFill, 552 drawPathsIter->fFill,
595 dstCopy); 553 dstCopy);
596 break; 554 break;
597 } 555 }
598 case kSetState_Cmd: 556 case kSetState_Cmd:
599 SkAssertResult(stateIter.next()); 557 SkAssertResult(stateIter.next());
600 fDstGpu->setDrawState(stateIter.get()); 558 fDstGpu->setDrawState(stateIter.get());
601 break; 559 break;
602 case kSetClip_Cmd: 560 case kSetClip_Cmd:
603 SkAssertResult(clipIter.next()); 561 SkAssertResult(clipIter.next());
604 clipData.fClipStack = &clipIter->fStack; 562 clipData.fClipStack = &clipIter->fStack;
605 clipData.fOrigin = clipIter->fOrigin; 563 clipData.fOrigin = clipIter->fOrigin;
606 fDstGpu->setClip(&clipData); 564 fDstGpu->setClip(&clipData);
607 break; 565 break;
608 case kClear_Cmd: 566 case kClear_Cmd:
609 SkAssertResult(clearIter.next()); 567 SkAssertResult(clearIter.next());
610 if (GrColor_ILLEGAL == clearIter->fColor) { 568 if (GrColor_ILLEGAL == clearIter->fColor) {
611 fDstGpu->discard(clearIter->fRenderTarget); 569 fDstGpu->discard(clearIter->renderTarget());
612 } else { 570 } else {
613 fDstGpu->clear(&clearIter->fRect, 571 fDstGpu->clear(&clearIter->fRect,
614 clearIter->fColor, 572 clearIter->fColor,
615 clearIter->fCanIgnoreRect, 573 clearIter->fCanIgnoreRect,
616 clearIter->fRenderTarget); 574 clearIter->renderTarget());
617 } 575 }
618 break; 576 break;
619 case kCopySurface_Cmd: 577 case kCopySurface_Cmd:
620 SkAssertResult(copySurfaceIter.next()); 578 SkAssertResult(copySurfaceIter.next());
621 fDstGpu->copySurface(copySurfaceIter->fDst.get(), 579 fDstGpu->copySurface(copySurfaceIter->dst(),
622 copySurfaceIter->fSrc.get(), 580 copySurfaceIter->src(),
623 copySurfaceIter->fSrcRect, 581 copySurfaceIter->fSrcRect,
624 copySurfaceIter->fDstPoint); 582 copySurfaceIter->fDstPoint);
625 break; 583 break;
626 } 584 }
627 if (cmd_has_trace_marker(fCmds[c])) { 585 if (cmd_has_trace_marker(fCmds[c])) {
628 fDstGpu->removeGpuTraceMarker(&newMarker); 586 fDstGpu->removeGpuTraceMarker(&newMarker);
629 } 587 }
630 } 588 }
631 fDstGpu->restoreActiveTraceMarkers(); 589 fDstGpu->restoreActiveTraceMarkers();
632 // we should have consumed all the states, clips, etc. 590 // we should have consumed all the states, clips, etc.
(...skipping 12 matching lines...) Expand all
645 prevDrawState->unref(); 603 prevDrawState->unref();
646 this->reset(); 604 this->reset();
647 ++fDrawID; 605 ++fDrawID;
648 } 606 }
649 607
650 bool GrInOrderDrawBuffer::onCopySurface(GrSurface* dst, 608 bool GrInOrderDrawBuffer::onCopySurface(GrSurface* dst,
651 GrSurface* src, 609 GrSurface* src,
652 const SkIRect& srcRect, 610 const SkIRect& srcRect,
653 const SkIPoint& dstPoint) { 611 const SkIPoint& dstPoint) {
654 if (fDstGpu->canCopySurface(dst, src, srcRect, dstPoint)) { 612 if (fDstGpu->canCopySurface(dst, src, srcRect, dstPoint)) {
655 CopySurface* cs = this->recordCopySurface(); 613 CopySurface* cs = this->recordCopySurface(dst, src);
656 cs->fDst.reset(SkRef(dst));
657 cs->fSrc.reset(SkRef(src));
658 cs->fSrcRect = srcRect; 614 cs->fSrcRect = srcRect;
659 cs->fDstPoint = dstPoint; 615 cs->fDstPoint = dstPoint;
660 return true; 616 return true;
661 } else { 617 } else {
662 return false; 618 return false;
663 } 619 }
664 } 620 }
665 621
666 bool GrInOrderDrawBuffer::onCanCopySurface(GrSurface* dst, 622 bool GrInOrderDrawBuffer::onCanCopySurface(GrSurface* dst,
667 GrSurface* src, 623 GrSurface* src,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 754
799 // Similar to releaseReservedVertexSpace we return any unused portion at 755 // Similar to releaseReservedVertexSpace we return any unused portion at
800 // the tail 756 // the tail
801 size_t reservedIndexBytes = sizeof(uint16_t) * geoSrc.fIndexCount; 757 size_t reservedIndexBytes = sizeof(uint16_t) * geoSrc.fIndexCount;
802 fIndexPool.putBack(reservedIndexBytes - poolState.fUsedPoolIndexBytes); 758 fIndexPool.putBack(reservedIndexBytes - poolState.fUsedPoolIndexBytes);
803 poolState.fUsedPoolIndexBytes = 0; 759 poolState.fUsedPoolIndexBytes = 0;
804 poolState.fPoolIndexBuffer = NULL; 760 poolState.fPoolIndexBuffer = NULL;
805 poolState.fPoolStartIndex = 0; 761 poolState.fPoolStartIndex = 0;
806 } 762 }
807 763
808 void GrInOrderDrawBuffer::onSetVertexSourceToArray(const void* vertexArray, 764 void GrInOrderDrawBuffer::onSetVertexSourceToArray(const void* vertexArray, int vertexCount) {
809 int vertexCount) {
810
811 GeometryPoolState& poolState = fGeoPoolStateStack.back(); 765 GeometryPoolState& poolState = fGeoPoolStateStack.back();
812 SkASSERT(0 == poolState.fUsedPoolVertexBytes); 766 SkASSERT(0 == poolState.fUsedPoolVertexBytes);
813 #ifdef SK_DEBUG 767 #ifdef SK_DEBUG
814 bool success = 768 bool success =
815 #endif 769 #endif
816 fVertexPool.appendVertices(this->getVertexSize(), 770 fVertexPool.appendVertices(this->getVertexSize(),
817 vertexCount, 771 vertexCount,
818 vertexArray, 772 vertexArray,
819 &poolState.fPoolVertexBuffer, 773 &poolState.fPoolVertexBuffer,
820 &poolState.fPoolStartVertex); 774 &poolState.fPoolStartVertex);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 poolState.fUsedPoolVertexBytes = 0; 806 poolState.fUsedPoolVertexBytes = 0;
853 poolState.fUsedPoolIndexBytes = 0; 807 poolState.fUsedPoolIndexBytes = 0;
854 #ifdef SK_DEBUG 808 #ifdef SK_DEBUG
855 poolState.fPoolVertexBuffer = (GrVertexBuffer*)~0; 809 poolState.fPoolVertexBuffer = (GrVertexBuffer*)~0;
856 poolState.fPoolStartVertex = ~0; 810 poolState.fPoolStartVertex = ~0;
857 poolState.fPoolIndexBuffer = (GrIndexBuffer*)~0; 811 poolState.fPoolIndexBuffer = (GrIndexBuffer*)~0;
858 poolState.fPoolStartIndex = ~0; 812 poolState.fPoolStartIndex = ~0;
859 #endif 813 #endif
860 } 814 }
861 815
862 void GrInOrderDrawBuffer::geometrySourceWillPop( 816 void GrInOrderDrawBuffer::geometrySourceWillPop(const GeometrySrcState& restored State) {
863 const GeometrySrcState& restoredState) {
864 SkASSERT(fGeoPoolStateStack.count() > 1); 817 SkASSERT(fGeoPoolStateStack.count() > 1);
865 fGeoPoolStateStack.pop_back(); 818 fGeoPoolStateStack.pop_back();
866 GeometryPoolState& poolState = fGeoPoolStateStack.back(); 819 GeometryPoolState& poolState = fGeoPoolStateStack.back();
867 // we have to assume that any slack we had in our vertex/index data 820 // we have to assume that any slack we had in our vertex/index data
868 // is now unreleasable because data may have been appended later in the 821 // is now unreleasable because data may have been appended later in the
869 // pool. 822 // pool.
870 if (kReserved_GeometrySrcType == restoredState.fVertexSrc || 823 if (kReserved_GeometrySrcType == restoredState.fVertexSrc ||
871 kArray_GeometrySrcType == restoredState.fVertexSrc) { 824 kArray_GeometrySrcType == restoredState.fVertexSrc) {
872 poolState.fUsedPoolVertexBytes = restoredState.fVertexSize * restoredSta te.fVertexCount; 825 poolState.fUsedPoolVertexBytes = restoredState.fVertexSize * restoredSta te.fVertexCount;
873 } 826 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 } 880 }
928 } 881 }
929 882
930 void GrInOrderDrawBuffer::recordClip() { 883 void GrInOrderDrawBuffer::recordClip() {
931 fClips.push_back().fStack = *this->getClip()->fClipStack; 884 fClips.push_back().fStack = *this->getClip()->fClipStack;
932 fClips.back().fOrigin = this->getClip()->fOrigin; 885 fClips.back().fOrigin = this->getClip()->fOrigin;
933 fClipSet = false; 886 fClipSet = false;
934 this->addToCmdBuffer(kSetClip_Cmd); 887 this->addToCmdBuffer(kSetClip_Cmd);
935 } 888 }
936 889
937 GrInOrderDrawBuffer::DrawRecord* GrInOrderDrawBuffer::recordDraw(const DrawInfo& info) { 890 GrInOrderDrawBuffer::Draw* GrInOrderDrawBuffer::recordDraw(const DrawInfo& info,
891 const GrVertexBuffer* vb,
892 const GrIndexBuffer* ib) {
938 this->addToCmdBuffer(kDraw_Cmd); 893 this->addToCmdBuffer(kDraw_Cmd);
939 return &fDraws.push_back(info); 894 return GrNEW_APPEND_TO_ALLOCATOR(&fDraws, Draw, (info, vb, ib));
940 } 895 }
941 896
942 GrInOrderDrawBuffer::StencilPath* GrInOrderDrawBuffer::recordStencilPath() { 897 GrInOrderDrawBuffer::StencilPath* GrInOrderDrawBuffer::recordStencilPath(const G rPath* path) {
943 this->addToCmdBuffer(kStencilPath_Cmd); 898 this->addToCmdBuffer(kStencilPath_Cmd);
944 return &fStencilPaths.push_back(); 899 return GrNEW_APPEND_TO_ALLOCATOR(&fStencilPaths, StencilPath, (path));
945 } 900 }
946 901
947 GrInOrderDrawBuffer::DrawPath* GrInOrderDrawBuffer::recordDrawPath() { 902 GrInOrderDrawBuffer::DrawPath* GrInOrderDrawBuffer::recordDrawPath(const GrPath* path) {
948 this->addToCmdBuffer(kDrawPath_Cmd); 903 this->addToCmdBuffer(kDrawPath_Cmd);
949 return &fDrawPath.push_back(); 904 return GrNEW_APPEND_TO_ALLOCATOR(&fDrawPath, DrawPath, (path));
950 } 905 }
951 906
952 GrInOrderDrawBuffer::DrawPaths* GrInOrderDrawBuffer::recordDrawPaths() { 907 GrInOrderDrawBuffer::DrawPaths* GrInOrderDrawBuffer::recordDrawPaths(const GrPat hRange* pathRange) {
953 this->addToCmdBuffer(kDrawPaths_Cmd); 908 this->addToCmdBuffer(kDrawPaths_Cmd);
954 return &fDrawPaths.push_back(); 909 return GrNEW_APPEND_TO_ALLOCATOR(&fDrawPaths, DrawPaths, (pathRange));
955 } 910 }
956 911
957 GrInOrderDrawBuffer::Clear* GrInOrderDrawBuffer::recordClear() { 912 GrInOrderDrawBuffer::Clear* GrInOrderDrawBuffer::recordClear(GrRenderTarget* rt) {
958 this->addToCmdBuffer(kClear_Cmd); 913 this->addToCmdBuffer(kClear_Cmd);
959 return &fClears.push_back(); 914 return GrNEW_APPEND_TO_ALLOCATOR(&fClears, Clear, (rt));
960 } 915 }
961 916
962 GrInOrderDrawBuffer::CopySurface* GrInOrderDrawBuffer::recordCopySurface() { 917 GrInOrderDrawBuffer::CopySurface* GrInOrderDrawBuffer::recordCopySurface(GrSurfa ce* dst,
918 GrSurfa ce* src) {
963 this->addToCmdBuffer(kCopySurface_Cmd); 919 this->addToCmdBuffer(kCopySurface_Cmd);
964 return &fCopySurfaces.push_back(); 920 return GrNEW_APPEND_TO_ALLOCATOR(&fCopySurfaces, CopySurface, (dst, src));
965 } 921 }
966 922
967 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) { 923 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) {
968 INHERITED::clipWillBeSet(newClipData); 924 INHERITED::clipWillBeSet(newClipData);
969 fClipSet = true; 925 fClipSet = true;
970 fClipProxyState = kUnknown_ClipProxyState; 926 fClipProxyState = kUnknown_ClipProxyState;
971 } 927 }
OLDNEW
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698