Bug 1383786 - Changes to the ffi boundary. r=sotaro
authorNicolas Silva <nsilva@mozilla.com>
Fri, 28 Jul 2017 14:08:11 +0200
changeset 422821 b8847dab6f580b96a143573cdc42cb628f955996
parent 422820 a85a338ca6343e7406caf744fa142401d993371f
child 422822 816e61957699d19eb96dfccd014ca0487337f065
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssotaro
bugs1383786
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 1383786 - Changes to the ffi boundary. r=sotaro
gfx/webrender_bindings/WebRenderAPI.cpp
gfx/webrender_bindings/WebRenderAPI.h
gfx/webrender_bindings/src/bindings.rs
gfx/webrender_bindings/webrender_ffi_generated.h
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -433,38 +433,64 @@ WebRenderAPI::AddExternalImage(ImageKey 
                             key,
                             &aDescriptor,
                             aExtID,
                             aBufferType,
                             aChannelIndex);
 }
 
 void
-WebRenderAPI::AddExternalImageBuffer(ImageKey key,
+WebRenderAPI::AddExternalImageBuffer(ImageKey aKey,
                                      const ImageDescriptor& aDescriptor,
                                      ExternalImageId aHandle)
 {
-  wr_api_add_external_image_buffer(mRenderApi,
-                                   key,
-                                   &aDescriptor,
-                                   aHandle);
+  auto channelIndex = 0;
+  AddExternalImage(aKey, aDescriptor, aHandle,
+                   wr::WrExternalImageBufferType::ExternalBuffer,
+                   channelIndex);
 }
 
 void
 WebRenderAPI::UpdateImageBuffer(ImageKey aKey,
                                 const ImageDescriptor& aDescriptor,
                                 Range<uint8_t> aBytes)
 {
   wr_api_update_image(mRenderApi,
                       aKey,
                       &aDescriptor,
                       RangeToByteSlice(aBytes));
 }
 
 void
+WebRenderAPI::UpdateBlobImage(ImageKey aKey,
+                              const ImageDescriptor& aDescriptor,
+                              Range<uint8_t> aBytes)
+{
+  wr_api_update_blob_image(mRenderApi,
+                           aKey,
+                           &aDescriptor,
+                           RangeToByteSlice(aBytes));
+}
+
+void
+WebRenderAPI::UpdateExternalImage(ImageKey aKey,
+                                  const ImageDescriptor& aDescriptor,
+                                  ExternalImageId aExtID,
+                                  wr::WrExternalImageBufferType aBufferType,
+                                  uint8_t aChannelIndex)
+{
+  wr_api_update_external_image(mRenderApi,
+                               aKey,
+                               &aDescriptor,
+                               aExtID,
+                               aBufferType,
+                               aChannelIndex);
+}
+
+void
 WebRenderAPI::DeleteImage(ImageKey aKey)
 {
   wr_api_delete_image(mRenderApi, aKey);
 }
 
 void
 WebRenderAPI::AddRawFont(wr::FontKey aKey, Range<uint8_t> aBytes, uint32_t aIndex)
 {
--- a/gfx/webrender_bindings/WebRenderAPI.h
+++ b/gfx/webrender_bindings/WebRenderAPI.h
@@ -82,22 +82,32 @@ public:
   void AddExternalImageBuffer(ImageKey key,
                               const ImageDescriptor& aDescriptor,
                               ExternalImageId aHandle);
 
   void AddExternalImage(ImageKey key,
                         const ImageDescriptor& aDescriptor,
                         ExternalImageId aExtID,
                         WrExternalImageBufferType aBufferType,
-                        uint8_t aChannelIndex);
+                        uint8_t aChannelIndex = 0);
 
   void UpdateImageBuffer(wr::ImageKey aKey,
                          const ImageDescriptor& aDescriptor,
                          Range<uint8_t> aBytes);
 
+  void UpdateBlobImage(wr::ImageKey aKey,
+                       const ImageDescriptor& aDescriptor,
+                       Range<uint8_t> aBytes);
+
+  void UpdateExternalImage(ImageKey aKey,
+                           const ImageDescriptor& aDescriptor,
+                           ExternalImageId aExtID,
+                           wr::WrExternalImageBufferType aBufferType,
+                           uint8_t aChannelIndex = 0);
+
   void DeleteImage(wr::ImageKey aKey);
 
   void AddRawFont(wr::FontKey aKey, Range<uint8_t> aBytes, uint32_t aIndex);
 
   void DeleteFont(wr::FontKey aKey);
 
   void SetProfilerEnabled(bool aEnabled);
 
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -639,43 +639,64 @@ pub extern "C" fn wr_api_add_external_im
                                           id: external_image_id.into(),
                                           channel_index: channel_index,
                                           image_type: buffer_type,
                                       }),
                   None);
 }
 
 #[no_mangle]
