Final tweaks: use expect and remove unnecessary crate attributes

This commit is contained in:
Fernando Jiménez Moreno 2019-07-04 10:22:57 +02:00
parent 63920da347
commit 208473cdbc
5 changed files with 37 additions and 55 deletions

8
Cargo.lock generated
View file

@ -2725,8 +2725,8 @@ dependencies = [
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
"servo-media 0.1.0 (git+https://github.com/servo/media)", "servo-media 0.1.0 (git+https://github.com/servo/media)",
"servo_config 0.0.1", "servo_config 0.0.1",
"webrender 0.60.0 (git+https://github.com/servo/webrender)", "webrender 0.60.0 (git+https://github.com/jdm/webrender?branch=servo-hl)",
"webrender_api 0.60.0 (git+https://github.com/servo/webrender)", "webrender_api 0.60.0 (git+https://github.com/jdm/webrender?branch=servo-hl)",
"webrender_traits 0.0.1", "webrender_traits 0.0.1",
] ]
@ -5407,8 +5407,8 @@ name = "webrender_traits"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender 0.60.0 (git+https://github.com/servo/webrender)", "webrender 0.60.0 (git+https://github.com/jdm/webrender?branch=servo-hl)",
"webrender_api 0.60.0 (git+https://github.com/servo/webrender)", "webrender_api 0.60.0 (git+https://github.com/jdm/webrender?branch=servo-hl)",
] ]
[[package]] [[package]]

View file

@ -464,7 +464,7 @@ pub struct InitialConstellationState {
/// The XR device registry /// The XR device registry
pub webxr_registry: webxr_api::Registry, pub webxr_registry: webxr_api::Registry,
pub glplayer_threads: Option<GLPlayerThreads>, pub glplayer_threads: Option<GLPlayerThreads>,
/// Application window's GL Context for Media player /// Application window's GL Context for Media player

View file

@ -192,7 +192,7 @@ pub struct InitialPipelineState {
/// The XR device registry /// The XR device registry
pub webxr_registry: webxr_api::Registry, pub webxr_registry: webxr_api::Registry,
/// Application window's GL Context for Media player /// Application window's GL Context for Media player
pub player_context: WindowGLContext, pub player_context: WindowGLContext,
} }

View file

@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#![crate_name = "media"]
#![crate_type = "rlib"]
#![deny(unsafe_code)] #![deny(unsafe_code)]
#[macro_use] #[macro_use]

View file

@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#![crate_name = "webrender_traits"]
#![crate_type = "rlib"]
#![deny(unsafe_code)] #![deny(unsafe_code)]
use euclid::Size2D; use euclid::Size2D;
@ -110,56 +108,42 @@ impl webrender::ExternalImageHandler for WebrenderExternalImageHandlers {
_channel_index: u8, _channel_index: u8,
_rendering: webrender_api::ImageRendering, _rendering: webrender_api::ImageRendering,
) -> webrender::ExternalImage { ) -> webrender::ExternalImage {
if let Some(handler_type) = self.external_images.lock().unwrap().get(&key) { let external_images = self.external_images.lock().unwrap();
let (texture_id, uv) = match handler_type { let handler_type = external_images
WebrenderImageHandlerType::WebGL => { .get(&key)
let (texture_id, size) = self.webgl_handler.as_mut().unwrap().lock(key.0); .expect("Tried to get unknown external image");
( let (texture_id, uv) = match handler_type {
texture_id, WebrenderImageHandlerType::WebGL => {
webrender_api::TexelRect::new( let (texture_id, size) = self.webgl_handler.as_mut().unwrap().lock(key.0);
0.0, (
size.height as f32, texture_id,
size.width as f32, webrender_api::TexelRect::new(0.0, size.height as f32, size.width as f32, 0.0),
0.0, )
), },
) WebrenderImageHandlerType::Media => {
}, let (texture_id, size) = self.media_handler.as_mut().unwrap().lock(key.0);
WebrenderImageHandlerType::Media => { (
let (texture_id, size) = self.media_handler.as_mut().unwrap().lock(key.0); texture_id,
( webrender_api::TexelRect::new(0.0, 0.0, size.width as f32, size.height as f32),
texture_id, )
webrender_api::TexelRect::new( },
0.0, };
0.0, webrender::ExternalImage {
size.width as f32, uv,
size.height as f32, source: webrender::ExternalImageSource::NativeTexture(texture_id),
),
)
},
};
webrender::ExternalImage {
uv,
source: webrender::ExternalImageSource::NativeTexture(texture_id),
}
} else {
unreachable!()
} }
} }
/// Unlock the external image. The WR should not read the image /// Unlock the external image. The WR should not read the image
/// content after this call. /// content after this call.
fn unlock(&mut self, key: webrender_api::ExternalImageId, _channel_index: u8) { fn unlock(&mut self, key: webrender_api::ExternalImageId, _channel_index: u8) {
if let Some(handler_type) = self.external_images.lock().unwrap().get(&key) { let external_images = self.external_images.lock().unwrap();
match handler_type { let handler_type = external_images
WebrenderImageHandlerType::WebGL => { .get(&key)
self.webgl_handler.as_mut().unwrap().unlock(key.0) .expect("Tried to get unknown external image");
}, match handler_type {
WebrenderImageHandlerType::Media => { WebrenderImageHandlerType::WebGL => self.webgl_handler.as_mut().unwrap().unlock(key.0),
self.media_handler.as_mut().unwrap().unlock(key.0) WebrenderImageHandlerType::Media => self.media_handler.as_mut().unwrap().unlock(key.0),
}, };
};
} else {
unreachable!();
}
} }
} }