Bug 1256045 - Add a null-check in BufferTextureHost::EnsureWrappingTextureSource. r=jnicol a=ritu
authorNicolas Silva <nsilva@mozilla.com>
Fri, 18 Mar 2016 16:16:06 +0100
changeset 324497 3ab8e6e778285d31984675edfdadffac9f4e2a7a
parent 324496 1ec38a5dd866c76cb254cb2316598b9690c9fdba
child 324498 2516691981a36595ca0bd33e50aa5508423f33d8
push id6038
push userkwierso@gmail.com
push dateTue, 31 May 2016 23:02:48 +0000
treeherdermozilla-beta@cf6ec12bd620 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjnicol, ritu
bugs1256045
milestone47.0
Bug 1256045 - Add a null-check in BufferTextureHost::EnsureWrappingTextureSource. r=jnicol a=ritu
gfx/layers/composite/TextureHost.cpp
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -511,16 +511,26 @@ BufferTextureHost::EnsureWrappingTexture
     gfx::Factory::CreateWrappingDataSourceSurface(GetBuffer(),
       ImageDataSerializer::ComputeRGBStride(mFormat, mSize.width), mSize, mFormat);
 
   if (!surf) {
     return false;
   }
 
   mFirstSource = mCompositor->CreateDataTextureSourceAround(surf);
+  if (!mFirstSource) {
+    // BasicCompositor::CreateDataTextureSourceAround never returns null
+    // and we don't expect to take this branch if we are using another backend.
+    // Returning false is fine but if we get into this situation it probably
+    // means something fishy is going on, like a texture being used with
+    // several compositor backends.
+    NS_WARNING("Failed to use a BufferTextureHost without intermediate buffer");
+    return false;
+  }
+
   mFirstSource->SetUpdateSerial(mUpdateSerial);
   mFirstSource->SetOwner(this);
 
   return true;
 }
 
 void
 BufferTextureHost::PrepareTextureSource(CompositableTextureSourceRef& aTexture)