Flutter Engine
The Flutter Engine
shell
platform
android
io
flutter
embedding
engine
renderer
SurfaceTextureSurfaceProducer.java
Go to the documentation of this file.
1
package
io.flutter.embedding.engine.renderer;
2
3
import
android
.graphics.SurfaceTexture;
4
import
android
.os.Handler;
5
import
android
.view.Surface;
6
import
androidx.annotation.NonNull;
7
import
androidx.annotation.Nullable;
8
import
io.flutter.embedding.engine.FlutterJNI;
9
import
io.flutter.view.TextureRegistry;
10
11
/** Uses a {@link android.graphics.SurfaceTexture} to populate the texture registry. */
12
final
class
SurfaceTextureSurfaceProducer
13
implements
TextureRegistry
.SurfaceProducer,
TextureRegistry
.GLTextureConsumer {
14
private
final
long
id;
15
private
int
requestBufferWidth;
16
private
int
requestedBufferHeight;
17
private
boolean
released;
18
@Nullable
private
Surface surface;
19
@NonNull
private
final
TextureRegistry.SurfaceTextureEntry texture;
20
@NonNull
private
final
Handler handler;
21
@NonNull
private
final
FlutterJNI
flutterJNI;
22
23
SurfaceTextureSurfaceProducer
(
24
long
id
,
25
@NonNull Handler handler,
26
@NonNull
FlutterJNI
flutterJNI,
27
@NonNull
TextureRegistry
.
SurfaceTextureEntry
texture) {
28
this.id =
id
;
29
this.handler = handler;
30
this.flutterJNI = flutterJNI;
31
this.texture =
texture
;
32
}
33
34
@Override
35
protected
void
finalize
() throws Throwable {
36
try
{
37
if
(released) {
38
return
;
39
}
40
release
();
41
handler.post(
new
FlutterRenderer
.
TextureFinalizerRunnable
(
id
, flutterJNI));
42
}
finally
{
43
super.finalize();
44
}
45
}
46
47
@Override
48
public
long
id
() {
49
return
id
;
50
}
51
52
@Override
53
public
void
release
() {
54
texture
.release();
55
released =
true
;
56
}
57
58
@Override
59
@NonNull
60
public
SurfaceTexture
getSurfaceTexture
() {
61
return
texture
.surfaceTexture();
62
}
63
64
@Override
65
public
void
setSize
(
int
width
,
int
height
) {
66
requestBufferWidth =
width
;
67
requestedBufferHeight =
height
;
68
getSurfaceTexture
().setDefaultBufferSize(
width
,
height
);
69
}
70
71
@Override
72
public
int
getWidth
() {
73
return
requestBufferWidth;
74
}
75
76
@Override
77
public
int
getHeight
() {
78
return
requestedBufferHeight;
79
}
80
81
@Override
82
public
Surface
getSurface
() {
83
if
(
surface
==
null
) {
84
surface
=
new
Surface(
texture
.surfaceTexture());
85
}
86
return
surface
;
87
}
88
89
@Override
90
public
void
scheduleFrame
() {
91
flutterJNI.markTextureFrameAvailable(
id
);
92
}
93
}
io.flutter.embedding.engine.FlutterJNI
Definition:
FlutterJNI.java:106
io.flutter.embedding.engine.renderer.FlutterRenderer.TextureFinalizerRunnable
Definition:
FlutterRenderer.java:387
io.flutter.embedding.engine.renderer.FlutterRenderer
Definition:
FlutterRenderer.java:55
io.flutter.embedding.engine.renderer.SurfaceTextureSurfaceProducer
Definition:
SurfaceTextureSurfaceProducer.java:13
io.flutter.embedding.engine.renderer.SurfaceTextureSurfaceProducer.getWidth
int getWidth()
Definition:
SurfaceTextureSurfaceProducer.java:72
io.flutter.embedding.engine.renderer.SurfaceTextureSurfaceProducer.release
void release()
Definition:
SurfaceTextureSurfaceProducer.java:53
io.flutter.embedding.engine.renderer.SurfaceTextureSurfaceProducer.getHeight
int getHeight()
Definition:
SurfaceTextureSurfaceProducer.java:77
io.flutter.embedding.engine.renderer.SurfaceTextureSurfaceProducer.finalize
void finalize()
Definition:
SurfaceTextureSurfaceProducer.java:35
io.flutter.embedding.engine.renderer.SurfaceTextureSurfaceProducer.getSurfaceTexture
SurfaceTexture getSurfaceTexture()
Definition:
SurfaceTextureSurfaceProducer.java:60
io.flutter.embedding.engine.renderer.SurfaceTextureSurfaceProducer.getSurface
Surface getSurface()
Definition:
SurfaceTextureSurfaceProducer.java:82
io.flutter.embedding.engine.renderer.SurfaceTextureSurfaceProducer.id
long id()
Definition:
SurfaceTextureSurfaceProducer.java:48
io.flutter.embedding.engine.renderer.SurfaceTextureSurfaceProducer.SurfaceTextureSurfaceProducer
SurfaceTextureSurfaceProducer(long id, @NonNull Handler handler, @NonNull FlutterJNI flutterJNI, @NonNull TextureRegistry.SurfaceTextureEntry texture)
Definition:
SurfaceTextureSurfaceProducer.java:23
io.flutter.embedding.engine.renderer.SurfaceTextureSurfaceProducer.scheduleFrame
void scheduleFrame()
Definition:
SurfaceTextureSurfaceProducer.java:90
io.flutter.embedding.engine.renderer.SurfaceTextureSurfaceProducer.setSize
void setSize(int width, int height)
Definition:
SurfaceTextureSurfaceProducer.java:65
surface
VkSurfaceKHR surface
Definition:
main.cc:49
io.flutter.view.TextureRegistry.SurfaceTextureEntry
Definition:
TextureRegistry.java:97
io.flutter.view.TextureRegistry
Definition:
TextureRegistry.java:20
texture
FlTexture * texture
Definition:
mock_texture_registrar.cc:24
android
Definition:
BitmapRegionDecoder.cpp:14
height
int32_t height
Definition:
serialization_callbacks.cc:1
width
int32_t width
Definition:
serialization_callbacks.cc:0
id
const uintptr_t id
Definition:
texture_unittests.cc:27
Generated on Sun Jun 23 2024 21:55:09 for Flutter Engine by
1.9.4