mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Implement DOM to texture
This commit is contained in:
parent
a9022be0c3
commit
8ae0739bab
17 changed files with 238 additions and 13 deletions
|
@ -6,7 +6,7 @@ use euclid::Size2D;
|
|||
use nonzero::NonZeroU32;
|
||||
use offscreen_gl_context::{GLContextAttributes, GLLimits};
|
||||
use std::fmt;
|
||||
use webrender_api;
|
||||
use webrender_api::{DocumentId, ImageKey, PipelineId};
|
||||
|
||||
/// Sender type used in WebGLCommands.
|
||||
pub use ::webgl_channel::WebGLSender;
|
||||
|
@ -46,7 +46,9 @@ pub enum WebGLMsg {
|
|||
/// Unlock messages are always sent after a Lock message.
|
||||
Unlock(WebGLContextId),
|
||||
/// Creates or updates the image keys required for WebRender.
|
||||
UpdateWebRenderImage(WebGLContextId, WebGLSender<webrender_api::ImageKey>),
|
||||
UpdateWebRenderImage(WebGLContextId, WebGLSender<ImageKey>),
|
||||
/// Commands used for the DOMToTexture feature.
|
||||
DOMToTextureCommand(DOMToTextureCommand),
|
||||
/// Frees all resources and closes the thread.
|
||||
Exit,
|
||||
}
|
||||
|
@ -86,6 +88,11 @@ impl WebGLMsgSender {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the WebGLContextId associated to this sender
|
||||
pub fn context_id(&self) -> WebGLContextId {
|
||||
self.ctx_id
|
||||
}
|
||||
|
||||
/// Send a WebGLCommand message
|
||||
#[inline]
|
||||
pub fn send(&self, command: WebGLCommand) -> WebGLSendResult {
|
||||
|
@ -113,9 +120,13 @@ impl WebGLMsgSender {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn send_update_wr_image(&self, sender: WebGLSender<webrender_api::ImageKey>) -> WebGLSendResult {
|
||||
pub fn send_update_wr_image(&self, sender: WebGLSender<ImageKey>) -> WebGLSendResult {
|
||||
self.sender.send(WebGLMsg::UpdateWebRenderImage(self.ctx_id, sender))
|
||||
}
|
||||
|
||||
pub fn send_dom_to_texture(&self, command: DOMToTextureCommand) -> WebGLSendResult {
|
||||
self.sender.send(WebGLMsg::DOMToTextureCommand(command))
|
||||
}
|
||||
}
|
||||
|
||||
/// WebGL Commands for a specific WebGLContext
|
||||
|
@ -379,6 +390,17 @@ pub trait WebVRRenderHandler: Send {
|
|||
fn handle(&mut self, command: WebVRCommand, texture: Option<(u32, Size2D<i32>)>);
|
||||
}
|
||||
|
||||
/// WebGL commands required to implement DOMToTexture feature.
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
pub enum DOMToTextureCommand {
|
||||
/// Attaches a HTMLIFrameElement to a WebGLTexture.
|
||||
Attach(WebGLContextId, WebGLTextureId, DocumentId, PipelineId, Size2D<i32>),
|
||||
/// Releases the HTMLIFrameElement to WebGLTexture attachment.
|
||||
Detach(WebGLTextureId),
|
||||
/// Lock message used for a correct synchronization with WebRender GL flow.
|
||||
Lock(PipelineId, usize, WebGLSender<Option<(u32, Size2D<i32>)>>),
|
||||
}
|
||||
|
||||
impl fmt::Debug for WebGLCommand {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
use self::WebGLCommand::*;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue