mirror of
https://github.com/servo/servo.git
synced 2025-07-29 10:10:34 +01:00
Fix typos, warnings and other nits
This commit is contained in:
parent
0da87ad169
commit
cd17b6ca66
7 changed files with 35 additions and 53 deletions
|
@ -35,8 +35,8 @@ pub enum GLPlayerMsgForward {
|
|||
|
||||
/// GLPlayer thread Message API
|
||||
///
|
||||
/// These are the message that the thread will receive from the
|
||||
/// constellation, the webrender::ExternalImageHandle multiplexor
|
||||
/// These are the messages that the thread will receive from the
|
||||
/// constellation, the webrender::ExternalImageHandle demultiplexor
|
||||
/// implementation, or a htmlmediaelement
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub enum GLPlayerMsg {
|
||||
|
|
|
@ -11,10 +11,10 @@ use std::sync::{Arc, Mutex};
|
|||
use std::thread;
|
||||
use webrender_traits::{WebrenderExternalImageRegistry, WebrenderImageHandlerType};
|
||||
|
||||
/// A GLPlayerThrx1ead manages the life cycle and message multiplexign of
|
||||
/// A GLPlayerThread manages the life cycle and message demultiplexing of
|
||||
/// a set of video players with GL render.
|
||||
pub struct GLPlayerThread {
|
||||
// Map of live players.
|
||||
/// Map of live players.
|
||||
players: FnvHashMap<u64, GLPlayerSender<GLPlayerMsgForward>>,
|
||||
/// List of registered webrender external images.
|
||||
/// We use it to get an unique ID for new players.
|
||||
|
@ -50,7 +50,7 @@ impl GLPlayerThread {
|
|||
sender
|
||||
}
|
||||
|
||||
/// Handles a generic WebGLMsg message
|
||||
/// Handles a generic GLPlayerMsg message
|
||||
#[inline]
|
||||
fn handle_msg(&mut self, msg: GLPlayerMsg) -> bool {
|
||||
trace!("processing {:?}", msg);
|
||||
|
|
|
@ -73,6 +73,7 @@ use js::jsval::JSVal;
|
|||
use js::rust::{GCMethods, Handle, Runtime};
|
||||
use js::typedarray::TypedArray;
|
||||
use js::typedarray::TypedArrayElement;
|
||||
use media::WindowGLContext;
|
||||
use metrics::{InteractiveMetrics, InteractiveWindow};
|
||||
use mime::Mime;
|
||||
use msg::constellation_msg::{
|
||||
|
@ -507,6 +508,7 @@ unsafe_no_jsmanaged_fields!(Rotation3D<f64>, Transform2D<f32>, Transform3D<f64>)
|
|||
unsafe_no_jsmanaged_fields!(Point2D<f32>, Vector2D<f32>, Rect<Au>);
|
||||
unsafe_no_jsmanaged_fields!(Rect<f32>, RigidTransform3D<f64>);
|
||||
unsafe_no_jsmanaged_fields!(CascadeData);
|
||||
unsafe_no_jsmanaged_fields!(WindowGLContext);
|
||||
|
||||
unsafe impl<'a> JSTraceable for &'a str {
|
||||
#[inline]
|
||||
|
|
|
@ -133,7 +133,7 @@ impl FrameHolder {
|
|||
}
|
||||
|
||||
pub struct MediaFrameRenderer {
|
||||
id: u64,
|
||||
player_id: Option<u64>,
|
||||
api: RenderApi,
|
||||
current_frame: Option<(ImageKey, i32, i32)>,
|
||||
old_frame: Option<ImageKey>,
|
||||
|
@ -144,7 +144,7 @@ pub struct MediaFrameRenderer {
|
|||
impl MediaFrameRenderer {
|
||||
fn new(render_api_sender: RenderApiSender) -> Self {
|
||||
Self {
|
||||
id: 0,
|
||||
player_id: None,
|
||||
api: render_api_sender.create_api(),
|
||||
current_frame: None,
|
||||
old_frame: None,
|
||||
|
@ -187,7 +187,7 @@ impl FrameRenderer for MediaFrameRenderer {
|
|||
ImageData::Raw(frame.get_data()),
|
||||
&webrender_api::DirtyRect::All,
|
||||
);
|
||||
} else if self.id != 0 {
|
||||
} else if self.player_id.is_some() {
|
||||
self.current_frame_holder
|
||||
.get_or_insert_with(|| FrameHolder::new(frame.clone()))
|
||||
.set(frame);
|
||||
|
@ -207,55 +207,35 @@ impl FrameRenderer for MediaFrameRenderer {
|
|||
*width = frame.get_width();
|
||||
*height = frame.get_height();
|
||||
|
||||
if !frame.is_gl_texture() {
|
||||
txn.add_image(
|
||||
new_image_key,
|
||||
descriptor,
|
||||
ImageData::Raw(frame.get_data()),
|
||||
None,
|
||||
);
|
||||
} else if self.id != 0 {
|
||||
txn.add_image(
|
||||
new_image_key,
|
||||
descriptor,
|
||||
ImageData::External(ExternalImageData {
|
||||
id: ExternalImageId(self.id),
|
||||
channel_index: 0,
|
||||
image_type: ExternalImageType::TextureHandle(TextureTarget::Default),
|
||||
}),
|
||||
None,
|
||||
);
|
||||
|
||||
let image_data = if let Some(player_id) = self.player_id {
|
||||
self.current_frame_holder
|
||||
.get_or_insert_with(|| FrameHolder::new(frame.clone()))
|
||||
.set(frame);
|
||||
}
|
||||
ImageData::External(ExternalImageData {
|
||||
id: ExternalImageId(player_id),
|
||||
channel_index: 0,
|
||||
image_type: ExternalImageType::TextureHandle(TextureTarget::Default),
|
||||
})
|
||||
} else {
|
||||
ImageData::Raw(frame.get_data())
|
||||
};
|
||||
txn.add_image(new_image_key, descriptor, image_data, None);
|
||||
},
|
||||
None => {
|
||||
let image_key = self.api.generate_image_key();
|
||||
self.current_frame = Some((image_key, frame.get_width(), frame.get_height()));
|
||||
|
||||
if !frame.is_gl_texture() {
|
||||
txn.add_image(
|
||||
image_key,
|
||||
descriptor,
|
||||
ImageData::Raw(frame.get_data()),
|
||||
None,
|
||||
);
|
||||
} else if self.id != 0 {
|
||||
txn.add_image(
|
||||
image_key,
|
||||
descriptor,
|
||||
let image_data = if let Some(player_id) = self.player_id {
|
||||
self.current_frame_holder = Some(FrameHolder::new(frame));
|
||||
ImageData::External(ExternalImageData {
|
||||
id: ExternalImageId(self.id),
|
||||
id: ExternalImageId(player_id),
|
||||
channel_index: 0,
|
||||
image_type: ExternalImageType::TextureHandle(TextureTarget::Default),
|
||||
}),
|
||||
None,
|
||||
);
|
||||
|
||||
self.current_frame_holder = Some(FrameHolder::new(frame));
|
||||
}
|
||||
})
|
||||
} else {
|
||||
ImageData::Raw(frame.get_data())
|
||||
};
|
||||
txn.add_image(image_key, descriptor, image_data, None);
|
||||
},
|
||||
}
|
||||
self.api.update_resources(txn.resource_updates);
|
||||
|
@ -1371,7 +1351,7 @@ impl HTMLMediaElement {
|
|||
.unwrap_or((0, None));
|
||||
|
||||
self.id.set(player_id);
|
||||
self.frame_renderer.lock().unwrap().id = player_id;
|
||||
self.frame_renderer.lock().unwrap().player_id = Some(player_id);
|
||||
|
||||
if let Some(image_receiver) = image_receiver {
|
||||
let trusted_node = Trusted::new(self);
|
||||
|
|
|
@ -513,8 +513,6 @@ unsafe_no_jsmanaged_fields!(TaskQueue<MainThreadScriptMsg>);
|
|||
unsafe_no_jsmanaged_fields!(dyn BackgroundHangMonitorRegister);
|
||||
unsafe_no_jsmanaged_fields!(dyn BackgroundHangMonitor);
|
||||
|
||||
unsafe_no_jsmanaged_fields!(WindowGLContext);
|
||||
|
||||
#[derive(JSTraceable)]
|
||||
// ScriptThread instances are rooted on creation, so this is okay
|
||||
#[allow(unrooted_must_root)]
|
||||
|
|
|
@ -74,6 +74,7 @@ impl GlContext {
|
|||
GlContext::None => unreachable!(),
|
||||
};
|
||||
}
|
||||
#[allow(unreachable_code, unused_variables)]
|
||||
pub fn raw_context(&self) -> RawContext {
|
||||
match self {
|
||||
GlContext::Current(c) => {
|
||||
|
@ -135,6 +136,7 @@ impl GlContext {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn egl_display(&self) -> Option<*const raw::c_void> {
|
||||
match self {
|
||||
GlContext::Current(c) => unsafe { c.get_egl_display() },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue