Bug 1351189 - update WR external image callback interface. r=sotaro
authorJerryShih <hshih@mozilla.com>
Fri, 28 Apr 2017 14:16:26 +0800
changeset 357006 f0661ae8183826aa0b07c7cac8598120863a6a20
parent 355204 29f8f98fb7baf586f1b953e48c6eec235a7515aa
child 357007 9e5cbfb0705e9da45147be40f075720dcf5e937a
push id31780
push userkwierso@gmail.com
push dateMon, 08 May 2017 20:34:47 +0000
treeherdermozilla-central@bab7046ee2d8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssotaro
bugs1351189
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 1351189 - update WR external image callback interface. r=sotaro The new parameter "channel index" is used to select the specific channel data from a multiple channel textureHost(e.g. yuv format textureHost). MozReview-Commit-ID: Ey1cA25Z6WH
gfx/webrender_bindings/RendererOGL.cpp
gfx/webrender_bindings/RendererOGL.h
gfx/webrender_bindings/src/bindings.rs
gfx/webrender_bindings/webrender_ffi_generated.h
--- a/gfx/webrender_bindings/RendererOGL.cpp
+++ b/gfx/webrender_bindings/RendererOGL.cpp
@@ -11,17 +11,17 @@
 #include "mozilla/layers/CompositorThread.h"
 #include "mozilla/webrender/RenderBufferTextureHost.h"
 #include "mozilla/webrender/RenderTextureHostOGL.h"
 #include "mozilla/widget/CompositorWidget.h"
 
 namespace mozilla {
 namespace wr {
 
-WrExternalImage LockExternalImage(void* aObj, WrExternalImageId aId)
+WrExternalImage LockExternalImage(void* aObj, WrExternalImageId aId, uint8_t aChannelIndex)
 {
   RendererOGL* renderer = reinterpret_cast<RendererOGL*>(aObj);
   RenderTextureHost* texture = renderer->GetRenderTexture(aId);
 
   if (texture->AsBufferTextureHost()) {
     RenderBufferTextureHost* bufferTexture = texture->AsBufferTextureHost();
     MOZ_ASSERT(bufferTexture);
     bufferTexture->Lock();
@@ -37,17 +37,17 @@ WrExternalImage LockExternalImage(void* 
     textureOGL->Lock();
 
     return NativeTextureToWrExternalImage(textureOGL->GetGLHandle(),
                                           0, 0,
                                           size.width, size.height);
   }
 }
 
-void UnlockExternalImage(void* aObj, WrExternalImageId aId)
+void UnlockExternalImage(void* aObj, WrExternalImageId aId, uint8_t aChannelIndex)
 {
   RendererOGL* renderer = reinterpret_cast<RendererOGL*>(aObj);
   RenderTextureHost* texture = renderer->GetRenderTexture(aId);
   MOZ_ASSERT(texture);
   texture->Unlock();
 }
 
 RendererOGL::RendererOGL(RefPtr<RenderThread>&& aThread,
--- a/gfx/webrender_bindings/RendererOGL.h
+++ b/gfx/webrender_bindings/RendererOGL.h
@@ -35,18 +35,18 @@ class RenderTextureHost;
 
 /// Owns the WebRender renderer and GL context.
 ///
 /// There is one renderer per window, all owned by the render thread.
 /// This class is a similar abstraction to CompositorOGL except that it is used
 /// on the render thread instead of the compositor thread.
 class RendererOGL
 {
-  friend WrExternalImage LockExternalImage(void* aObj, WrExternalImageId aId);
-  friend void UnlockExternalImage(void* aObj, WrExternalImageId aId);
+  friend WrExternalImage LockExternalImage(void* aObj, WrExternalImageId aId, uint8_t aChannelIndex);
+  friend void UnlockExternalImage(void* aObj, WrExternalImageId aId, uint8_t aChannelIndex);
 
 public:
   WrExternalImageHandler GetExternalImageHandler();
 
   /// This can be called on the render thread only.
   void Update();
 
   /// This can be called on the render thread only.
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -550,32 +550,32 @@ struct WrExternalImage {
     u1: f32,
     v1: f32,
 
     // external image buffer
     buff: *const u8,
     size: usize,
 }
 
-type LockExternalImageCallback = fn(*mut c_void, WrExternalImageId) -> WrExternalImage;
-type UnlockExternalImageCallback = fn(*mut c_void, WrExternalImageId);
+type LockExternalImageCallback = fn(*mut c_void, WrExternalImageId, u8) -> WrExternalImage;
+type UnlockExternalImageCallback = fn(*mut c_void, WrExternalImageId, u8);
 
 #[repr(C)]
 pub struct WrExternalImageHandler {
     external_image_obj: *mut c_void,
     lock_func: LockExternalImageCallback,
     unlock_func: UnlockExternalImageCallback,
 }
 
 impl ExternalImageHandler for WrExternalImageHandler {
     fn lock(&mut self,
             id: ExternalImageId,
-            _channel_index: u8)
+            channel_index: u8)
             -> ExternalImage {
-        let image = (self.lock_func)(self.external_image_obj, id.into());
+        let image = (self.lock_func)(self.external_image_obj, id.into(), channel_index);
 
         match image.image_type {
             WrExternalImageType::NativeTexture => {
                 ExternalImage {
                     u0: image.u0,
                     v0: image.v0,
                     u1: image.u1,
                     v1: image.v1,
@@ -591,18 +591,18 @@ impl ExternalImageHandler for WrExternal
                     source: ExternalImageSource::RawData(make_slice(image.buff, image.size)),
                 }
             },
         }
     }
 
     fn unlock(&mut self,
               id: ExternalImageId,
-              _channel_index: u8) {
-        (self.unlock_func)(self.external_image_obj, id.into());
+              channel_index: u8) {
+        (self.unlock_func)(self.external_image_obj, id.into(), channel_index);
     }
 }
 
 /// cbindgen:field-names=[mHandle]
 /// cbindgen:struct-gen-op-lt=true
 /// cbindgen:struct-gen-op-lte=true
 #[repr(C)]
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
--- a/gfx/webrender_bindings/webrender_ffi_generated.h
+++ b/gfx/webrender_bindings/webrender_ffi_generated.h
@@ -480,19 +480,19 @@ struct WrExternalImage {
       v0 == aOther.v0 &&
       u1 == aOther.u1 &&
       v1 == aOther.v1 &&
       buff == aOther.buff &&
       size == aOther.size;
   }
 };
 
-typedef WrExternalImage (*LockExternalImageCallback)(void*, WrExternalImageId);
+typedef WrExternalImage (*LockExternalImageCallback)(void*, WrExternalImageId, uint8_t);
 
-typedef void (*UnlockExternalImageCallback)(void*, WrExternalImageId);
+typedef void (*UnlockExternalImageCallback)(void*, WrExternalImageId, uint8_t);
 
 struct WrExternalImageHandler {
   void* external_image_obj;
   LockExternalImageCallback lock_func;
   UnlockExternalImageCallback unlock_func;
 
   bool operator==(const WrExternalImageHandler& aOther) const {
     return external_image_obj == aOther.external_image_obj &&