Bug 1404518 - Return when OpenSharedTexture is false; r?jgilbert draft
authorDaosheng Mu <daoshengmu@gmail.com>
Mon, 02 Oct 2017 14:32:07 +0800
changeset 674022 f56afae6e76fb7b0193c90acef003b995d9ca29b
parent 673165 44643fce30b43a8981535c335aaccb45006e456b
child 734197 e0b50188d76d2809d0af7054a4a70b8b544945c4
push id82695
push userbmo:dmu@mozilla.com
push dateTue, 03 Oct 2017 02:05:34 +0000
reviewersjgilbert
bugs1404518
milestone58.0a1
Bug 1404518 - Return when OpenSharedTexture is false; r?jgilbert MozReview-Commit-ID: EIChMhAt5Hk
gfx/gl/GLBlitHelperD3D.cpp
--- a/gfx/gl/GLBlitHelperD3D.cpp
+++ b/gfx/gl/GLBlitHelperD3D.cpp
@@ -54,17 +54,17 @@ StreamFromD3DTexture(ID3D11Texture2D* co
 
 static RefPtr<ID3D11Texture2D>
 OpenSharedTexture(ID3D11Device* const d3d, const WindowsHandle handle)
 {
     RefPtr<ID3D11Texture2D> tex;
     auto hr = d3d->OpenSharedResource((HANDLE)handle, __uuidof(ID3D11Texture2D),
                                       (void**)(ID3D11Texture2D**)getter_AddRefs(tex));
     if (FAILED(hr)) {
-        MOZ_ASSERT(false, "OpenSharedResource should not fail");
+        gfxCriticalError() << "Error code from OpenSharedResource: " << gfx::hexa(hr);
         return nullptr;
     }
     return tex;
 }
 
 // -------------------------------------
 
 class BindAnglePlanes final
@@ -260,16 +260,20 @@ GLBlitHelper::BlitDescriptor(const layer
 
     if (format != gfx::SurfaceFormat::NV12) {
         gfxCriticalError() << "Non-NV12 format for SurfaceDescriptorD3D10: "
                            << uint32_t(format);
         return false;
     }
 
     const auto tex = OpenSharedTexture(d3d, handle);
+    if (!tex) {
+        MOZ_ASSERT(false, "Get a nullptr from OpenSharedResource.");
+        return false;
+    }
     const RefPtr<ID3D11Texture2D> texList[2] = { tex, tex };
     const EGLAttrib postAttribs0[] = {
         LOCAL_EGL_NATIVE_BUFFER_PLANE_OFFSET_IMG, 0,
         LOCAL_EGL_NONE
     };
     const EGLAttrib postAttribs1[] = {
         LOCAL_EGL_NATIVE_BUFFER_PLANE_OFFSET_IMG, 1,
         LOCAL_EGL_NONE