1
1
use crate :: FlutterEngine ;
2
+ use flutter_engine_sys:: FlutterOpenGLTexture ;
2
3
#[ cfg( feature ="image" ) ]
3
4
use image:: RgbaImage ;
4
5
use parking_lot:: Mutex ;
5
6
use std:: collections:: HashMap ;
6
- use std:: sync:: Arc ;
7
- use std:: sync:: atomic:: { AtomicI64 , Ordering } ;
8
- use flutter_engine_sys:: FlutterOpenGLTexture ;
9
7
use std:: os:: raw:: c_void;
8
+ use std:: sync:: atomic:: { AtomicI64 , Ordering } ;
9
+ use std:: sync:: Arc ;
10
10
11
11
pub ( crate ) struct TextureRegistry {
12
12
last_id : AtomicI64 ,
@@ -41,12 +41,15 @@ impl TextureRegistry {
41
41
}
42
42
}
43
43
44
- pub fn get_texture_frame ( & self , texture_id : TextureId , _size : ( usize , usize ) ) ->Option < TextureFrame > {
44
+ pub fn get_texture_frame (
45
+ & self ,
46
+ texture_id : TextureId ,
47
+ _size : ( usize , usize ) ,
48
+ ) ->Option < TextureFrame > {
45
49
self . frames . lock ( ) . remove ( & texture_id)
46
50
}
47
51
}
48
52
49
-
50
53
pub type TextureId =i64 ;
51
54
52
55
pub struct Texture {
@@ -100,10 +103,8 @@ impl Texture {
100
103
let engine_weak = engine. downgrade ( ) ;
101
104
let frame =TextureFrame :: new ( gl:: TEXTURE_2D , glid, gl:: RGBA , move ||{
102
105
if let Some ( engine) = engine_weak. upgrade ( ) {
103
- engine. run_on_render_thread ( move |_|{
104
- unsafe {
105
- gl:: DeleteTextures ( 1 , & glidas * const _ ) ;
106
- }
106
+ engine. run_on_render_thread ( move |_|unsafe {
107
+ gl:: DeleteTextures ( 1 , & glidas * const _ ) ;
107
108
} ) ;
108
109
}
109
110
} ) ;
@@ -113,7 +114,12 @@ impl Texture {
113
114
}
114
115
}
115
116
116
- fn post_frame_internal ( engine : & FlutterEngine , texture_id : TextureId , frames : & Arc < Mutex < HashMap < TextureId , TextureFrame > > > , frame : TextureFrame ) {
117
+ fn post_frame_internal (
118
+ engine : & FlutterEngine ,
119
+ texture_id : TextureId ,
120
+ frames : & Arc < Mutex < HashMap < TextureId , TextureFrame > > > ,
121
+ frame : TextureFrame ,
122
+ ) {
117
123
frames. lock ( ) . insert ( texture_id, frame) ;
118
124
119
125
let texture_id = texture_id;
@@ -153,14 +159,9 @@ pub struct TextureFrame {
153
159
}
154
160
155
161
impl TextureFrame {
156
- pub fn new < F > (
157
- target : u32 ,
158
- name : u32 ,
159
- format : u32 ,
160
- destruction_callback : F ,
161
- ) ->TextureFrame
162
- where
163
- F : FnOnce ( ) ->( ) +' static +Send ,
162
+ pub fn new < F > ( target : u32 , name : u32 , format : u32 , destruction_callback : F ) ->TextureFrame
163
+ where
164
+ F : FnOnce ( ) ->( ) +' static +Send ,
164
165
{
165
166
Self {
166
167
target,