Bug 1147894 - Only use non-null compositors with TextureHost::SetCompositor. r=sotaro
authorNicolas Silva <nsilva@mozilla.com>
Fri, 27 Mar 2015 11:16:18 +0100
changeset 266409 f39fd4c98562e02f71a7e1797f9763bbdf869575
parent 266408 1df07e80e3c7a8a127b95d0f98b71a4af77300df
child 266410 f1dfed74dc9a6cba35b71a9c163966c617de34c6
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssotaro
bugs1147894
milestone39.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 1147894 - Only use non-null compositors with TextureHost::SetCompositor. r=sotaro
gfx/layers/composite/CanvasLayerComposite.cpp
gfx/layers/composite/CompositableHost.cpp
gfx/layers/composite/PaintedLayerComposite.cpp
gfx/layers/composite/TextureHost.cpp
gfx/layers/composite/TiledContentHost.cpp
gfx/layers/d3d11/TextureD3D11.cpp
gfx/layers/d3d9/TextureD3D9.cpp
gfx/layers/opengl/GrallocTextureHost.cpp
gfx/layers/opengl/TextureHostOGL.cpp
--- a/gfx/layers/composite/CanvasLayerComposite.cpp
+++ b/gfx/layers/composite/CanvasLayerComposite.cpp
@@ -61,17 +61,17 @@ CanvasLayerComposite::GetLayer()
   return this;
 }
 
 void
 CanvasLayerComposite::SetLayerManager(LayerManagerComposite* aManager)
 {
   LayerComposite::SetLayerManager(aManager);
   mManager = aManager;
-  if (mImageHost) {
+  if (mImageHost && mCompositor) {
     mImageHost->SetCompositor(mCompositor);
   }
 }
 
 LayerRenderState
 CanvasLayerComposite::GetRenderState()
 {
   if (mDestroyed || !mImageHost || !mImageHost->IsAttached()) {
--- a/gfx/layers/composite/CompositableHost.cpp
+++ b/gfx/layers/composite/CompositableHost.cpp
@@ -114,27 +114,30 @@ CompositableHost::UseTextureHost(Texture
   }
 }
 
 void
 CompositableHost::UseComponentAlphaTextures(TextureHost* aTextureOnBlack,
                                             TextureHost* aTextureOnWhite)
 {
   MOZ_ASSERT(aTextureOnBlack && aTextureOnWhite);
-  aTextureOnBlack->SetCompositor(GetCompositor());
-  aTextureOnWhite->SetCompositor(GetCompositor());
+  if (GetCompositor()) {
+    aTextureOnBlack->SetCompositor(GetCompositor());
+    aTextureOnWhite->SetCompositor(GetCompositor());
+  }
 }
 
 void
 CompositableHost::RemoveTextureHost(TextureHost* aTexture)
 {}
 
 void
 CompositableHost::SetCompositor(Compositor* aCompositor)
 {
+  MOZ_ASSERT(aCompositor);
   mCompositor = aCompositor;
 }
 
 bool
 CompositableHost::AddMaskEffect(EffectChain& aEffects,
                                 const gfx::Matrix4x4& aTransform,
                                 bool aIs3D)
 {
--- a/gfx/layers/composite/PaintedLayerComposite.cpp
+++ b/gfx/layers/composite/PaintedLayerComposite.cpp
@@ -84,17 +84,17 @@ PaintedLayerComposite::GetLayer()
   return this;
 }
 
 void
 PaintedLayerComposite::SetLayerManager(LayerManagerComposite* aManager)
 {
   LayerComposite::SetLayerManager(aManager);
   mManager = aManager;
-  if (mBuffer) {
+  if (mBuffer && mCompositor) {
     mBuffer->SetCompositor(mCompositor);
   }
 }
 
 TiledLayerComposer*
 PaintedLayerComposite::GetTiledLayerComposer()
 {
   if (!mBuffer) {
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -404,16 +404,17 @@ BufferTextureHost::Updated(const nsIntRe
     DebugOnly<bool> result = MaybeUpload(!mNeedsFullUpdate ? &mMaybeUpdatedRegion : nullptr);
     NS_WARN_IF_FALSE(result, "Failed to upload a texture");
   }
 }
 
 void
 BufferTextureHost::SetCompositor(Compositor* aCompositor)
 {
+  MOZ_ASSERT(aCompositor);
   if (mCompositor == aCompositor) {
     return;
   }
   RefPtr<TextureSource> it = mFirstSource;
   while (it) {
     it->SetCompositor(aCompositor);
     it = it->GetNextSibling();
   }
--- a/gfx/layers/composite/TiledContentHost.cpp
+++ b/gfx/layers/composite/TiledContentHost.cpp
@@ -207,16 +207,17 @@ TiledLayerBufferComposite::ValidateTile(
   }
 #endif
   return aTile;
 }
 
 void
 TiledLayerBufferComposite::SetCompositor(Compositor* aCompositor)
 {
+  MOZ_ASSERT(aCompositor);
   if (!IsValid()) {
     return;
   }
   for (size_t i = 0; i < mRetainedTiles.Length(); i++) {
     if (mRetainedTiles[i].IsPlaceholderTile()) continue;
     mRetainedTiles[i].mTextureHost->SetCompositor(aCompositor);
     if (mRetainedTiles[i].mTextureHostOnWhite) {
       mRetainedTiles[i].mTextureHostOnWhite->SetCompositor(aCompositor);
@@ -386,16 +387,17 @@ TiledContentHost::UseTiledLayerBuffer(IS
 void
 TiledContentHost::Composite(EffectChain& aEffectChain,
                             float aOpacity,
                             const gfx::Matrix4x4& aTransform,
                             const gfx::Filter& aFilter,
                             const gfx::Rect& aClipRect,
                             const nsIntRegion* aVisibleRegion /* = nullptr */)
 {
+  MOZ_ASSERT(mCompositor);
   if (mPendingUpload) {
     mTiledBuffer.SetCompositor(mCompositor);
     mTiledBuffer.Upload();
 
     // For a single-buffered tiled buffer, Upload will upload the shared memory
     // surface to texture memory and we no longer need to read from them.
     if (!mTiledBuffer.HasDoubleBufferedTiles()) {
       mTiledBuffer.ReadUnlock();
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -600,16 +600,17 @@ ID3D11Device*
 DXGITextureHostD3D11::GetDevice()
 {
   return gfxWindowsPlatform::GetPlatform()->GetD3D11Device();
 }
 
 void
 DXGITextureHostD3D11::SetCompositor(Compositor* aCompositor)
 {
+  MOZ_ASSERT(aCompositor);
   mCompositor = static_cast<CompositorD3D11*>(aCompositor);
 }
 
 bool
 DXGITextureHostD3D11::Lock()
 {
   if (!GetDevice()) {
     NS_WARNING("trying to lock a TextureHost without a D3D device");
@@ -694,16 +695,17 @@ ID3D11Device*
 DXGIYCbCrTextureHostD3D11::GetDevice()
 {
   return gfxWindowsPlatform::GetPlatform()->GetD3D11Device();
 }
 
 void
 DXGIYCbCrTextureHostD3D11::SetCompositor(Compositor* aCompositor)
 {
+  MOZ_ASSERT(aCompositor);
   mCompositor = static_cast<CompositorD3D11*>(aCompositor);
 }
 
 bool
 DXGIYCbCrTextureHostD3D11::Lock()
 {
   if (!GetDevice()) {
     NS_WARNING("trying to lock a TextureHost without a D3D device");
@@ -881,16 +883,17 @@ DataTextureSourceD3D11::GetTileRect()
 {
   IntRect rect = GetTileRect(mCurrentTile);
   return nsIntRect(rect.x, rect.y, rect.width, rect.height);
 }
 
 void
 DataTextureSourceD3D11::SetCompositor(Compositor* aCompositor)
 {
+  MOZ_ASSERT(aCompositor);
   CompositorD3D11* d3dCompositor = static_cast<CompositorD3D11*>(aCompositor);
   if (mCompositor && mCompositor != d3dCompositor) {
     Reset();
   }
   mCompositor = d3dCompositor;
 }
 
 CompositingRenderTargetD3D11::CompositingRenderTargetD3D11(ID3D11Texture2D* aTexture,
--- a/gfx/layers/d3d9/TextureD3D9.cpp
+++ b/gfx/layers/d3d9/TextureD3D9.cpp
@@ -512,16 +512,17 @@ DataTextureSourceD3D9::Update(gfxWindows
   }
 
   return true;
 }
 
 void
 DataTextureSourceD3D9::SetCompositor(Compositor* aCompositor)
 {
+  MOZ_ASSERT(aCompositor);
   CompositorD3D9* d3dCompositor = static_cast<CompositorD3D9*>(aCompositor);
   if (mCompositor && mCompositor != d3dCompositor) {
     Reset();
   }
   mCompositor = d3dCompositor;
 }
 
 void
@@ -1022,16 +1023,17 @@ DXGITextureHostD3D9::Unlock()
 {
   MOZ_ASSERT(mIsLocked);
   mIsLocked = false;
 }
 
 void
 DXGITextureHostD3D9::SetCompositor(Compositor* aCompositor)
 {
+  MOZ_ASSERT(aCompositor);
   mCompositor = static_cast<CompositorD3D9*>(aCompositor);
 }
 
 void
 DXGITextureHostD3D9::DeallocateDeviceData()
 {
   mTextureSource = nullptr;
 }
@@ -1053,16 +1055,17 @@ IDirect3DDevice9*
 DXGIYCbCrTextureHostD3D9::GetDevice()
 {
   return mCompositor ? mCompositor->device() : nullptr;
 }
 
 void
 DXGIYCbCrTextureHostD3D9::SetCompositor(Compositor* aCompositor)
 {
+  MOZ_ASSERT(aCompositor);
   mCompositor = static_cast<CompositorD3D9*>(aCompositor);
 }
 
 bool
 DXGIYCbCrTextureHostD3D9::Lock()
 {
   if (!GetDevice()) {
     NS_WARNING("trying to lock a TextureHost without a D3D device");
--- a/gfx/layers/opengl/GrallocTextureHost.cpp
+++ b/gfx/layers/opengl/GrallocTextureHost.cpp
@@ -122,16 +122,17 @@ GrallocTextureHostOGL::GrallocTextureHos
 GrallocTextureHostOGL::~GrallocTextureHostOGL()
 {
   DestroyEGLImage();
 }
 
 void
 GrallocTextureHostOGL::SetCompositor(Compositor* aCompositor)
 {
+  MOZ_ASSERT(aCompositor);
   mCompositor = static_cast<CompositorOGL*>(aCompositor);
   if (mGLTextureSource) {
     mGLTextureSource->SetCompositor(mCompositor);
   }
 
   if (mCompositor && aCompositor != mCompositor) {
     DestroyEGLImage();
   }
--- a/gfx/layers/opengl/TextureHostOGL.cpp
+++ b/gfx/layers/opengl/TextureHostOGL.cpp
@@ -304,16 +304,17 @@ TextureImageTextureSourceOGL::CopyTo(con
   mCompositor->BlitTextureImageHelper()->BlitTextureImage(mTexImage, aSourceRect,
                                                   dest->mTexImage, aDestRect);
   dest->mTexImage->MarkValid();
 }
 
 void
 TextureImageTextureSourceOGL::SetCompositor(Compositor* aCompositor)
 {
+  MOZ_ASSERT(aCompositor);
   CompositorOGL* glCompositor = static_cast<CompositorOGL*>(aCompositor);
 
   if (!glCompositor || (mCompositor != glCompositor)) {
     DeallocateDeviceData();
     mCompositor = glCompositor;
   }
 }
 
@@ -409,16 +410,17 @@ GLTextureSource::BindTexture(GLenum aTex
   gl()->fActiveTexture(aTextureUnit);
   gl()->fBindTexture(mTextureTarget, mTextureHandle);
   ApplyFilterToBoundTexture(gl(), aFilter, mTextureTarget);
 }
 
 void
 GLTextureSource::SetCompositor(Compositor* aCompositor)
 {
+  MOZ_ASSERT(aCompositor);
   mCompositor = static_cast<CompositorOGL*>(aCompositor);
 }
 
 bool
 GLTextureSource::IsValid() const
 {
   return !!gl() && mTextureHandle != 0;
 }
@@ -467,16 +469,17 @@ SurfaceTextureSource::BindTexture(GLenum
   mSurfTex->UpdateTexImage();
 
   ApplyFilterToBoundTexture(gl(), aFilter, mTextureTarget);
 }
 
 void
 SurfaceTextureSource::SetCompositor(Compositor* aCompositor)
 {
+  MOZ_ASSERT(aCompositor);
   if (mCompositor != aCompositor) {
     DeallocateDeviceData();
   }
 
   mCompositor = static_cast<CompositorOGL*>(aCompositor);
 }
 
 bool
@@ -548,16 +551,17 @@ void
 SurfaceTextureHost::Unlock()
 {
   mSurfTex->Detach();
 }
 
 void
 SurfaceTextureHost::SetCompositor(Compositor* aCompositor)
 {
+  MOZ_ASSERT(aCompositor);
   CompositorOGL* glCompositor = static_cast<CompositorOGL*>(aCompositor);
   mCompositor = glCompositor;
   if (mTextureSource) {
     mTextureSource->SetCompositor(glCompositor);
   }
 }
 
 gfx::SurfaceFormat
@@ -608,16 +612,17 @@ EGLImageTextureSource::BindTexture(GLenu
   gl()->fEGLImageTargetTexture2D(LOCAL_GL_TEXTURE_2D, mImage);
 
   ApplyFilterToBoundTexture(gl(), aFilter, mTextureTarget);
 }
 
 void
 EGLImageTextureSource::SetCompositor(Compositor* aCompositor)
 {
+  MOZ_ASSERT(aCompositor);
   mCompositor = static_cast<CompositorOGL*>(aCompositor);
 }
 
 bool
 EGLImageTextureSource::IsValid() const
 {
   return !!gl();
 }
@@ -689,16 +694,17 @@ EGLImageTextureHost::Lock()
 void
 EGLImageTextureHost::Unlock()
 {
 }
 
 void
 EGLImageTextureHost::SetCompositor(Compositor* aCompositor)
 {
+  MOZ_ASSERT(aCompositor);
   CompositorOGL* glCompositor = static_cast<CompositorOGL*>(aCompositor);
   mCompositor = glCompositor;
   if (mTextureSource) {
     mTextureSource->SetCompositor(glCompositor);
   }
 }
 
 gfx::SurfaceFormat