Revert "[graphite] Allow GetSkColorTypeFromBufferFormat to be used in Graphite"

This reverts commit cdc40b40cdde070414d75ac289f47c401b7f26b3.

Reason for revert: Android is calling this!!!!!!

Original change's description:
> [graphite] Allow GetSkColorTypeFromBufferFormat to be used in Graphite
>
> Bug: b/237108194
> Change-Id: Ie14c9a9849e4965de1d9258adfe0b746bccb8710
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/787516
> Reviewed-by: Nicolette Prevost <nicolettep@google.com>
> Commit-Queue: Robert Phillips <robertphillips@google.com>
> Reviewed-by: Kevin Lubick <kjlubick@google.com>

Bug: b/237108194
Change-Id: Ib2fc311059e2d4ff6afecf717e73a345a785e1f1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/788459
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Robert Phillips <robertphillips@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index 53b9411..aeec2d9 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -962,10 +962,6 @@
     public_defines += [ "SK_METAL" ]
     sources += skia_shared_mtl_sources
   }
-
-  if (is_android) {
-    sources += skia_shared_android_sources
-  }
 }
 
 optional("gpu") {
diff --git a/bazel/exporter_tool/main.go b/bazel/exporter_tool/main.go
index 550201b..76c58fa 100644
--- a/bazel/exporter_tool/main.go
+++ b/bazel/exporter_tool/main.go
@@ -420,11 +420,6 @@
 				"//src/gpu/mtl:mtl_hdrs",
 				"//src/gpu/mtl:mtl_srcs",
 			}},
