Flutter Engine
The Flutter Engine
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
flutter::ImageExternalTexture Class Referenceabstract

#include <image_external_texture.h>

Inheritance diagram for flutter::ImageExternalTexture:
flutter::Texture flutter::ContextListener flutter::ImageExternalTextureGL flutter::ImageExternalTextureVK flutter::ImageExternalTextureGLImpeller flutter::ImageExternalTextureGLSkia

Public Member Functions

 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 ()
 
virtual void Paint (PaintContext &context, const SkRect &bounds, bool freeze, const DlImageSampling sampling)=0
 
virtual void MarkNewFrameAvailable ()=0
 
virtual void OnTextureUnregistered ()=0
 
int64_t Id ()
 
- Public Member Functions inherited from flutter::ContextListener
 ContextListener ()
 
 ~ContextListener ()
 
virtual void OnGrContextCreated ()=0
 
virtual void OnGrContextDestroyed ()=0
 

Protected Types

enum class  AttachmentState { kUninitialized , kAttached , kDetached }
 

Protected Member Functions

virtual void Attach (PaintContext &context)=0
 
virtual void Detach ()=0
 
virtual void ProcessFrame (PaintContext &context, const SkRect &bounds)=0
 
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

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 21 of file image_external_texture.h.

Member Enumeration Documentation

◆ AttachmentState

Enumerator
kUninitialized 
kAttached 
kDetached 

Definition at line 63 of file image_external_texture.h.

Constructor & Destructor Documentation

◆ ImageExternalTexture()

flutter::ImageExternalTexture::ImageExternalTexture ( int64_t  id,
const fml::jni::ScopedJavaGlobalRef< jobject > &  image_texture_entry,
const std::shared_ptr< PlatformViewAndroidJNI > &  jni_facade 
)
explicit

Definition at line 16 of file image_external_texture.cc.

20 : Texture(id),
21 image_texture_entry_(image_texture_entry),
22 jni_facade_(jni_facade) {}
std::shared_ptr< PlatformViewAndroidJNI > jni_facade_
fml::jni::ScopedJavaGlobalRef< jobject > image_texture_entry_
Texture(int64_t id)
Definition: texture.cc:13

◆ ~ImageExternalTexture()

virtual flutter::ImageExternalTexture::~ImageExternalTexture ( )
virtualdefault

Member Function Documentation

◆ AcquireLatestImage()

JavaLocalRef flutter::ImageExternalTexture::AcquireLatestImage ( )
protected

Definition at line 74 of file image_external_texture.cc.

