From 51510de95b0d1eba9bb3f228c4df242a9ede4f9c Mon Sep 17 00:00:00 2001 From: JerryShih Date: Thu, 27 Apr 2017 15:08:20 +0800 Subject: [PATCH] Bug 1359738 - Add push_yuv_image() in WR binding. Please check [1] for webrender_ffi_generated.h updates. [1] https://dxr.mozilla.org/mozilla-central/rev/f229b7e5d91eb70d23d3e31db7caff9d69a2ef04/gfx/webrender_bindings/webrender_ffi_generated.h#7 MozReview-Commit-ID: 3PolFzfQB0l --- gfx/webrender_bindings/src/bindings.rs | 32 +++++++++++++++++-- .../webrender_ffi_generated.h | 16 ++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/gfx/webrender_bindings/src/bindings.rs b/gfx/webrender_bindings/src/bindings.rs index f2114d17945b..ec9acffbfd1f 100644 --- a/gfx/webrender_bindings/src/bindings.rs +++ b/gfx/webrender_bindings/src/bindings.rs @@ -49,6 +49,8 @@ type WrPipelineId = PipelineId; type WrImageKey = ImageKey; /// cbindgen:field-names=[mNamespace, mHandle] type WrFontKey = FontKey; +/// cbindgen:field-names=[mNamespace, mHandle] +type WrYuvColorSpace = YuvColorSpace; /// cbindgen:field-names=[mHandle] #[repr(C)] @@ -1328,11 +1330,9 @@ pub extern "C" fn wr_dp_push_image(state: &mut WrState, key: WrImageKey) { assert!(unsafe { is_in_main_thread() }); - let bounds = bounds.into(); - state.frame_builder .dl_builder - .push_image(bounds, + .push_image(bounds.into(), clip.into(), stretch_size.into(), tile_spacing.into(), @@ -1340,6 +1340,32 @@ pub extern "C" fn wr_dp_push_image(state: &mut WrState, key); } +#[no_mangle] +pub extern "C" fn wr_dp_push_yuv_image(state: &mut WrState, + bounds: WrRect, + clip: WrClipRegion, + image_keys: *const WrImageKey, + key_num: u8, + color_space: WrYuvColorSpace) { + assert!(unsafe { is_in_main_thread() }); + assert!(key_num == 3); + unsafe { + for key_index in 0..key_num { + assert!(!image_keys.offset(key_index as isize).is_null()); + } + } + let key_slice = make_slice(image_keys, key_num as usize); + + state.frame_builder + .dl_builder + .push_yuv_image(bounds.into(), + clip.into(), + key_slice[0], + key_slice[1], + key_slice[2], + color_space); +} + #[no_mangle] pub extern "C" fn wr_dp_push_text(state: &mut WrState, bounds: WrRect, diff --git a/gfx/webrender_bindings/webrender_ffi_generated.h b/gfx/webrender_bindings/webrender_ffi_generated.h index 9e6e35dad097..82d7fc3324a3 100644 --- a/gfx/webrender_bindings/webrender_ffi_generated.h +++ b/gfx/webrender_bindings/webrender_ffi_generated.h @@ -94,6 +94,13 @@ enum class WrRepeatMode : uint32_t { Sentinel /* this must be last for serialization purposes. */ }; +enum class WrYuvColorSpace : uint32_t { + Rec601 = 1, + Rec709 = 2, + + Sentinel /* this must be last for serialization purposes. */ +}; + struct WrAPI; struct WrImageKey { @@ -805,6 +812,15 @@ wr_dp_push_text(WrState* state, float glyph_size) WR_FUNC; +WR_INLINE void +wr_dp_push_yuv_image(WrState* state, + WrRect bounds, + WrClipRegion clip, + const WrImageKey* image_keys, + uint8_t key_num, + WrYuvColorSpace color_space) +WR_FUNC; + WR_INLINE void wr_rendered_epochs_delete(WrRenderedEpochs* pipeline_epochs) WR_DESTRUCTOR_SAFE_FUNC;