Skip to content

Commit

Permalink
Fix typos, warnings and other nits
Browse files Browse the repository at this point in the history
  • Loading branch information
ferjm committed Jul 4, 2019
1 parent 0da87ad commit cd17b6c
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 53 deletions.
4 changes: 2 additions & 2 deletions components/media/lib.rs
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions components/media/media_thread.rs
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions components/script/dom/bindings/trace.rs
Expand Up @@ -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::{
Expand Down Expand Up @@ -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]
Expand Down
68 changes: 24 additions & 44 deletions components/script/dom/htmlmediaelement.rs
Expand Up @@ -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>,
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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,
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 = Some(FrameHolder::new(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(image_key, descriptor, image_data, None);
},
}
self.api.update_resources(txn.resource_updates);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/window.rs
Expand Up @@ -319,7 +319,7 @@ pub struct Window {
/// Replace unpaired surrogates in DOM strings with U+FFFD.
/// See <https://github.com/servo/servo/issues/6564>
replace_surrogates: bool,

/// Window's GL context from application
#[ignore_malloc_size_of = "defined in script_thread"]
player_context: WindowGLContext,
Expand Down
4 changes: 1 addition & 3 deletions components/script/script_thread.rs
Expand Up @@ -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)]
Expand Down Expand Up @@ -681,7 +679,7 @@ pub struct ScriptThread {

/// An optional string allowing the user agent to be set for testing.
user_agent: Cow<'static, str>,

/// Application window's GL Context for Media player
player_context: WindowGLContext,
}
Expand Down
2 changes: 2 additions & 0 deletions ports/glutin/context.rs
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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() },
Expand Down

0 comments on commit cd17b6c

Please sign in to comment.