74 {
76 FML_CHECK(env != nullptr);
77
78 // ImageTextureEntry.acquireLatestImage.
79 JavaLocalRef image_java =
80 jni_facade_->ImageProducerTextureEntryAcquireLatestImage(
82 return image_java;
83}
#define FML_CHECK(condition)
Definition: logging.h:85
Definition: __init__.py:1
std::nullptr_t JavaLocalRef
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:34

◆ AHardwareBufferFor()

AHardwareBuffer * flutter::ImageExternalTexture::AHardwareBufferFor ( const fml::jni::JavaRef< jobject > &  hardware_buffer)
protected

Definition at line 109 of file image_external_texture.cc.

110 {
112 FML_CHECK(env != nullptr);
113 const auto& proc =
114 impeller::android::GetProcTable().AHardwareBuffer_fromHardwareBuffer;
115 return proc ? proc(env, hardware_buffer.obj()) : nullptr;
116}
const ProcTable & GetProcTable()
Definition: proc_table.cc:12

◆ Attach()

virtual void flutter::ImageExternalTexture::Attach ( PaintContext context)
protectedpure virtual

◆ CloseHardwareBuffer()

void flutter::ImageExternalTexture::CloseHardwareBuffer ( const fml::jni::JavaRef< jobject > &  hardware_buffer)
protected

Definition at line 92 of file image_external_texture.cc.

93 {
94 if (hardware_buffer.obj() == nullptr) {
95 return;
96 }
97 jni_facade_->HardwareBufferClose(JavaLocalRef(hardware_buffer));
98}

◆ CloseImage()

void flutter::ImageExternalTexture::CloseImage ( const fml::jni::JavaRef< jobject > &  image)
protected

Definition at line 85 of file image_external_texture.cc.

85 {
86 if (image.obj() == nullptr) {
87 return;
88 }
89 jni_facade_->ImageClose(JavaLocalRef(image));
90}
sk_sp< const SkImage > image
Definition: SkRecords.h:269

◆ Detach()

virtual void flutter::ImageExternalTexture::Detach ( )
protectedpure virtual

◆ FML_DISALLOW_COPY_AND_ASSIGN()

flutter::ImageExternalTexture::FML_DISALLOW_COPY_AND_ASSIGN ( ImageExternalTexture  )
protected

◆ HardwareBufferFor()

JavaLocalRef flutter::ImageExternalTexture::HardwareBufferFor ( const fml::jni::JavaRef< jobject > &  image)
protected

Definition at line 100 of file image_external_texture.cc.

101 {
102 if (image.obj() == nullptr) {
103 return JavaLocalRef();
104 }
105 // Image.getHardwareBuffer.
106 return jni_facade_->ImageGetHardwareBuffer(JavaLocalRef(image));
107}

◆ MarkNewFrameAvailable()

void flutter::ImageExternalTexture::MarkNewFrameAvailable ( )
overridevirtual

Implements flutter::Texture.

Definition at line 52 of file image_external_texture.cc.

52 {
53 // NOOP.
54}

◆ OnGrContextCreated()

void flutter::ImageExternalTexture::OnGrContextCreated ( )
overridevirtual

◆ OnGrContextDestroyed()

void flutter::ImageExternalTexture::OnGrContextDestroyed ( )
overridevirtual

Implements flutter::ContextListener.

Definition at line 65 of file image_external_texture.cc.

◆ OnTextureUnregistered()

void flutter::ImageExternalTexture::OnTextureUnregistered ( )
overridevirtual

Implements flutter::Texture.

Definition at line 57 of file image_external_texture.cc.

57{}

◆ Paint()

void flutter::ImageExternalTexture::Paint ( PaintContext context,
const SkRect bounds,
bool  freeze,
const DlImageSampling  sampling 
)
overridevirtual

Implements flutter::Texture.

Definition at line 25 of file image_external_texture.cc.

28 {
30 return;
31 }
32 Attach(context);
33 const bool should_process_frame = !freeze;
34 if (should_process_frame) {
35 ProcessFrame(context, bounds);
36 }
37 if (dl_image_) {
38 context.canvas->DrawImageRect(
39 dl_image_, // image
40 SkRect::Make(dl_image_->bounds()), // source rect
41 bounds, // destination rect
42 sampling, // sampling
43 context.paint, // paint
45 );
46 } else {
47 FML_LOG(INFO) << "No DlImage available for ImageExternalTexture to paint.";
48 }
49}
SkIRect bounds() const
Definition: dl_image.cc:31
virtual void ProcessFrame(PaintContext &context, const SkRect &bounds)=0
virtual void Attach(PaintContext &context)=0
#define FML_LOG(severity)
Definition: logging.h:82
Optional< SkRect > bounds
Definition: SkRecords.h:189
SkSamplingOptions sampling
Definition: SkRecords.h:337
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669

◆ ProcessFrame()

virtual void flutter::ImageExternalTexture::ProcessFrame ( PaintContext context,
const SkRect bounds 
)
protectedpure virtual

Member Data Documentation

◆ dl_image_

sk_sp<flutter::DlImage> flutter::ImageExternalTexture::dl_image_
protected

Definition at line 65 of file image_external_texture.h.

◆ image_lru_

ImageLRU flutter::ImageExternalTexture::image_lru_ = ImageLRU()
protected

Definition at line 66 of file image_external_texture.h.

◆ image_texture_entry_

fml::jni::ScopedJavaGlobalRef<jobject> flutter::ImageExternalTexture::image_texture_entry_
protected

Definition at line 60 of file image_external_texture.h.

◆ jni_facade_

std::shared_ptr<PlatformViewAndroidJNI> flutter::ImageExternalTexture::jni_facade_
protected

Definition at line 61 of file image_external_texture.h.

◆ state_

AttachmentState flutter::ImageExternalTexture::state_ = AttachmentState::kUninitialized
protected

Definition at line 64 of file image_external_texture.h.


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