[gpu] Remove legacy multiplanar codepath from SkiaGraphiteDawnRep

Now that legacy multiplanar with GpuMemoryBuffer codepath is gone,
we can remove legacy_plane_index_ and is_yuv_plane_ from
SkiaGraphiteDawnImageRepresentation.

Bug: 332564976
Change-Id: I1d2fe8bf570297691a91afc2d1316e29a62b0f80
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5722729
Reviewed-by: Colin Blundell <blundell@chromium.org>
Commit-Queue: Saifuddin Hitawala <hitawala@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1330248}
diff --git a/gpu/command_buffer/service/shared_image/d3d_image_backing.cc b/gpu/command_buffer/service/shared_image/d3d_image_backing.cc
index e079ab3..448a464 100644
--- a/gpu/command_buffer/service/shared_image/d3d_image_backing.cc
+++ b/gpu/command_buffer/service/shared_image/d3d_image_backing.cc
@@ -53,25 +53,6 @@
 
 namespace {
 
-size_t NumPlanes(DXGI_FORMAT dxgi_format) {
-  switch (dxgi_format) {
-    case DXGI_FORMAT_NV12:
-    case DXGI_FORMAT_P010:
-      return 2;
-    case DXGI_FORMAT_R8_UNORM:
-    case DXGI_FORMAT_R8G8_UNORM:
-    case DXGI_FORMAT_R16_UNORM:
-    case DXGI_FORMAT_R16G16_UNORM:
-    case DXGI_FORMAT_R8G8B8A8_UNORM:
-    case DXGI_FORMAT_B8G8R8A8_UNORM:
-    case DXGI_FORMAT_R10G10B10A2_UNORM:
-    case DXGI_FORMAT_R16G16B16A16_FLOAT:
-      return 1;
-    default:
-      NOTREACHED_NORETURN() << "Unsupported DXGI format: " << dxgi_format;
-  }
-}
-
 bool BindEGLImageToTexture(GLenum texture_target, void* egl_image) {
   if (!egl_image) {
     LOG(ERROR) << "EGL image is null";
@@ -1033,11 +1014,10 @@
     LOG(ERROR) << "Could not create Dawn Representation";
     return nullptr;
   }
-  const bool is_yuv_plane = NumPlanes(d3d11_texture_desc_.Format) > 1;
   return SkiaGraphiteDawnImageRepresentation::Create(
       std::move(dawn_representation), context_state,
       context_state->gpu_main_graphite_recorder(), manager, this, tracker,
-      is_yuv_plane, /*legacy_plane_index=*/0, array_slice_);
+      array_slice_);
 }
 #endif  // BUILDFLAG(SKIA_USE_DAWN)
 
diff --git a/gpu/command_buffer/service/shared_image/iosurface_image_backing.h b/gpu/command_buffer/service/shared_image/iosurface_image_backing.h
index 16edb9b..ac072b0 100644
--- a/gpu/command_buffer/service/shared_image/iosurface_image_backing.h
+++ b/gpu/command_buffer/service/shared_image/iosurface_image_backing.h
@@ -210,7 +210,6 @@
   const gfx::ScopedIOSurface io_surface_;
   const gfx::Size io_surface_size_;
   const uint32_t io_surface_format_;
-  const size_t io_surface_num_planes_;
   const gfx::GenericSharedMemoryId io_surface_id_;
 
   // DawnSharedTextureHolder that keeps an internal cache of per-device
diff --git a/gpu/command_buffer/service/shared_image/iosurface_image_backing.mm b/gpu/command_buffer/service/shared_image/iosurface_image_backing.mm
index 01fd0e2e..ec0a24c9a 100644
--- a/gpu/command_buffer/service/shared_image/iosurface_image_backing.mm
+++ b/gpu/command_buffer/service/shared_image/iosurface_image_backing.mm
@@ -1002,7 +1002,6 @@
       io_surface_size_(IOSurfaceGetWidth(io_surface_.get()),
                        IOSurfaceGetHeight(io_surface_.get())),
       io_surface_format_(IOSurfaceGetPixelFormat(io_surface_.get())),
-      io_surface_num_planes_(IOSurfaceGetPlaneCount(io_surface_.get())),
       io_surface_id_(io_surface_id),
       dawn_texture_holder_(std::make_unique<DawnSharedTextureHolder>()),
       gl_target_(gl_target),
@@ -1473,13 +1472,11 @@
       LOG(ERROR) << "Could not create Dawn Representation";
       return nullptr;
     }
-    const bool is_yuv_plane = io_surface_num_planes_ > 1;
     // Use GPU main recorder since this should only be called for
     // fulfilling Graphite promise images on GPU main thread.
     return SkiaGraphiteDawnImageRepresentation::Create(
         std::move(dawn_representation), context_state,
-        context_state->gpu_main_graphite_recorder(), manager, this, tracker,
-        is_yuv_plane);
+        context_state->gpu_main_graphite_recorder(), manager, this, tracker);
 #else
   NOTREACHED_NORETURN();
 #endif
diff --git a/gpu/command_buffer/service/shared_image/skia_graphite_dawn_image_representation.cc b/gpu/command_buffer/service/shared_image/skia_graphite_dawn_image_representation.cc
index 96d4a44..08c69af 100644
--- a/gpu/command_buffer/service/shared_image/skia_graphite_dawn_image_representation.cc
+++ b/gpu/command_buffer/service/shared_image/skia_graphite_dawn_image_representation.cc
@@ -49,8 +49,6 @@
     SharedImageManager* manager,
     SharedImageBacking* backing,
     MemoryTypeTracker* tracker,
-    bool is_yuv_plane,
-    int legacy_plane_index,
     int array_slice) {
   CHECK(dawn_representation);
   const bool is_dcomp_surface =
@@ -60,12 +58,11 @@
   const bool supports_multiplanar_copy =
       SupportsMultiplanarCopy(context_state.get());
   wgpu::TextureUsage supported_tex_usages = SupportedDawnTextureUsage(
-      backing->format(), is_yuv_plane, is_dcomp_surface,
+      backing->format(), backing->format().is_multi_plane(), is_dcomp_surface,
       supports_multiplanar_rendering, supports_multiplanar_copy);
   return base::WrapUnique(new SkiaGraphiteDawnImageRepresentation(
       std::move(dawn_representation), recorder, std::move(context_state),
-      manager, backing, tracker, is_yuv_plane, legacy_plane_index, array_slice,
-      supported_tex_usages));
+      manager, backing, tracker, array_slice, supported_tex_usages));
 }
 
 SkiaGraphiteDawnImageRepresentation::SkiaGraphiteDawnImageRepresentation(
@@ -75,16 +72,12 @@
     SharedImageManager* manager,
     SharedImageBacking* backing,
     MemoryTypeTracker* tracker,
-    bool is_yuv_plane,
-    int legacy_plane_index,
     int array_slice,
     wgpu::TextureUsage supported_tex_usages)
     : SkiaGraphiteImageRepresentation(manager, backing, tracker),
       dawn_representation_(std::move(dawn_representation)),
       context_state_(std::move(context_state)),
       recorder_(recorder),
-      is_yuv_plane_(is_yuv_plane),
-      legacy_plane_index_(legacy_plane_index),
       array_slice_(array_slice),
       supported_tex_usages_(supported_tex_usages) {
   CHECK(dawn_representation_);
@@ -128,17 +121,7 @@
           supports_multiplanar_copy);
       backend_textures.emplace_back(plane_size, plane_info, texture.Get());
     }
-  } else if (is_yuv_plane_) {
-    // Legacy multi-planar NV12 - format() is either R8 or RG8.
-    SkISize plane_size = gfx::SizeToSkISize(size());
-    skgpu::graphite::DawnTextureInfo plane_info = DawnBackendTextureInfo(
-        format(), readonly, /*is_yuv_plane=*/true, legacy_plane_index_,
-        array_slice_, /*mipmapped=*/false, /*scanout_dcomp_surface=*/false,
-        supports_multiplanar_rendering, supports_multiplanar_copy);
-    backend_textures = {
-        skgpu::graphite::BackendTexture(plane_size, plane_info, texture.Get())};
   } else {
-    CHECK(format().is_single_plane() && !format().IsLegacyMultiplanar());
     backend_textures = {skgpu::graphite::BackendTexture(texture.Get())};
   }
 
diff --git a/gpu/command_buffer/service/shared_image/skia_graphite_dawn_image_representation.h b/gpu/command_buffer/service/shared_image/skia_graphite_dawn_image_representation.h
index 8d3497a..b38f5615 100644
--- a/gpu/command_buffer/service/shared_image/skia_graphite_dawn_image_representation.h
+++ b/gpu/command_buffer/service/shared_image/skia_graphite_dawn_image_representation.h
@@ -23,8 +23,6 @@
       SharedImageManager* manager,
       SharedImageBacking* backing,
       MemoryTypeTracker* tracker,
-      bool is_yuv_plane = false,
-      int legacy_plane_index = 0,
       int array_slice = 0);
 
   ~SkiaGraphiteDawnImageRepresentation() override;
@@ -47,8 +45,6 @@
       SharedImageManager* manager,
       SharedImageBacking* backing,
       MemoryTypeTracker* tracker,
-      bool is_yuv_plane,
-      int legacy_plane_index,
       int array_slice,
       wgpu::TextureUsage supported_tex_usages);
 
@@ -60,8 +56,6 @@
   std::unique_ptr<DawnImageRepresentation::ScopedAccess> dawn_scoped_access_;
   scoped_refptr<SharedContextState> context_state_;
   const raw_ptr<skgpu::graphite::Recorder> recorder_;
-  const bool is_yuv_plane_;
-  const int legacy_plane_index_;
   const int array_slice_;
   const wgpu::TextureUsage supported_tex_usages_;
   RepresentationAccessMode mode_ = RepresentationAccessMode::kNone;