Bug 1341968 - Update webrender_bindings to go with new offset field in ImageDescriptor. r?jrmuizel draft
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 27 Feb 2017 12:42:29 -0500
changeset 490127 10a27c4b6bbd72cfbe7aafe4c6d7d3bb75b4abef
parent 490126 50e20d329d5e08bd2796d11b6973c53e5836a9bc
child 490128 10898239618827da52c2f628836f36b2703c136a
push id47003
push userkgupta@mozilla.com
push dateMon, 27 Feb 2017 17:43:51 +0000
reviewersjrmuizel
bugs1341968
milestone54.0a1
Bug 1341968 - Update webrender_bindings to go with new offset field in ImageDescriptor. r?jrmuizel MozReview-Commit-ID: 6kyTi0UxAO1
gfx/webrender_bindings/src/bindings.rs
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -59,16 +59,29 @@ pub struct WrWindowId(u64);
 pub struct WrImageDescriptor {
     pub format: ImageFormat,
     pub width: u32,
     pub height: u32,
     pub stride: u32,
     pub is_opaque: bool,
 }
 
+impl WrImageDescriptor {
+    pub fn to_descriptor(&self) -> ImageDescriptor {
+        ImageDescriptor {
+            width: self.width,
+            height: self.height,
+            stride: if self.stride != 0 { Some(self.stride) } else { None },
+            format: self.format,
+            is_opaque: self.is_opaque,
+            offset: 0,
+        }
+    }
+}
+
 fn get_proc_address(glcontext_ptr: *mut c_void, name: &str) -> *const c_void{
 
     extern  {
         fn get_proc_address_from_glcontext(glcontext_ptr: *mut c_void, procname: *const c_char) -> *const c_void;
     }
 
     let symbol_name = CString::new(name).unwrap();
     let symbol = unsafe {
@@ -592,23 +605,17 @@ pub extern fn wr_api_generate_image_key(
 }
 
 #[no_mangle]
 pub extern fn wr_api_add_image(api: &mut RenderApi, image_key: ImageKey, descriptor: &WrImageDescriptor, bytes: * const u8, size: usize) {
     assert!( unsafe { is_in_compositor_thread() });
     let bytes = unsafe { slice::from_raw_parts(bytes, size).to_owned() };
     api.add_image(
         image_key,
-        ImageDescriptor {
-            width: descriptor.width,
-            height: descriptor.height,
-            stride: if descriptor.stride != 0 { Some(descriptor.stride) } else { None },
-            format: descriptor.format,
-            is_opaque: descriptor.is_opaque,
-        },
+        descriptor.to_descriptor(),
         ImageData::new(bytes)
     );
 }
 
 #[no_mangle]
 pub extern fn wr_api_add_external_image_texture(api: &mut RenderApi, width: u32, height: u32, format: ImageFormat, external_image_id: u64) -> ImageKey {
     assert!( unsafe { is_in_compositor_thread() });
     unimplemented!(); // TODO
@@ -617,23 +624,17 @@ pub extern fn wr_api_add_external_image_
 
 #[no_mangle]
 pub extern fn wr_api_update_image(api: &mut RenderApi, key: ImageKey, descriptor: &WrImageDescriptor, bytes: * const u8, size: usize) {
     assert!( unsafe { is_in_compositor_thread() });
     let bytes = unsafe { slice::from_raw_parts(bytes, size).to_owned() };
 
     api.update_image(
         key,
-        ImageDescriptor {
-            width: descriptor.width,
-            height: descriptor.height,
-            stride: if descriptor.stride != 0 { Some(descriptor.stride) } else { None },
-            format: descriptor.format,
-            is_opaque: descriptor.is_opaque,
-        },
+        descriptor.to_descriptor(),
         bytes
     );
 }
 #[no_mangle]
 pub extern fn wr_api_delete_image(api: &mut RenderApi, key: ImageKey) {
     assert!( unsafe { is_in_compositor_thread() });
     api.delete_image(key)
 }