Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
io.flutter.embedding.engine.renderer.SurfaceTextureWrapper Class Reference

Public Member Functions

 SurfaceTextureWrapper (@NonNull SurfaceTexture surfaceTexture)
 
 SurfaceTextureWrapper ( @NonNull SurfaceTexture surfaceTexture, @Nullable Runnable onFrameConsumed)
 
SurfaceTexture surfaceTexture ()
 
void markDirty ()
 
boolean shouldUpdate ()
 
void updateTexImage ()
 
void release ()
 
void attachToGLContext (int texName)
 
void detachFromGLContext ()
 
void getTransformMatrix (@NonNull float[] mtx)
 

Detailed Description

A wrapper for a SurfaceTexture that tracks whether the texture has been released.

The engine calls SurfaceTexture.release on the platform thread, but
updateTexImage
is called on the raster thread. This wrapper will prevent updateTexImage calls on an abandoned texture.

Definition at line 20 of file SurfaceTextureWrapper.java.

Constructor & Destructor Documentation

◆ SurfaceTextureWrapper() [1/2]

io.flutter.embedding.engine.renderer.SurfaceTextureWrapper.SurfaceTextureWrapper ( @NonNull SurfaceTexture  surfaceTexture)
inline

Definition at line 27 of file SurfaceTextureWrapper.java.

27 {
28 this(surfaceTexture, null);
29 }

◆ SurfaceTextureWrapper() [2/2]

io.flutter.embedding.engine.renderer.SurfaceTextureWrapper.SurfaceTextureWrapper ( @NonNull SurfaceTexture  surfaceTexture,
@Nullable Runnable  onFrameConsumed 
)
inline

A wrapper for a SurfaceTexture.

The provided onFrameConsumed callback must be invoked when the most recent image was consumed.

Parameters
onFrameConsumedThe callback after the updateTexImage is called.

Definition at line 39 of file SurfaceTextureWrapper.java.

40 {
41 this.surfaceTexture = surfaceTexture;
42 this.released = false;
43 this.onFrameConsumed = onFrameConsumed;
44 }

Member Function Documentation

◆ attachToGLContext()

void io.flutter.embedding.engine.renderer.SurfaceTextureWrapper.attachToGLContext ( int  texName)
inline

Definition at line 89 of file SurfaceTextureWrapper.java.

89 {
90 synchronized (this) {
91 if (released) {
92 return;
93 }
94 // When the rasterizer tasks run on a different thread, the GrContext is re-created.
95 // This causes the texture to be in an uninitialized state.
96 // This should *not* be an issue once platform views are always rendered as TextureLayers
97 // since thread merging will be always disabled on Android.
98 // For more see: SurfaceTextureExternalTextureGL::OnGrContextCreated in
99 // surface_texture_external_texture_gl.cc, and
100 // https://github.com/flutter/flutter/issues/98155
101 if (attached) {
102 surfaceTexture.detachFromGLContext();
103 }
104 surfaceTexture.attachToGLContext(texName);
105 attached = true;
106 }
107 }

◆ detachFromGLContext()

void io.flutter.embedding.engine.renderer.SurfaceTextureWrapper.detachFromGLContext ( )
inline

Definition at line 111 of file SurfaceTextureWrapper.java.

111 {
112 synchronized (this) {
113 if (attached && !released) {
114 surfaceTexture.detachFromGLContext();
115 attached = false;
116 }
117 }
118 }

◆ getTransformMatrix()

void io.flutter.embedding.engine.renderer.SurfaceTextureWrapper.getTransformMatrix ( @NonNull float[]  mtx)
inline

Definition at line 122 of file SurfaceTextureWrapper.java.

122 {
123 surfaceTexture.getTransformMatrix(mtx);
124 }

◆ markDirty()

void io.flutter.embedding.engine.renderer.SurfaceTextureWrapper.markDirty ( )
inline

Definition at line 51 of file SurfaceTextureWrapper.java.

51 {
52 synchronized (this) {
53 newFrameAvailable = true;
54 }
55 }

◆ release()

void io.flutter.embedding.engine.renderer.SurfaceTextureWrapper.release ( )
inline

Definition at line 77 of file SurfaceTextureWrapper.java.

77 {
78 synchronized (this) {
79 if (!released) {
80 surfaceTexture.release();
81 released = true;
82 attached = false;
83 }
84 }
85 }

◆ shouldUpdate()

boolean io.flutter.embedding.engine.renderer.SurfaceTextureWrapper.shouldUpdate ( )
inline

Definition at line 57 of file SurfaceTextureWrapper.java.

57 {
58 synchronized (this) {
59 return newFrameAvailable;
60 }
61 }

◆ surfaceTexture()

SurfaceTexture io.flutter.embedding.engine.renderer.SurfaceTextureWrapper.surfaceTexture ( )
inline

Definition at line 47 of file SurfaceTextureWrapper.java.

47 {
48 return surfaceTexture;
49 }

◆ updateTexImage()

void io.flutter.embedding.engine.renderer.SurfaceTextureWrapper.updateTexImage ( )
inline

Definition at line 65 of file SurfaceTextureWrapper.java.

65 {
66 synchronized (this) {
67 newFrameAvailable = false;
68 if (!released) {
69 surfaceTexture.updateTexImage();
70 if (onFrameConsumed != null) {
71 onFrameConsumed.run();
72 }
73 }
74 }
75 }

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