Remove bridge code for legacy GL GrBackendSurface code

While doing this, I ran into a small #include issue with
GrGLGpu, so I enforced IWYU on it.

Client CLs:
 - https://crrev.com/c/4739911
 - http://cl/553620143
 - http://cl/553628593
 - http://cl/553637942
 - http://cl/553705311
 - http://cl/553821763
 - http://cl/553837992
 - http://ag/24343000
 - http://ag/24343454
 - http://ag/24420576
 - http://ag/24445187
 - https://github.com/flutter/engine/pull/44334
 - https://github.com/flutter/engine/pull/44682

Change-Id: If07cbe3a60593810911c147b8a81e30459623f28
Bug: b/293490566
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/741437
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
diff --git a/include/gpu/GrBackendSurface.h b/include/gpu/GrBackendSurface.h
index 1855261..7279219 100644
--- a/include/gpu/GrBackendSurface.h
+++ b/include/gpu/GrBackendSurface.h
@@ -18,11 +18,6 @@
 
 #include "include/gpu/mock/GrMockTypes.h"
 
-#if !defined(SK_DISABLE_LEGACY_GL_BACKEND_SURFACE) && defined(SK_GL)
-#include "include/gpu/gl/GrGLTypes.h" // IWYU pragma: keep
-#include "include/private/gpu/ganesh/GrGLTypesPriv.h" // IWYU pragma: keep
-#endif
-
 #ifdef SK_VULKAN
 #include "include/gpu/vk/GrVkTypes.h"
 #include "include/private/gpu/ganesh/GrVkTypesPriv.h"
@@ -242,13 +237,6 @@
         } fMock;
     };
     GrTextureType fTextureType = GrTextureType::kNone;
-
-#if !defined(SK_DISABLE_LEGACY_GL_BACKEND_SURFACE) && defined(SK_GL)
-public:
-static GrBackendFormat MakeGL(GrGLenum format, GrGLenum target);
-GrGLFormat asGLFormat() const;
-GrGLenum asGLFormatEnum() const;
-#endif
 };
 
 class SK_API GrBackendTexture {
@@ -450,17 +438,6 @@
 #endif
 
     sk_sp<skgpu::MutableTextureStateRef> fMutableState;
-
-#if !defined(SK_DISABLE_LEGACY_GL_BACKEND_SURFACE) && defined(SK_GL)
-public:
-    GrBackendTexture(int width,
-                     int height,
-                     GrMipmapped,
-                     const GrGLTextureInfo& glInfo,
-                     std::string_view label = {});
-    bool getGLTextureInfo(GrGLTextureInfo*) const;
-    void glTextureParametersModified();
-#endif
 };
 
 class SK_API GrBackendRenderTarget {
@@ -653,16 +630,6 @@
     GrDawnRenderTargetInfo  fDawnInfo;
 #endif
     sk_sp<skgpu::MutableTextureStateRef> fMutableState;
-
-#if !defined(SK_DISABLE_LEGACY_GL_BACKEND_SURFACE) && defined(SK_GL)
-public:
-    GrBackendRenderTarget(int width,
-                          int height,
-                          int sampleCnt,
-                          int stencilBits,
-                          const GrGLFramebufferInfo& glInfo);
-    bool getGLFramebufferInfo(GrGLFramebufferInfo*) const;
-#endif
 };
 
 #endif
diff --git a/src/gpu/ganesh/gl/GrGLBackendSurface.cpp b/src/gpu/ganesh/gl/GrGLBackendSurface.cpp
index 63b255c..43990b3 100644
--- a/src/gpu/ganesh/gl/GrGLBackendSurface.cpp
+++ b/src/gpu/ganesh/gl/GrGLBackendSurface.cpp
@@ -299,55 +299,3 @@
 }
 
 }  // namespace GrBackendRenderTargets
