Disable BGRA MSAA on Mesa

When a client attempts to wrap a GPU-backed texture into an SkSurface
with MSAA, Ganesh will create a MSAA renderbuffer to first render to
before resolving to the single-sampled texture [1]. Mesa claims to
support EXT_texture_format_BGRA8888, and according to the spec [2],
this should imply support for both BGRA textures and renderbuffers.
In practice, however, Mesa only supports BGRA textures and will error
on glRenderbufferStorage* if the internalformat is BGRA [3].

This causes issues on Chromebooks running mesa, so this CL disables
BGRA MSAA in Skia. This will in turn be read by Chrome to stop
antialiased rasterization of BGRA content.

[1] https://source.chromium.org/chromium/chromium/src/+/main:third_party/skia/src/gpu/ganesh/gl/GrGLGpu.cpp;l=1298;drc=ee5503bf7e1ef7d95d7ff7b248fe82c2ab20d53a
[2] https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_format_BGRA8888.txt
[3] https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/src/mesa/main/fbobject.c#L2326

Bug: b/240075426
Change-Id: Ie6f0d44325ec37567f2156936b273abb9a79a0cd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/567638
Commit-Queue: Brian Ho <hob@chromium.org>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/ganesh/gl/GrGLCaps.cpp b/src/gpu/ganesh/gl/GrGLCaps.cpp
index 1a8e5f5..756cd72 100644
--- a/src/gpu/ganesh/gl/GrGLCaps.cpp
+++ b/src/gpu/ganesh/gl/GrGLCaps.cpp
@@ -1975,7 +1975,15 @@
                 // We are confident that Angle does it as we expect. Our non-angle test bots do seem
                 // to pass and draw correctly so we could consider enabling this more broadly in the
                 // future.
-                if (ctxInfo.angleBackend() != GrGLANGLEBackend::kUnknown) {
+                // In addition, we also need to disable BGRA MSAA on Mesa. When a client attempts
+                // to wrap a GPU-backed texture into an SkSurface with MSAA, Ganesh will create
+                // a MSAA renderbuffer to first render to before resolving to the single-sampled
+                // texture. Mesa claims to support EXT_texture_format_BGRA8888, and according to
+                // the spec, this should imply support for both BGRA textures and renderbuffers.
+                // In practice, however, Mesa only supports BGRA textures and will error on
+                // glRenderbufferStorage* if the internalformat is BGRA.
+                if (ctxInfo.angleBackend() != GrGLANGLEBackend::kUnknown &&
+                    ctxInfo.angleDriver() != GrGLDriver::kMesa) {
                     // Angle incorrectly requires GL_BGRA8_EXT for the interalFormat for both ES2
                     // and ES3 even though this extension does not define that value. The extension
                     // only defines GL_BGRA_EXT as an internal format.
diff --git a/src/gpu/ganesh/gl/GrGLContext.h b/src/gpu/ganesh/gl/GrGLContext.h
index cf34354..28441ce 100644
--- a/src/gpu/ganesh/gl/GrGLContext.h
+++ b/src/gpu/ganesh/gl/GrGLContext.h
@@ -52,6 +52,7 @@
         }
     }
     GrGLANGLEBackend angleBackend() const { return fDriverInfo.fANGLEBackend; }
+    GrGLDriver angleDriver() const { return fDriverInfo.fANGLEDriver; }
     GrGLVendor angleVendor() const { return fDriverInfo.fANGLEVendor; }
     GrGLRenderer angleRenderer() const { return fDriverInfo.fANGLERenderer; }
     /** What driver is running our GL implementation? This is not necessarily related to the vendor.