Bug 1369677 - Handle RenderTexture lock() failed. r=nical
authorJerryShih <hshih@mozilla.com>
Thu, 31 Aug 2017 03:17:00 -0400
changeset 378021 3442318a1024c691ff97bd1e31bae7889519d6a1
parent 378020 5456ea5ec717f308683bec850c322470f0aff863
child 378022 530358f38866878c5bd86c0ac6801656de6aac62
push id50155
push userryanvm@gmail.com
push dateThu, 31 Aug 2017 18:14:04 +0000
treeherderautoland@3442318a1024 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1369677
milestone57.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 1369677 - Handle RenderTexture lock() failed. r=nical MozReview-Commit-ID: Ghez1SJ6ghf
gfx/webrender_bindings/RenderBufferTextureHost.cpp
gfx/webrender_bindings/RendererOGL.cpp
--- a/gfx/webrender_bindings/RenderBufferTextureHost.cpp
+++ b/gfx/webrender_bindings/RenderBufferTextureHost.cpp
@@ -42,16 +42,20 @@ RenderBufferTextureHost::~RenderBufferTe
 {
   MOZ_COUNT_DTOR_INHERITED(RenderBufferTextureHost, RenderTextureHost);
 }
 
 bool
 RenderBufferTextureHost::Lock()
 {
   if (!mLocked) {
+    if (!GetBuffer()) {
+      // We hit some problems to get the shmem.
+      return false;
+    }
     if (mFormat != gfx::SurfaceFormat::YUV) {
       mSurface = gfx::Factory::CreateWrappingDataSourceSurface(GetBuffer(),
                                                                layers::ImageDataSerializer::GetRGBStride(mDescriptor.get_RGBDescriptor()),
                                                                mSize,
                                                                mFormat);
       if (NS_WARN_IF(!mSurface)) {
         return false;
       }
--- a/gfx/webrender_bindings/RendererOGL.cpp
+++ b/gfx/webrender_bindings/RendererOGL.cpp
@@ -21,33 +21,42 @@ namespace wr {
 wr::WrExternalImage LockExternalImage(void* aObj, wr::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();
-    RenderBufferTextureHost::RenderBufferData data =
-        bufferTexture->GetBufferDataForRender(aChannelIndex);
+
+    if (bufferTexture->Lock()) {
+      RenderBufferTextureHost::RenderBufferData data =
+          bufferTexture->GetBufferDataForRender(aChannelIndex);
 
-    return RawDataToWrExternalImage(data.mData, data.mBufferSize);
+      return RawDataToWrExternalImage(data.mData, data.mBufferSize);
+    } else {
+      return RawDataToWrExternalImage(nullptr, 0);
+    }
   } else {
     // texture handle case
     RenderTextureHostOGL* textureOGL = texture->AsTextureHostOGL();
     MOZ_ASSERT(textureOGL);
 
     textureOGL->SetGLContext(renderer->mGL);
-    textureOGL->Lock();
     gfx::IntSize size = textureOGL->GetSize(aChannelIndex);
-
-    return NativeTextureToWrExternalImage(textureOGL->GetGLHandle(aChannelIndex),
-                                          0, 0,
-                                          size.width, size.height);
+    if (textureOGL->Lock()) {
+      return NativeTextureToWrExternalImage(textureOGL->GetGLHandle(aChannelIndex),
+                                            0, 0,
+                                            size.width, size.height);
+    } else {
+      // Just use 0 for the gl handle if the lock() was failed.
+      return NativeTextureToWrExternalImage(0,
+                                            0, 0,
+                                            size.width, size.height);
+    }
   }
 }
 
 void UnlockExternalImage(void* aObj, wr::WrExternalImageId aId, uint8_t aChannelIndex)
 {
   RendererOGL* renderer = reinterpret_cast<RendererOGL*>(aObj);
   RenderTextureHost* texture = renderer->GetRenderTexture(aId);
   MOZ_ASSERT(texture);