Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
yuv_conversion_vk.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_YUV_CONVERSION_VK_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_YUV_CONVERSION_VK_H_
7
8#include <unordered_map>
9
18
19namespace impeller {
20
21//------------------------------------------------------------------------------
22/// A descriptor used to create a new YUV conversion in a conversion library.
23///
25 vk::StructureChain<vk::SamplerYcbcrConversionCreateInfo
26#if FML_OS_ANDROID
27 // For VK_ANDROID_external_memory_android_hardware_buffer
28 ,
29 vk::ExternalFormatANDROID
30#endif // FML_OS_ANDROID
31 >;
32
34
35//------------------------------------------------------------------------------
36/// @brief It is sometimes necessary to deal with formats not native to
37/// Vulkan. In such cases, extra information is necessary to access
38/// images. A YUV conversion object is needed in such instances.
39///
40/// There are usually only a handful of viable conversions in a
41/// given context. However, due to the way the Vulkan spec. treats
42/// "identically defined" conversions, only a single conversion
43/// object is valid for an equivalent `YUVConversionDescriptorVK`.
44/// Because of this restriction, it is not possible to just create a
45/// conversion from a descriptor (as the underlying handles will be
46/// equivalent but different). Instead, a conversion may only be
47/// obtained from a conversion library. Libraries handle hashing and
48/// caching conversions by descriptor. Caller can find a library on
49/// the top-level context. They may not create their own (the
50/// constructor is private).
51///
52class YUVConversionVK final {
53 public:
55
57
59
60 //----------------------------------------------------------------------------
61 /// @return `true` if this conversion is valid for use with images and
62 /// samplers.
63 ///
64 bool IsValid() const;
65
66 //----------------------------------------------------------------------------
67 /// @brief Get the descriptor used to create this conversion.
68 ///
70
71 //----------------------------------------------------------------------------
72 /// @return The Vulkan handle of the YUV conversion.
73 ///
74 vk::SamplerYcbcrConversion GetConversion() const;
75
76 private:
78
79 std::weak_ptr<DeviceHolderVK> device_holder_;
81 vk::UniqueSamplerYcbcrConversion conversion_;
82
83 YUVConversionVK(const std::shared_ptr<DeviceHolderVK>& device_holder,
84 const YUVConversionDescriptorVK& chain);
85};
86
88 std::size_t operator()(const YUVConversionDescriptorVK& object) const;
89};
90
95
96struct ImmutableSamplerKeyVK : public Comparable<ImmutableSamplerKeyVK> {
99
100 explicit ImmutableSamplerKeyVK(const SamplerVK& sampler);
101
102 // |Comparable<ImmutableSamplerKey>|
103 std::size_t GetHash() const override;
104
105 // |Comparable<ImmutableSamplerKey>|
106 bool IsEqual(const ImmutableSamplerKeyVK& other) const override;
107};
108
109} // namespace impeller
110
111#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_YUV_CONVERSION_VK_H_
Due the way the Vulkan spec. treats "identically defined" conversions, creating two conversion with i...
It is sometimes necessary to deal with formats not native to Vulkan. In such cases,...
YUVConversionVK & operator=(const YUVConversionVK &)=delete
vk::SamplerYcbcrConversion GetConversion() const
const YUVConversionDescriptorVK & GetDescriptor() const
Get the descriptor used to create this conversion.
YUVConversionVK(const YUVConversionVK &)=delete
vk::StructureChain< vk::SamplerYcbcrConversionCreateInfo > YUVConversionDescriptorVK
bool IsEqual(const ImmutableSamplerKeyVK &other) const override
YUVConversionDescriptorVK yuv_conversion
std::size_t GetHash() const override
bool operator()(const YUVConversionDescriptorVK &lhs, const YUVConversionDescriptorVK &rhs) const
std::size_t operator()(const YUVConversionDescriptorVK &object) const