Bug 1354951 - Add some typedefs in bindings.rs to make the rust function signatures better match the signatures in webrender_ffi.h. r=rhunt
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 10 Apr 2017 10:28:45 -0400
changeset 400882 22a9e4fe2c6f63f88b2bb04d47cf29b0a503388a
parent 400881 f7851b58db67c8906c9e8d2a59da98ca371d0d6f
child 400883 5b98a41fea59fc63a87b63bf2046d7480035fefe
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrhunt
bugs1354951
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1354951 - Add some typedefs in bindings.rs to make the rust function signatures better match the signatures in webrender_ffi.h. r=rhunt MozReview-Commit-ID: 8JZDNMwLDpN
gfx/webrender_bindings/src/bindings.rs
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -10,16 +10,33 @@ use webrender_traits::*;
 use webrender::renderer::{Renderer, RendererOptions};
 use webrender::renderer::{ExternalImage, ExternalImageHandler, ExternalImageSource};
 use webrender::{ApiRecordingReceiver, BinaryRecorder};
 use app_units::Au;
 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 WrFontKey = FontKey;
+type WrGlyphInstance = GlyphInstance;
+type WrIdNamespace = IdNamespace;
+type WrImageFormat = ImageFormat;
+type WrImageRendering = ImageRendering;
+type WrImageKey = ImageKey;
+type WrMixBlendMode = MixBlendMode;
+type WrPipelineId = PipelineId;
+type WrRenderedEpochs = Vec<(WrPipelineId, WrEpoch)>;
+type WrRenderer = Renderer;
+
 static ENABLE_RECORDING: bool = false;
 
 // This macro adds some checks to make sure we notice when the memory representation of
 // types change.
 macro_rules! check_ffi_type {
     ($check_sizes_match:ident struct $TypeName:ident as ($T1:ident, $T2:ident)) => (
         fn $check_sizes_match() {
             #[repr(C)] struct TestType($T1, $T2);
@@ -32,50 +49,50 @@ macro_rules! check_ffi_type {
             let _ = mem::transmute::<$TypeName, TestType>;
         }
     );
     ($check_sizes_match:ident enum $TypeName:ident as $T:ident) => (
         fn $check_sizes_match() { let _ = mem::transmute::<$TypeName, $T>; }
     );
 }
 
-check_ffi_type!(_pipeline_id_repr struct PipelineId as (u32, u32));
-check_ffi_type!(_image_key_repr struct ImageKey as (u32, u32));
-check_ffi_type!(_font_key_repr struct FontKey as (u32, u32));
-check_ffi_type!(_epoch_repr struct Epoch as (u32));
-check_ffi_type!(_image_format_repr enum ImageFormat as u32);
-check_ffi_type!(_border_style_repr enum BorderStyle as u32);
-check_ffi_type!(_image_rendering_repr enum ImageRendering as u32);
-check_ffi_type!(_mix_blend_mode_repr enum MixBlendMode as u32);
-check_ffi_type!(_box_shadow_clip_mode_repr enum BoxShadowClipMode as u32);
-check_ffi_type!(_namespace_id_repr struct IdNamespace as (u32));
+check_ffi_type!(_pipeline_id_repr struct WrPipelineId as (u32, u32));
+check_ffi_type!(_image_key_repr struct WrImageKey as (u32, u32));
+check_ffi_type!(_font_key_repr struct WrFontKey as (u32, u32));
+check_ffi_type!(_epoch_repr struct WrEpoch as (u32));
+check_ffi_type!(_image_format_repr enum WrImageFormat as u32);
+check_ffi_type!(_border_style_repr enum WrBorderStyle as u32);
+check_ffi_type!(_image_rendering_repr enum WrImageRendering as u32);
+check_ffi_type!(_mix_blend_mode_repr enum WrMixBlendMode as u32);
+check_ffi_type!(_box_shadow_clip_mode_repr enum WrBoxShadowClipMode as u32);
+check_ffi_type!(_namespace_id_repr struct WrIdNamespace as (u32));
 
 const GL_FORMAT_BGRA_GL: gl::GLuint = gl::BGRA;
 const GL_FORMAT_BGRA_GLES: gl::GLuint = gl::BGRA_EXT;
 
 fn get_gl_format_bgra(gl: &gl::Gl) -> gl::GLuint {
     match gl.get_type() {
         gl::GlType::Gl => {
             GL_FORMAT_BGRA_GL
         }
         gl::GlType::Gles => {
             GL_FORMAT_BGRA_GLES
         }
     }
 }
 
 #[repr(C)]
-pub struct ByteSlice {
+pub struct WrByteSlice {
     buffer: *const u8,
     len: usize,
 }
 
-impl ByteSlice {
-    pub fn new(slice: &[u8]) -> ByteSlice {
-        ByteSlice { buffer: &slice[0], len: slice.len() }
+impl WrByteSlice {
+    pub fn new(slice: &[u8]) -> WrByteSlice {
+        WrByteSlice { buffer: &slice[0], len: slice.len() }
     }
 
     pub fn as_slice(&self) -> &[u8] {
         unsafe { slice::from_raw_parts(self.buffer, self.len) }
     }
 }
 
 #[repr(C)]
@@ -214,17 +231,17 @@ impl WrGradientStop {
     pub fn to_gradient_stops(stops: &[WrGradientStop]) -> Vec<GradientStop> {
         stops.iter().map(|x| x.to_gradient_stop()).collect()
     }
 }
 
 #[repr(C)]
 pub struct WrBorderSide {
     color: WrColor,
-    style: BorderStyle,
+    style: WrBorderStyle,
 }
 
 impl WrBorderSide {
     pub fn to_border_side(&self) -> BorderSide {
         BorderSide {
             color: self.color.to_color(),
             style: self.style,
         }
@@ -324,17 +341,17 @@ impl WrRepeatMode
            WrRepeatMode::Round => RepeatMode::Round,
            WrRepeatMode::Space => RepeatMode::Space,
        }
    }
 }
 
 #[repr(C)]
 pub struct WrImageMask {
-    image: ImageKey,
+    image: WrImageKey,
     rect: WrRect,
     repeat: bool,
 }
 
 impl WrImageMask {
     pub fn to_image_mask(&self) -> ImageMask {
         ImageMask {
             image: self.image,
@@ -499,17 +516,17 @@ impl ExternalImageHandler for WrExternal
 
 #[repr(C)]
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
 pub struct WrWindowId(u64);
 
 #[repr(C)]
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
 pub struct WrImageDescriptor {
-    pub format: ImageFormat,
+    pub format: WrImageFormat,
     pub width: u32,
     pub height: u32,
     pub stride: u32,
     pub is_opaque: bool,
 }
 
 impl WrImageDescriptor {
     pub fn to_descriptor(&self) -> ImageDescriptor {
@@ -611,44 +628,44 @@ impl webrender_traits::RenderNotifier fo
     fn external_event(&mut self, event: ExternalEvent) {
         unsafe {
             wr_notifier_external_event(self.window_id, event.unwrap());
         }
     }
 }
 
 #[no_mangle]
-pub extern "C" fn wr_renderer_set_external_image_handler(renderer: &mut Renderer,
+pub extern "C" fn wr_renderer_set_external_image_handler(renderer: &mut WrRenderer,
                                                          external_image_handler: *mut WrExternalImageHandler) {
     if !external_image_handler.is_null() {
         renderer.set_external_image_handler(Box::new(
             unsafe {
                 WrExternalImageHandler {
                     external_image_obj: (*external_image_handler).external_image_obj,
                     lock_func: (*external_image_handler).lock_func,
                     unlock_func: (*external_image_handler).unlock_func,
                     release_func: (*external_image_handler).release_func,
                 }
             }));
     }
 }
 
 #[no_mangle]
-pub extern "C" fn wr_renderer_update(renderer: &mut Renderer) {
+pub extern "C" fn wr_renderer_update(renderer: &mut WrRenderer) {
     renderer.update();
 }
 
 #[no_mangle]
-pub extern "C" fn wr_renderer_render(renderer: &mut Renderer, width: u32, height: u32) {
+pub extern "C" fn wr_renderer_render(renderer: &mut WrRenderer, width: u32, height: u32) {
     renderer.render(DeviceUintSize::new(width, height));
 }
 
 // Call wr_renderer_render() before calling this function.
 #[no_mangle]
-pub unsafe extern "C" fn wr_renderer_readback(renderer: &mut Renderer,
+pub unsafe extern "C" fn wr_renderer_readback(renderer: &mut WrRenderer,
                                               width: u32,
                                               height: u32,
                                               dst_buffer: *mut u8,
                                               buffer_size: usize) {
     assert!(is_in_render_thread());
 
     renderer.gl().flush();
 
@@ -658,72 +675,72 @@ pub unsafe extern "C" fn wr_renderer_rea
                                           width as gl::GLsizei,
                                           height as gl::GLsizei,
                                           get_gl_format_bgra(renderer.gl()),
                                           gl::UNSIGNED_BYTE,
                                           slice);
 }
 
 #[no_mangle]
-pub extern "C" fn wr_renderer_set_profiler_enabled(renderer: &mut Renderer, enabled: bool) {
+pub extern "C" fn wr_renderer_set_profiler_enabled(renderer: &mut WrRenderer, enabled: bool) {
     renderer.set_profiler_enabled(enabled);
 }
 
 #[no_mangle]
-pub extern "C" fn wr_renderer_current_epoch(renderer: &mut Renderer,
-                                            pipeline_id: PipelineId,
-                                            out_epoch: &mut Epoch)
+pub extern "C" fn wr_renderer_current_epoch(renderer: &mut WrRenderer,
+                                            pipeline_id: WrPipelineId,
+                                            out_epoch: &mut WrEpoch)
                                             -> bool {
     if let Some(epoch) = renderer.current_epoch(pipeline_id) {
         *out_epoch = epoch;
         return true;
     }
     return false;
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn wr_renderer_delete(renderer: *mut Renderer) {
+pub unsafe extern "C" fn wr_renderer_delete(renderer: *mut WrRenderer) {
     Box::from_raw(renderer);
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn wr_renderer_flush_rendered_epochs(renderer: &mut Renderer)
-                                                           -> *mut Vec<(PipelineId, Epoch)> {
+pub unsafe extern "C" fn wr_renderer_flush_rendered_epochs(renderer: &mut WrRenderer)
+                                                           -> *mut WrRenderedEpochs {
     let map = renderer.flush_rendered_epochs();
     let pipeline_epochs = Box::new(map.into_iter().collect());
     return Box::into_raw(pipeline_epochs);
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn wr_rendered_epochs_next(pipeline_epochs: &mut Vec<(PipelineId, Epoch)>,
-                                                 out_pipeline: &mut PipelineId,
-                                                 out_epoch: &mut Epoch)
+pub unsafe extern "C" fn wr_rendered_epochs_next(pipeline_epochs: &mut WrRenderedEpochs,
+                                                 out_pipeline: &mut WrPipelineId,
+                                                 out_epoch: &mut WrEpoch)
                                                  -> bool {
     if let Some((pipeline, epoch)) = pipeline_epochs.pop() {
         *out_pipeline = pipeline;
         *out_epoch = epoch;
         return true;
     }
     return false;
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn wr_rendered_epochs_delete(pipeline_epochs: *mut Vec<(PipelineId, Epoch)>) {
+pub unsafe extern "C" fn wr_rendered_epochs_delete(pipeline_epochs: *mut WrRenderedEpochs) {
     Box::from_raw(pipeline_epochs);
 }
 
 // Call MakeCurrent before this.
 #[no_mangle]
 pub extern "C" fn wr_window_new(window_id: WrWindowId,
                                 window_width: u32,
                                 window_height: u32,
                                 gl_context: *mut c_void,
                                 enable_profiler: bool,
-                                out_api: &mut *mut RenderApi,
-                                out_renderer: &mut *mut Renderer)
+                                out_api: &mut *mut WrAPI,
+                                out_renderer: &mut *mut WrRenderer)
                                 -> bool {
     assert!(unsafe { is_in_render_thread() });
 
     let recorder: Option<Box<ApiRecordingReceiver>> = if ENABLE_RECORDING {
         let name = format!("wr-record-{}.bin", window_id.0);
         Some(Box::new(BinaryRecorder::new(&PathBuf::from(name))))
     } else {
         None
@@ -746,138 +763,138 @@ pub extern "C" fn wr_window_new(window_i
         enable_subpixel_aa: true,
         enable_profiler: enable_profiler,
         recorder: recorder,
         blob_image_renderer: Some(Box::new(Moz2dImageRenderer::new())),
         ..Default::default()
     };
 
     let window_size = DeviceUintSize::new(window_width, window_height);
-    let (renderer, sender) = match Renderer::new(gl, opts, window_size) {
+    let (renderer, sender) = match WrRenderer::new(gl, opts, window_size) {
         Ok((renderer, sender)) => (renderer, sender),
         Err(e) => {
-            println!(" Failed to create a Renderer: {:?}", e);
+            println!(" Failed to create a WrRenderer: {:?}", e);
             let msg = CString::new(format!("wr_window_new: {:?}", e)).unwrap();
             unsafe { gfx_critical_note(msg.as_ptr()); }
             return false;
         }
     };
 
     renderer.set_render_notifier(Box::new(CppNotifier { window_id: window_id }));
 
     *out_api = Box::into_raw(Box::new(sender.create_api()));
     *out_renderer = Box::into_raw(Box::new(renderer));
 
     return true;
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn wr_api_delete(api: *mut RenderApi) {
+pub unsafe extern "C" fn wr_api_delete(api: *mut WrAPI) {
     let api = Box::from_raw(api);
     api.shut_down();
 }
 
 #[no_mangle]
-pub extern "C" fn wr_api_add_image(api: &mut RenderApi,
-                                   image_key: ImageKey,
+pub extern "C" fn wr_api_add_image(api: &mut WrAPI,
+                                   image_key: WrImageKey,
                                    descriptor: &WrImageDescriptor,
-                                   bytes: ByteSlice) {
+                                   bytes: WrByteSlice) {
     assert!(unsafe { is_in_compositor_thread() });
     let copied_bytes = bytes.as_slice().to_owned();
     api.add_image(image_key,
                   descriptor.to_descriptor(),
                   ImageData::new(copied_bytes),
                   None);
 }
 
 #[no_mangle]
-pub extern "C" fn wr_api_add_blob_image(api: &mut RenderApi,
-                                        image_key: ImageKey,
+pub extern "C" fn wr_api_add_blob_image(api: &mut WrAPI,
+                                        image_key: WrImageKey,
                                         descriptor: &WrImageDescriptor,
-                                        bytes: ByteSlice) {
+                                        bytes: WrByteSlice) {
     assert!(unsafe { is_in_compositor_thread() });
     let copied_bytes = bytes.as_slice().to_owned();
     api.add_image(image_key,
                   descriptor.to_descriptor(),
                   ImageData::new_blob_image(copied_bytes),
                   None);
 }
 
 #[no_mangle]
-pub extern "C" fn wr_api_add_external_image_handle(api: &mut RenderApi,
-                                                   image_key: ImageKey,
+pub extern "C" fn wr_api_add_external_image_handle(api: &mut WrAPI,
+                                                   image_key: WrImageKey,
                                                    descriptor: &WrImageDescriptor,
                                                    external_image_id: u64) {
     assert!(unsafe { is_in_compositor_thread() });
     api.add_image(image_key,
                   descriptor.to_descriptor(),
                   ImageData::External(ExternalImageData {
                       id: ExternalImageId(external_image_id),
                       image_type: ExternalImageType::Texture2DHandle
                   }),
                   None);
 }
 
 #[no_mangle]
-pub extern "C" fn wr_api_add_external_image_buffer(api: &mut RenderApi,
-                                                   image_key: ImageKey,
+pub extern "C" fn wr_api_add_external_image_buffer(api: &mut WrAPI,
+                                                   image_key: WrImageKey,
                                                    descriptor: &WrImageDescriptor,
                                                    external_image_id: u64) {
     assert!(unsafe { is_in_compositor_thread() });
     api.add_image(image_key,
                   descriptor.to_descriptor(),
                   ImageData::External(ExternalImageData {
                       id: ExternalImageId(external_image_id),
                       image_type: ExternalImageType::ExternalBuffer
                   }),
                   None);
 }
 
 #[no_mangle]
-pub extern "C" fn wr_api_update_image(api: &mut RenderApi,
-                                      key: ImageKey,
+pub extern "C" fn wr_api_update_image(api: &mut WrAPI,
+                                      key: WrImageKey,
                                       descriptor: &WrImageDescriptor,
-                                      bytes: ByteSlice) {
+                                      bytes: WrByteSlice) {
     assert!(unsafe { is_in_compositor_thread() });
     let copied_bytes = bytes.as_slice().to_owned();
 
     api.update_image(key,
                      descriptor.to_descriptor(),
                      ImageData::new(copied_bytes),
                      None);
 }
 
 #[no_mangle]
-pub extern "C" fn wr_api_delete_image(api: &mut RenderApi, key: ImageKey) {
+pub extern "C" fn wr_api_delete_image(api: &mut WrAPI, key: WrImageKey) {
     assert!(unsafe { is_in_compositor_thread() });
     api.delete_image(key)
 }
 
 #[no_mangle]
-pub extern "C" fn wr_api_set_root_pipeline(api: &mut RenderApi, pipeline_id: PipelineId) {
+pub extern "C" fn wr_api_set_root_pipeline(api: &mut WrAPI, pipeline_id: WrPipelineId) {
     api.set_root_pipeline(pipeline_id);
     api.generate_frame(None);
 }
 
 #[no_mangle]
-pub extern "C" fn wr_api_set_window_parameters(api: &mut RenderApi, width: i32, height: i32) {
+pub extern "C" fn wr_api_set_window_parameters(api: &mut WrAPI, width: i32, height: i32) {
     let size = DeviceUintSize::new(width as u32, height as u32);
     api.set_window_parameters(size, DeviceUintRect::new(DeviceUintPoint::new(0, 0), size));
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn wr_api_set_root_display_list(api: &mut RenderApi,
-                                                      epoch: Epoch,
+pub unsafe extern "C" fn wr_api_set_root_display_list(api: &mut WrAPI,
+                                                      epoch: WrEpoch,
                                                       viewport_width: f32,
                                                       viewport_height: f32,
-                                                      pipeline_id: PipelineId,
-                                                      dl_descriptor: BuiltDisplayListDescriptor,
+                                                      pipeline_id: WrPipelineId,
+                                                      dl_descriptor: WrBuiltDisplayListDescriptor,
                                                       dl_data: *mut u8,
                                                       dl_size: usize,
-                                                      aux_descriptor: AuxiliaryListsDescriptor,
+                                                      aux_descriptor: WrAuxiliaryListsDescriptor,
                                                       aux_data: *mut u8,
                                                       aux_size: usize) {
     let root_background_color = ColorF::new(0.3, 0.0, 0.0, 1.0);
     // See the documentation of set_display_list in api.rs. I don't think
     // it makes a difference in gecko at the moment(until APZ is figured out)
     // but I suppose it is a good default.
     let preserve_frame_state = true;
 
@@ -896,45 +913,45 @@ pub unsafe extern "C" fn wr_api_set_root
     api.set_display_list(Some(root_background_color),
                          epoch,
                          LayoutSize::new(viewport_width, viewport_height),
                          (pipeline_id, dl, aux),
                          preserve_frame_state);
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn wr_api_clear_root_display_list(api: &mut RenderApi,
-                                                        epoch: Epoch,
-                                                        pipeline_id: PipelineId) {
+pub unsafe extern "C" fn wr_api_clear_root_display_list(api: &mut WrAPI,
+                                                        epoch: WrEpoch,
+                                                        pipeline_id: WrPipelineId) {
     let root_background_color = ColorF::new(0.3, 0.0, 0.0, 1.0);
     let preserve_frame_state = true;
     let frame_builder = WebRenderFrameBuilder::new(pipeline_id);
 
     api.set_display_list(Some(root_background_color),
                          epoch,
                          LayoutSize::new(0.0, 0.0),
                          frame_builder.dl_builder.finalize(),
                          preserve_frame_state);
 }
 
 #[no_mangle]
-pub extern "C" fn wr_api_generate_frame(api: &mut RenderApi) {
+pub extern "C" fn wr_api_generate_frame(api: &mut WrAPI) {
     api.generate_frame(None);
 }
 
 #[no_mangle]
-pub extern "C" fn wr_api_send_external_event(api: &mut RenderApi, evt: usize) {
+pub extern "C" fn wr_api_send_external_event(api: &mut WrAPI, evt: usize) {
     assert!(unsafe { !is_in_render_thread() });
 
     api.send_external_event(ExternalEvent::from_raw(evt));
 }
 
 #[no_mangle]
-pub extern "C" fn wr_api_add_raw_font(api: &mut RenderApi,
-                                      key: FontKey,
+pub extern "C" fn wr_api_add_raw_font(api: &mut WrAPI,
+                                      key: WrFontKey,
                                       font_buffer: *mut u8,
                                       buffer_size: usize) {
     assert!(unsafe { is_in_compositor_thread() });
 
     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);
 
@@ -944,53 +961,53 @@ pub extern "C" fn wr_api_add_raw_font(ap
 #[no_mangle]
 pub extern "C" fn wr_api_delete_font(api: &mut RenderApi, key: FontKey)
 {
     assert!( unsafe { is_in_compositor_thread() });
     api.delete_font(key);
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn wr_api_get_namespace(api: &mut RenderApi) -> IdNamespace {
+pub unsafe extern "C" fn wr_api_get_namespace(api: &mut WrAPI) -> WrIdNamespace {
     api.id_namespace
 }
 
 // RenderThread WIP notes:
 // In order to separate the compositor thread (or ipc receiver) and the render
 // thread, some of the logic below needs to be rewritten. In particular
 // the WrWindowState and Notifier implementations aren't designed to work with
 // a separate render thread.
 // As part of that I am moving the bindings closer to WebRender's API boundary,
 // and moving more of the logic in C++ land.
 // This work is tracked by bug 1328602.
 //
 // See RenderThread.h for some notes about how the pieces fit together.
 
 pub struct WebRenderFrameBuilder {
-    pub root_pipeline_id: PipelineId,
+    pub root_pipeline_id: WrPipelineId,
     pub dl_builder: webrender_traits::DisplayListBuilder,
 }
 
 impl WebRenderFrameBuilder {
-    pub fn new(root_pipeline_id: PipelineId) -> WebRenderFrameBuilder {
+    pub fn new(root_pipeline_id: WrPipelineId) -> WebRenderFrameBuilder {
         WebRenderFrameBuilder {
             root_pipeline_id: root_pipeline_id,
             dl_builder: webrender_traits::DisplayListBuilder::new(root_pipeline_id),
         }
     }
 }
 
 pub struct WrState {
-    pipeline_id: PipelineId,
+    pipeline_id: WrPipelineId,
     z_index: i32,
     frame_builder: WebRenderFrameBuilder,
 }
 
 #[no_mangle]
-pub extern "C" fn wr_state_new(pipeline_id: PipelineId) -> *mut WrState {
+pub extern "C" fn wr_state_new(pipeline_id: WrPipelineId) -> *mut WrState {
     assert!(unsafe { is_in_main_thread() });
 
     let state = Box::new(WrState {
                              pipeline_id: pipeline_id,
                              z_index: 0,
                              frame_builder: WebRenderFrameBuilder::new(pipeline_id),
                          });
 
@@ -1020,17 +1037,17 @@ pub extern "C" fn wr_dp_begin(state: &mu
 
     state.frame_builder
         .dl_builder
         .push_stacking_context(webrender_traits::ScrollPolicy::Scrollable,
                                bounds,
                                0,
                                None,
                                None,
-                               webrender_traits::MixBlendMode::Normal,
+                               MixBlendMode::Normal,
                                Vec::new());
 }
 
 #[no_mangle]
 pub extern "C" fn wr_dp_end(state: &mut WrState) {
     assert!(unsafe { is_in_main_thread() });
     state.frame_builder.dl_builder.pop_stacking_context();
 }
@@ -1059,17 +1076,17 @@ pub extern "C" fn wr_dp_new_clip_region(
 
 #[no_mangle]
 pub extern "C" fn wr_dp_push_stacking_context(state: &mut WrState,
                                               bounds: WrRect,
                                               overflow: WrRect,
                                               mask: *const WrImageMask,
                                               opacity: f32,
                                               transform: &LayoutTransform,
-                                              mix_blend_mode: MixBlendMode) {
+                                              mix_blend_mode: WrMixBlendMode) {
     assert!(unsafe { is_in_main_thread() });
     state.z_index += 1;
 
     let bounds = bounds.to_rect();
     let overflow = overflow.to_rect();
 
     // convert from the C type to the Rust type
     let mask = unsafe {
@@ -1132,17 +1149,17 @@ pub extern "C" fn wr_dp_pop_scroll_layer
     assert!(unsafe { is_in_main_thread() });
     state.frame_builder.dl_builder.pop_scroll_layer();
 }
 
 #[no_mangle]
 pub extern "C" fn wr_dp_push_iframe(state: &mut WrState,
                                     rect: WrRect,
                                     clip: WrClipRegion,
-                                    pipeline_id: PipelineId) {
+                                    pipeline_id: WrPipelineId) {
     assert!(unsafe { is_in_main_thread() });
 
     state.frame_builder.dl_builder.push_iframe(rect.to_rect(), clip.to_clip_region(), pipeline_id);
 }
 
 #[no_mangle]
 pub extern "C" fn wr_dp_push_rect(state: &mut WrState,
                                   rect: WrRect,
@@ -1156,18 +1173,18 @@ pub extern "C" fn wr_dp_push_rect(state:
 }
 
 #[no_mangle]
 pub extern "C" fn wr_dp_push_image(state: &mut WrState,
                                    bounds: WrRect,
                                    clip: WrClipRegion,
                                    stretch_size: WrSize,
                                    tile_spacing: WrSize,
-                                   image_rendering: ImageRendering,
-                                   key: ImageKey) {
+                                   image_rendering: WrImageRendering,
+                                   key: WrImageKey) {
     assert!(unsafe { is_in_main_thread() });
 
     let bounds = bounds.to_rect();
 
     state.frame_builder.dl_builder.push_image(bounds,
                                               clip.to_clip_region(),
                                               stretch_size.to_size(),
                                               tile_spacing.to_size(),
@@ -1175,18 +1192,18 @@ pub extern "C" fn wr_dp_push_image(state
                                               key);
 }
 
 #[no_mangle]
 pub extern "C" fn wr_dp_push_text(state: &mut WrState,
                                   bounds: WrRect,
                                   clip: WrClipRegion,
                                   color: WrColor,
-                                  font_key: FontKey,
-                                  glyphs: *mut GlyphInstance,
+                                  font_key: WrFontKey,
+                                  glyphs: *mut WrGlyphInstance,
                                   glyph_count: u32,
                                   glyph_size: f32) {
     assert!(unsafe { is_in_main_thread() });
 
     let glyph_slice = unsafe { slice::from_raw_parts(glyphs, glyph_count as usize) };
     let mut glyph_vector = Vec::new();
     glyph_vector.extend_from_slice(&glyph_slice);
 
@@ -1229,17 +1246,17 @@ pub extern "C" fn wr_dp_push_border(stat
                                     border_details);
 }
 
 #[no_mangle]
 pub extern "C" fn wr_dp_push_border_image(state: &mut WrState,
                                           rect: WrRect,
                                           clip: WrClipRegion,
                                           widths: WrBorderWidths,
-                                          image: ImageKey,
+                                          image: WrImageKey,
                                           patch: WrNinePatchDescriptor,
                                           outset: WrSideOffsets2D<f32>,
                                           repeat_horizontal: WrRepeatMode,
                                           repeat_vertical: WrRepeatMode) {
     assert!( unsafe { is_in_main_thread() });
     let border_details = BorderDetails::Image(ImageBorder {
         image_key: image,
         patch: patch.to_nine_patch_descriptor(),
@@ -1353,78 +1370,78 @@ pub extern "C" fn wr_dp_push_box_shadow(
                                         rect: WrRect,
                                         clip: WrClipRegion,
                                         box_bounds: WrRect,
                                         offset: WrPoint,
                                         color: WrColor,
                                         blur_radius: f32,
                                         spread_radius: f32,
                                         border_radius: f32,
-                                        clip_mode: BoxShadowClipMode) {
+                                        clip_mode: WrBoxShadowClipMode) {
     assert!(unsafe { is_in_main_thread() });
 
     state.frame_builder.dl_builder.push_box_shadow(rect.to_rect(),
                                                    clip.to_clip_region(),
                                                    box_bounds.to_rect(),
                                                    offset.to_point(),
                                                    color.to_color(),
                                                    blur_radius,
                                                    spread_radius,
                                                    border_radius,
                                                    clip_mode);
 }
 
 #[no_mangle]
 pub unsafe extern "C" fn wr_api_finalize_builder(state: &mut WrState,
-                                                 dl_descriptor: &mut BuiltDisplayListDescriptor,
+                                                 dl_descriptor: &mut WrBuiltDisplayListDescriptor,
                                                  dl_data: &mut WrVecU8,
-                                                 aux_descriptor: &mut AuxiliaryListsDescriptor,
+                                                 aux_descriptor: &mut WrAuxiliaryListsDescriptor,
                                                  aux_data: &mut WrVecU8) {
     let frame_builder = mem::replace(&mut state.frame_builder,
                                      WebRenderFrameBuilder::new(state.pipeline_id));
     let (_, dl, aux) = frame_builder.dl_builder.finalize();
     let (data, descriptor) = dl.into_data();
     *dl_data = WrVecU8::from_vec(data);
     *dl_descriptor = descriptor;
 
     let (data, descriptor) = aux.into_data();
     *aux_data = WrVecU8::from_vec(data);
     *aux_descriptor = descriptor;
 }
 
 #[no_mangle]
 pub unsafe extern "C" fn wr_dp_push_built_display_list(state: &mut WrState,
-                                                       dl_descriptor: BuiltDisplayListDescriptor,
+                                                       dl_descriptor: WrBuiltDisplayListDescriptor,
                                                        dl_data: WrVecU8,
-                                                       aux_descriptor: AuxiliaryListsDescriptor,
+                                                       aux_descriptor: WrAuxiliaryListsDescriptor,
                                                        aux_data: WrVecU8) {
     let dl_vec = dl_data.to_vec();
     let aux_vec = aux_data.to_vec();
 
     let dl = BuiltDisplayList::from_data(dl_vec, dl_descriptor);
     let aux = AuxiliaryLists::from_data(aux_vec, aux_descriptor);
 
     state.frame_builder.dl_builder.push_built_display_list(dl, aux);
 }
 
 struct Moz2dImageRenderer {
-    images: HashMap<ImageKey, BlobImageResult>
+    images: HashMap<WrImageKey, BlobImageResult>
 }
 
 impl BlobImageRenderer for Moz2dImageRenderer {
     fn request_blob_image(&mut self,
-                          key: ImageKey,
+                          key: WrImageKey,
                           data: Arc<BlobImageData>,
                           descriptor: &BlobImageDescriptor,
                           _dirty_rect: Option<DeviceUintRect>) {
         let result = self.render_blob_image(data, descriptor);
         self.images.insert(key, result);
     }
 
-    fn resolve_blob_image(&mut self, key: ImageKey) -> BlobImageResult {
+    fn resolve_blob_image(&mut self, key: WrImageKey) -> BlobImageResult {
         return match self.images.remove(&key) {
             Some(result) => result,
             None => Err(BlobImageError::InvalidKey),
         }
     }
 }
 
 impl Moz2dImageRenderer {
@@ -1435,17 +1452,17 @@ impl Moz2dImageRenderer {
     }
 
     fn render_blob_image(&mut self, data: Arc<BlobImageData>, descriptor: &BlobImageDescriptor) -> BlobImageResult {
         let mut output = Vec::with_capacity(
             (descriptor.width * descriptor.height * descriptor.format.bytes_per_pixel().unwrap()) as usize
         );
 
         unsafe {
-            if wr_moz2d_render_cb(ByteSlice::new(&data[..]),
+            if wr_moz2d_render_cb(WrByteSlice::new(&data[..]),
                                   descriptor.width,
                                   descriptor.height,
                                   descriptor.format,
                                   MutByteSlice::new(output.as_mut_slice())) {
                 return Ok(RasterizedBlobImage {
                     width: descriptor.width,
                     height: descriptor.height,
                     data: output,
@@ -1454,14 +1471,14 @@ impl Moz2dImageRenderer {
         }
 
         Err(BlobImageError::Other("unimplemented!".to_string()))
     }
 }
 
 extern "C" {
     // TODO: figure out the API for tiled blob images.
-    fn wr_moz2d_render_cb(blob: ByteSlice,
+    fn wr_moz2d_render_cb(blob: WrByteSlice,
                           width: u32,
                           height: u32,
-                          format: ImageFormat,
+                          format: WrImageFormat,
                           output: MutByteSlice) -> bool;
 }