-
-#if !defined(SK_DISABLE_LEGACY_GL_BACKEND_SURFACE) && defined(SK_GL)
-GrBackendFormat GrBackendFormat::MakeGL(GrGLenum format, GrGLenum target) {
-    return GrBackendFormats::MakeGL(format, target);
-}
-
-GrGLFormat GrBackendFormat::asGLFormat() const {
-    return GrBackendFormats::AsGLFormat(*this);
-}
-
-GrGLenum GrBackendFormat::asGLFormatEnum() const {
-    return GrBackendFormats::AsGLFormatEnum(*this);
-}
-
-GrBackendTexture::GrBackendTexture(int width,
-                                   int height,
-                                   skgpu::Mipmapped mipped,
-                                   const GrGLTextureInfo& glInfo,
-                                   std::string_view label)
-        : GrBackendTexture(width,
-                           height,
-                           label,
-                           mipped,
-                           GrBackendApi::kOpenGL,
-                           gl_target_to_gr_target(glInfo.fTarget),
-                           GrGLBackendTextureData(glInfo, sk_make_sp<GrGLTextureParameters>())) {
-    // Make no assumptions about client's texture's parameters.
-    GrBackendTextures::GLTextureParametersModified(this);
-}
-
-bool GrBackendTexture::getGLTextureInfo(GrGLTextureInfo* outInfo) const {
-    return GrBackendTextures::GetGLTextureInfo(*this, outInfo);
-}
-
-void GrBackendTexture::glTextureParametersModified() {
-    GrBackendTextures::GLTextureParametersModified(this);
-}
-
-GrBackendRenderTarget::GrBackendRenderTarget(
-        int width, int height, int sampleCnt, int stencilBits, const GrGLFramebufferInfo& glInfo)
-        : GrBackendRenderTarget(width,
-                                height,
-                                std::max(1, sampleCnt),
-                                stencilBits,
-                                GrBackendApi::kOpenGL,
-                                /*framebufferOnly=*/false,
-                                GrGLBackendRenderTargetData(glInfo)) {}
-
-bool GrBackendRenderTarget::getGLFramebufferInfo(GrGLFramebufferInfo* outInfo) const {
-    return GrBackendRenderTargets::GetGLFramebufferInfo(*this, outInfo);
-}
-#endif
diff --git a/src/gpu/ganesh/gl/GrGLGpu.cpp b/src/gpu/ganesh/gl/GrGLGpu.cpp
index 922807c..710227f 100644
--- a/src/gpu/ganesh/gl/GrGLGpu.cpp
+++ b/src/gpu/ganesh/gl/GrGLGpu.cpp
@@ -7,52 +7,75 @@
 
 #include "src/gpu/ganesh/gl/GrGLGpu.h"
 
+#include "include/core/SkAlphaType.h"
+#include "include/core/SkColor.h"
 #include "include/core/SkColorSpace.h"
-#include "include/core/SkPixmap.h"
+#include "include/core/SkData.h"
+#include "include/core/SkRect.h"
+#include "include/core/SkSize.h"
+#include "include/core/SkString.h"
 #include "include/core/SkTextureCompressionType.h"
 #include "include/core/SkTypes.h"
+#include "include/gpu/GpuTypes.h"
 #include "include/gpu/GrBackendSemaphore.h"
 #include "include/gpu/GrBackendSurface.h"
+#include "include/gpu/GrContextOptions.h"
 #include "include/gpu/GrDirectContext.h"
+#include "include/gpu/GrDriverBugWorkarounds.h"
 #include "include/gpu/GrTypes.h"
+#include "include/gpu/gl/GrGLConfig.h"
+#include "include/private/base/SkFloatingPoint.h"
+#include "include/private/base/SkMath.h"
+#include "include/private/base/SkPoint_impl.h"
 #include "include/private/base/SkTemplates.h"
 #include "include/private/base/SkTo.h"
-#include "src/base/SkAutoMalloc.h"
-#include "src/base/SkHalf.h"
 #include "src/base/SkScopeExit.h"
 #include "src/core/SkCompressedDataUtils.h"
 #include "src/core/SkLRUCache.h"
 #include "src/core/SkMipmap.h"
+#include "src/core/SkSLTypeShared.h"
 #include "src/core/SkTraceEvent.h"
 #include "src/gpu/PipelineUtils.h"
 #include "src/gpu/SkRenderEngineAbortf.h"
+#include "src/gpu/Swizzle.h"
+#include "src/gpu/ganesh/GrAttachment.h"
 #include "src/gpu/ganesh/GrBackendSurfacePriv.h"
 #include "src/gpu/ganesh/GrBackendUtils.h"
-#include "src/gpu/ganesh/GrCpuBuffer.h"
+#include "src/gpu/ganesh/GrBuffer.h"
 #include "src/gpu/ganesh/GrDataUtils.h"
 #include "src/gpu/ganesh/GrDirectContextPriv.h"
-#include "src/gpu/ganesh/GrGpuResourcePriv.h"
+#include "src/gpu/ganesh/GrGpuBuffer.h"
+#include "src/gpu/ganesh/GrImageInfo.h"
 #include "src/gpu/ganesh/GrPipeline.h"
 #include "src/gpu/ganesh/GrProgramInfo.h"
 #include "src/gpu/ganesh/GrRenderTarget.h"
