Bug 1347062 - P2: use WrImageDescriptor for wr_api_add_external_image_handle(). r=nical,sotaro
authorJerryShih <hshih@mozilla.com>
Fri, 31 Mar 2017 22:29:14 +0800
changeset 555316 4b54605f1dcdeb67f5678f3dc1b4e822090344ec
parent 555315 f9813e4134ae48d65dc30ba70b5229c3bb7b16ff
child 555317 5aea276a528332383a3b51a48a46f48bc59a3663
push id52214
push userkgupta@mozilla.com
push dateTue, 04 Apr 2017 02:58:29 +0000
reviewersnical, sotaro
bugs1347062
milestone55.0a1
Bug 1347062 - P2: use WrImageDescriptor for wr_api_add_external_image_handle(). r=nical,sotaro MozReview-Commit-ID: 1dNQRZGeKaA
gfx/webrender_bindings/WebRenderAPI.cpp
gfx/webrender_bindings/WebRenderAPI.h
gfx/webrender_bindings/src/bindings.rs
gfx/webrender_bindings/webrender_ffi.h
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -41,28 +41,28 @@ public:
     MOZ_COUNT_DTOR(NewRenderer);
   }
 
   virtual void Run(RenderThread& aRenderThread, WindowId aWindowId) override
   {
     layers::AutoCompleteTask complete(mTask);
 
     RefPtr<gl::GLContext> gl;
-    if (gfxVars::UseWebRenderANGLE()) {
+    if (gfx::gfxVars::UseWebRenderANGLE()) {
       gl = gl::GLContextProviderEGL::CreateForCompositorWidget(mCompositorWidget, true);
       if (!gl || !gl->IsANGLE()) {
-        gfxCriticalNote << "Failed ANGLE GL context creation for WebRender: " << hexa(gl.get());
+        gfxCriticalNote << "Failed ANGLE GL context creation for WebRender: " << gfx::hexa(gl.get());
         return;
       }
     }
     if (!gl) {
       gl = gl::GLContextProvider::CreateForCompositorWidget(mCompositorWidget, true);
     }
     if (!gl || !gl->MakeCurrent()) {
-      gfxCriticalNote << "Failed GL context creation for WebRender: " << hexa(gl.get());
+      gfxCriticalNote << "Failed GL context creation for WebRender: " << gfx::hexa(gl.get());
       return;
     }
 
     gl->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, mMaxTextureSize);
     *mUseANGLE = gl->IsANGLE();
 
     WrRenderer* wrRenderer = nullptr;
     if (!wr_window_new(aWindowId, mSize.width, mSize.height, gl.get(),
@@ -322,24 +322,22 @@ WebRenderAPI::AddBlobImage(ImageKey key,
   wr_api_add_blob_image(mWrApi,
                         key,
                         &aDescriptor,
                         RangeToByteSlice(aBytes));
 }
 
 void
 WebRenderAPI::AddExternalImageHandle(ImageKey key,
-                                     gfx::IntSize aSize,
-                                     gfx::SurfaceFormat aFormat,
+                                     const ImageDescriptor& aDescriptor,
                                      uint64_t aHandle)
 {
-  auto format = SurfaceFormatToWrImageFormat(aFormat).value();
   wr_api_add_external_image_handle(mWrApi,
                                    key,
-                                   aSize.width, aSize.height, format,
+                                   &aDescriptor,
                                    aHandle);
 }
 
 void
 WebRenderAPI::AddExternalImageBuffer(ImageKey key,
                                      const ImageDescriptor& aDescriptor,
                                      uint64_t aHandle)
 {
--- a/gfx/webrender_bindings/WebRenderAPI.h
+++ b/gfx/webrender_bindings/WebRenderAPI.h
@@ -67,18 +67,17 @@ public:
                 const ImageDescriptor& aDescriptor,
                 Range<uint8_t> aBytes);
 
   void AddBlobImage(wr::ImageKey aKey,
                     const ImageDescriptor& aDescriptor,
                     Range<uint8_t> aBytes);
 
   void AddExternalImageHandle(ImageKey key,
-                              gfx::IntSize aSize,
-                              gfx::SurfaceFormat aFormat,
+                              const ImageDescriptor& aDescriptor,
                               uint64_t aHandle);
 
   void AddExternalImageBuffer(ImageKey key,
                               const ImageDescriptor& aDescriptor,
                               uint64_t aHandle);
 
   void UpdateImageBuffer(wr::ImageKey aKey,
                          const ImageDescriptor& aDescriptor,
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -799,30 +799,21 @@ pub extern "C" fn wr_api_add_blob_image(
                   descriptor.to_descriptor(),
                   ImageData::new_blob_image(copied_bytes),
                   None);
 }
 
 #[no_mangle]
 pub extern "C" fn wr_api_add_external_image_handle(api: &mut RenderApi,
                                                    image_key: ImageKey,
-                                                   width: u32,
-                                                   height: u32,
-                                                   format: ImageFormat,
+                                                   descriptor: &WrImageDescriptor,
                                                    external_image_id: u64) {
     assert!(unsafe { is_in_compositor_thread() });
     api.add_image(image_key,
-                  ImageDescriptor {
-                      width: width,
-                      height: height,
-                      stride: None,
-                      format: format,
-                      is_opaque: false,
-                      offset: 0,
-                  },
+                  descriptor.to_descriptor(),
                   ImageData::ExternalHandle(ExternalImageId(external_image_id)),
                   None);
 }
 
 #[no_mangle]
 pub extern "C" fn wr_api_add_external_image_buffer(api: &mut RenderApi,
                                                    image_key: ImageKey,
                                                    descriptor: &WrImageDescriptor,
--- a/gfx/webrender_bindings/webrender_ffi.h
+++ b/gfx/webrender_bindings/webrender_ffi.h
@@ -540,18 +540,19 @@ WR_INLINE void
 wr_api_add_image(WrAPI* api, WrImageKey key, const WrImageDescriptor* descriptor, const WrByteSlice aSlice)
 WR_FUNC;
 
 WR_INLINE void
 wr_api_add_blob_image(WrAPI* api, WrImageKey key, const WrImageDescriptor* descriptor, const WrByteSlice aSlice)
 WR_FUNC;
 
 WR_INLINE void
-wr_api_add_external_image_handle(WrAPI* api, WrImageKey key, uint32_t width, uint32_t height,
-                                 WrImageFormat format, uint64_t external_image_id)
+wr_api_add_external_image_handle(WrAPI* api, WrImageKey key,
+                                 const WrImageDescriptor* descriptor,
+                                 uint64_t external_image_id)
 WR_FUNC;
 
 WR_INLINE void
 wr_api_add_external_image_buffer(WrAPI* api, WrImageKey key,
                                  const WrImageDescriptor* descriptor,
                                  uint64_t external_image_id)
 WR_FUNC;