diff --git a/Cargo.lock b/Cargo.lock index af4b77cf736..30aee29523f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3178,7 +3178,7 @@ dependencies = [ [[package]] name = "webrender" version = "0.23.0" -source = "git+https://github.com/servo/webrender#bfef6dbb9fe69a8c408568c85b392186d3853477" +source = "git+https://github.com/servo/webrender#94f255dfae21d9e66041a07f5fbcf2cdd2c73208" dependencies = [ "app_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "bincode 1.0.0-alpha2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3206,7 +3206,7 @@ dependencies = [ [[package]] name = "webrender_traits" version = "0.24.0" -source = "git+https://github.com/servo/webrender#bfef6dbb9fe69a8c408568c85b392186d3853477" +source = "git+https://github.com/servo/webrender#94f255dfae21d9e66041a07f5fbcf2cdd2c73208" dependencies = [ "app_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 12f742e12b9..bbdf1863857 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -1327,7 +1327,7 @@ impl IOCompositor { } fn update_page_zoom_for_webrender(&mut self) { - let page_zoom = webrender_traits::PageZoomFactor::new(self.page_zoom.get()); + let page_zoom = webrender_traits::ZoomFactor::new(self.page_zoom.get()); self.webrender_api.set_page_zoom(page_zoom); } diff --git a/components/net/image_cache_thread.rs b/components/net/image_cache_thread.rs index 2ead7e06db6..a9cdca099d7 100644 --- a/components/net/image_cache_thread.rs +++ b/components/net/image_cache_thread.rs @@ -336,6 +336,21 @@ fn get_placeholder_image(webrender_api: &webrender_traits::RenderApi) -> io::Res Ok(Arc::new(image)) } +fn premultiply(data: &mut [u8]) { + let length = data.len(); + + for i in (0..length).step_by(4) { + let b = data[i + 0] as u32; + let g = data[i + 1] as u32; + let r = data[i + 2] as u32; + let a = data[i + 3] as u32; + + data[i + 0] = (b * a / 255) as u8; + data[i + 1] = (g * a / 255) as u8; + data[i + 2] = (r * a / 255) as u8; + } +} + impl ImageCache { fn run(webrender_api: webrender_traits::RenderApi, ipc_command_receiver: IpcReceiver) { @@ -484,6 +499,9 @@ impl ImageCache { let format = convert_format(image.format); let mut bytes = Vec::new(); bytes.extend_from_slice(&*image.bytes); + if format == webrender_traits::ImageFormat::RGBA8 { + premultiply(bytes.as_mut_slice()); + } let descriptor = webrender_traits::ImageDescriptor { width: image.width, height: image.height, diff --git a/components/net/lib.rs b/components/net/lib.rs index b2a1ff97764..90999cfcf62 100644 --- a/components/net/lib.rs +++ b/components/net/lib.rs @@ -5,6 +5,7 @@ #![deny(unsafe_code)] #![feature(box_syntax)] #![feature(mpsc_select)] +#![feature(step_by)] extern crate brotli; extern crate cookie as cookie_rs; diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index d554b574926..c53b72ba96c 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -31256,7 +31256,7 @@ "support" ], "mozilla/webgl/tex_image_2d_mipmap.html": [ - "80f79d8804ee9cdb2b12c02223bf1e15854122d7", + "b4d54f0f58f75ff622a9c3f9bab3f59d9f1fb0e7", "reftest" ], "mozilla/webgl/tex_image_2d_mipmap_ref.html": [ @@ -31264,7 +31264,7 @@ "support" ], "mozilla/webgl/tex_image_2d_simple.html": [ - "636673ea0aa2a16f4aec362ca40cd82e78ff3396", + "1811000d21dcdb5d27c67afbf22e77a83c6820d6", "reftest" ], "mozilla/webgl/tex_image_2d_simple_ref.html": [ diff --git a/tests/wpt/mozilla/tests/mozilla/webgl/tex_image_2d_mipmap.html b/tests/wpt/mozilla/tests/mozilla/webgl/tex_image_2d_mipmap.html index 5391417795d..09ca0fba7ee 100644 --- a/tests/wpt/mozilla/tests/mozilla/webgl/tex_image_2d_mipmap.html +++ b/tests/wpt/mozilla/tests/mozilla/webgl/tex_image_2d_mipmap.html @@ -106,6 +106,7 @@ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST); + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); gl.generateMipmap(gl.TEXTURE_2D); diff --git a/tests/wpt/mozilla/tests/mozilla/webgl/tex_image_2d_simple.html b/tests/wpt/mozilla/tests/mozilla/webgl/tex_image_2d_simple.html index f3bba7d4f2d..3defd7a5f96 100644 --- a/tests/wpt/mozilla/tests/mozilla/webgl/tex_image_2d_simple.html +++ b/tests/wpt/mozilla/tests/mozilla/webgl/tex_image_2d_simple.html @@ -106,6 +106,7 @@ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); gl.drawArrays(gl.TRIANGLES, 0, 6);