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

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

Issue 211683002: Add discard API to SkCanvas, plumb it to glDiscardFramebuffer() (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: move to ToT Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.h ('k') | src/gpu/GrRenderTarget.cpp » ('j') | 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"
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 SkASSERT(NULL != renderTarget); 497 SkASSERT(NULL != renderTarget);
498 } 498 }
499 if (NULL == rect) { 499 if (NULL == rect) {
500 // We could do something smart and remove previous draws and clears to 500 // We could do something smart and remove previous draws and clears to
501 // the current render target. If we get that smart we have to make sure 501 // the current render target. If we get that smart we have to make sure
502 // those draws aren't read before this clear (render-to-texture). 502 // those draws aren't read before this clear (render-to-texture).
503 r.setLTRB(0, 0, renderTarget->width(), renderTarget->height()); 503 r.setLTRB(0, 0, renderTarget->width(), renderTarget->height());
504 rect = &r; 504 rect = &r;
505 } 505 }
506 Clear* clr = this->recordClear(); 506 Clear* clr = this->recordClear();
507 GrColorIsPMAssert(color);
507 clr->fColor = color; 508 clr->fColor = color;
508 clr->fRect = *rect; 509 clr->fRect = *rect;
509 clr->fCanIgnoreRect = canIgnoreRect; 510 clr->fCanIgnoreRect = canIgnoreRect;
510 clr->fRenderTarget = renderTarget; 511 clr->fRenderTarget = renderTarget;
511 renderTarget->ref(); 512 renderTarget->ref();
512 } 513 }
513 514
515 void GrInOrderDrawBuffer::discard(GrRenderTarget* renderTarget) {
516 if (!this->caps()->discardRenderTargetSupport()) {
517 return;
518 }
519 if (NULL == renderTarget) {
520 renderTarget = this->drawState()->getRenderTarget();
521 SkASSERT(NULL != renderTarget);
522 }
523 Clear* clr = this->recordClear();
524 clr->fColor = GrColor_ILLEGAL;
525 clr->fRenderTarget = renderTarget;
526 renderTarget->ref();
527 }
528
514 void GrInOrderDrawBuffer::reset() { 529 void GrInOrderDrawBuffer::reset() {
515 SkASSERT(1 == fGeoPoolStateStack.count()); 530 SkASSERT(1 == fGeoPoolStateStack.count());
516 this->resetVertexSource(); 531 this->resetVertexSource();
517 this->resetIndexSource(); 532 this->resetIndexSource();
518 int numDraws = fDraws.count(); 533 int numDraws = fDraws.count();
519 for (int d = 0; d < numDraws; ++d) { 534 for (int d = 0; d < numDraws; ++d) {
520 // we always have a VB, but not always an IB 535 // we always have a VB, but not always an IB
521 SkASSERT(NULL != fDraws[d].fVertexBuffer); 536 SkASSERT(NULL != fDraws[d].fVertexBuffer);
522 fDraws[d].fVertexBuffer->unref(); 537 fDraws[d].fVertexBuffer->unref();
523 SkSafeUnref(fDraws[d].fIndexBuffer); 538 SkSafeUnref(fDraws[d].fIndexBuffer);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 fStates[currState].restoreTo(&playbackState); 638 fStates[currState].restoreTo(&playbackState);
624 ++currState; 639 ++currState;
625 break; 640 break;
626 case kSetClip_Cmd: 641 case kSetClip_Cmd:
627 clipData.fClipStack = &fClips[currClip]; 642 clipData.fClipStack = &fClips[currClip];
628 clipData.fOrigin = fClipOrigins[currClip]; 643 clipData.fOrigin = fClipOrigins[currClip];
629 fDstGpu->setClip(&clipData); 644 fDstGpu->setClip(&clipData);
630 ++currClip; 645 ++currClip;
631 break; 646 break;
632 case kClear_Cmd: 647 case kClear_Cmd:
633 fDstGpu->clear(&fClears[currClear].fRect, 648 if (GrColor_ILLEGAL == fClears[currClear].fColor) {
634 fClears[currClear].fColor, 649 fDstGpu->discard(fClears[currClear].fRenderTarget);
635 fClears[currClear].fCanIgnoreRect, 650 } else {
636 fClears[currClear].fRenderTarget); 651 fDstGpu->clear(&fClears[currClear].fRect,
652 fClears[currClear].fColor,
653 fClears[currClear].fCanIgnoreRect,
654 fClears[currClear].fRenderTarget);
655 }
637 ++currClear; 656 ++currClear;
638 break; 657 break;
639 case kCopySurface_Cmd: 658 case kCopySurface_Cmd:
640 fDstGpu->copySurface(fCopySurfaces[currCopySurface].fDst.get(), 659 fDstGpu->copySurface(fCopySurfaces[currCopySurface].fDst.get(),
641 fCopySurfaces[currCopySurface].fSrc.get(), 660 fCopySurfaces[currCopySurface].fSrc.get(),
642 fCopySurfaces[currCopySurface].fSrcRect, 661 fCopySurfaces[currCopySurface].fSrcRect,
643 fCopySurfaces[currCopySurface].fDstPoint); 662 fCopySurfaces[currCopySurface].fDstPoint);
644 ++currCopySurface; 663 ++currCopySurface;
645 break; 664 break;
646 } 665 }
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 this->addToCmdBuffer(kCopySurface_Cmd); 982 this->addToCmdBuffer(kCopySurface_Cmd);
964 return &fCopySurfaces.push_back(); 983 return &fCopySurfaces.push_back();
965 } 984 }
966 985
967 986
968 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) { 987 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) {
969 INHERITED::clipWillBeSet(newClipData); 988 INHERITED::clipWillBeSet(newClipData);
970 fClipSet = true; 989 fClipSet = true;
971 fClipProxyState = kUnknown_ClipProxyState; 990 fClipProxyState = kUnknown_ClipProxyState;
972 } 991 }
OLDNEW
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.h ('k') | src/gpu/GrRenderTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698