Hide formats in GrGLCaps and use specific getters for different GL functions.
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1580003002

Review URL: https://codereview.chromium.org/1580003002
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index db60ad2..c51dce1 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -29,24 +29,6 @@
 public:
     typedef GrGLStencilAttachment::Format StencilFormat;
 
-    /** Provides information about the mappiing from GrPixelConfig to GL formats. */
-    struct ConfigFormats {
-        ConfigFormats() {
-            // Inits to known bad GL enum values.
-            memset(this, 0xAB, sizeof(ConfigFormats));
-        }
-        GrGLenum fBaseInternalFormat;
-        GrGLenum fSizedInternalFormat;
-        GrGLenum fExternalFormat;
-        GrGLenum fExternalType;
-
-        // The <format> parameter to use for glTexImage and glTexSubImage.
-        // This is usually the same as fExternalFormat except for kSRGBA on some GL contexts.
-        GrGLenum fExternalFormatForTexImage;
-        // Either the base or sized internal format depending on the GL and config.
-        GrGLenum fInternalFormatTexImage;
-    };
-
     /**
      * The type of MSAA for FBOs supported. Different extensions have different
      * semantics of how / when a resolve is performed.
@@ -138,16 +120,22 @@
         }
     }
 
-    /** Returns conversions to various GL format parameters for a GrPixelCfonig. */
-    const ConfigFormats& configGLFormats(GrPixelConfig config) const {
-        return fConfigTable[config].fFormats;
-    }
-
     /** Returns the mapping between GrPixelConfig components and GL internal format components. */
     const GrSwizzle& configSwizzle(GrPixelConfig config) const {
         return fConfigTable[config].fSwizzle;
     }
 
+    bool getTexImageFormats(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig,
+                            GrGLenum* internalFormat, GrGLenum* externalFormat,
+                            GrGLenum* externalType) const;
+
+    bool getCompressedTexImageFormats(GrPixelConfig surfaceConfig, GrGLenum* internalFormat) const;
+
+    bool getReadPixelsFormat(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig,
+                             GrGLenum* externalFormat, GrGLenum* externalType) const;
+
+    bool getRenderbufferFormat(GrPixelConfig config, GrGLenum* internalFormat) const;
+
     /**
     * Gets an array of legal stencil formats. These formats are not guaranteed
     * to be supported by the driver but are legal GLenum names given the GL
@@ -290,14 +278,10 @@
     bool ES2CompatibilitySupport() const { return fES2CompatibilitySupport; }
 
     /// Can we call glDisable(GL_MULTISAMPLE)?
-    bool multisampleDisableSupport() const {
-        return fMultisampleDisableSupport;
-    }
+    bool multisampleDisableSupport() const { return fMultisampleDisableSupport; }
 
     /// Use indices or vertices in CPU arrays rather than VBOs for dynamic content.
-    bool useNonVBOVertexAndIndexDynamicData() const {
-        return fUseNonVBOVertexAndIndexDynamicData;
-    }
+    bool useNonVBOVertexAndIndexDynamicData() const { return fUseNonVBOVertexAndIndexDynamicData; }
 
     /// Does ReadPixels support the provided format/type combo?
     bool readPixelsSupported(const GrGLInterface* intf,
@@ -334,6 +318,17 @@
     const GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get()); }
 
 private:
+    enum ExternalFormatUsage {
+        kTexImage_ExternalFormatUsage,
+        kOther_ExternalFormatUsage,
+
+        kLast_ExternalFormatUsage = kOther_ExternalFormatUsage
+    };
+    static const int kExternalFormatUsageCnt = kLast_ExternalFormatUsage + 1;
+    bool getExternalFormat(GrPixelConfig surfaceConfig, GrPixelConfig memoryConfig,
+                           ExternalFormatUsage usage, GrGLenum* externalFormat,
+                           GrGLenum* externalType) const;
+
     void init(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterface*);
     void initGLSL(const GrGLContextInfo&);
     bool hasPathRenderingSupport(const GrGLContextInfo&, const GrGLInterface*);
@@ -396,6 +391,29 @@
         GrGLenum fType;
     };
 
+    struct ConfigFormats {
+        ConfigFormats() {
+            // Inits to known bad GL enum values.
+            memset(this, 0xAB, sizeof(ConfigFormats));
+        }
+        GrGLenum fBaseInternalFormat;
+        GrGLenum fSizedInternalFormat;
+
+        /** The external format and type are to be used when uploading/downloading data using this
+            config where both the CPU data and GrSurface are the same config. To get the external
+            format and type when converting between configs while copying to/from memory use
+            getExternalFormat(). 
+            The kTexImage external format is usually the same as kOther except for kSRGBA on some
+            GL contexts. */
+        GrGLenum fExternalFormat[kExternalFormatUsageCnt];
+        GrGLenum fExternalType;
+
+
+        // Either the base or sized internal format depending on the GL and config.
+        GrGLenum fInternalFormatTexImage;
+        GrGLenum fInternalFormatRenderbuffer;
+    };
+
     struct ConfigInfo {
         ConfigInfo() : fStencilFormatIndex(kUnknown_StencilIndex), fFlags(0) {}