+#include "src/gpu/ganesh/GrSemaphore.h"
 #include "src/gpu/ganesh/GrShaderCaps.h"
+#include "src/gpu/ganesh/GrShaderVar.h"
 #include "src/gpu/ganesh/GrStagingBufferManager.h"
-#include "src/gpu/ganesh/GrSurfaceProxyPriv.h"
+#include "src/gpu/ganesh/GrSurface.h"
 #include "src/gpu/ganesh/GrTexture.h"
 #include "src/gpu/ganesh/GrUtil.h"
+#include "src/gpu/ganesh/GrWindowRectangles.h"
 #include "src/gpu/ganesh/gl/GrGLAttachment.h"
 #include "src/gpu/ganesh/gl/GrGLBackendSurfacePriv.h"
 #include "src/gpu/ganesh/gl/GrGLBuffer.h"
 #include "src/gpu/ganesh/gl/GrGLOpsRenderPass.h"
+#include "src/gpu/ganesh/gl/GrGLProgram.h"
 #include "src/gpu/ganesh/gl/GrGLSemaphore.h"
 #include "src/gpu/ganesh/gl/GrGLTextureRenderTarget.h"
 #include "src/gpu/ganesh/gl/builders/GrGLShaderStringBuilder.h"
-#include "src/sksl/SkSLCompiler.h"
 #include "src/sksl/SkSLProgramKind.h"
 #include "src/sksl/SkSLProgramSettings.h"
+#include "src/sksl/ir/SkSLProgram.h"
 
+#include <algorithm>
+#include <atomic>
 #include <cmath>
+#include <functional>
 #include <memory>
+#include <string>
+#include <utility>
 
 using namespace skia_private;
 
diff --git a/src/gpu/ganesh/gl/GrGLGpu.h b/src/gpu/ganesh/gl/GrGLGpu.h
index 86639b5..8733b6b 100644
--- a/src/gpu/ganesh/gl/GrGLGpu.h
+++ b/src/gpu/ganesh/gl/GrGLGpu.h
@@ -8,32 +8,81 @@
 #ifndef GrGLGpu_DEFINED
 #define GrGLGpu_DEFINED
 
+#include "include/core/SkRefCnt.h"
+#include "include/core/SkSamplingOptions.h"
 #include "include/core/SkTypes.h"
+#include "include/gpu/GrBackendSurface.h"
+#include "include/gpu/GrTypes.h"
 #include "include/gpu/ganesh/gl/GrGLBackendSurface.h"
+#include "include/gpu/gl/GrGLFunctions.h"
+#include "include/gpu/gl/GrGLInterface.h"
+#include "include/gpu/gl/GrGLTypes.h"
+#include "include/private/SkColorData.h"
+#include "include/private/base/SkDebug.h"
 #include "include/private/base/SkTArray.h"
+#include "include/private/base/SkTemplates.h"
+#include "include/private/base/SkTo.h"
+#include "include/private/gpu/ganesh/GrGLTypesPriv.h"
+#include "include/private/gpu/ganesh/GrTypesPriv.h"
 #include "src/core/SkChecksum.h"
 #include "src/core/SkLRUCache.h"
+#include "src/gpu/Blend.h"
+#include "src/gpu/ganesh/GrCaps.h"
 #include "src/gpu/ganesh/GrFinishCallbacks.h"
 #include "src/gpu/ganesh/GrGpu.h"
+#include "src/gpu/ganesh/GrGpuResource.h"
 #include "src/gpu/ganesh/GrNativeRect.h"
+#include "src/gpu/ganesh/GrOpsRenderPass.h"
 #include "src/gpu/ganesh/GrProgramDesc.h"
+#include "src/gpu/ganesh/GrSamplerState.h"
+#include "src/gpu/ganesh/GrScissorState.h"
+#include "src/gpu/ganesh/GrShaderCaps.h"
+#include "src/gpu/ganesh/GrStencilSettings.h"
 #include "src/gpu/ganesh/GrThreadSafePipelineBuilder.h"
 #include "src/gpu/ganesh/GrWindowRectsState.h"
 #include "src/gpu/ganesh/GrXferProcessor.h"
-#include "src/gpu/ganesh/gl/GrGLAttachment.h"
+#include "src/gpu/ganesh/gl/GrGLCaps.h"
 #include "src/gpu/ganesh/gl/GrGLContext.h"
