Capture ES3 MSAA blit restrictions using BlitFramebufferSupport not MSFBOType.

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3416

Change-Id: I2baeb954bceb9d92e43e585320ae5fda1b996641
Reviewed-on: https://skia-review.googlesource.com/3416
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 7d1bea3..c2e8f11 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -930,12 +930,9 @@
             fMSFBOType = kES_IMG_MsToTexture_MSFBOType;
         } else if (fUsesMixedSamples) {
             fMSFBOType = kMixedSamples_MSFBOType;
-        } else if (ctxInfo.version() >= GR_GL_VER(3,0)) {
-            fMSFBOType = GrGLCaps::kES_3_0_MSFBOType;
-        } else if (ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample")) {
-            // chrome's extension is equivalent to the EXT msaa
-            // and fbo_blit extensions.
-            fMSFBOType = kDesktop_EXT_MSFBOType;
+        } else if (ctxInfo.version() >= GR_GL_VER(3,0) ||
+                   ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample")) {
+            fMSFBOType = kStandard_MSFBOType;
         } else if (ctxInfo.hasExtension("GL_APPLE_framebuffer_multisample")) {
             fMSFBOType = kES_Apple_MSFBOType;
         }
@@ -953,13 +950,13 @@
         if (fUsesMixedSamples) {
             fMSFBOType = kMixedSamples_MSFBOType;
             fBlitFramebufferSupport = kFull_BlitFramebufferSupport;
-        } else if ((ctxInfo.version() >= GR_GL_VER(3,0)) ||
-            ctxInfo.hasExtension("GL_ARB_framebuffer_object")) {
-            fMSFBOType = GrGLCaps::kDesktop_ARB_MSFBOType;
+        } else if (ctxInfo.version() >= GR_GL_VER(3,0) ||
+                   ctxInfo.hasExtension("GL_ARB_framebuffer_object")) {
+            fMSFBOType = kStandard_MSFBOType;
             fBlitFramebufferSupport = kFull_BlitFramebufferSupport;
         } else if (ctxInfo.hasExtension("GL_EXT_framebuffer_multisample") &&
                    ctxInfo.hasExtension("GL_EXT_framebuffer_blit")) {
-            fMSFBOType = GrGLCaps::kDesktop_EXT_MSFBOType;
+            fMSFBOType = kEXT_MSFBOType;
             fBlitFramebufferSupport = kFull_BlitFramebufferSupport;
         }
     }
@@ -1082,22 +1079,20 @@
 
     static const char* kMSFBOExtStr[] = {
         "None",
-        "ARB",
         "EXT",
-        "ES 3.0",
+        "Standard",
         "Apple",
         "IMG MS To Texture",
         "EXT MS To Texture",
         "MixedSamples",
     };
     GR_STATIC_ASSERT(0 == kNone_MSFBOType);