-		{Var: "skia_shared_android_sources",
-			Rules: []string{
-				"//src/gpu/android:shared_android_hdrs",
-				"//src/gpu/android:shared_android_srcs",
-			}},
 	}},
 	{GNI: "modules/svg/svg.gni", Vars: []exporter.GNIFileListExportDesc{
 		{Var: "skia_svg_public",
diff --git a/gn/gpu.gni b/gn/gpu.gni
index 7831823..c7cfaa9 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -18,7 +18,6 @@
 #   //include/private/gpu/ganesh/BUILD.bazel
 #   //include/private/gpu/vk/BUILD.bazel
 #   //src/gpu/BUILD.bazel
-#   //src/gpu/android/BUILD.bazel
 #   //src/gpu/ganesh/BUILD.bazel
 #   //src/gpu/ganesh/d3d/BUILD.bazel
 #   //src/gpu/ganesh/effects/BUILD.bazel
@@ -1121,11 +1120,3 @@
   "$_src/gpu/mtl/MtlUtils.mm",
   "$_src/gpu/mtl/MtlUtilsPriv.h",
 ]
-
-# List generated by Bazel rules:
-#  //src/gpu/android:shared_android_hdrs
-#  //src/gpu/android:shared_android_srcs
-skia_shared_android_sources = [
-  "$_src/gpu/android/AHardwareBufferUtils.cpp",
-  "$_src/gpu/android/AHardwareBufferUtils.h",
-]
diff --git a/include/android/GrAHardwareBufferUtils.h b/include/android/GrAHardwareBufferUtils.h
index 1bbc9cf..474e9f4 100644
--- a/include/android/GrAHardwareBufferUtils.h
+++ b/include/android/GrAHardwareBufferUtils.h
@@ -22,6 +22,8 @@
 
 namespace GrAHardwareBufferUtils {
 
+SkColorType GetSkColorTypeFromBufferFormat(uint32_t bufferFormat);
+
 #if !defined(SK_DISABLE_LEGACY_ANDROID_HW_UTILS)
 GrBackendFormat GetBackendFormat(GrDirectContext* dContext, AHardwareBuffer* hardwareBuffer,
                                  uint32_t bufferFormat, bool requireKnownFormat);
diff --git a/src/gpu/BUILD.bazel b/src/gpu/BUILD.bazel
index 23540ae..a06915c 100644
--- a/src/gpu/BUILD.bazel
+++ b/src/gpu/BUILD.bazel
@@ -151,7 +151,6 @@
     ] + select(
         {
             ":has_vulkan": ["//src/gpu/vk:srcs"],
-            "@platforms//os:android": ["//src/gpu/android:android_srcs"],
             "//conditions:default": [],
         },
     ),
diff --git a/src/gpu/android/AHardwareBufferUtils.cpp b/src/gpu/android/AHardwareBufferUtils.cpp
deleted file mode 100644
index 73d786a..0000000
--- a/src/gpu/android/AHardwareBufferUtils.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "src/gpu/android/AHardwareBufferUtils.h"
-
-#if __ANDROID_API__ >= 26
-
-#include <android/hardware_buffer.h>
-
-namespace AHardwareBufferUtils {
-
-SkColorType GetSkColorTypeFromBufferFormat(uint32_t bufferFormat) {
-    switch (bufferFormat) {
-        case AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM:
-            return kRGBA_8888_SkColorType;
-        case AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM:
-            return kRGB_888x_SkColorType;
-        case AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT:
-            return kRGBA_F16_SkColorType;
-        case AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM:
-            return kRGB_565_SkColorType;
-        case AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM:
-            return kRGB_888x_SkColorType;
-        case AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM:
-            return kRGBA_1010102_SkColorType;
-#if __ANDROID_API__ >= 33
-        case AHARDWAREBUFFER_FORMAT_R8_UNORM:
-            return kAlpha_8_SkColorType;
-#endif
-        default:
-            // Given that we only use this texture as a source, colorType will not impact how Skia
-            // uses the texture.  The only potential affect this is anticipated to have is that for
-            // some format types if we are not bound as an OES texture we may get invalid results
-            // for SKP capture if we read back the texture.
-            return kRGBA_8888_SkColorType;
-    }
-}
-
-}  // namespace AHardwareBufferUtils
-
-#endif
diff --git a/src/gpu/android/AHardwareBufferUtils.h b/src/gpu/android/AHardwareBufferUtils.h
deleted file mode 100644
index a1f4f7e..0000000
--- a/src/gpu/android/AHardwareBufferUtils.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#ifndef AHardwareBufferUtils_DEFINED
-#define AHardwareBufferUtils_DEFINED
-
-#include "include/core/SkColorType.h"
-#include "include/core/SkTypes.h"
-
-#if __ANDROID_API__ >= 26
-
-namespace AHardwareBufferUtils {
-
-SkColorType GetSkColorTypeFromBufferFormat(uint32_t bufferFormat);
-
-}  // namespace AHardwareBufferUtils
-
-#endif
-
-#endif // AHardwareBufferUtils_DEFINED
diff --git a/src/gpu/android/BUILD.bazel b/src/gpu/android/BUILD.bazel
deleted file mode 100644
index 1f3805f..0000000
--- a/src/gpu/android/BUILD.bazel
+++ /dev/null
@@ -1,27 +0,0 @@
-load("//bazel:skia_rules.bzl", "exports_files_legacy", "skia_filegroup", "split_srcs_and_hdrs")
-
-licenses(["notice"])
-
-exports_files_legacy()
-
-SHARED_ANDROID_FILES = [
-    "AHardwareBufferUtils.h",
-    "AHardwareBufferUtils.cpp",
-]
-
-split_srcs_and_hdrs(
-    name = "shared_android",
-    files = SHARED_ANDROID_FILES,
-)
-
-skia_filegroup(
-    name = "android_srcs",
-    srcs = [":shared_android_srcs"],
-    visibility = ["//src/gpu:__pkg__"],
-)
-
-skia_filegroup(
-    name = "private_hdrs",
-    srcs = [":shared_android_hdrs"],
-    visibility = ["//src/gpu:__pkg__"],
-)
diff --git a/src/gpu/ganesh/GrAHardwareBufferImageGenerator.cpp b/src/gpu/ganesh/GrAHardwareBufferImageGenerator.cpp
index 39cf958..2de02ee 100644
--- a/src/gpu/ganesh/GrAHardwareBufferImageGenerator.cpp
+++ b/src/gpu/ganesh/GrAHardwareBufferImageGenerator.cpp
@@ -18,7 +18,6 @@
 #include "include/gpu/GrRecordingContext.h"
 #include "include/gpu/gl/GrGLTypes.h"
 #include "src/core/SkMessageBus.h"
-#include "src/gpu/android/AHardwareBufferUtils.h"
 #include "src/gpu/ganesh/GrCaps.h"
 #include "src/gpu/ganesh/GrDirectContextPriv.h"
 #include "src/gpu/ganesh/GrProxyProvider.h"
@@ -39,7 +38,7 @@
     AHardwareBuffer_describe(graphicBuffer, &bufferDesc);
 
     SkColorType colorType =
-            AHardwareBufferUtils::GetSkColorTypeFromBufferFormat(bufferDesc.format);
+            GrAHardwareBufferUtils::GetSkColorTypeFromBufferFormat(bufferDesc.format);
     SkImageInfo info = SkImageInfo::Make(bufferDesc.width, bufferDesc.height, colorType,
                                          alphaType, std::move(colorSpace));
 
diff --git a/src/gpu/ganesh/GrAHardwareBufferUtils.cpp b/src/gpu/ganesh/GrAHardwareBufferUtils.cpp
index 91ec9fd..c7dffb7 100644
--- a/src/gpu/ganesh/GrAHardwareBufferUtils.cpp
+++ b/src/gpu/ganesh/GrAHardwareBufferUtils.cpp
@@ -19,6 +19,33 @@
 
 namespace GrAHardwareBufferUtils {
 
+SkColorType GetSkColorTypeFromBufferFormat(uint32_t bufferFormat) {
+    switch (bufferFormat) {
+        case AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM:
+            return kRGBA_8888_SkColorType;
+        case AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM:
+            return kRGB_888x_SkColorType;
+        case AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT:
+            return kRGBA_F16_SkColorType;
+        case AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM:
+            return kRGB_565_SkColorType;
+        case AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM:
+            return kRGB_888x_SkColorType;
+        case AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM:
+            return kRGBA_1010102_SkColorType;
+#if __ANDROID_API__ >= 33
+        case AHARDWAREBUFFER_FORMAT_R8_UNORM:
+            return kAlpha_8_SkColorType;
+#endif
+        default:
+            // Given that we only use this texture as a source, colorType will not impact how Skia
+            // uses the texture.  The only potential affect this is anticipated to have is that for
+            // some format types if we are not bound as an OES texture we may get invalid results
+            // for SKP capture if we read back the texture.
+            return kRGBA_8888_SkColorType;
+    }
+}
+
 #if !defined(SK_DISABLE_LEGACY_ANDROID_HW_UTILS)
 GrBackendFormat GetBackendFormat(GrDirectContext* dContext, AHardwareBuffer* hardwareBuffer,
                                  uint32_t bufferFormat, bool requireKnownFormat) {
diff --git a/src/gpu/ganesh/surface/SkSurface_AndroidFactories.cpp b/src/gpu/ganesh/surface/SkSurface_AndroidFactories.cpp
index 255e7f2..b2a401e 100644
--- a/src/gpu/ganesh/surface/SkSurface_AndroidFactories.cpp
+++ b/src/gpu/ganesh/surface/SkSurface_AndroidFactories.cpp
@@ -36,7 +36,6 @@
 #include "src/gpu/SkRenderEngineAbortf.h"
 #include "src/gpu/ganesh/Device.h"
 #include "include/android/GrAHardwareBufferUtils.h"
-#include "src/gpu/android/AHardwareBufferUtils.h"
 #include "src/gpu/ganesh/GrCaps.h"
 #include "src/gpu/ganesh/GrContextThreadSafeProxyPriv.h"
 #include "src/gpu/ganesh/GrDirectContextPriv.h"
@@ -76,9 +75,6 @@
     }
 
     bool isTextureable = SkToBool(bufferDesc.usage & AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE);
-    if (!isTextureable) {
-        return nullptr;
-    }
 
     GrBackendFormat backendFormat = GrAHardwareBufferUtils::GetBackendFormat(
             dContext, hardwareBuffer, bufferDesc.format, true);
@@ -86,49 +82,53 @@
         return nullptr;
     }
 
-    GrAHardwareBufferUtils::DeleteImageProc deleteImageProc = nullptr;
-    GrAHardwareBufferUtils::UpdateImageProc updateImageProc = nullptr;
-    GrAHardwareBufferUtils::TexImageCtx deleteImageCtx = nullptr;
+    if (isTextureable) {
+        GrAHardwareBufferUtils::DeleteImageProc deleteImageProc = nullptr;
+        GrAHardwareBufferUtils::UpdateImageProc updateImageProc = nullptr;
+        GrAHardwareBufferUtils::TexImageCtx deleteImageCtx = nullptr;
 
-    bool isProtectedContent =
-            SkToBool(bufferDesc.usage & AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT);
+        bool isProtectedContent =
+                SkToBool(bufferDesc.usage & AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT);
 
-    bool fromWindowLocal = false;
+        bool fromWindowLocal = false;
 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
-    fromWindowLocal = fromWindow;
+        fromWindowLocal = fromWindow;
 #endif
 
-    GrBackendTexture backendTexture =
-            GrAHardwareBufferUtils::MakeBackendTexture(dContext,
-                                                       hardwareBuffer,
-                                                       bufferDesc.width,
-                                                       bufferDesc.height,
-                                                       &deleteImageProc,
-                                                       &updateImageProc,
-                                                       &deleteImageCtx,
-                                                       isProtectedContent,
-                                                       backendFormat,
-                                                       true,
-                                                       fromWindowLocal);
-    if (!backendTexture.isValid()) {
+        GrBackendTexture backendTexture =
+                GrAHardwareBufferUtils::MakeBackendTexture(dContext,
+                                                           hardwareBuffer,
+                                                           bufferDesc.width,
+                                                           bufferDesc.height,
+                                                           &deleteImageProc,
+                                                           &updateImageProc,
+                                                           &deleteImageCtx,
+                                                           isProtectedContent,
+                                                           backendFormat,
+                                                           true,
+                                                           fromWindowLocal);
+        if (!backendTexture.isValid()) {
+            return nullptr;
+        }
+
+        SkColorType colorType =
+                GrAHardwareBufferUtils::GetSkColorTypeFromBufferFormat(bufferDesc.format);
+
+        // Will call deleteImageProc if SkSurface creation fails.
+        sk_sp<SkSurface> surface = SkSurfaces::WrapBackendTexture(dContext,
+                                                                  backendTexture,
+                                                                  origin,
+                                                                  0,
+                                                                  colorType,
+                                                                  std::move(colorSpace),
+                                                                  surfaceProps,
+                                                                  deleteImageProc,
+                                                                  deleteImageCtx);
+
+        return surface;
+    } else {
         return nullptr;
     }
-
-    SkColorType colorType =
-            AHardwareBufferUtils::GetSkColorTypeFromBufferFormat(bufferDesc.format);
-
-    // Will call deleteImageProc if SkSurface creation fails.
-    sk_sp<SkSurface> surface = SkSurfaces::WrapBackendTexture(dContext,
-                                                              backendTexture,
-                                                              origin,
-                                                              0,
-                                                              colorType,
-                                                              std::move(colorSpace),
-                                                              surfaceProps,
-                                                              deleteImageProc,
-                                                              deleteImageCtx);
-
-    return surface;
 }
 
 }  // namespace SkSurfaces
diff --git a/src/image/SkImage_AndroidFactories.cpp b/src/image/SkImage_AndroidFactories.cpp
index 5a1d5da..a595c96 100644
--- a/src/image/SkImage_AndroidFactories.cpp
+++ b/src/image/SkImage_AndroidFactories.cpp
@@ -37,7 +37,6 @@
 #include "src/core/SkImageInfoPriv.h"
 #include "src/gpu/RefCntedCallback.h"
 #include "src/gpu/SkBackingFit.h"
-#include "src/gpu/android/AHardwareBufferUtils.h"
 #include "src/gpu/ganesh/GrAHardwareBufferImageGenerator.h"
 #include "src/gpu/ganesh/GrBackendTextureImageGenerator.h"
 #include "src/gpu/ganesh/GrBackendUtils.h"
@@ -128,7 +127,7 @@
     auto releaseHelper = skgpu::RefCntedCallback::Make(deleteImageProc, deleteImageCtx);
 
     SkColorType colorType =
-            AHardwareBufferUtils::GetSkColorTypeFromBufferFormat(bufferDesc.format);
+            GrAHardwareBufferUtils::GetSkColorTypeFromBufferFormat(bufferDesc.format);
 
     GrColorType grColorType = SkColorTypeToGrColorType(colorType);
 
diff --git a/tests/MultiPictureDocumentTest.cpp b/tests/MultiPictureDocumentTest.cpp
index 275946c..6cbead0 100644
--- a/tests/MultiPictureDocumentTest.cpp
+++ b/tests/MultiPictureDocumentTest.cpp
@@ -189,7 +189,6 @@
 #include "include/core/SkColorType.h"
 #include "include/gpu/GrDirectContext.h"
 #include "include/gpu/ganesh/SkImageGanesh.h"
-#include "src/gpu/android/AHardwareBufferUtils.h"
 #include "src/gpu/ganesh/GrCaps.h"
 #include "src/gpu/ganesh/GrDirectContextPriv.h"
 
@@ -311,7 +310,7 @@
         backendFormat,
         false   // isRenderable
     );
-    SkColorType colorType = AHardwareBufferUtils::GetSkColorTypeFromBufferFormat(hwbDesc.format);
+    SkColorType colorType = GrAHardwareBufferUtils::GetSkColorTypeFromBufferFormat(hwbDesc.format);
     sk_sp<SkImage> image = SkImages::BorrowTextureFrom(context,
                                                        texture,
                                                        kTopLeft_GrSurfaceOrigin,