diff --git a/gfx/webrender_bindings/WebRenderAPI.cpp b/gfx/webrender_bindings/WebRenderAPI.cpp index d447ddaf9e71..c05a1d99fc27 100644 --- a/gfx/webrender_bindings/WebRenderAPI.cpp +++ b/gfx/webrender_bindings/WebRenderAPI.cpp @@ -438,14 +438,14 @@ WebRenderAPI::AddExternalImage(ImageKey key, } 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 @@ -459,6 +459,32 @@ WebRenderAPI::UpdateImageBuffer(ImageKey aKey, RangeToByteSlice(aBytes)); } +void +WebRenderAPI::UpdateBlobImage(ImageKey aKey, + const ImageDescriptor& aDescriptor, + Range 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) { diff --git a/gfx/webrender_bindings/WebRenderAPI.h b/gfx/webrender_bindings/WebRenderAPI.h index c8b9042a2b4d..04c99cfddc2b 100644 --- a/gfx/webrender_bindings/WebRenderAPI.h +++ b/gfx/webrender_bindings/WebRenderAPI.h @@ -87,12 +87,22 @@ public: const ImageDescriptor& aDescriptor, ExternalImageId aExtID, WrExternalImageBufferType aBufferType, - uint8_t aChannelIndex); + uint8_t aChannelIndex = 0); void UpdateImageBuffer(wr::ImageKey aKey, const ImageDescriptor& aDescriptor, Range aBytes); + void UpdateBlobImage(wr::ImageKey aKey, + const ImageDescriptor& aDescriptor, + Range 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 aBytes, uint32_t aIndex); diff --git a/gfx/webrender_bindings/src/bindings.rs b/gfx/webrender_bindings/src/bindings.rs index fae953fd2bf5..88b7df29a404 100644 --- a/gfx/webrender_bindings/src/bindings.rs +++ b/gfx/webrender_bindings/src/bindings.rs @@ -643,22 +643,6 @@ pub extern "C" fn wr_api_add_external_image(api: &mut RenderApi, 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, @@ -670,6 +654,43 @@ pub extern "C" fn wr_api_update_image(api: &mut RenderApi, 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) { diff --git a/gfx/webrender_bindings/webrender_ffi_generated.h b/gfx/webrender_bindings/webrender_ffi_generated.h index 33cdffdeb717..139bfd2f1b2c 100644 --- a/gfx/webrender_bindings/webrender_ffi_generated.h +++ b/gfx/webrender_bindings/webrender_ffi_generated.h @@ -636,13 +636,6 @@ void wr_api_add_external_image(RenderApi *aApi, 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, @@ -730,6 +723,22 @@ void wr_api_set_window_parameters(RenderApi *aApi, 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,