-    GR_STATIC_ASSERT(1 == kDesktop_ARB_MSFBOType);
-    GR_STATIC_ASSERT(2 == kDesktop_EXT_MSFBOType);
-    GR_STATIC_ASSERT(3 == kES_3_0_MSFBOType);
-    GR_STATIC_ASSERT(4 == kES_Apple_MSFBOType);
-    GR_STATIC_ASSERT(5 == kES_IMG_MsToTexture_MSFBOType);
-    GR_STATIC_ASSERT(6 == kES_EXT_MsToTexture_MSFBOType);
-    GR_STATIC_ASSERT(7 == kMixedSamples_MSFBOType);
+    GR_STATIC_ASSERT(1 == kEXT_MSFBOType);
+    GR_STATIC_ASSERT(2 == kStandard_MSFBOType);
+    GR_STATIC_ASSERT(3 == kES_Apple_MSFBOType);
+    GR_STATIC_ASSERT(4 == kES_IMG_MsToTexture_MSFBOType);
+    GR_STATIC_ASSERT(5 == kES_EXT_MsToTexture_MSFBOType);
+    GR_STATIC_ASSERT(6 == kMixedSamples_MSFBOType);
     GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMSFBOExtStr) == kLast_MSFBOType + 1);
 
     static const char* kInvalidateFBTypeStr[] = {
@@ -1635,9 +1630,8 @@
     fConfigTable[kAlpha_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
     fConfigTable[kAlpha_8_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
     if (this->textureRedSupport() ||
-        (kDesktop_ARB_MSFBOType == this->msFBOType() &&
-         ctxInfo.renderer() != kOSMesa_GrGLRenderer)) {
-        // desktop ARB extension/3.0+ supports ALPHA8 as renderable.
+        (kStandard_MSFBOType == this->msFBOType() && ctxInfo.renderer() != kOSMesa_GrGLRenderer)) {
+        // OpenGL 3.0+ (and GL_ARB_framebuffer_object) supports ALPHA8 as renderable.
         // However, osmesa fails if it used even when GL_ARB_framebuffer_object is present.
         // Core profile removes ALPHA8 support, but we should have chosen R8 in that case.
         fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= allRenderFlags;
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index f0b0940..e162b38 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -42,17 +42,13 @@
          */
         kNone_MSFBOType = 0,
         /**
-         * GL3.0-style MSAA FBO (GL_ARB_framebuffer_object).
+         * OpenGL < 3.0 with GL_EXT_framebuffer_object. Doesn't allow rendering to ALPHA.
          */
-        kDesktop_ARB_MSFBOType,
+        kEXT_MSFBOType,
         /**
-         * earlier GL_EXT_framebuffer* extensions
+         * OpenGL 3.0+, OpenGL ES 3.0+, and GL_ARB_framebuffer_object.
          */
-        kDesktop_EXT_MSFBOType,
-        /**
-         * Similar to kDesktop_ARB but with additional restrictions on glBlitFramebuffer.
-         */
-        kES_3_0_MSFBOType,
+        kStandard_MSFBOType,
         /**
          * GL_APPLE_framebuffer_multisample ES extension
          */
@@ -84,6 +80,11 @@
          * or mirroring.
          */
         kNoScalingNoMirroring_BlitFramebufferSupport,
+        /**
+         * ES3 has restricted support when the src is MSAA: src rect == dst rect, dst format == src
+         * format.
+         */
+        kRectsAndFormatsMatchForMSAASrc_BlitFramebufferSupport,
         kFull_BlitFramebufferSupport
     };
 
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 56f01ed..eae0aa9 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1472,10 +1472,9 @@
     CLEAR_ERROR_BEFORE_ALLOC(ctx.interface());
     SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType());
     switch (ctx.caps()->msFBOType()) {
-        case GrGLCaps::kDesktop_ARB_MSFBOType:
-        case GrGLCaps::kDesktop_EXT_MSFBOType:
+        case GrGLCaps::kEXT_MSFBOType:
+        case GrGLCaps::kStandard_MSFBOType:
         case GrGLCaps::kMixedSamples_MSFBOType:
-        case GrGLCaps::kES_3_0_MSFBOType:
             GL_ALLOC_CALL(ctx.interface(),
                             RenderbufferStorageMultisample(GR_GL_RENDERBUFFER,
                                                             sampleCount,
@@ -3488,14 +3487,17 @@
                     return false;
                 }
                 break;
-            case GrGLCaps::kFull_BlitFramebufferSupport:
+                // ES3 doesn't allow framebuffer blits when the src has MSAA and the configs don't
+                // match or the rects are not the same (not just the same size but have the same
+                // edges).
+            case GrGLCaps::kRectsAndFormatsMatchForMSAASrc_BlitFramebufferSupport:
+                if ((src->desc().fSampleCnt > 0 || src->config() != dst->config())) {
+                    return false;
+                }
                 break;
-        }
-        // ES3 doesn't allow framebuffer blits when the src has MSAA and the configs don't match
-        // or the rects are not the same (not just the same size but have the same edges).
-        if (GrGLCaps::kES_3_0_MSFBOType == gpu->glCaps().msFBOType() &&
-            (src->desc().fSampleCnt > 0 || src->config() != dst->config())) {
-           return false;
+
+            case GrGLCaps::kFull_BlitFramebufferSupport:
+                return true;
         }
         const GrGLTexture* dstTex = static_cast<const GrGLTexture*>(dst->asTexture());
         if (dstTex && dstTex->target() != GR_GL_TEXTURE_2D) {