#ifndef GPU_COMMAND_BUFFER_SERVICE_SHARED_IMAGE_SHARED_IMAGE_FORMAT_SERVICE_UTILS_H_
#define GPU_COMMAND_BUFFER_SERVICE_SHARED_IMAGE_SHARED_IMAGE_FORMAT_SERVICE_UTILS_H_
#include "build/build_config.h"
#include "components/viz/common/resources/shared_image_format.h"
#include "gpu/command_buffer/common/gl2_types.h"
#include "gpu/config/gpu_preferences.h"
#include "gpu/gpu_gles2_export.h"
#include "gpu/vulkan/buildflags.h"
#include "skia/buildflags.h"
#include "third_party/dawn/include/dawn/webgpu.h"
#include "third_party/dawn/include/dawn/webgpu_cpp.h"
#include "third_party/skia/include/core/SkYUVAInfo.h"
#include "third_party/skia/include/gpu/graphite/TextureInfo.h"
#include "ui/gfx/buffer_types.h"
#if BUILDFLAG(ENABLE_VULKAN)
#include <vulkan/vulkan_core.h>
#endif
namespace skgpu::graphite {
class TextureInfo;
struct DawnTextureInfo;
}
namespace gpu {
struct VulkanYCbCrInfo;
namespace gles2 {
class FeatureInfo;
}
struct GLFormatDesc { … };
GPU_GLES2_EXPORT gfx::BufferFormat ToBufferFormat(
viz::SharedImageFormat format);
GPU_GLES2_EXPORT SkYUVAInfo::PlaneConfig ToSkYUVAPlaneConfig(
viz::SharedImageFormat format);
GPU_GLES2_EXPORT SkYUVAInfo::Subsampling ToSkYUVASubsampling(
viz::SharedImageFormat format);
GPU_GLES2_EXPORT SkColorType
ToClosestSkColorTypeExternalSampler(viz::SharedImageFormat format);
class GPU_GLES2_EXPORT GLFormatCaps { … };
#if BUILDFLAG(ENABLE_VULKAN)
GPU_GLES2_EXPORT bool HasVkFormat(viz::SharedImageFormat format);
GPU_GLES2_EXPORT VkFormat
ToVkFormatExternalSampler(viz::SharedImageFormat format);
GPU_GLES2_EXPORT VkFormat ToVkFormatSinglePlanar(viz::SharedImageFormat format);
GPU_GLES2_EXPORT VkFormat ToVkFormat(viz::SharedImageFormat format,
int plane_index);
#endif
GPU_GLES2_EXPORT wgpu::TextureFormat ToDawnFormat(
viz::SharedImageFormat format);
GPU_GLES2_EXPORT wgpu::TextureFormat ToDawnTextureViewFormat(
viz::SharedImageFormat format,
int plane_index);
wgpu::TextureUsage SupportedDawnTextureUsage(
viz::SharedImageFormat format,
bool is_yuv_plane,
bool is_dcomp_surface,
bool supports_multiplanar_rendering,
bool supports_multiplanar_copy);
wgpu::TextureAspect ToDawnTextureAspect(bool is_yuv_plane, int plane_index);
#if BUILDFLAG(IS_APPLE)
GPU_GLES2_EXPORT unsigned int ToMTLPixelFormat(viz::SharedImageFormat format,
int plane_index = 0);
GPU_GLES2_EXPORT uint32_t
SharedImageFormatToIOSurfacePixelFormat(viz::SharedImageFormat format,
bool override_rgba_to_bgra);
#endif
GPU_GLES2_EXPORT skgpu::graphite::TextureInfo GraphiteBackendTextureInfo(
GrContextType gr_context_type,
viz::SharedImageFormat format,
bool readonly,
int plane_index,
bool is_yuv_plane,
bool mipmapped,
bool scanout_dcomp_surface,
bool supports_multiplanar_rendering,
bool supports_multiplanar_copy);
GPU_GLES2_EXPORT skgpu::graphite::TextureInfo GraphitePromiseTextureInfo(
GrContextType gr_context_type,
viz::SharedImageFormat format,
std::optional<VulkanYCbCrInfo> ycbcr_info,
int plane_index = 0,
bool mipmapped = false);
#if BUILDFLAG(SKIA_USE_DAWN)
GPU_GLES2_EXPORT skgpu::graphite::DawnTextureInfo DawnBackendTextureInfo(
viz::SharedImageFormat format,
bool readonly,
bool is_yuv_plane,
int plane_index,
int array_slice,
bool mipmapped,
bool scanout_dcomp_surface,
bool supports_multiplanar_rendering,
bool support_multiplanar_copy);
#endif
#if BUILDFLAG(SKIA_USE_METAL)
GPU_GLES2_EXPORT skgpu::graphite::TextureInfo GraphiteMetalTextureInfo(
viz::SharedImageFormat format,
int plane_index = 0,
bool is_yuv_plane = false,
bool mipmapped = false);
#endif
GPU_GLES2_EXPORT
skgpu::graphite::TextureInfo FallbackGraphiteBackendTextureInfo(
const skgpu::graphite::TextureInfo& texture_info);
}
#endif