#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/gpu/chromeos/vulkan_overlay_adaptor.h"
#include "base/bits.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/task/thread_pool.h"
#include "gpu/vulkan/init/vulkan_factory.h"
#include "gpu/vulkan/vulkan_function_pointers.h"
#include "media/base/media_switches.h"
#include "media/gpu/chromeos/platform_video_frame_utils.h"
#include "media/gpu/chromeos/shaders/shaders.h"
#include "media/gpu/macros.h"
#include "ui/gfx/color_space.h"
#include "ui/gfx/gpu_memory_buffer.h"
namespace media {
class VulkanOverlayAdaptor::VulkanRenderPass { … };
class VulkanOverlayAdaptor::VulkanShader { … };
class VulkanOverlayAdaptor::VulkanPipeline { … };
class VulkanOverlayAdaptor::VulkanDescriptorPool { … };
class VulkanOverlayAdaptor::VulkanDeviceQueueWrapper { … };
class VulkanOverlayAdaptor::VulkanCommandPoolWrapper { … };
class VulkanOverlayAdaptor::VulkanTextureImage { … };
class VulkanOverlayAdaptor::VulkanSampler { … };
VulkanOverlayAdaptor::VulkanRenderPass::VulkanRenderPass(
VkDevice logical_device,
VkRenderPass render_pass)
: … { … }
VulkanOverlayAdaptor::VulkanRenderPass::~VulkanRenderPass() { … }
VkRenderPass VulkanOverlayAdaptor::VulkanRenderPass::Get() { … }
std::unique_ptr<VulkanOverlayAdaptor::VulkanRenderPass>
VulkanOverlayAdaptor::VulkanRenderPass::Create(VkFormat format,
VkDevice logical_device) { … }
VulkanOverlayAdaptor::VulkanShader::VulkanShader(VkDevice logical_device,
VkShaderModule shader)
: … { … }
VulkanOverlayAdaptor::VulkanShader::~VulkanShader() { … }
VkShaderModule VulkanOverlayAdaptor::VulkanShader::Get() { … }
std::unique_ptr<VulkanOverlayAdaptor::VulkanShader>
VulkanOverlayAdaptor::VulkanShader::Create(const uint32_t* shader_code,
size_t shader_code_size,
VkDevice logical_device) { … }
VulkanOverlayAdaptor::VulkanPipeline::VulkanPipeline(
VkPipeline pipeline,
VkDescriptorSetLayout descriptor_set_layout,
VkPipelineLayout pipeline_layout,
std::unique_ptr<VulkanOverlayAdaptor::VulkanShader> vert_shader,
std::unique_ptr<VulkanOverlayAdaptor::VulkanShader> frag_shader,
VkDevice logical_device)
: … { … }
VulkanOverlayAdaptor::VulkanPipeline::~VulkanPipeline() { … }
VkPipeline VulkanOverlayAdaptor::VulkanPipeline::Get() { … }
VkDescriptorSetLayout
VulkanOverlayAdaptor::VulkanPipeline::GetDescriptorSetLayout() { … }
VkPipelineLayout VulkanOverlayAdaptor::VulkanPipeline::GetPipelineLayout() { … }
std::unique_ptr<VulkanOverlayAdaptor::VulkanPipeline>
VulkanOverlayAdaptor::VulkanPipeline::Create(
const std::vector<VkVertexInputBindingDescription>& binding_descriptions,
const std::vector<VkVertexInputAttributeDescription>&
attribute_descriptions,
const std::vector<VkDescriptorSetLayoutBinding>& ubo_bindings,
std::unique_ptr<VulkanOverlayAdaptor::VulkanShader> vert_shader,
std::unique_ptr<VulkanOverlayAdaptor::VulkanShader> frag_shader,
const std::vector<size_t>& push_constants_size,
VkRenderPass render_pass,
VkDevice logical_device) { … }
VulkanOverlayAdaptor::VulkanDescriptorPool::VulkanDescriptorPool(
std::vector<VkDescriptorSet> descriptor_sets,
VkDescriptorPool descriptor_pool,
VkDevice logical_device)
: … { … }
VulkanOverlayAdaptor::VulkanDescriptorPool::~VulkanDescriptorPool() { … }
const std::vector<VkDescriptorSet>&
VulkanOverlayAdaptor::VulkanDescriptorPool::Get() { … }
std::unique_ptr<VulkanOverlayAdaptor::VulkanDescriptorPool>
VulkanOverlayAdaptor::VulkanDescriptorPool::Create(
size_t num_descriptor_sets,
std::vector<VkDescriptorType> descriptor_types,
VkDescriptorSetLayout descriptor_set_layout,
VkDevice logical_device) { … }
VulkanOverlayAdaptor::VulkanTextureImage::VulkanTextureImage(
gpu::VulkanImage& image,
const std::vector<VkImageView>& image_views,
const std::vector<VkFramebuffer>& framebuffers,
VkImageLayout initial_layout,
VkDevice logical_device)
: … { … }
VulkanOverlayAdaptor::VulkanTextureImage::~VulkanTextureImage() { … }
VkImage VulkanOverlayAdaptor::VulkanTextureImage::GetImage() { … }
const std::vector<VkImageView>&
VulkanOverlayAdaptor::VulkanTextureImage::GetImageViews() { … }
const std::vector<VkFramebuffer>&
VulkanOverlayAdaptor::VulkanTextureImage::GetFramebuffers() { … }
void VulkanOverlayAdaptor::VulkanTextureImage::TransitionImageLayout(
gpu::VulkanCommandBuffer* command_buf,
VkImageLayout new_layout,
uint32_t src_queue_family_index,
uint32_t dst_queue_family_index) { … }
std::unique_ptr<VulkanOverlayAdaptor::VulkanTextureImage>
VulkanOverlayAdaptor::VulkanTextureImage::Create(
gpu::VulkanImage& image,
const std::vector<VkFormat>& formats,
const std::vector<gfx::Size>& sizes,
const std::vector<VkImageAspectFlagBits>& aspects,
bool is_framebuffer,
VkRenderPass render_pass,
VkDevice logical_device) { … }
VulkanOverlayAdaptor::VulkanDeviceQueueWrapper::VulkanDeviceQueueWrapper(
std::unique_ptr<gpu::VulkanDeviceQueue> vulkan_device_queue)
: … { … }
VulkanOverlayAdaptor::VulkanDeviceQueueWrapper::~VulkanDeviceQueueWrapper() { … }
gpu::VulkanDeviceQueue*
VulkanOverlayAdaptor::VulkanDeviceQueueWrapper::GetVulkanDeviceQueue() { … }
VkPhysicalDevice
VulkanOverlayAdaptor::VulkanDeviceQueueWrapper::GetVulkanPhysicalDevice() { … }
VkPhysicalDeviceProperties VulkanOverlayAdaptor::VulkanDeviceQueueWrapper::
GetVulkanPhysicalDeviceProperties() { … }
VkDevice VulkanOverlayAdaptor::VulkanDeviceQueueWrapper::GetVulkanDevice() { … }
VkQueue VulkanOverlayAdaptor::VulkanDeviceQueueWrapper::GetVulkanQueue() { … }
uint32_t VulkanOverlayAdaptor::VulkanDeviceQueueWrapper::GetVulkanQueueIndex() { … }
std::unique_ptr<VulkanOverlayAdaptor::VulkanDeviceQueueWrapper>
VulkanOverlayAdaptor::VulkanDeviceQueueWrapper::Create(
gpu::VulkanImplementation* implementation) { … }
VulkanOverlayAdaptor::VulkanCommandPoolWrapper::VulkanCommandPoolWrapper(
std::unique_ptr<gpu::VulkanCommandPool> command_pool)
: … { … }
VulkanOverlayAdaptor::VulkanCommandPoolWrapper::~VulkanCommandPoolWrapper() { … }
std::unique_ptr<gpu::VulkanCommandBuffer>
VulkanOverlayAdaptor::VulkanCommandPoolWrapper::CreatePrimaryCommandBuffer() { … }
std::unique_ptr<VulkanOverlayAdaptor::VulkanCommandPoolWrapper>
VulkanOverlayAdaptor::VulkanCommandPoolWrapper::Create(
gpu::VulkanDeviceQueue* device_queue,
bool allow_protected_memory) { … }
VulkanOverlayAdaptor::VulkanSampler::VulkanSampler(VkSampler sampler,
VkDevice logical_device)
: … { … }
std::unique_ptr<VulkanOverlayAdaptor::VulkanSampler>
VulkanOverlayAdaptor::VulkanSampler::Create(VkFilter filter_mode,
bool normalize_coords,
VkDevice logical_device) { … }
VkSampler& VulkanOverlayAdaptor::VulkanSampler::Get() { … }
VulkanOverlayAdaptor::VulkanSampler::~VulkanSampler() { … }
VulkanOverlayAdaptor::VulkanOverlayAdaptor(
std::unique_ptr<gpu::VulkanImplementation> vulkan_implementation,
std::unique_ptr<VulkanOverlayAdaptor::VulkanDeviceQueueWrapper>
vulkan_device_queue,
std::unique_ptr<VulkanOverlayAdaptor::VulkanCommandPoolWrapper>
command_pool,
std::unique_ptr<VulkanOverlayAdaptor::VulkanRenderPass> convert_render_pass,
std::unique_ptr<VulkanOverlayAdaptor::VulkanRenderPass>
transform_render_pass,
std::unique_ptr<VulkanOverlayAdaptor::VulkanPipeline> convert_pipeline,
std::unique_ptr<VulkanOverlayAdaptor::VulkanPipeline> transform_pipeline,
std::unique_ptr<VulkanOverlayAdaptor::VulkanDescriptorPool>
convert_descriptor_pool,
std::unique_ptr<VulkanOverlayAdaptor::VulkanDescriptorPool>
transform_descriptor_pool,
std::unique_ptr<VulkanOverlayAdaptor::VulkanSampler> sampler,
std::unique_ptr<gpu::VulkanImage> pivot_image,
std::unique_ptr<VulkanOverlayAdaptor::VulkanTextureImage> pivot_texture,
bool is_protected,
TiledImageFormat tile_format)
: … { … }
VulkanOverlayAdaptor::~VulkanOverlayAdaptor() { … }
std::unique_ptr<VulkanOverlayAdaptor> VulkanOverlayAdaptor::Create(
bool is_protected,
TiledImageFormat format,
const gfx::Size& max_size) { … }
void VulkanOverlayAdaptor::Process(gpu::VulkanImage& in_image,
const gfx::Size& input_visible_size,
gpu::VulkanImage& out_image,
const gfx::RectF& display_rect,
const gfx::RectF& crop_rect,
gfx::OverlayTransform transform,
std::vector<VkSemaphore>& begin_semaphores,
std::vector<VkSemaphore>& end_semaphores) { … }
gpu::VulkanDeviceQueue* VulkanOverlayAdaptor::GetVulkanDeviceQueue() { … }
gpu::VulkanImplementation& VulkanOverlayAdaptor::GetVulkanImplementation() { … }
TiledImageFormat VulkanOverlayAdaptor::GetTileFormat() const { … }
}