mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
add back browser_host::composite() method for embedding
this changes the way that applications will use servo. whereas previously it was only necessary to call initialize() -> makecurrent, it's now necessary to explicitly call the composite() method in order to trigger the gl rendering. any other composite attempts (by servo) will trigger the on_paint() method, informing the app that a frame is ready. it's then up to the app to schedule the composite() such that the frame is rendered in a timely manner
This commit is contained in:
parent
12d792f427
commit
5697d9ff2c
2 changed files with 22 additions and 4 deletions
|
@ -15,13 +15,15 @@ use geom::size::TypedSize2D;
|
|||
use libc::{c_double, c_int};
|
||||
use msg::constellation_msg::{self, KeyModifiers, KeyState};
|
||||
use script_traits::MouseButton;
|
||||
use std::cell::RefCell;
|
||||
use std::cell::{Cell, RefCell};
|
||||
|
||||
pub struct ServoCefBrowserHost {
|
||||
/// A reference to the browser.
|
||||
pub browser: RefCell<Option<CefBrowser>>,
|
||||
/// A reference to the client.
|
||||
pub client: CefClient,
|
||||
/// flag for return value of prepare_for_composite
|
||||
pub composite_ok: Cell<bool>,
|
||||
}
|
||||
|
||||
full_cef_class_impl! {
|
||||
|
@ -176,6 +178,12 @@ full_cef_class_impl! {
|
|||
this.downcast().send_window_event(WindowEvent::InitializeCompositing);
|
||||
}}
|
||||
|
||||
fn composite(&this,) -> () {{
|
||||
this.downcast().composite_ok.set(true);
|
||||
this.downcast().send_window_event(WindowEvent::Refresh);
|
||||
this.downcast().composite_ok.set(false);
|
||||
}}
|
||||
|
||||
fn get_window_handle(&this,) -> cef_window_handle_t {{
|
||||
let t = this.downcast();
|
||||
let browser = t.browser.borrow();
|
||||
|
@ -189,6 +197,7 @@ impl ServoCefBrowserHost {
|
|||
ServoCefBrowserHost {
|
||||
browser: RefCell::new(None),
|
||||
client: client,
|
||||
composite_ok: Cell::new(false),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -296,12 +296,21 @@ impl WindowMethods for Window {
|
|||
fn prepare_for_composite(&self, width: usize, height: usize) -> bool {
|
||||
let browser = self.cef_browser.borrow();
|
||||
match *browser {
|
||||
None => {}
|
||||
None => {
|
||||
panic!("No browser?!?");
|
||||
}
|
||||
Some(ref browser) => {
|
||||
browser.get_host().get_client().get_render_handler().paint(browser.clone(), width, height);
|
||||
if browser.downcast().host.downcast().composite_ok.get() == true {
|
||||
true
|
||||
} else {
|
||||
if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) &&
|
||||
check_ptr_exist!(browser.get_host().get_client().get_render_handler(), on_paint) {
|
||||
browser.get_host().get_client().get_render_handler().paint(browser.clone(), width, height);
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
fn load_end(&self) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue