Add GL_CHROMIUM_framebuffer_multisample support.
authorbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 23 Mar 2011 13:50:34 +0000 (13:50 +0000)
committerbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 23 Mar 2011 13:50:34 +0000 (13:50 +0000)
Review URL: http://codereview.appspot.com/4287072/

git-svn-id: http://skia.googlecode.com/svn/trunk@984 2bbb7eff-a529-9590-31e7-b0007b416f81

gpu/include/GrGLConfig_chrome.h
gpu/src/GrGLInterface.cpp
gpu/src/GrGpuGL.cpp
gpu/src/GrGpuGL.h

index 227e013afc9bb2c4b361ca464604c15fd65a9da0..3e420271dc09728ba5c39c1409d9fc1231ef7cf6 100644 (file)
@@ -7,6 +7,7 @@
 // prototypes.
 #define GL_OES_mapbuffer                      0
 
+#define GL_GLEXT_PROTOTYPES
 #define GR_GL_PLATFORM_HEADER       <GLES2/gl2.h>
 #define GR_GL_PLATFORM_HEADER_EXT   <GLES2/gl2ext.h>
 
index 702b057e3eb92284d5b4e685b7147514dbd12b37..9c3d5bbd6bafb3f29ca86136df8bd6088fb743fe 100644 (file)
@@ -212,11 +212,26 @@ void InitializeGLInterfaceExtensions(GrGLInterface* glBindings) {
         fboFound = true;
     }
     #endif
-
+    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 (has_gl_extension_from_string("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
 
index 1862784c1ec5c3edd1703460bcca9bcb456cbd0f..2ed6aa601c064a355ae957aea0c93ee46f9fdc5e 100644 (file)
@@ -230,25 +230,37 @@ GrGpuGL::GrGpuGL() {
 
     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 @@ void GrGpuGL::resolveTextureRenderTarget(GrGLTexture* texture) {
         // 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);
-
     }
 }
 
index 01344072d51d93cc41c59208a735dc47c3e6d65f..bd6250b728f664ba31995e94f54a073b31f5f243 100644 (file)
@@ -165,9 +165,10 @@ private:
 
     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.