1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
media / gpu / chromeos / vulkan_overlay_adaptor.h [blame]
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_GPU_CHROMEOS_VULKAN_OVERLAY_ADAPTOR_H_
#define MEDIA_GPU_CHROMEOS_VULKAN_OVERLAY_ADAPTOR_H_
#include <vulkan/vulkan_core.h>
#include <memory>
#include <vector>
#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_image.h"
#include "gpu/vulkan/vulkan_implementation.h"
#include "media/gpu/media_gpu_export.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/overlay_transform.h"
namespace media {
enum TiledImageFormat { kMM21, kMT2T };
// An image processor using Vulkan to perform MM21 detiling.
class MEDIA_GPU_EXPORT VulkanOverlayAdaptor {
public:
VulkanOverlayAdaptor(const VulkanOverlayAdaptor&) = delete;
VulkanOverlayAdaptor& operator=(const VulkanOverlayAdaptor&) = delete;
~VulkanOverlayAdaptor();
// TODO(greenjustin): Change the |is_protected| bool to an enum.
static std::unique_ptr<VulkanOverlayAdaptor> Create(
bool is_protected,
TiledImageFormat format = kMM21,
const gfx::Size& max_size = gfx::Size(3840, 2160));
// Note: |crop_rect| is actually the crop *in addition* to the |visible_rect|
// cropping. It is equivalent to |uv_rect| in an OverlayCandidate.
void 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_sempahores);
gpu::VulkanDeviceQueue* GetVulkanDeviceQueue();
gpu::VulkanImplementation& GetVulkanImplementation();
TiledImageFormat GetTileFormat() const;
private:
class VulkanRenderPass;
class VulkanShader;
class VulkanPipeline;
class VulkanDescriptorPool;
class VulkanDeviceQueueWrapper;
class VulkanCommandBufferWrapper;
class VulkanCommandPoolWrapper;
class VulkanTextureImage;
class VulkanSampler;
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);
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_;
const TiledImageFormat tile_format_;
};
} // namespace media
#endif // MEDIA_GPU_CHROMEOS_VULKAN_OVERLAY_ADAPTOR_H_