| Flutter Impeller |

ahb_texture_source_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_ANDROID_AHB_TEXTURE_SOURCE_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_ANDROID_AHB_TEXTURE_SOURCE_VK_H_
7
8 #include "flutter/fml/macros.h"
9 #include "impeller/geometry/size.h"
10 #include "impeller/renderer/backend/vulkan/formats_vk.h"
11 #include "impeller/renderer/backend/vulkan/texture_source_vk.h"
12 #include "impeller/renderer/backend/vulkan/vk.h"
13 #include "impeller/renderer/backend/vulkan/yuv_conversion_vk.h"
14
15 #include <android/hardware_buffer.h>
16 #include <android/hardware_buffer_jni.h>
17
18 namespace impeller {
19
20 class ContextVK;
21
22 //------------------------------------------------------------------------------
23 /// @brief A texture source that wraps an instance of AHardwareBuffer.
24 ///
25 /// The formats and conversions supported by Android Hardware
26 /// Buffers are a superset of those supported by Impeller (and
27 /// Vulkan for that matter). Impeller and Vulkan descriptors
28 /// obtained from the these texture sources are advisory and it
29 /// usually isn't possible to create copies of images and image
30 /// views held in these texture sources using the inferred
31 /// descriptors. The objects are meant to be used directly (either
32 /// as render targets or sources for sampling), not copied.
33 ///
34 class AHBTextureSourceVK final : public TextureSourceVK {
35 public:
36 AHBTextureSourceVK(const std::shared_ptr<ContextVK>& context,
37 struct AHardwareBuffer* hardware_buffer,
38 const AHardwareBuffer_Desc& hardware_buffer_desc);
39
40 // |TextureSourceVK|
41 ~AHBTextureSourceVK() override;
42
43 // |TextureSourceVK|
44 vk::Image GetImage() const override;
45
46 // |TextureSourceVK|
47 vk::ImageView GetImageView() const override;
48
49 // |TextureSourceVK|
50 vk::ImageView GetRenderTargetView() const override;
51
52 bool IsValid() const;
53
54 // |TextureSourceVK|
55 bool IsSwapchainImage() const override;
56
57 // |TextureSourceVK|
58 std::shared_ptr<YUVConversionVK> GetYUVConversion() const override;
59
60 private:
61 vk::UniqueDeviceMemory device_memory_ = {};
62 vk::UniqueImage image_ = {};
63 vk::UniqueImageView image_view_ = {};
64 std::shared_ptr<YUVConversionVK> yuv_conversion_ = {};
65 bool needs_yuv_conversion_ = false;
66 bool is_valid_ = false;
67
68 AHBTextureSourceVK(const AHBTextureSourceVK&) = delete;
69
70 AHBTextureSourceVK& operator=(const AHBTextureSourceVK&) = delete;
71 };
72
73 } // namespace impeller
74
75 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_ANDROID_AHB_TEXTURE_SOURCE_VK_H_
hardware_buffer.h
impeller::TextureSourceVK
Abstract base class that represents a vkImage and an vkImageView.
Definition: texture_source_vk.h:28
impeller::AHBTextureSourceVK::IsValid
bool IsValid() const
Definition: ahb_texture_source_vk.cc:365
impeller::AHBTextureSourceVK::~AHBTextureSourceVK
~AHBTextureSourceVK() override
impeller::AHBTextureSourceVK::AHBTextureSourceVK
AHBTextureSourceVK(const std::shared_ptr< ContextVK > &context, struct AHardwareBuffer *hardware_buffer, const AHardwareBuffer_Desc &hardware_buffer_desc)
Definition: ahb_texture_source_vk.cc:282
impeller::AHBTextureSourceVK::GetImageView
vk::ImageView GetImageView() const override
Retrieve the image view used for sampling/blitting/compute with this texture source.
Definition: ahb_texture_source_vk.cc:375
texture_source_vk.h
formats_vk.h
vk.h
impeller::AHBTextureSourceVK::GetImage
vk::Image GetImage() const override
Get the image handle for this texture source.
Definition: ahb_texture_source_vk.cc:370
yuv_conversion_vk.h
impeller::AHBTextureSourceVK
A texture source that wraps an instance of AHardwareBuffer.
Definition: ahb_texture_source_vk.h:34
impeller::AHBTextureSourceVK::GetRenderTargetView
vk::ImageView GetRenderTargetView() const override
Retrieve the image view used for render target attachments with this texture source.
Definition: ahb_texture_source_vk.cc:380
impeller
Definition: aiks_blur_unittests.cc:20
impeller::AHBTextureSourceVK::IsSwapchainImage
bool IsSwapchainImage() const override
Determines if swapchain image. That is, an image used as the root render target.
Definition: ahb_texture_source_vk.cc:385
size.h
impeller::AHBTextureSourceVK::GetYUVConversion
std::shared_ptr< YUVConversionVK > GetYUVConversion() const override
When sampling from textures whose formats are not known to Vulkan, a custom conversion is necessary t...
Definition: ahb_texture_source_vk.cc:390