-#include "src/gpu/ganesh/gl/GrGLProgram.h"
+#include "src/gpu/ganesh/gl/GrGLDefines.h"
 #include "src/gpu/ganesh/gl/GrGLRenderTarget.h"
 #include "src/gpu/ganesh/gl/GrGLTexture.h"
+#include "src/gpu/ganesh/gl/GrGLUtil.h"
 #include "src/gpu/ganesh/gl/GrGLVertexArray.h"
 
+#include <array>
+#include <cstddef>
+#include <cstdint>
+#include <memory>
+#include <string_view>
+
+class GrAttachment;
+class GrBackendSemaphore;
+class GrBuffer;
+class GrDirectContext;
 class GrGLBuffer;
 class GrGLOpsRenderPass;
-class GrPipeline;
+class GrGLProgram;
+class GrGpuBuffer;
+class GrProgramInfo;
+class GrRenderTarget;
+class GrSemaphore;
+class GrStagingBufferManager;
+class GrSurface;
+class GrSurfaceProxy;
+class GrTexture;
+class SkData;
 enum class SkTextureCompressionType;
+struct GrContextOptions;
+struct SkIPoint;
+struct SkIRect;
+struct SkISize;
+
+namespace SkSL { enum class GLSLGeneration; }
 
 namespace skgpu {
+class RefCntedCallback;
 class Swizzle;
+enum class Budgeted : bool;
 }
 
 class GrGLGpu final : public GrGpu {
diff --git a/src/gpu/ganesh/gl/GrGLOpsRenderPass.cpp b/src/gpu/ganesh/gl/GrGLOpsRenderPass.cpp
index 35b86a6..b86f3a7 100644
--- a/src/gpu/ganesh/gl/GrGLOpsRenderPass.cpp
+++ b/src/gpu/ganesh/gl/GrGLOpsRenderPass.cpp
@@ -9,6 +9,7 @@
 
 #include "src/gpu/ganesh/GrProgramInfo.h"
 #include "src/gpu/ganesh/GrRenderTarget.h"
+#include "src/gpu/ganesh/gl/GrGLProgram.h"
 
 #ifdef SK_DEBUG
 #include "include/gpu/GrDirectContext.h"
diff --git a/src/gpu/ganesh/surface/SkSurface_Ganesh.cpp b/src/gpu/ganesh/surface/SkSurface_Ganesh.cpp
index 04acbed..5ded0ad 100644
--- a/src/gpu/ganesh/surface/SkSurface_Ganesh.cpp
+++ b/src/gpu/ganesh/surface/SkSurface_Ganesh.cpp
@@ -48,6 +48,11 @@
 #include "src/gpu/ganesh/image/SkImage_Ganesh.h"
 #include "src/image/SkImage_Base.h"
 
+#ifdef SK_IN_RENDERENGINE
+#include "include/gpu/ganesh/gl/GrGLBackendSurface.h"
+#include "include/gpu/gl/GrGLTypes.h"
+#endif
+
 #include <algorithm>
 #include <cstddef>
 #include <utility>
@@ -651,9 +656,11 @@
             GrWrapCacheable::kNo,
             std::move(releaseHelper)));
     if (!proxy) {
+        // TODO(scroggo,kjlubick) inline this into Android's AutoBackendTexture.cpp so we
+        // don't have a sometimes-dependency on the GL backend.
 #ifdef SK_IN_RENDERENGINE
         GrGLTextureInfo textureInfo;
-        bool retrievedTextureInfo = tex.getGLTextureInfo(&textureInfo);
+        bool retrievedTextureInfo = GrBackendTextures::GetGLTextureInfo(tex, &textureInfo);
         RENDERENGINE_ABORTF(
                 "%s failed to wrap the texture into a renderable target "
                 "\n\tGrBackendTexture: (%i x %i) hasMipmaps: %i isProtected: %i texType: %i"
diff --git a/toolchain/linux_trampolines/clang_trampoline_linux.sh b/toolchain/linux_trampolines/clang_trampoline_linux.sh
index 2b17982..b046c32 100755
--- a/toolchain/linux_trampolines/clang_trampoline_linux.sh
+++ b/toolchain/linux_trampolines/clang_trampoline_linux.sh
@@ -128,6 +128,7 @@
   "src/gpu/ganesh/SkGr.cpp"
   "src/gpu/ganesh/effects/GrPerlinNoise2Effect.cpp"
   "src/gpu/ganesh/gl/GrGLBackendSurface.cpp"
+  "src/gpu/ganesh/gl/GrGLGpu.cpp"
   "src/pdf/SkJpeg"
 
   # See //bazel/generate_cpp_files_for_headers.bzl and //include/BUILD.bazel for more.