Instances of external textures peered to android.graphics.SurfaceTexture.
More...
#include <surface_texture_external_texture.h>
Public Member Functions | |
| SurfaceTextureExternalTexture (int64_t id, const fml::jni::ScopedJavaGlobalRef< jobject > &surface_texture, const std::shared_ptr< PlatformViewAndroidJNI > &jni_facade) | |
| ~SurfaceTextureExternalTexture () 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 () | |
Protected Types | |
| enum class | AttachmentState { kUninitialized , kAttached , kDetached } |
| Specifies how this instance is bound to the underlying surface texture. More... | |
Protected Member Functions | |
| virtual void | ProcessFrame (PaintContext &context, const SkRect &bounds)=0 |
| Subclasses override this method to bind the OpenGL texture resource represented by this surface texture to the package specific texture (SkImage, impeller::Texture, etc...). | |
| virtual void | DrawFrame (PaintContext &context, const SkRect &bounds, const DlImageSampling sampling) const |
| const SkM44 & | GetCurrentUVTransformation () const |
| Get the transformation that should be applied to the UV texture coordinates when sampling from this texture. | |
| virtual void | Detach () |
| Provides an opportunity for the subclasses to sever the connection between the OpenGL texture resource represented by this surface texture and the underlying package handle (SkImage, impeller::Texture, etc...). | |
| void | Attach (int gl_tex_id) |
| Attaches the given OpenGL texture handle to the surface texture via a bind operation. | |
| bool | ShouldUpdate () |
| void | Update () |
| Update the surface texture contents and transformation matrix. | |
Protected Attributes | |
| std::shared_ptr< PlatformViewAndroidJNI > | jni_facade_ |
| fml::jni::ScopedJavaGlobalRef< jobject > | surface_texture_ |
| AttachmentState | state_ = AttachmentState::kUninitialized |
| sk_sp< flutter::DlImage > | dl_image_ |
Instances of external textures peered to android.graphics.SurfaceTexture.
SurfaceTextures are used on older versions of Android (API < 29). On newer versions, the Android Hardware Buffer backend flutter::ImageExternalTexture instances are used instead.
Due to the way surface textures are designed, it is not possible to have a Vulkan renderer interoperate with such textures. Consequently, both Skia and Impeller only have OpenGL implementations for these kinds of textures.
This is an abstract base class. Minimally, subclasses override the pure virtual ProcessFrame method to bind the package specific texture implementation to the surface texture.
Definition at line 33 of file surface_texture_external_texture.h.
|
strongprotected |
Specifies how this instance is bound to the underlying surface texture.
| Enumerator | |
|---|---|
| kUninitialized | |
| kAttached | |
| kDetached | |
Definition at line 107 of file surface_texture_external_texture.h.
| flutter::SurfaceTextureExternalTexture::SurfaceTextureExternalTexture | ( | int64_t | id, |
| const fml::jni::ScopedJavaGlobalRef< jobject > & | surface_texture, | ||
| const std::shared_ptr< PlatformViewAndroidJNI > & | jni_facade | ||
| ) |
Definition at line 19 of file surface_texture_external_texture.cc.
|
override |
Definition at line 28 of file surface_texture_external_texture.cc.
|
protected |
Attaches the given OpenGL texture handle to the surface texture via a bind operation.
@important It is the responsibility of the subclass to ensure that a context is current when this call is made. Subclass can do this by overriding this method, making the context current in the implementation and calling the base class method.
| [in] | gl_tex_id | The gl tex identifier |
Definition at line 123 of file surface_texture_external_texture.cc.
References jni_facade_, kAttached, state_, and surface_texture_.
|
protectedvirtual |
Provides an opportunity for the subclasses to sever the connection between the OpenGL texture resource represented by this surface texture and the underlying package handle (SkImage, impeller::Texture, etc...).
@important It is the responsibility of the subclass to ensure that a context is current when this call is made. Subclass can do this by overriding this method, making the context current in the implementation and calling the base class method.
Definition at line 117 of file surface_texture_external_texture.cc.
References dl_image_, jni_facade_, and surface_texture_.
|
protectedvirtual |
Definition at line 64 of file surface_texture_external_texture.cc.
References flutter::Texture::PaintContext::canvas, dl_image_, flutter::DlCanvas::DrawImage(), flutter::DlCanvas::DrawRect(), FML_LOG, GetCurrentUVTransformation(), flutter::kClamp, flutter::DlColorSource::MakeImage(), impeller::TRect< Scalar >::MakeWH(), flutter::Texture::PaintContext::paint, flutter::DlCanvas::Scale(), flutter::DlPaint::setColorSource(), flutter::ToDlMatrix(), transform, and flutter::DlCanvas::Translate().
|
protected |
Get the transformation that should be applied to the UV texture coordinates when sampling from this texture.
Definition at line 141 of file surface_texture_external_texture.cc.
Referenced by DrawFrame().
|
protectedpure virtual |
Subclasses override this method to bind the OpenGL texture resource represented by this surface texture to the package specific texture (SkImage, impeller::Texture, etc...).
@important The state of texture should be AttachmentState::kAttached after a call to this method. That is the responsibility of the subclass.
| context | The context. | |
| [in] | bounds | The bounds of the texture. |
|
protected |
Definition at line 129 of file surface_texture_external_texture.cc.
References jni_facade_, and surface_texture_.
|
protected |
Update the surface texture contents and transformation matrix.
Definition at line 134 of file surface_texture_external_texture.cc.
References jni_facade_, and surface_texture_.
|
protected |
Definition at line 112 of file surface_texture_external_texture.h.
Referenced by Detach(), and DrawFrame().
|
protected |
Definition at line 109 of file surface_texture_external_texture.h.
Referenced by Attach(), Detach(), ShouldUpdate(), and Update().
|
protected |
Definition at line 111 of file surface_texture_external_texture.h.
Referenced by Attach().
|
protected |
Definition at line 110 of file surface_texture_external_texture.h.
Referenced by Attach(), Detach(), ShouldUpdate(), and Update().