Merge inbound to mozilla-central. a=merge
authorMihai Alexandru Michis <malexandru@mozilla.com>
Mon, 17 Jun 2019 12:59:31 +0300
changeset 479080 8ba01fc4f7e017b5ef1754d435c911c4e3847ef8
parent 479079 82daf65cbe5e55ddefa27e293dfcbfe27af23062 (current diff)
parent 479070 987a32cede5fe6b75c920f2ca13df89134ef0cca (diff)
child 479081 ffde7e3218fb941ac17bd3a9b154965635f863dd
push id113459
push usermalexandru@mozilla.com
push dateMon, 17 Jun 2019 10:07:02 +0000
treeherdermozilla-inbound@8ba01fc4f7e0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone69.0a1
first release with
nightly linux32
8ba01fc4f7e0 / 69.0a1 / 20190617100015 / files
nightly linux64
8ba01fc4f7e0 / 69.0a1 / 20190617100015 / files
nightly mac
8ba01fc4f7e0 / 69.0a1 / 20190617100015 / files
nightly win32
8ba01fc4f7e0 / 69.0a1 / 20190617100015 / files
nightly win64
8ba01fc4f7e0 / 69.0a1 / 20190617100015 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge inbound to mozilla-central. a=merge
--- a/gfx/gl/GLScreenBuffer.cpp
+++ b/gfx/gl/GLScreenBuffer.cpp
@@ -472,17 +472,20 @@ bool GLScreenBuffer::Swap(const gfx::Int
     // uint32_t srcPixel = ReadPixel(src);
     // uint32_t destPixel = ReadPixel(dest);
     // printf_stderr("Before: src: 0x%08x, dest: 0x%08x\n", srcPixel,
     // destPixel);
 #ifdef DEBUG
     GLContext::LocalErrorScope errorScope(*mGL);
 #endif
 
-    SharedSurface::ProdCopy(src, dest, mFactory.get());
+    if (!SharedSurface::ProdCopy(src, dest, mFactory.get())) {
+      newBack->Surf()->ProducerRelease();
+      return false;
+    }
 
 #ifdef DEBUG
     MOZ_ASSERT(!errorScope.GetError());
 #endif
 
     // srcPixel = ReadPixel(src);
     // destPixel = ReadPixel(dest);
     // printf_stderr("After: src: 0x%08x, dest: 0x%08x\n", srcPixel, destPixel);
--- a/gfx/gl/SharedSurface.cpp
+++ b/gfx/gl/SharedSurface.cpp
@@ -8,46 +8,51 @@
 #include "../2d/2D.h"
 #include "GLBlitHelper.h"
 #include "GLContext.h"
 #include "GLReadTexImageHelper.h"
 #include "GLScreenBuffer.h"
 #include "nsThreadUtils.h"
 #include "ScopedGLHelpers.h"
 #include "SharedSurfaceGL.h"
+#include "mozilla/gfx/Logging.h"
 #include "mozilla/layers/CompositorTypes.h"
 #include "mozilla/layers/TextureClientSharedSurface.h"
 #include "mozilla/layers/TextureForwarder.h"
 #include "mozilla/Unused.h"
 #include "VRManagerChild.h"
 
 namespace mozilla {
 namespace gl {
 
 /*static*/
-void SharedSurface::ProdCopy(SharedSurface* src, SharedSurface* dest,
+bool SharedSurface::ProdCopy(SharedSurface* src, SharedSurface* dest,
                              SurfaceFactory* factory) {
   GLContext* gl = src->mGL;
 
   // If `src` begins locked, it must end locked, though we may
   // temporarily unlock it if we need to.
   MOZ_ASSERT((src == gl->GetLockedSurface()) == src->IsLocked());
 
   gl->MakeCurrent();
 
   if (src->mAttachType == AttachmentType::Screen &&
       dest->mAttachType == AttachmentType::Screen) {
     // Here, we actually need to blit through a temp surface, so let's make one.
     UniquePtr<SharedSurface_Basic> tempSurf;
     tempSurf = SharedSurface_Basic::Create(gl, factory->mFormats, src->mSize,
                                            factory->mCaps.alpha);
+    if (!tempSurf) {
+      gfxCriticalNote << "Failed to allocate SharedSurface_Basic.";
+      return false;
+    }
 
     ProdCopy(src, tempSurf.get(), factory);
     ProdCopy(tempSurf.get(), dest, factory);
-    return;
+    return true;
   }
 
   if (src->mAttachType == AttachmentType::Screen) {
     SharedSurface* origLocked = gl->GetLockedSurface();
     bool srcNeedsUnlock = false;
     bool origNeedsRelock = false;
     if (origLocked != src) {
       if (origLocked) {
@@ -76,17 +81,17 @@ void SharedSurface::ProdCopy(SharedSurfa
     } else {
       MOZ_CRASH("GFX: Unhandled dest->mAttachType 1.");
     }
 
     if (srcNeedsUnlock) src->UnlockProd();
 
     if (origNeedsRelock) origLocked->LockProd();
 
-    return;
+    return true;
   }
 
   if (dest->mAttachType == AttachmentType::Screen) {
     SharedSurface* origLocked = gl->GetLockedSurface();
     bool destNeedsUnlock = false;
     bool origNeedsRelock = false;
     if (origLocked != dest) {
       if (origLocked) {
@@ -115,44 +120,44 @@ void SharedSurface::ProdCopy(SharedSurfa
     } else {
       MOZ_CRASH("GFX: Unhandled src->mAttachType 2.");
     }
 
     if (destNeedsUnlock) dest->UnlockProd();
 
     if (origNeedsRelock) origLocked->LockProd();
 
-    return;
+    return true;
   }
 
   // Alright, done with cases involving Screen types.
   // Only {src,dest}x{texture,renderbuffer} left.
 
   if (src->mAttachType == AttachmentType::GLTexture) {
     GLuint srcTex = src->ProdTexture();
     GLenum srcTarget = src->ProdTextureTarget();
 
     if (dest->mAttachType == AttachmentType::GLTexture) {
       GLuint destTex = dest->ProdTexture();
       GLenum destTarget = dest->ProdTextureTarget();
 
       gl->BlitHelper()->BlitTextureToTexture(
           srcTex, destTex, src->mSize, dest->mSize, srcTarget, destTarget);
 
-      return;
+      return true;
     }
 
     if (dest->mAttachType == AttachmentType::GLRenderbuffer) {
       GLuint destRB = dest->ProdRenderbuffer();
       ScopedFramebufferForRenderbuffer destWrapper(gl, destRB);
       const ScopedBindFramebuffer bindFB(gl, destWrapper.FB());
       gl->BlitHelper()->BlitTextureToFramebuffer(srcTex, src->mSize,
                                                  dest->mSize, srcTarget);
 
-      return;
+      return true;
     }
 
     MOZ_CRASH("GFX: Unhandled dest->mAttachType 3.");
   }
 
   if (src->mAttachType == AttachmentType::GLRenderbuffer) {
     GLuint srcRB = src->ProdRenderbuffer();
     ScopedFramebufferForRenderbuffer srcWrapper(gl, srcRB);
@@ -160,27 +165,27 @@ void SharedSurface::ProdCopy(SharedSurfa
     if (dest->mAttachType == AttachmentType::GLTexture) {
       GLuint destTex = dest->ProdTexture();
       GLenum destTarget = dest->ProdTextureTarget();
       const ScopedBindFramebuffer bindFB(gl, srcWrapper.FB());
 
       gl->BlitHelper()->BlitFramebufferToTexture(destTex, src->mSize,
                                                  dest->mSize, destTarget);
 
-      return;
+      return true;
     }
 
     if (dest->mAttachType == AttachmentType::GLRenderbuffer) {
       GLuint destRB = dest->ProdRenderbuffer();
       ScopedFramebufferForRenderbuffer destWrapper(gl, destRB);
 
       gl->BlitHelper()->BlitFramebufferToFramebuffer(
           srcWrapper.FB(), destWrapper.FB(), src->mSize, dest->mSize);
 
-      return;
+      return true;
     }
 
     MOZ_CRASH("GFX: Unhandled dest->mAttachType 4.");
   }
 
   MOZ_CRASH("GFX: Unhandled src->mAttachType 5.");
 }
 
--- a/gfx/gl/SharedSurface.h
+++ b/gfx/gl/SharedSurface.h
@@ -49,17 +49,17 @@ class TextureClient;
 namespace gl {
 
 class GLContext;
 class SurfaceFactory;
 class ShSurfHandle;
 
 class SharedSurface {
  public:
-  static void ProdCopy(SharedSurface* src, SharedSurface* dest,
+  static bool ProdCopy(SharedSurface* src, SharedSurface* dest,
                        SurfaceFactory* factory);
 
   const SharedSurfaceType mType;
   const AttachmentType mAttachType;
   const WeakPtr<GLContext> mGL;
   const gfx::IntSize mSize;
   const bool mHasAlpha;
   const bool mCanRecycle;
--- a/gfx/layers/client/CanvasClient.cpp
+++ b/gfx/layers/client/CanvasClient.cpp
@@ -360,19 +360,23 @@ static already_AddRefed<SharedSurfaceTex
   RefPtr<SharedSurfaceTextureClient> dest = factory->NewTexClient(src->mSize);
   if (!dest) {
     return nullptr;
   }
 
   gl::SharedSurface* destSurf = dest->Surf();
 
   destSurf->ProducerAcquire();
-  SharedSurface::ProdCopy(src, dest->Surf(), factory);
+  bool ret = SharedSurface::ProdCopy(src, dest->Surf(), factory);
   destSurf->ProducerRelease();
 
+  if (!ret) {
+    return nullptr;
+  }
+
   return dest.forget();
 }
 
 void CanvasClientSharedSurface::Update(gfx::IntSize aSize,
                                        ShareableCanvasRenderer* aCanvasRenderer,
                                        wr::RenderRoot aRenderRoot) {
   Renderer renderer;
   renderer.construct<ShareableCanvasRenderer*>(aCanvasRenderer);