Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
flutter::ImageExternalTextureVK Class Reference

#include <image_external_texture_vk.h>

Inheritance diagram for flutter::ImageExternalTextureVK:
flutter::ImageExternalTexture flutter::Texture flutter::ContextListener

Public Member Functions

 ImageExternalTextureVK (const std::shared_ptr< impeller::ContextVK > &impeller_context, int64_t id, const fml::jni::ScopedJavaGlobalRef< jobject > &hardware_buffer_texture_entry, const std::shared_ptr< PlatformViewAndroidJNI > &jni_facade)
 
 ~ImageExternalTextureVK () override
 
- Public Member Functions inherited from flutter::ImageExternalTexture
 ImageExternalTexture (int64_t id, const fml::jni::ScopedJavaGlobalRef< jobject > &image_texture_entry, const std::shared_ptr< PlatformViewAndroidJNI > &jni_facade)
 
virtual ~ImageExternalTexture ()=default
 
void Paint (PaintContext &context, const SkRect &bounds, bool freeze, const DlImageSampling sampling) override
 
void MarkNewFrameAvailable () override
 
void OnTextureUnregistered () override
 
void OnGrContextCreated () override
 
void OnGrContextDestroyed () override
 
- Public Member Functions inherited from flutter::Texture
 Texture (int64_t id)
 
virtual ~Texture ()
 
int64_t Id ()
 
- Public Member Functions inherited from flutter::ContextListener
 ContextListener ()
 
 ~ContextListener ()
 

Private Member Functions

void Attach (PaintContext &context) override
 
void ProcessFrame (PaintContext &context, const SkRect &bounds) override
 
void Detach () override
 

Additional Inherited Members

- Protected Types inherited from flutter::ImageExternalTexture
enum class  AttachmentState { kUninitialized , kAttached , kDetached }
 
- Protected Member Functions inherited from flutter::ImageExternalTexture
JavaLocalRef AcquireLatestImage ()
 
void CloseImage (const fml::jni::JavaRef< jobject > &image)
 
JavaLocalRef HardwareBufferFor (const fml::jni::JavaRef< jobject > &image)
 
void CloseHardwareBuffer (const fml::jni::JavaRef< jobject > &hardware_buffer)
 
AHardwareBufferAHardwareBufferFor (const fml::jni::JavaRef< jobject > &hardware_buffer)
 
 FML_DISALLOW_COPY_AND_ASSIGN (ImageExternalTexture)
 
- Protected Attributes inherited from flutter::ImageExternalTexture
fml::jni::ScopedJavaGlobalRef< jobject > image_texture_entry_
 
std::shared_ptr< PlatformViewAndroidJNIjni_facade_
 
AttachmentState state_ = AttachmentState::kUninitialized
 
sk_sp< flutter::DlImagedl_image_
 
ImageLRU image_lru_ = ImageLRU()
 

Detailed Description

Definition at line 19 of file image_external_texture_vk.h.

Constructor & Destructor Documentation

◆ ImageExternalTextureVK()

flutter::ImageExternalTextureVK::ImageExternalTextureVK ( const std::shared_ptr< impeller::ContextVK > &  impeller_context,
int64_t  id,
const fml::jni::ScopedJavaGlobalRef< jobject > &  hardware_buffer_texture_entry,
const std::shared_ptr< PlatformViewAndroidJNI > &  jni_facade 
)

Definition at line 20 of file image_external_texture_vk.cc.

25 : ImageExternalTexture(id, image_texture_entry, jni_facade),
26 impeller_context_(impeller_context) {}
ImageExternalTexture(int64_t id, const fml::jni::ScopedJavaGlobalRef< jobject > &image_texture_entry, const std::shared_ptr< PlatformViewAndroidJNI > &jni_facade)

◆ ~ImageExternalTextureVK()

flutter::ImageExternalTextureVK::~ImageExternalTextureVK ( )
override

Definition at line 28 of file image_external_texture_vk.cc.

28{}

Member Function Documentation

◆ Attach()

void flutter::ImageExternalTextureVK::Attach ( PaintContext context)
overrideprivatevirtual

◆ Detach()

void flutter::ImageExternalTextureVK::Detach ( )
overrideprivatevirtual

Implements flutter::ImageExternalTexture.

Definition at line 37 of file image_external_texture_vk.cc.

37{}

◆ ProcessFrame()

void flutter::ImageExternalTextureVK::ProcessFrame ( PaintContext context,
const SkRect bounds 
)
overrideprivatevirtual

Implements flutter::ImageExternalTexture.

Definition at line 39 of file image_external_texture_vk.cc.

40 {
42 if (image.is_null()) {
43 return;
44 }
45 JavaLocalRef hardware_buffer = HardwareBufferFor(image);
46 AHardwareBuffer* latest_hardware_buffer = AHardwareBufferFor(hardware_buffer);
47
48 auto hb_desc =
49 impeller::android::HardwareBuffer::Describe(latest_hardware_buffer);
50 std::optional<HardwareBufferKey> key =
52 latest_hardware_buffer);
53 auto existing_image = image_lru_.FindImage(key);
54 if (existing_image != nullptr || !hb_desc.has_value()) {
55 dl_image_ = existing_image;
56
57 CloseHardwareBuffer(hardware_buffer);
58 return;
59 }
60
61 auto texture_source = std::make_shared<impeller::AHBTextureSourceVK>(
62 impeller_context_, latest_hardware_buffer, hb_desc.value());
63 if (!texture_source->IsValid()) {
64 CloseHardwareBuffer(hardware_buffer);
65 return;
66 }
67
68 auto texture =
69 std::make_shared<impeller::TextureVK>(impeller_context_, texture_source);
70 // Transition the layout to shader read.
71 {
72 auto buffer = impeller_context_->CreateCommandBuffer();
73 impeller::CommandBufferVK& buffer_vk =
75
76 impeller::BarrierVK barrier;
77 barrier.cmd_buffer = buffer_vk.GetEncoder()->GetCommandBuffer();
78 barrier.src_access = impeller::vk::AccessFlagBits::eColorAttachmentWrite |
79 impeller::vk::AccessFlagBits::eTransferWrite;
80 barrier.src_stage =
81 impeller::vk::PipelineStageFlagBits::eColorAttachmentOutput |
82 impeller::vk::PipelineStageFlagBits::eTransfer;
83 barrier.dst_access = impeller::vk::AccessFlagBits::eShaderRead;
84 barrier.dst_stage = impeller::vk::PipelineStageFlagBits::eFragmentShader;
85
86 barrier.new_layout = impeller::vk::ImageLayout::eShaderReadOnlyOptimal;
87
88 if (!texture->SetLayout(barrier)) {
89 return;
90 }
91 if (!impeller_context_->GetCommandQueue()->Submit({buffer}).ok()) {
92 return;
93 }
94 }
95
97 if (key.has_value()) {
99 }
100 CloseHardwareBuffer(hardware_buffer);
101}
struct AHardwareBuffer AHardwareBuffer
AHardwareBuffer * AHardwareBufferFor(const fml::jni::JavaRef< jobject > &hardware_buffer)
JavaLocalRef HardwareBufferFor(const fml::jni::JavaRef< jobject > &image)
void CloseHardwareBuffer(const fml::jni::JavaRef< jobject > &hardware_buffer)
sk_sp< flutter::DlImage > dl_image_
HardwareBufferKey AddImage(const sk_sp< flutter::DlImage > &image, HardwareBufferKey key)
Add a new image to the cache with a key, returning the key of the LRU entry that was removed.
Definition image_lru.cc:42
sk_sp< flutter::DlImage > FindImage(std::optional< HardwareBufferKey > key)
Retrieve the image associated with the given [key], or nullptr.
Definition image_lru.cc:9
static CommandBufferVK & Cast(CommandBuffer &base)
const std::shared_ptr< CommandEncoderVK > & GetEncoder()
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
static std::optional< AHardwareBuffer_Desc > Describe(AHardwareBuffer *buffer)
std::optional< uint64_t > GetSystemUniqueID() const
Get the system wide unique ID of the hardware buffer if possible. This is only available on Android A...
sk_sp< SkImage > image
Definition examples.cpp:29
FlTexture * texture
std::nullptr_t JavaLocalRef
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition switches.h:126
Defines an operations and memory access barrier on a resource.
Definition barrier_vk.h:28
vk::CommandBuffer cmd_buffer
Definition barrier_vk.h:29
vk::AccessFlags src_access
Definition barrier_vk.h:40
vk::PipelineStageFlags dst_stage
Definition barrier_vk.h:45
vk::ImageLayout new_layout
Definition barrier_vk.h:30
vk::PipelineStageFlags src_stage
Definition barrier_vk.h:35
vk::AccessFlags dst_access
Definition barrier_vk.h:50

The documentation for this class was generated from the following files: