Add discard API to SkCanvas, plumb it to glDiscardFramebuffer()
BUG=skia:2349
R=robertphillips@google.com, reed@google.com
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/211683002
git-svn-id: http://skia.googlecode.com/svn/trunk@13976 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index 178df75..8d34e6c 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -504,6 +504,7 @@
rect = &r;
}
Clear* clr = this->recordClear();
+ GrColorIsPMAssert(color);
clr->fColor = color;
clr->fRect = *rect;
clr->fCanIgnoreRect = canIgnoreRect;
@@ -511,6 +512,20 @@
renderTarget->ref();
}
+void GrInOrderDrawBuffer::discard(GrRenderTarget* renderTarget) {
+ if (!this->caps()->discardRenderTargetSupport()) {
+ return;
+ }
+ if (NULL == renderTarget) {
+ renderTarget = this->drawState()->getRenderTarget();
+ SkASSERT(NULL != renderTarget);
+ }
+ Clear* clr = this->recordClear();
+ clr->fColor = GrColor_ILLEGAL;
+ clr->fRenderTarget = renderTarget;
+ renderTarget->ref();
+}
+
void GrInOrderDrawBuffer::reset() {
SkASSERT(1 == fGeoPoolStateStack.count());
this->resetVertexSource();
@@ -630,10 +645,14 @@
++currClip;
break;
case kClear_Cmd:
- fDstGpu->clear(&fClears[currClear].fRect,
- fClears[currClear].fColor,
- fClears[currClear].fCanIgnoreRect,
- fClears[currClear].fRenderTarget);
+ if (GrColor_ILLEGAL == fClears[currClear].fColor) {
+ fDstGpu->discard(fClears[currClear].fRenderTarget);
+ } else {
+ fDstGpu->clear(&fClears[currClear].fRect,
+ fClears[currClear].fColor,
+ fClears[currClear].fCanIgnoreRect,
+ fClears[currClear].fRenderTarget);
+ }
++currClear;
break;
case kCopySurface_Cmd: