#include "gpu/command_buffer/service/shared_image/external_vk_image_backing_factory.h"
#include "build/build_config.h"
#include "components/viz/common/gpu/vulkan_context_provider.h"
#include "components/viz/common/resources/shared_image_format.h"
#include "gpu/command_buffer/common/shared_image_usage.h"
#include "gpu/command_buffer/service/shared_image/external_vk_image_backing.h"
#include "gpu/command_buffer/service/shared_image/shared_image_format_service_utils.h"
#include "gpu/command_buffer/service/shared_image/shared_image_representation.h"
#include "gpu/vulkan/vulkan_command_buffer.h"
#include "gpu/vulkan/vulkan_command_pool.h"
#include "gpu/vulkan/vulkan_device_queue.h"
#include "gpu/vulkan/vulkan_fence_helper.h"
#include "gpu/vulkan/vulkan_function_pointers.h"
#include "gpu/vulkan/vulkan_implementation.h"
#include "ui/gfx/buffer_format_util.h"
#include "ui/gfx/gpu_memory_buffer.h"
#include "ui/gl/buildflags.h"
namespace gpu {
namespace {
VkImageUsageFlags GetMaximalImageUsageFlags(
VkFormatFeatureFlags feature_flags) { … }
base::flat_map<VkFormat, VkImageUsageFlags> CreateImageUsageCache(
VkPhysicalDevice vk_physical_device) { … }
bool IsFormatSupported(viz::SharedImageFormat format,
gfx::GpuMemoryBufferType gmb_type,
gpu::SharedImageUsageSet usage) { … }
}
constexpr SharedImageUsageSet kSupportedUsage = …;
ExternalVkImageBackingFactory::ExternalVkImageBackingFactory(
scoped_refptr<SharedContextState> context_state)
: … { … }
ExternalVkImageBackingFactory::~ExternalVkImageBackingFactory() { … }
std::unique_ptr<SharedImageBacking>
ExternalVkImageBackingFactory::CreateSharedImage(
const Mailbox& mailbox,
viz::SharedImageFormat format,
SurfaceHandle surface_handle,
const gfx::Size& size,
const gfx::ColorSpace& color_space,
GrSurfaceOrigin surface_origin,
SkAlphaType alpha_type,
SharedImageUsageSet usage,
std::string debug_label,
bool is_thread_safe) { … }
std::unique_ptr<SharedImageBacking>
ExternalVkImageBackingFactory::CreateSharedImage(
const Mailbox& mailbox,
viz::SharedImageFormat format,
const gfx::Size& size,
const gfx::ColorSpace& color_space,
GrSurfaceOrigin surface_origin,
SkAlphaType alpha_type,
SharedImageUsageSet usage,
std::string debug_label,
bool is_thread_safe,
base::span<const uint8_t> pixel_data) { … }
std::unique_ptr<SharedImageBacking>
ExternalVkImageBackingFactory::CreateSharedImage(
const Mailbox& mailbox,
viz::SharedImageFormat format,
const gfx::Size& size,
const gfx::ColorSpace& color_space,
GrSurfaceOrigin surface_origin,
SkAlphaType alpha_type,
SharedImageUsageSet usage,
std::string debug_label,
gfx::GpuMemoryBufferHandle handle) { … }
std::unique_ptr<SharedImageBacking>
ExternalVkImageBackingFactory::CreateSharedImage(
const Mailbox& mailbox,
viz::SharedImageFormat format,
SurfaceHandle surface_handle,
const gfx::Size& size,
const gfx::ColorSpace& color_space,
GrSurfaceOrigin surface_origin,
SkAlphaType alpha_type,
SharedImageUsageSet usage,
std::string debug_label,
bool is_thread_safe,
gfx::BufferUsage buffer_usage) { … }
bool ExternalVkImageBackingFactory::CanImportGpuMemoryBuffer(
gfx::GpuMemoryBufferType memory_buffer_type) { … }
bool ExternalVkImageBackingFactory::IsSupported(
SharedImageUsageSet usage,
viz::SharedImageFormat format,
const gfx::Size& size,
bool thread_safe,
gfx::GpuMemoryBufferType gmb_type,
GrContextType gr_context_type,
base::span<const uint8_t> pixel_data) { … }
SharedImageBackingType ExternalVkImageBackingFactory::GetBackingType() { … }
}