Bug 1381949 - Expose functions for dealing Arc<Vec<u8>> r=rhunt
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Mon, 17 Jul 2017 18:21:07 -0400
changeset 418710 8000ce4433095f60619118fd2b19259e640b9062
parent 418709 8e46fc907da91a5ad9630fdca9fddaf3557eda63
child 418711 52da209e46fbcb3e7913ef28c0d4762ed13f8a62
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrhunt
bugs1381949
milestone56.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 1381949 - Expose functions for dealing Arc<Vec<u8>> r=rhunt We'll need this for interacting with the font data from C++
gfx/webrender_bindings/src/bindings.rs
gfx/webrender_bindings/webrender_ffi_generated.h
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -1419,16 +1419,29 @@ pub extern "C" fn wr_dp_push_built_displ
 
     let dl = BuiltDisplayList::from_data(dl_vec, dl_descriptor);
 
     state.frame_builder.dl_builder.push_nested_display_list(&dl);
     let (data, _) = dl.into_data();
     mem::replace(dl_data, WrVecU8::from_vec(data));
 }
 
+pub type VecU8 = Vec<u8>;
+pub type ArcVecU8 = Arc<VecU8>;
+
+#[no_mangle]
+pub extern "C" fn wr_add_ref_arc(arc: &ArcVecU8) -> *const VecU8 {
+    Arc::into_raw(arc.clone())
+}
+
+#[no_mangle]
+pub unsafe extern "C" fn wr_dec_ref_arc(arc: *const VecU8) {
+    Arc::from_raw(arc);
+}
+
 // TODO: nical
 // Update for the new blob image interface changes.
 //
 extern "C" {
      // TODO: figure out the API for tiled blob images.
      pub fn wr_moz2d_render_cb(blob: ByteSlice,
                                width: u32,
                                height: u32,
--- a/gfx/webrender_bindings/webrender_ffi_generated.h
+++ b/gfx/webrender_bindings/webrender_ffi_generated.h
@@ -137,22 +137,26 @@ enum class WrFilterOpType : uint32_t {
 
 enum class WrYuvColorSpace : uint32_t {
   Rec601 = 0,
   Rec709 = 1,
 
   Sentinel /* this must be last for serialization purposes. */
 };
 
+struct ArcVecU8;
+
 struct LayerPixel;
 
 struct RenderApi;
 
 struct Renderer;
 
+struct VecU8;
+
 struct WrRenderedEpochs;
 
 struct WrState;
 
 struct WrThreadPool;
 
 struct WrImageKey {
   uint32_t mNamespace;
@@ -590,16 +594,20 @@ struct WrExternalImageHandler {
 /* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen.
  * To generate this file:
  *   1. Get the latest cbindgen using `cargo install --force cbindgen`
  *      a. Alternatively, you can clone `https://github.com/rlhunt/cbindgen` and use a tagged release
  *   2. Run `cbindgen toolkit/library/rust/ --crate webrender_bindings -o gfx/webrender_bindings/webrender_ffi_generated.h`
  */
 
 WR_INLINE
+const VecU8 *wr_add_ref_arc(const ArcVecU8 *aArc)
+WR_FUNC;
+
+WR_INLINE
 void wr_api_add_blob_image(RenderApi *aApi,
                            WrImageKey aImageKey,
                            const WrImageDescriptor *aDescriptor,
                            ByteSlice aBytes)
 WR_FUNC;
 
 WR_INLINE
 void wr_api_add_external_image(RenderApi *aApi,
@@ -707,16 +715,20 @@ WR_FUNC;
 WR_INLINE
 void wr_api_update_image(RenderApi *aApi,
                          WrImageKey aKey,
                          const WrImageDescriptor *aDescriptor,
                          ByteSlice aBytes)
 WR_FUNC;
 
 WR_INLINE
+void wr_dec_ref_arc(const VecU8 *aArc)
+WR_FUNC;
+
+WR_INLINE
 void wr_dp_begin(WrState *aState,
                  uint32_t aWidth,
                  uint32_t aHeight)
 WR_FUNC;
 
 WR_INLINE
 void wr_dp_end(WrState *aState)
 WR_FUNC;