Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit95a6d59

Browse files
committed
Request egl for rendering API
1 parent0218372 commit95a6d59

File tree

5 files changed

+37
-63
lines changed

5 files changed

+37
-63
lines changed

‎Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎flutter-glfw/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ copypasta = "0.6.2"
1313
flutter-engine-sys = {path ="../flutter-engine-sys" }
1414
flutter-engine = {path ="../flutter-engine" }
1515
flutter-plugins = {path ="../flutter-plugins" }
16-
gl ="0.14.0"
1716
locale_config ="0.3.0"
1817
log ="0.4.8"
1918
parking_lot ="0.10.0"
20-
glfw ="0.34.0"
19+
glfw ="0.37.0"
2120
lazy_static ="1.4.0"

‎flutter-glfw/src/handler.rs

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use flutter_plugins::textinput::TextInputHandler;
55
use flutter_plugins::window::{PositionParams,WindowHandler};
66
use glfw::Context;
77
use parking_lot::Mutex;
8+
use std::cell::RefCell;
89
use std::ffi::c_void;
910
use std::sync::Arc;
1011

@@ -25,35 +26,27 @@ impl TaskRunnerHandler for GlfwPlatformTaskHandler {
2526
}
2627

2728
pub(crate)structGlfwOpenGLHandler{
28-
pub(crate)glfw: glfw::Glfw,
29-
pub(crate)window:Arc<Mutex<glfw::Window>>,
30-
pub(crate)resource_window:Arc<Mutex<glfw::Window>>,
29+
render_ctx:RefCell<glfw::RenderContext>,
30+
resource_ctx:RefCell<glfw::RenderContext>,
3131
}
3232

