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

Unified Diff: src/gpu/gl/GrGpuGL.cpp

Issue 218763006: Use glInvalidateFramebuffer() when it is supported. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGLCaps.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGpuGL.cpp
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 93adb508fd30712b7da7fceb7f4b00b85d4f7275..b21043307016a6f0c2ee2a63163669f5c720bc5f 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -1296,6 +1296,9 @@ void GrGpuGL::onClear(const SkIRect* rect, GrColor color, bool canIgnoreRect) {
}
void GrGpuGL::discard(GrRenderTarget* renderTarget) {
+ if (!this->caps()->discardRenderTargetSupport()) {
+ return;
+ }
if (NULL == renderTarget) {
renderTarget = this->drawState()->getRenderTarget();
if (NULL == renderTarget) {
@@ -1308,8 +1311,31 @@ void GrGpuGL::discard(GrRenderTarget* renderTarget) {
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));
+ switch (this->glCaps().invalidateFBType()) {
+ case GrGLCaps::kNone_FBFetchType:
+ GrCrash("Should never get here.");
+ break;
+ case GrGLCaps::kInvalidate_InvalidateFBType:
+ if (0 == glRT->renderFBOID()) {
+ // When rendering to the default framebuffer the legal values for attachments
+ // are GL_COLOR, GL_DEPTH, GL_STENCIL, ... rather than the various FBO attachment
+ // types.
+ static const GrGLenum attachments[] = { GR_GL_COLOR };
+ GL_CALL(InvalidateFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT(attachments),
+ attachments));
+ } else {
+ static const GrGLenum attachments[] = { GR_GL_COLOR_ATTACHMENT0 };
+ GL_CALL(InvalidateFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT(attachments),
+ attachments));
+ }
+ break;
+ case GrGLCaps::kDiscard_InvalidateFBType: {
+ static const GrGLenum attachments[] = { GR_GL_COLOR };
+ GL_CALL(DiscardFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT(attachments),
+ attachments));
+ break;
+ }
+ }
renderTarget->flagAsResolved();
}
« no previous file with comments | « src/gpu/gl/GrGLCaps.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698