Update azure

https://github.com/servo/rust-azure/pull/293
This commit is contained in:
Anthony Ramine 2018-09-16 20:53:38 +02:00
parent f1e8eb640c
commit 21e992bf40
2 changed files with 42 additions and 41 deletions

10
Cargo.lock generated
View file

@ -109,8 +109,8 @@ dependencies = [
[[package]] [[package]]
name = "azure" name = "azure"
version = "0.33.0" version = "0.34.0"
source = "git+https://github.com/servo/rust-azure#43e61bda11f26e8462cfa63affac17c43df53b84" source = "git+https://github.com/servo/rust-azure#1536ca66954356ece017343e3cd30b293134dc3f"
dependencies = [ dependencies = [
"cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -324,7 +324,7 @@ dependencies = [
name = "canvas" name = "canvas"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"azure 0.33.0 (git+https://github.com/servo/rust-azure)", "azure 0.34.0 (git+https://github.com/servo/rust-azure)",
"canvas_traits 0.0.1", "canvas_traits 0.0.1",
"compositing 0.0.1", "compositing 0.0.1",
"cssparser 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2851,7 +2851,7 @@ dependencies = [
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -4335,7 +4335,7 @@ dependencies = [
"checksum atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb2dcb6e6d35f20276943cc04bb98e538b348d525a04ac79c10021561d202f21" "checksum atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb2dcb6e6d35f20276943cc04bb98e538b348d525a04ac79c10021561d202f21"
"checksum atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "21e50800ec991574876040fff8ee46b136a53e985286fbe6a3bdfe6421b78860" "checksum atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "21e50800ec991574876040fff8ee46b136a53e985286fbe6a3bdfe6421b78860"
"checksum audio-video-metadata 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "3c23600291b35b9cd381f5cfca636f5d7d75e7d7192eddf867de84a6732cad5c" "checksum audio-video-metadata 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "3c23600291b35b9cd381f5cfca636f5d7d75e7d7192eddf867de84a6732cad5c"
"checksum azure 0.33.0 (git+https://github.com/servo/rust-azure)" = "<none>" "checksum azure 0.34.0 (git+https://github.com/servo/rust-azure)" = "<none>"
"checksum backtrace 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "72f9b4182546f4b04ebc4ab7f84948953a118bd6021a1b6a6c909e3e94f6be76" "checksum backtrace 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "72f9b4182546f4b04ebc4ab7f84948953a118bd6021a1b6a6c909e3e94f6be76"
"checksum backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "44585761d6161b0f57afc49482ab6bd067e4edef48c12a152c237eb0203f7661" "checksum backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "44585761d6161b0f57afc49482ab6bd067e4edef48c12a152c237eb0203f7661"
"checksum base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "96434f987501f0ed4eb336a411e0631ecd1afa11574fe148587adc4ff96143c9" "checksum base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "96434f987501f0ed4eb336a411e0631ecd1afa11574fe148587adc4ff96143c9"

View file

@ -405,14 +405,14 @@ impl<'a> CanvasData<'a> {
} }
} }
#[allow(unsafe_code)]
pub fn send_pixels(&mut self, chan: IpcSender<Option<ByteBuf>>) { pub fn send_pixels(&mut self, chan: IpcSender<Option<ByteBuf>>) {
self.drawtarget.snapshot().get_data_surface().with_data(|element| { let data = unsafe { self.drawtarget.snapshot().get_data_surface().data().to_vec() };
chan.send(Some(Vec::from(element).into())).unwrap(); chan.send(Some(data.into())).unwrap();
})
} }
#[allow(unsafe_code)]
pub fn send_data(&mut self, chan: IpcSender<CanvasImageData>) { pub fn send_data(&mut self, chan: IpcSender<CanvasImageData>) {
self.drawtarget.snapshot().get_data_surface().with_data(|element| {
let size = self.drawtarget.get_size(); let size = self.drawtarget.get_size();
let descriptor = webrender_api::ImageDescriptor { let descriptor = webrender_api::ImageDescriptor {
@ -423,7 +423,9 @@ impl<'a> CanvasData<'a> {
is_opaque: false, is_opaque: false,
allow_mipmaps: false, allow_mipmaps: false,
}; };
let data = webrender_api::ImageData::Raw(Arc::new(element.into())); let data = webrender_api::ImageData::Raw(Arc::new(
unsafe { self.drawtarget.snapshot().get_data_surface().data().into() },
));
let mut txn = webrender_api::Transaction::new(); let mut txn = webrender_api::Transaction::new();
@ -449,7 +451,6 @@ impl<'a> CanvasData<'a> {
image_key: self.image_key.unwrap(), image_key: self.image_key.unwrap(),
}; };
chan.send(data).unwrap(); chan.send(data).unwrap();
})
} }
pub fn image_data( pub fn image_data(
@ -606,6 +607,7 @@ impl<'a> CanvasData<'a> {
/// It reads image data from the canvas /// It reads image data from the canvas
/// canvas_size: The size of the canvas we're reading from /// canvas_size: The size of the canvas we're reading from
/// read_rect: The area of the canvas we want to read from /// read_rect: The area of the canvas we want to read from
#[allow(unsafe_code)]
pub fn read_pixels(&self, read_rect: Rect<i32>, canvas_size: Size2D<f64>) -> Vec<u8> { pub fn read_pixels(&self, read_rect: Rect<i32>, canvas_size: Size2D<f64>) -> Vec<u8> {
let canvas_size = canvas_size.to_i32(); let canvas_size = canvas_size.to_i32();
let canvas_rect = Rect::new(Point2D::new(0i32, 0i32), canvas_size); let canvas_rect = Rect::new(Point2D::new(0i32, 0i32), canvas_size);
@ -617,8 +619,7 @@ impl<'a> CanvasData<'a> {
} }
let data_surface = self.drawtarget.snapshot().get_data_surface(); let data_surface = self.drawtarget.snapshot().get_data_surface();
let mut src_data = Vec::new(); let src_data = unsafe { data_surface.data() };
data_surface.with_data(|element| { src_data = element.to_vec(); });
let stride = data_surface.stride(); let stride = data_surface.stride();
//start offset of the copyable rectangle //start offset of the copyable rectangle