Add the ability to pass a prebuilt canvas (#1394)
This allows Winit to take control of existing canvas elements in the DOM, which is useful for web applications with other content in the page.
This commit is contained in:
parent
9daa0738a9
commit
1fe4a7a4ea
7 changed files with 69 additions and 23 deletions
|
|
@ -23,13 +23,13 @@ impl Window {
|
|||
pub fn new<T>(
|
||||
target: &EventLoopWindowTarget<T>,
|
||||
attr: WindowAttributes,
|
||||
_: PlatformSpecificBuilderAttributes,
|
||||
platform_attr: PlatformSpecificBuilderAttributes,
|
||||
) -> Result<Self, RootOE> {
|
||||
let runner = target.runner.clone();
|
||||
|
||||
let id = target.generate_id();
|
||||
|
||||
let mut canvas = backend::Canvas::create()?;
|
||||
let mut canvas = backend::Canvas::create(platform_attr)?;
|
||||
|
||||
let register_redraw_request = Box::new(move || runner.request_redraw(RootWI(id)));
|
||||
|
||||
|
|
@ -281,5 +281,7 @@ impl Id {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct PlatformSpecificBuilderAttributes;
|
||||
#[derive(Default, Clone)]
|
||||
pub struct PlatformSpecificBuilderAttributes {
|
||||
pub(crate) canvas: Option<backend::RawCanvasType>,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue