Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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"
14
16#include <android/hardware_buffer_jni.h>
17
18namespace impeller {
19
20class 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///
34class 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|
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_
struct AHardwareBuffer AHardwareBuffer
A texture source that wraps an instance of AHardwareBuffer.
bool IsSwapchainImage() const override
Determines if swapchain image. That is, an image used as the root render target.
vk::Image GetImage() const override
Get the image handle for this texture source.
std::shared_ptr< YUVConversionVK > GetYUVConversion() const override
When sampling from textures whose formats are not known to Vulkan, a custom conversion is necessary t...
AHBTextureSourceVK(const std::shared_ptr< ContextVK > &context, struct AHardwareBuffer *hardware_buffer, const AHardwareBuffer_Desc &hardware_buffer_desc)
vk::ImageView GetImageView() const override
Retrieve the image view used for sampling/blitting/compute with this texture source.
vk::ImageView GetRenderTargetView() const override
Retrieve the image view used for render target attachments with this texture source.
Abstract base class that represents a vkImage and an vkImageView.