Bug 1256045 - Add a null-check in BufferTextureHost::EnsureWrappingTextureSource. r=jnicol
authorNicolas Silva <nsilva@mozilla.com>
Fri, 18 Mar 2016 16:16:06 +0100
changeset 289362 7960c66bd18957d88369ba0028000d5197564a81
parent 289361 dc66a53a75fdd729307c7c675d0141d7392da994
child 289363 a5bd947546623f30a25113b0bb996d781ff938f2
push id30102
push userryanvm@gmail.com
push dateSat, 19 Mar 2016 15:23:17 +0000
treeherdermozilla-central@720fb3d55e28 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjnicol
bugs1256045
milestone48.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 1256045 - Add a null-check in BufferTextureHost::EnsureWrappingTextureSource. r=jnicol
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)