cargo fix --edition-idioms

This commit is contained in:
Simon Sapin 2018-11-01 21:43:04 +01:00
parent b1fd6237d1
commit 2012be4a8b
203 changed files with 665 additions and 1281 deletions

View file

@ -169,7 +169,7 @@ impl GLContextWrapper {
}
}
pub fn gl(&self) -> &gl::Gl {
pub fn gl(&self) -> &dyn gl::Gl {
match *self {
GLContextWrapper::Native(ref ctx) => ctx.gl(),
GLContextWrapper::OSMesa(ref ctx) => ctx.gl(),
@ -236,7 +236,7 @@ impl MainThreadDispatcher {
}
}
impl GLContextDispatcher for MainThreadDispatcher {
fn dispatch(&self, f: Box<Fn() + Send>) {
fn dispatch(&self, f: Box<dyn Fn() + Send>) {
self.compositor_proxy
.lock()
.unwrap()

View file

@ -4,23 +4,8 @@
#![deny(unsafe_code)]
extern crate azure;
extern crate canvas_traits;
extern crate compositing;
extern crate cssparser;
extern crate euclid;
extern crate fnv;
extern crate gleam;
extern crate ipc_channel;
#[macro_use]
extern crate log;
extern crate num_traits;
extern crate offscreen_gl_context;
extern crate pixels;
extern crate serde_bytes;
extern crate servo_config;
extern crate webrender;
extern crate webrender_api;
pub mod canvas_data;
pub mod canvas_paint_thread;

View file

@ -23,13 +23,13 @@ impl WebGLThreads {
/// Creates a new WebGLThreads object
pub fn new(
gl_factory: GLContextFactory,
webrender_gl: Rc<gl::Gl>,
webrender_gl: Rc<dyn gl::Gl>,
webrender_api_sender: webrender_api::RenderApiSender,
webvr_compositor: Option<Box<WebVRRenderHandler>>,
webvr_compositor: Option<Box<dyn WebVRRenderHandler>>,
) -> (
WebGLThreads,
Box<webrender::ExternalImageHandler>,
Option<Box<webrender::OutputImageHandler>>,
Box<dyn webrender::ExternalImageHandler>,
Option<Box<dyn webrender::OutputImageHandler>>,
) {
// This implementation creates a single `WebGLThread` for all the pipelines.
let channel = WebGLThread::start(
@ -70,7 +70,7 @@ impl WebGLThreads {
/// Bridge between the webrender::ExternalImage callbacks and the WebGLThreads.
struct WebGLExternalImages {
webrender_gl: Rc<gl::Gl>,
webrender_gl: Rc<dyn gl::Gl>,
webgl_channel: WebGLSender<WebGLMsg>,
// Used to avoid creating a new channel on each received WebRender request.
lock_channel: (
@ -80,7 +80,7 @@ struct WebGLExternalImages {
}
impl WebGLExternalImages {
fn new(webrender_gl: Rc<gl::Gl>, channel: WebGLSender<WebGLMsg>) -> Self {
fn new(webrender_gl: Rc<dyn gl::Gl>, channel: WebGLSender<WebGLMsg>) -> Self {
Self {
webrender_gl,
webgl_channel: channel,
@ -111,7 +111,7 @@ impl WebGLExternalImageApi for WebGLExternalImages {
}
/// Wrapper to send WebVR commands used in `WebGLThread`.
struct WebVRRenderWrapper(Box<WebVRRenderHandler>);
struct WebVRRenderWrapper(Box<dyn WebVRRenderHandler>);
impl WebVRRenderHandler for WebVRRenderWrapper {
fn handle(&mut self, command: WebVRCommand, texture: Option<(u32, Size2D<i32>)>) {
@ -122,7 +122,7 @@ impl WebVRRenderHandler for WebVRRenderWrapper {
/// struct used to implement DOMToTexture feature and webrender::OutputImageHandler trait.
type OutputHandlerData = Option<(u32, Size2D<i32>)>;
struct OutputHandler {
webrender_gl: Rc<gl::Gl>,
webrender_gl: Rc<dyn gl::Gl>,
webgl_channel: WebGLSender<WebGLMsg>,
// Used to avoid creating a new channel on each received WebRender request.
lock_channel: (
@ -133,7 +133,7 @@ struct OutputHandler {
}
impl OutputHandler {
fn new(webrender_gl: Rc<gl::Gl>, channel: WebGLSender<WebGLMsg>) -> Self {
fn new(webrender_gl: Rc<dyn gl::Gl>, channel: WebGLSender<WebGLMsg>) -> Self {
Self {
webrender_gl,
webgl_channel: channel,

View file

@ -1364,7 +1364,7 @@ impl WebGLImpl {
}
fn initialize_framebuffer(
gl: &gl::Gl,
gl: &dyn gl::Gl,
state: &GLState,
color: bool,
depth: bool,
@ -1424,7 +1424,7 @@ impl WebGLImpl {
}
#[allow(unsafe_code)]
fn link_program(gl: &gl::Gl, program: WebGLProgramId) -> ProgramLinkInfo {
fn link_program(gl: &dyn gl::Gl, program: WebGLProgramId) -> ProgramLinkInfo {
gl.link_program(program.get());
let mut linked = [0];
unsafe {
@ -1497,13 +1497,13 @@ impl WebGLImpl {
}
}
fn finish(gl: &gl::Gl, chan: &WebGLSender<()>) {
fn finish(gl: &dyn gl::Gl, chan: &WebGLSender<()>) {
gl.finish();
chan.send(()).unwrap();
}
fn shader_precision_format(
gl: &gl::Gl,
gl: &dyn gl::Gl,
shader_type: u32,
precision_type: u32,
chan: &WebGLSender<(i32, i32, i32)>,
@ -1512,13 +1512,13 @@ impl WebGLImpl {
chan.send(result).unwrap();
}
fn get_extensions(gl: &gl::Gl, chan: &WebGLSender<String>) {
fn get_extensions(gl: &dyn gl::Gl, chan: &WebGLSender<String>) {
chan.send(gl.get_string(gl::EXTENSIONS)).unwrap();
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6
fn get_framebuffer_attachment_parameter(
gl: &gl::Gl,
gl: &dyn gl::Gl,
target: u32,
attachment: u32,
pname: u32,
@ -1529,13 +1529,18 @@ impl WebGLImpl {
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7
fn get_renderbuffer_parameter(gl: &gl::Gl, target: u32, pname: u32, chan: &WebGLSender<i32>) {
fn get_renderbuffer_parameter(
gl: &dyn gl::Gl,
target: u32,
pname: u32,
chan: &WebGLSender<i32>,
) {
let parameter = gl.get_renderbuffer_parameter_iv(target, pname);
chan.send(parameter).unwrap();
}
fn uniform_location(
gl: &gl::Gl,
gl: &dyn gl::Gl,
program_id: WebGLProgramId,
name: &str,
chan: &WebGLSender<i32>,
@ -1545,18 +1550,18 @@ impl WebGLImpl {
chan.send(location).unwrap();
}
fn shader_info_log(gl: &gl::Gl, shader_id: WebGLShaderId, chan: &WebGLSender<String>) {
fn shader_info_log(gl: &dyn gl::Gl, shader_id: WebGLShaderId, chan: &WebGLSender<String>) {
let log = gl.get_shader_info_log(shader_id.get());
chan.send(log).unwrap();
}
fn program_info_log(gl: &gl::Gl, program_id: WebGLProgramId, chan: &WebGLSender<String>) {
fn program_info_log(gl: &dyn gl::Gl, program_id: WebGLProgramId, chan: &WebGLSender<String>) {
let log = gl.get_program_info_log(program_id.get());
chan.send(log).unwrap();
}
#[allow(unsafe_code)]
fn create_buffer(gl: &gl::Gl, chan: &WebGLSender<Option<WebGLBufferId>>) {
fn create_buffer(gl: &dyn gl::Gl, chan: &WebGLSender<Option<WebGLBufferId>>) {
let buffer = gl.gen_buffers(1)[0];
let buffer = if buffer == 0 {
None
@ -1567,7 +1572,7 @@ impl WebGLImpl {
}
#[allow(unsafe_code)]
fn create_framebuffer(gl: &gl::Gl, chan: &WebGLSender<Option<WebGLFramebufferId>>) {
fn create_framebuffer(gl: &dyn gl::Gl, chan: &WebGLSender<Option<WebGLFramebufferId>>) {
let framebuffer = gl.gen_framebuffers(1)[0];
let framebuffer = if framebuffer == 0 {
None
@ -1578,7 +1583,7 @@ impl WebGLImpl {
}
#[allow(unsafe_code)]
fn create_renderbuffer(gl: &gl::Gl, chan: &WebGLSender<Option<WebGLRenderbufferId>>) {
fn create_renderbuffer(gl: &dyn gl::Gl, chan: &WebGLSender<Option<WebGLRenderbufferId>>) {
let renderbuffer = gl.gen_renderbuffers(1)[0];
let renderbuffer = if renderbuffer == 0 {
None
@ -1589,7 +1594,7 @@ impl WebGLImpl {
}
#[allow(unsafe_code)]
fn create_texture(gl: &gl::Gl, chan: &WebGLSender<Option<WebGLTextureId>>) {
fn create_texture(gl: &dyn gl::Gl, chan: &WebGLSender<Option<WebGLTextureId>>) {
let texture = gl.gen_textures(1)[0];
let texture = if texture == 0 {
None
@ -1600,7 +1605,7 @@ impl WebGLImpl {
}
#[allow(unsafe_code)]
fn create_program(gl: &gl::Gl, chan: &WebGLSender<Option<WebGLProgramId>>) {
fn create_program(gl: &dyn gl::Gl, chan: &WebGLSender<Option<WebGLProgramId>>) {
let program = gl.create_program();
let program = if program == 0 {
None
@ -1611,7 +1616,7 @@ impl WebGLImpl {
}
#[allow(unsafe_code)]
fn create_shader(gl: &gl::Gl, shader_type: u32, chan: &WebGLSender<Option<WebGLShaderId>>) {
fn create_shader(gl: &dyn gl::Gl, shader_type: u32, chan: &WebGLSender<Option<WebGLShaderId>>) {
let shader = gl.create_shader(shader_type);
let shader = if shader == 0 {
None
@ -1622,7 +1627,7 @@ impl WebGLImpl {
}
#[allow(unsafe_code)]
fn create_vertex_array(gl: &gl::Gl, chan: &WebGLSender<Option<WebGLVertexArrayId>>) {
fn create_vertex_array(gl: &dyn gl::Gl, chan: &WebGLSender<Option<WebGLVertexArrayId>>) {
let vao = gl.gen_vertex_arrays(1)[0];
let vao = if vao == 0 {
None
@ -1634,7 +1639,7 @@ impl WebGLImpl {
#[inline]
fn bind_framebuffer<Native: NativeGLContextMethods>(
gl: &gl::Gl,
gl: &dyn gl::Gl,
target: u32,
request: WebGLFramebufferBindingRequest,
ctx: &GLContext<Native>,
@ -1650,7 +1655,7 @@ impl WebGLImpl {
}
#[inline]
fn compile_shader(gl: &gl::Gl, shader_id: WebGLShaderId, source: &str) {
fn compile_shader(gl: &dyn gl::Gl, shader_id: WebGLShaderId, source: &str) {
gl.shader_source(shader_id.get(), &[source.as_bytes()]);
gl.compile_shader(shader_id.get());
}