-pub extern "C" fn wr_api_add_external_image_buffer(api: &mut RenderApi,
-                                                   image_key: WrImageKey,
-                                                   descriptor: &WrImageDescriptor,
-                                                   external_image_id: WrExternalImageId) {
-    assert!(unsafe { is_in_compositor_thread() });
-    api.add_image(image_key,
-                  descriptor.into(),
-                  ImageData::External(ExternalImageData {
-                                          id: external_image_id.into(),
-                                          channel_index: 0,
-                                          image_type: ExternalImageType::ExternalBuffer,
-                                      }),
-                  None);
-}
-
-#[no_mangle]
 pub extern "C" fn wr_api_update_image(api: &mut RenderApi,
                                       key: WrImageKey,
                                       descriptor: &WrImageDescriptor,
                                       bytes: ByteSlice) {
     assert!(unsafe { is_in_compositor_thread() });
     let copied_bytes = bytes.as_slice().to_owned();
 
     api.update_image(key, descriptor.into(), ImageData::new(copied_bytes), None);
 }
 
 #[no_mangle]
+pub extern "C" fn wr_api_update_external_image(
+    api: &mut RenderApi,
+    key: WrImageKey,
+    descriptor: &WrImageDescriptor,
+    external_image_id: WrExternalImageId,
+    image_type: WrExternalImageBufferType,
+    channel_index: u8
+) {
+    assert!(unsafe { is_in_compositor_thread() });
+
+    let data = ImageData::External(
+        ExternalImageData {
+            id: external_image_id.into(),
+            channel_index,
+            image_type,
+        }
+    );
+
+    api.update_image(key, descriptor.into(), data, None);
+}
+
+#[no_mangle]
+pub extern "C" fn wr_api_update_blob_image(api: &mut RenderApi,
+                                           image_key: WrImageKey,
+                                           descriptor: &WrImageDescriptor,
+                                           bytes: ByteSlice) {
+    assert!(unsafe { is_in_compositor_thread() });
+    let copied_bytes = bytes.as_slice().to_owned();
+    api.update_image(
+        image_key,
+        descriptor.into(),
+        ImageData::new_blob_image(copied_bytes),
+        None
+    );
+}
+
+#[no_mangle]
 pub extern "C" fn wr_api_delete_image(api: &mut RenderApi,
                                       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,
--- a/gfx/webrender_bindings/webrender_ffi_generated.h
+++ b/gfx/webrender_bindings/webrender_ffi_generated.h
@@ -632,23 +632,16 @@ void wr_api_add_external_image(RenderApi
                                WrImageKey aImageKey,
                                const WrImageDescriptor *aDescriptor,
                                WrExternalImageId aExternalImageId,
                                WrExternalImageBufferType aBufferType,
                                uint8_t aChannelIndex)
 WR_FUNC;
 
 WR_INLINE
-void wr_api_add_external_image_buffer(RenderApi *aApi,
-                                      WrImageKey aImageKey,
-                                      const WrImageDescriptor *aDescriptor,
-                                      WrExternalImageId aExternalImageId)
-WR_FUNC;
-
-WR_INLINE
 void wr_api_add_image(RenderApi *aApi,
                       WrImageKey aImageKey,
                       const WrImageDescriptor *aDescriptor,
                       ByteSlice aBytes)
 WR_FUNC;
 
 WR_INLINE
 void wr_api_add_raw_font(RenderApi *aApi,
@@ -726,16 +719,32 @@ WR_FUNC;
 
 WR_INLINE
 void wr_api_set_window_parameters(RenderApi *aApi,
                                   int32_t aWidth,
                                   int32_t aHeight)
 WR_FUNC;
 
 WR_INLINE
+void wr_api_update_blob_image(RenderApi *aApi,
+                              WrImageKey aImageKey,
+                              const WrImageDescriptor *aDescriptor,
+                              ByteSlice aBytes)
+WR_FUNC;
+
+WR_INLINE
+void wr_api_update_external_image(RenderApi *aApi,
+                                  WrImageKey aKey,
+                                  const WrImageDescriptor *aDescriptor,
+                                  WrExternalImageId aExternalImageId,
+                                  WrExternalImageBufferType aImageType,
+                                  uint8_t aChannelIndex)
+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)