33-
unsafeimplSendforGlfwOpenGLHandler{}
34-
3533
implGlfwOpenGLHandler{
36-
pubfnnew(
37-
glfw: glfw::Glfw,
38-
window:Arc<Mutex<glfw::Window>>,
39-
resource_window:Arc<Mutex<glfw::Window>>,
40-
) ->Self{
34+
pubfnnew(render_ctx: glfw::RenderContext,resource_ctx: glfw::RenderContext) ->Self{
4135
Self{
42-
glfw,
43-
window,
44-
resource_window,
36+
render_ctx:RefCell::new(render_ctx),
37+
resource_ctx:RefCell::new(resource_ctx),
4538
}
4639
}
4740
}
4841

4942
implFlutterOpenGLHandlerforGlfwOpenGLHandler{
5043
fnswap_buffers(&self) ->bool{
51-
self.window.lock().swap_buffers();
44+
self.render_ctx.borrow_mut().swap_buffers();
5245
true
5346
}
5447

5548
fnmake_current(&self) ->bool{
56-
self.window.lock().make_current();
49+
self.render_ctx.borrow_mut().make_current();
5750
true
5851
}
5952

@@ -67,15 +60,12 @@ impl FlutterOpenGLHandler for GlfwOpenGLHandler {
6760
}
6861

6962
fnmake_resource_current(&self) ->bool{
70-
self.resource_window.lock().make_current();
63+
self.resource_ctx.borrow_mut().make_current();
7164
true
7265
}
7366

7467
fngl_proc_resolver(&self,proc:*consti8) ->*mutc_void{
75-
unsafe{
76-
self.glfw
77-
.get_proc_address_raw(&glfw::string_from_c_str(proc))as*mutc_void
78-
}
68+
unsafe{ glfw::ffi::glfwGetProcAddress(procas_)as_}
7969
}
8070
}
8171

‎flutter-glfw/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::window::{CreateError, FlutterWindow, WindowArgs};
22
use log::error;
33
use std::path::PathBuf;
44

5-
mod draw;
65
mod handler;
76
pubmod window;
87

‎flutter-glfw/src/window.rs

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
usecrate::draw;
21
usecrate::handler::{
32
GlfwOpenGLHandler,GlfwPlatformHandler,GlfwPlatformTaskHandler,GlfwTextInputHandler,
43
GlfwWindowHandler,
@@ -10,6 +9,8 @@ use flutter_engine::ffi::{
109
FlutterPointerSignalKind,
1110
};
1211
use flutter_engine::plugins::Plugin;
12+
use flutter_engine::tasks::TaskRunnerHandler;
13+
use flutter_engine::texture_registry::Texture;
1314
use flutter_engine::FlutterEngine;
1415
use flutter_plugins::dialog::DialogPlugin;
1516
use flutter_plugins::isolate::IsolatePlugin;
@@ -25,16 +26,13 @@ use flutter_plugins::window::WindowPlugin;
2526
use glfw::Context;
2627
use lazy_static::lazy_static;
2728
use log::{debug, info};
28-
use parking_lot::{Mutex,MutexGuard};
29+
use parking_lot::Mutex;
2930
use std::collections::{HashMap,VecDeque};
30-
use std::ops::DerefMut;
3131
use std::path::PathBuf;
3232
use std::sync::atomic::{AtomicBool,AtomicU64,Ordering};
3333
use std::sync::mpsc::{Receiver,SendError,Sender};
3434
use std::sync::{mpsc,Arc};
3535
use std::time::Instant;
36-
use flutter_engine::texture_registry::Texture;
37-
use flutter_engine::tasks::TaskRunnerHandler;
3836

3937
// seems to be about 2.5 lines of text
4038
constSCROLL_SPEED:f64 =50.0;
@@ -57,18 +55,12 @@ pub enum CreateError {
5755

5856
impl std::fmt::DisplayforCreateError{
5957
fnfmt(&self,f:&mut std::fmt::Formatter) -> std::fmt::Result{
60-
use std::error::Error;
61-
f.write_str(self.description())
62-
}
63-
}
64-
65-
impl std::error::ErrorforCreateError{
66-
fndescription(&self) ->&str{
67-
match*self{
58+
let msg =match*self{
6859
CreateError::WindowCreationFailed =>"Failed to create a window",
6960
CreateError::WindowAlreadyCreated =>"Window was already created",
7061
CreateError::MonitorNotFound =>"No monitor with the specified index found",
71-
}
62+
};
63+
f.write_str(msg)
7264
}
7365
}
7466

@@ -83,7 +75,6 @@ pub struct WindowArgs<'a> {
8375
pubheight:i32,
8476
pubtitle:&'astr,
8577
pubmode:WindowMode,
86-
pubbg_color:(u8,u8,u8),
8778
}
8879

8980
/// Wrap glfw::Window, so that it could be used in a lazy_static HashMap
@@ -111,7 +102,7 @@ pub struct FlutterWindow {
111102
glfw: glfw::Glfw,
112103
window:Arc<Mutex<glfw::Window>>,
113104
window_receiver:Receiver<(f64, glfw::WindowEvent)>,
114-
resource_window:Arc<Mutex<glfw::Window>>,
105+
_resource_window:glfw::Window,
115106
_resource_window_receiver:Receiver<(f64, glfw::WindowEvent)>,
116107
engine:FlutterEngine,
117108
pointer_currently_added:AtomicBool,
@@ -132,8 +123,17 @@ impl FlutterWindow {
132123
assets_path:PathBuf,
133124
arguments:Vec<String>,
134125
) ->Result<Self,CreateError>{
126+
glfw.window_hint(glfw::WindowHint::ContextVersion(3,2));
127+
glfw.window_hint(glfw::WindowHint::OpenGlForwardCompat(true));
128+
glfw.window_hint(glfw::WindowHint::OpenGlProfile(
129+
glfw::OpenGlProfileHint::Core,
130+
));
131+
glfw.window_hint(glfw::WindowHint::ContextCreationApi(
132+
glfw::ContextCreationApi::Egl,
133+
));
134+
135135
// Create window
136-
let(window, receiver) =match window_args.mode{
136+
let(mutwindow, receiver) =match window_args.mode{
137137
WindowMode::Windowed => glfw
138138
.create_window(
139139
window_args.widthasu32,
@@ -169,29 +169,19 @@ impl FlutterWindow {
169169
// Create invisible resource window
170170
glfw.window_hint(glfw::WindowHint::Decorated(false));
171171
glfw.window_hint(glfw::WindowHint::Visible(false));
172-
let(res_window, res_window_recv) = window
172+
let(mutres_window, res_window_recv) = window
173173
.create_shared(1,1,"", glfw::WindowMode::Windowed)
174174
.ok_or(CreateError::WindowCreationFailed)?;
175175
glfw.default_window_hints();
176176

177+
let render_ctx = window.render_context();
178+
177179
// Wrap
178180
let window =Arc::new(Mutex::new(window));
179-
let res_window =Arc::new(Mutex::new(res_window));
180-
181-
// draw initial screen to avoid blinking
182-
{
183-
letmut window = window.lock();
184-
window.make_current();
185-
letmut window =MutexGuard::deref_mut(&mut window);
186-
draw::init_gl(&mut window);
187-
draw::draw_bg(&mut window, window_args.bg_color);
188-
glfw::make_context_current(None);
189-
}
190181

191182
// Create engine
192183
let platform_task_handler =Arc::new(GlfwPlatformTaskHandler::new());
193-
let opengl_handler =
194-
GlfwOpenGLHandler::new(glfw.clone(), window.clone(), res_window.clone());
184+
let opengl_handler =GlfwOpenGLHandler::new(render_ctx, res_window.render_context());
195185

196186
let engine =FlutterEngineBuilder::new()
197187
.with_platform_handler(platform_task_handler.clone())
@@ -244,7 +234,7 @@ impl FlutterWindow {
244234
glfw: glfw.clone(),
245235
window,
246236
window_receiver: receiver,
247-
resource_window: res_window,
237+
_resource_window: res_window,
248238
_resource_window_receiver: res_window_recv,
249239
engine,
250240
pointer_currently_added:AtomicBool::new(false),
@@ -267,10 +257,6 @@ impl FlutterWindow {
267257
self.window.clone()
268258
}
269259

270-
pubfnresource_window(&self) ->Arc<Mutex<glfw::Window>>{
271-
self.resource_window.clone()
272-
}
273-
274260
pubfncreate_texture(&self) ->Texture{
275261
self.engine.create_texture()
276262
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp