Bug 1355187 - Update Rust FFI function signatures to use types with Wr prefix. r=rhunt
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 10 Apr 2017 17:38:01 -0400
changeset 559928 db087d30b56b363b559eb8e736885475c708bfcf
parent 559927 5b98a41fea59fc63a87b63bf2046d7480035fefe
child 559929 f71d33022a5e40a7623ac8d5da8619d83948ccb7
push id53284
push userkgupta@mozilla.com
push dateMon, 10 Apr 2017 22:25:08 +0000
reviewersrhunt
bugs1355187
milestone55.0a1
Bug 1355187 - Update Rust FFI function signatures to use types with Wr prefix. r=rhunt This patch: - adds a type alias for ExternalImageId and updates uses. - renames WrExternalImageStruct to drop the "Struct" suffix which is redundant and not present in the corresponding C++ struct. - updates the delete-font function to use aliases I added previously. MozReview-Commit-ID: ILsFihkMlIw
gfx/webrender_bindings/src/bindings.rs
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -16,16 +16,17 @@ use euclid::{TypedPoint2D, SideOffsets2D
 extern crate webrender_traits;
 
 type WrAPI = RenderApi;
 type WrAuxiliaryListsDescriptor = AuxiliaryListsDescriptor;
 type WrBorderStyle = BorderStyle;
 type WrBoxShadowClipMode = BoxShadowClipMode;
 type WrBuiltDisplayListDescriptor = BuiltDisplayListDescriptor;
 type WrEpoch = Epoch;
+type WrExternalImageId = ExternalImageId;
 type WrFontKey = FontKey;
 type WrGlyphInstance = GlyphInstance;
 type WrIdNamespace = IdNamespace;
 type WrImageFormat = ImageFormat;
 type WrImageRendering = ImageRendering;
 type WrImageKey = ImageKey;
 type WrMixBlendMode = MixBlendMode;
 type WrPipelineId = PipelineId;
@@ -443,46 +444,46 @@ impl From<ClipRegion> for WrClipRegion {
 #[repr(u32)]
 #[allow(dead_code)]
 enum WrExternalImageType {
     NativeTexture,
     RawData,
 }
 
 #[repr(C)]
-struct WrExternalImageStruct {
+struct WrExternalImage {
     image_type: WrExternalImageType,
 
     // external texture handle
     handle: u32,
     // external texture coordinate
     u0: f32,
     v0: f32,
     u1: f32,
     v1: f32,
 
     // external image buffer
     buff: *const u8,
     size: usize,
 }
 
-type LockExternalImageCallback = fn(*mut c_void, ExternalImageId) -> WrExternalImageStruct;
-type UnlockExternalImageCallback = fn(*mut c_void, ExternalImageId);
-type ReleaseExternalImageCallback = fn(*mut c_void, ExternalImageId);
+type LockExternalImageCallback = fn(*mut c_void, WrExternalImageId) -> WrExternalImage;
+type UnlockExternalImageCallback = fn(*mut c_void, WrExternalImageId);
+type ReleaseExternalImageCallback = fn(*mut c_void, WrExternalImageId);
 
 #[repr(C)]
 pub struct WrExternalImageHandler {
     external_image_obj: *mut c_void,
     lock_func: LockExternalImageCallback,
     unlock_func: UnlockExternalImageCallback,
     release_func: ReleaseExternalImageCallback,
 }
 
 impl ExternalImageHandler for WrExternalImageHandler {
-    fn lock(&mut self, id: ExternalImageId) -> ExternalImage {
+    fn lock(&mut self, id: WrExternalImageId) -> ExternalImage {
         let image = (self.lock_func)(self.external_image_obj, id);
 
         match image.image_type {
             WrExternalImageType::NativeTexture => {
                 ExternalImage {
                     u0: image.u0,
                     v0: image.v0,
                     u1: image.u1,
@@ -500,21 +501,21 @@ impl ExternalImageHandler for WrExternal
                                                              slice::from_raw_parts(image.buff,
                                                                                    image.size)
                                                          }),
                 }
             }
         }
     }
 
-    fn unlock(&mut self, id: ExternalImageId) {
+    fn unlock(&mut self, id: WrExternalImageId) {
         (self.unlock_func)(self.external_image_obj, id);
     }
 
-    fn release(&mut self, id: ExternalImageId) {
+    fn release(&mut self, id: WrExternalImageId) {
         (self.release_func)(self.external_image_obj, id);
     }
 }
 
 #[repr(C)]
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
 pub struct WrWindowId(u64);
 
@@ -954,17 +955,17 @@ pub extern "C" fn wr_api_add_raw_font(ap
     let font_slice = unsafe { slice::from_raw_parts(font_buffer, buffer_size as usize) };
     let mut font_vector = Vec::new();
     font_vector.extend_from_slice(font_slice);
 
     api.add_raw_font(key, font_vector);
 }
 
 #[no_mangle]
-pub extern "C" fn wr_api_delete_font(api: &mut RenderApi, key: FontKey)
+pub extern "C" fn wr_api_delete_font(api: &mut WrAPI, key: WrFontKey)
 {
     assert!( unsafe { is_in_compositor_thread() });
     api.delete_font(key);
 }
 
 #[no_mangle]
 pub unsafe extern "C" fn wr_api_get_namespace(api: &mut WrAPI) -> WrIdNamespace {
     api.id_namespace