Add GL_CHROMIUM_framebuffer_multisample support.
Review URL: http://codereview.appspot.com/4287072/
git-svn-id: http://skia.googlecode.com/svn/trunk@984 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrGLInterface.cpp b/gpu/src/GrGLInterface.cpp
index 702b057..9c3d5bb 100644
--- a/gpu/src/GrGLInterface.cpp
+++ b/gpu/src/GrGLInterface.cpp
@@ -212,11 +212,26 @@
fboFound = true;
}
#endif
-
- #if GL_APPLE_framebuffer_multisample
- if (has_gl_extension_from_string("GL_APPLE_framebuffer_multisample",
+ bool msaaFound = false;
+ // Chrome advertises the equivalent of GL_EXT_framebuffer_blit plus
+ // GL_EXT_framebuffer_multisample as GL_CHROMIUM_framebuffer_multisample
+ // The EXT suffixes are used on the functions, however.
+ #if GL_EXT_framebuffer_multisample
+ if (!msaaFound &&
+ has_gl_extension_from_string("GL_CHROMIUM_framebuffer_multisample",
extensionString)) {
+ GR_GL_GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT);
+ GR_GL_GET_PROC_SUFFIX(BlitFramebuffer, EXT);
+ msaaFound = true;
+ }
+ #endif
+ #if GL_APPLE_framebuffer_multisample
+ if (!msaaFound &&
+ has_gl_extension_from_string("GL_APPLE_framebuffer_multisample",
+ extensionString)) {
+ GR_GL_GET_PROC_SUFFIX(RenderbufferStorageMultisample, APPLE);
GR_GL_GET_PROC_SUFFIX(ResolveMultisampleFramebuffer, APPLE);
+ msaaFound = true;
}
#endif
diff --git a/gpu/src/GrGpuGL.cpp b/gpu/src/GrGpuGL.cpp
index 1862784..2ed6aa6 100644
--- a/gpu/src/GrGpuGL.cpp
+++ b/gpu/src/GrGpuGL.cpp
@@ -230,25 +230,37 @@
memset(fAASamples, 0, sizeof(fAASamples));
fMSFBOType = kNone_MSFBO;
- if (has_gl_extension("GL_APPLE_framebuffer_multisample")) {
- fMSFBOType = kApple_MSFBO;
- if (gPrintStartupSpew) {
- GrPrintf("MSAA Support: APPLE ES EXT.\n");
+ if (GR_GL_SUPPORT_ES) {
+ if (has_gl_extension("GL_CHROMIUM_framebuffer_multisample")) {
+ // chrome's extension is equivalent to the EXT msaa
+ // and fbo_blit extensions.
+ fMSFBOType = kDesktopEXT_MSFBO;
+ } else if (has_gl_extension("GL_APPLE_framebuffer_multisample")) {
+ fMSFBOType = kAppleES_MSFBO;
+ }
+ } else {
+ GrAssert(GR_GL_SUPPORT_DESKTOP);
+ if ((major >= 3) || has_gl_extension("GL_ARB_framebuffer_object")) {
+ fMSFBOType = kDesktopARB_MSFBO;
+ } else if (has_gl_extension("GL_EXT_framebuffer_multisample") &&
+ has_gl_extension("GL_EXT_framebuffer_blit")) {
+ fMSFBOType = kDesktopEXT_MSFBO;
}
}
- else if (GR_GL_SUPPORT_DESKTOP && (
- (major >= 3) ||
- has_gl_extension("GL_ARB_framebuffer_object") ||
- (has_gl_extension("GL_EXT_framebuffer_multisample") &&
- has_gl_extension("GL_EXT_framebuffer_blit")))) {
- fMSFBOType = kDesktop_MSFBO;
- if (gPrintStartupSpew) {
- GrPrintf("MSAA Support: DESKTOP\n");
- }
- }
- else {
- if (gPrintStartupSpew) {
- GrPrintf("MSAA Support: NONE\n");
+ if (gPrintStartupSpew) {
+ switch (fMSFBOType) {
+ case kNone_MSFBO:
+ GrPrintf("MSAA Support: NONE\n");
+ break;
+ case kDesktopARB_MSFBO:
+ GrPrintf("MSAA Support: DESKTOP ARB.\n");
+ break;
+ case kDesktopEXT_MSFBO:
+ GrPrintf("MSAA Support: DESKTOP EXT.\n");
+ break;
+ case kAppleES_MSFBO:
+ GrPrintf("MSAA Support: APPLE ES.\n");
+ break;
}
}
@@ -1324,19 +1336,24 @@
// we will have rendered to the top of the FBO.
GrGLint top = texture->allocHeight();
GrGLint bottom = texture->allocHeight() - texture->height();
- if (kApple_MSFBO == fMSFBOType) {
+ if (kAppleES_MSFBO == fMSFBOType) {
+ // Apple's extension uses the scissor as the blit bounds.
GR_GL(Enable(GR_GL_SCISSOR_TEST));
GR_GL(Scissor(left, bottom, right-left, top-bottom));
GR_GL(ResolveMultisampleFramebuffer());
fHWBounds.fScissorRect.invalidate();
fHWBounds.fScissorEnabled = true;
} else {
+ if (kDesktopARB_MSFBO != fMSFBOType) {
+ // these respect the scissor during the blit, so disable it.
+ GrAssert(kDesktopEXT_MSFBO == fMSFBOType);
+ flushScissor(NULL);
+ }
GR_GL(BlitFramebuffer(left, bottom, right, top,
left, bottom, right, top,
GR_GL_COLOR_BUFFER_BIT, GR_GL_NEAREST));
}
rt->setDirty(false);
-
}
}
diff --git a/gpu/src/GrGpuGL.h b/gpu/src/GrGpuGL.h
index 0134407..bd6250b 100644
--- a/gpu/src/GrGpuGL.h
+++ b/gpu/src/GrGpuGL.h
@@ -165,9 +165,10 @@
GrGLuint fAASamples[4];
enum {
- kNone_MSFBO = 0,
- kDesktop_MSFBO,
- kApple_MSFBO
+ kNone_MSFBO = 0, //<! no support for MSAA FBOs
+ kDesktopARB_MSFBO,//<! GL3.0-style MSAA FBO (GL_ARB_framebuffer_object)
+ kDesktopEXT_MSFBO,//<! earlier GL_EXT_framebuffer* extensions
+ kAppleES_MSFBO, //<! GL_APPLE_framebuffer_multisample ES extension
} fMSFBOType;
// Do we have stencil wrap ops.