Bug 914426. Don't try to dump DeprecatedTextureHost contents unless HTML tree dumping is enabled. Also, be lenient about null values and unknown formats. r=nrc
authorRobert O'Callahan <robert@ocallahan.org>
Mon, 09 Sep 2013 17:08:42 -0700
changeset 148950 722a17aaa05b211358b40c89a70c34e6b560cd2e
parent 148949 c1f06e0edcf5ca87a7dccb40219a806bac780693
child 148951 10205aaf44cddfe8811e481057e10b14c2d0e326
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersnrc
bugs914426
milestone27.0a1
Bug 914426. Don't try to dump DeprecatedTextureHost contents unless HTML tree dumping is enabled. Also, be lenient about null values and unknown formats. r=nrc
gfx/layers/composite/ContentHost.cpp
gfx/layers/composite/ThebesLayerComposite.cpp
gfx/layers/opengl/TextureHostOGL.cpp
--- a/gfx/layers/composite/ContentHost.cpp
+++ b/gfx/layers/composite/ContentHost.cpp
@@ -224,38 +224,36 @@ ContentHostBase::SetCompositor(Composito
 
 #ifdef MOZ_DUMP_PAINTING
 
 void
 ContentHostBase::Dump(FILE* aFile,
                       const char* aPrefix,
                       bool aDumpHtml)
 {
+  if (!aDumpHtml) {
+    return;
+  }
   if (!aFile) {
     aFile = stderr;
   }
-  if (aDumpHtml) {
-    fprintf(aFile, "<ul>");
-  }
+  fprintf(aFile, "<ul>");
   if (mDeprecatedTextureHost) {
     fprintf(aFile, "%s", aPrefix);
-    fprintf(aFile, aDumpHtml ? "<li> <a href=" : "Front buffer: ");
+    fprintf(aFile, "<li> <a href=");
     DumpDeprecatedTextureHost(aFile, mDeprecatedTextureHost);
-    fprintf(aFile, aDumpHtml ? "> Front buffer </a></li> " : " ");
+    fprintf(aFile, "> Front buffer </a></li> ");
   }
   if (mDeprecatedTextureHostOnWhite) {
     fprintf(aFile, "%s", aPrefix);
-    fprintf(aFile, aDumpHtml ? "<li> <a href=" : "DeprecatedTextureHost on white: ");
+    fprintf(aFile, "<li> <a href=");
     DumpDeprecatedTextureHost(aFile, mDeprecatedTextureHostOnWhite);
-    fprintf(aFile, aDumpHtml ? "> Front buffer on white </a> </li> " : " ");
+    fprintf(aFile, "> Front buffer on white </a> </li> ");
   }
-  if (aDumpHtml) {
-    fprintf(aFile, "</ul>");
-  }
-
+  fprintf(aFile, "</ul>");
 }
 
 #endif
 
 ContentHostSingleBuffered::~ContentHostSingleBuffered()
 {
   DestroyTextures();
   DestroyFrontHost();
@@ -749,38 +747,36 @@ ContentHostDoubleBuffered::PrintInfo(nsA
 
 #ifdef MOZ_DUMP_PAINTING
 void
 ContentHostDoubleBuffered::Dump(FILE* aFile,
                                 const char* aPrefix,
                                 bool aDumpHtml)
 {
   ContentHostBase::Dump(aFile, aPrefix, aDumpHtml);
+  if (!aDumpHtml) {
+    return;
+  }
   if (!aFile) {
     aFile = stderr;
   }
-  if (aDumpHtml) {
-    fprintf(aFile, "<ul>");
-  }
+  fprintf(aFile, "<ul>");
   if (mBackHost) {
     fprintf(aFile, "%s", aPrefix);
-    fprintf(aFile, aDumpHtml ? "<li> <a href=" : "Back buffer: ");
+    fprintf(aFile, "<li> <a href=");
     DumpDeprecatedTextureHost(aFile, mBackHost);
-    fprintf(aFile, aDumpHtml ? " >Back buffer</a></li>" : " ");
+    fprintf(aFile, " >Back buffer</a></li>");
   }
   if (mBackHostOnWhite) {
     fprintf(aFile, "%s", aPrefix);
-    fprintf(aFile, aDumpHtml ? "<li> <a href=" : "Back buffer on white: ");
+    fprintf(aFile, "<li> <a href=");
     DumpDeprecatedTextureHost(aFile, mBackHostOnWhite);
-    fprintf(aFile, aDumpHtml ? " >Back buffer on white</a> </li>" : " ");
+    fprintf(aFile, " >Back buffer on white</a> </li>");
   }
-  if (aDumpHtml) {
-    fprintf(aFile, "</ul>");
-  }
-
+  fprintf(aFile, "</ul>");
 }
 #endif
 
 LayerRenderState
 ContentHostBase::GetRenderState()
 {
   LayerRenderState result = mDeprecatedTextureHost->GetRenderState();
 
--- a/gfx/layers/composite/ThebesLayerComposite.cpp
+++ b/gfx/layers/composite/ThebesLayerComposite.cpp
@@ -109,17 +109,19 @@ ThebesLayerComposite::RenderLayer(const 
 
   gfx::Matrix4x4 transform;
   ToMatrix4x4(GetEffectiveTransform(), transform);
   gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);
 
 #ifdef MOZ_DUMP_PAINTING
   if (gfxUtils::sDumpPainting) {
     nsRefPtr<gfxImageSurface> surf = mBuffer->GetAsSurface();
-    WriteSnapshotToDumpFile(this, surf);
+    if (surf) {
+      WriteSnapshotToDumpFile(this, surf);
+    }
   }
 #endif
 
   EffectChain effectChain;
   LayerManagerComposite::AutoAddMaskEffect autoMaskEffect(mMaskLayer, effectChain);
 
   nsIntRegion visibleRegion = GetEffectiveVisibleRegion();
 
@@ -153,17 +155,17 @@ ThebesLayerComposite::RenderLayer(const 
   }
 
   mCompositeManager->GetCompositor()->MakeCurrent();
 }
 
 CompositableHost*
 ThebesLayerComposite::GetCompositableHost()
 {
-  if ( mBuffer && mBuffer->IsAttached()) {
+  if (mBuffer && mBuffer->IsAttached()) {
     return mBuffer.get();
   }
 
   return nullptr;
 }
 
 void
 ThebesLayerComposite::CleanupResources()
--- a/gfx/layers/opengl/TextureHostOGL.cpp
+++ b/gfx/layers/opengl/TextureHostOGL.cpp
@@ -1083,24 +1083,23 @@ void GrallocDeprecatedTextureHostOGL::Se
     DeleteTextures();
   }
   mCompositor = glCompositor;
 }
 
 gfx::SurfaceFormat
 GrallocDeprecatedTextureHostOGL::GetFormat() const
 {
-  if (mTextureTarget == LOCAL_GL_TEXTURE_EXTERNAL) {
-    return gfx::FORMAT_R8G8B8A8;
+  switch (mTextureTarget) {
+  case LOCAL_GL_TEXTURE_EXTERNAL: return gfx::FORMAT_R8G8B8A8;
+  case LOCAL_GL_TEXTURE_2D: return mFormat;
+  default: return gfx::FORMAT_UNKNOWN;
   }
-  MOZ_ASSERT(mTextureTarget == LOCAL_GL_TEXTURE_2D);
-  return mFormat;
 }
 
-
 void
 GrallocDeprecatedTextureHostOGL::DeleteTextures()
 {
   if (mEGLImage) {
     gl()->MakeCurrent();
     gl()->DestroyEGLImage(mEGLImage);
     mEGLImage = 0;
   }