aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-28 16:08:05 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-28 16:08:05 +0000
commit28361fad1054d59ed4e6a320c7a8b8782a1487c7 (patch)
tree77f1c92c7524c79802157e152429b14cf1e81d06 /src/gpu/gl
parentba0c5ea90d0e6b2e8b20696e54fea13ead6dda93 (diff)
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
Diffstat (limited to 'src/gpu/gl')
-rw-r--r--src/gpu/gl/GrGLCaps.cpp5
-rw-r--r--src/gpu/gl/GrGLCaps.h4
-rw-r--r--src/gpu/gl/GrGLDefines.h5
-rw-r--r--src/gpu/gl/GrGpuGL.cpp19
-rw-r--r--src/gpu/gl/GrGpuGL.h2
5 files changed, 27 insertions, 8 deletions
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 47f3f0f0c8..bf7939ccee 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -45,7 +45,6 @@ void GrGLCaps::reset() {
fUseNonVBOVertexAndIndexDynamicData = false;
fIsCoreProfile = false;
fFixedFunctionSupport = false;
- fDiscardFBSupport = false;
fFullClearIsFree = false;
fDropsTileOnZeroDivide = false;
}
@@ -83,7 +82,6 @@ GrGLCaps& GrGLCaps::operator = (const GrGLCaps& caps) {
fUseNonVBOVertexAndIndexDynamicData = caps.fUseNonVBOVertexAndIndexDynamicData;
fIsCoreProfile = caps.fIsCoreProfile;
fFixedFunctionSupport = caps.fFixedFunctionSupport;
- fDiscardFBSupport = caps.fDiscardFBSupport;
fFullClearIsFree = caps.fFullClearIsFree;
fDropsTileOnZeroDivide = caps.fDropsTileOnZeroDivide;
@@ -224,7 +222,7 @@ void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
fUseNonVBOVertexAndIndexDynamicData = true;
}
- fDiscardFBSupport = ctxInfo.hasExtension("GL_EXT_discard_framebuffer");
+ fDiscardRenderTargetSupport = ctxInfo.hasExtension("GL_EXT_discard_framebuffer");
if (kARM_GrGLVendor == ctxInfo.vendor() || kImagination_GrGLVendor == ctxInfo.vendor()) {
fFullClearIsFree = true;
@@ -664,7 +662,6 @@ SkString GrGLCaps::dump() const {
r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO"));
r.appendf("Use non-VBO for dynamic data: %s\n",
(fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO"));
- r.appendf("Discard FrameBuffer support: %s\n", (fDiscardFBSupport ? "YES" : "NO"));
r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO"));
r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO"));
return r;
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index 0939f80c26..21176d16dd 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -245,9 +245,6 @@ public:
bool fixedFunctionSupport() const { return fFixedFunctionSupport; }
- /// Is there support for discarding the frame buffer
- bool discardFBSupport() const { return fDiscardFBSupport; }
-
bool fullClearIsFree() const { return fFullClearIsFree; }
bool dropsTileOnZeroDivide() const { return fDropsTileOnZeroDivide; }
@@ -332,7 +329,6 @@ private:
bool fUseNonVBOVertexAndIndexDynamicData : 1;
bool fIsCoreProfile : 1;
bool fFixedFunctionSupport : 1;
- bool fDiscardFBSupport : 1;
bool fFullClearIsFree : 1;
bool fDropsTileOnZeroDivide : 1;
diff --git a/src/gpu/gl/GrGLDefines.h b/src/gpu/gl/GrGLDefines.h
index 0dbd425f0d..a4dc2f782b 100644
--- a/src/gpu/gl/GrGLDefines.h
+++ b/src/gpu/gl/GrGLDefines.h
@@ -691,6 +691,11 @@
#define GR_GL_DEPTH_ATTACHMENT 0x8D00
#define GR_GL_STENCIL_ATTACHMENT 0x8D20
+// GL_EXT_discard_framebuffer
+#define GR_GL_COLOR 0x1800
+#define GR_GL_DEPTH 0x1801
+#define GR_GL_STENCIL 0x1802
+
#define GR_GL_NONE 0
#define GR_GL_FRAMEBUFFER_COMPLETE 0x8CD5
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index dc2ef7d84e..78bf8f91cf 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -1295,6 +1295,25 @@ void GrGpuGL::onClear(const SkIRect* rect, GrColor color, bool canIgnoreRect) {
GL_CALL(Clear(GR_GL_COLOR_BUFFER_BIT));
}
+void GrGpuGL::discard(GrRenderTarget* renderTarget) {
+ if (NULL == renderTarget) {
+ renderTarget = this->drawState()->getRenderTarget();
+ if (NULL == renderTarget) {
+ return;
+ }
+ }
+
+ GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(renderTarget);
+ if (renderTarget != fHWBoundRenderTarget) {
+ fHWBoundRenderTarget = NULL;
+ GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, glRT->renderFBOID()));
+ }
+ GrGLenum attachments[] = { GR_GL_COLOR };
+ GL_CALL(DiscardFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT(attachments), attachments));
+ renderTarget->flagAsResolved();
+}
+
+
void GrGpuGL::clearStencil() {
if (NULL == this->getDrawState().getRenderTarget()) {
return;
diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h
index 6a895750c5..e173aeff71 100644
--- a/src/gpu/gl/GrGpuGL.h
+++ b/src/gpu/gl/GrGpuGL.h
@@ -40,6 +40,8 @@ public:
GrGLSLGeneration glslGeneration() const { return fGLContext.glslGeneration(); }
const GrGLCaps& glCaps() const { return *fGLContext.caps(); }
+ virtual void discard(GrRenderTarget*) SK_OVERRIDE;
+
// Used by GrGLProgram and GrGLTexGenProgramEffects to configure OpenGL state.
void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* texture);
void setProjectionMatrix(const SkMatrix& matrix,