Bug 621601. Part 3: Implement EndEmptyTransaction for D3D10. r=bas,a=joe
authorRobert O'Callahan <robert@ocallahan.org>
Wed, 19 Jan 2011 21:27:54 +1300
changeset 60859 1d293c9ffa95c5af5d9e4e2172bad973ba09247d
parent 60858 4fc581f1ff00e7dcf45fb982c0abd579beb32773
child 60860 710c1a6faf99d74232bfc82b813b922cf7e418b7
push idunknown
push userunknown
push dateunknown
reviewersbas, joe
bugs621601
milestone2.0b10pre
Bug 621601. Part 3: Implement EndEmptyTransaction for D3D10. r=bas,a=joe
gfx/layers/d3d10/LayerManagerD3D10.cpp
gfx/layers/d3d10/LayerManagerD3D10.h
gfx/layers/d3d10/ThebesLayerD3D10.cpp
--- a/gfx/layers/d3d10/LayerManagerD3D10.cpp
+++ b/gfx/layers/d3d10/LayerManagerD3D10.cpp
@@ -266,16 +266,26 @@ LayerManagerD3D10::BeginTransaction()
 }
 
 void
 LayerManagerD3D10::BeginTransactionWithTarget(gfxContext* aTarget)
 {
   mTarget = aTarget;
 }
 
+bool
+LayerManagerD3D10::EndEmptyTransaction()
+{
+  if (!mRoot)
+    return false;
+
+  EndTransaction(nsnull, nsnull);
+  return true;
+}
+
 void
 LayerManagerD3D10::EndTransaction(DrawThebesLayerCallback aCallback,
                                   void* aCallbackData)
 {
   mCurrentCallbackInfo.Callback = aCallback;
   mCurrentCallbackInfo.CallbackData = aCallbackData;
 
   // The results of our drawing always go directly into a pixel buffer,
--- a/gfx/layers/d3d10/LayerManagerD3D10.h
+++ b/gfx/layers/d3d10/LayerManagerD3D10.h
@@ -92,27 +92,29 @@ public:
 
   /*
    * LayerManager implementation.
    */
   virtual void Destroy();
 
   virtual void SetRoot(Layer *aLayer);
 
-  void BeginTransaction();
+  virtual void BeginTransaction();
 
-  void BeginTransactionWithTarget(gfxContext* aTarget);
+  virtual void BeginTransactionWithTarget(gfxContext* aTarget);
+
+  virtual bool EndEmptyTransaction();
 
   struct CallbackInfo {
     DrawThebesLayerCallback Callback;
     void *CallbackData;
   };
 
-  void EndTransaction(DrawThebesLayerCallback aCallback,
-                      void* aCallbackData);
+  virtual void EndTransaction(DrawThebesLayerCallback aCallback,
+                              void* aCallbackData);
 
   const CallbackInfo &GetCallbackInfo() { return mCurrentCallbackInfo; }
 
   virtual already_AddRefed<ThebesLayer> CreateThebesLayer();
 
   virtual already_AddRefed<ContainerLayer> CreateContainerLayer();
 
   virtual already_AddRefed<ImageLayer> CreateImageLayer();
--- a/gfx/layers/d3d10/ThebesLayerD3D10.cpp
+++ b/gfx/layers/d3d10/ThebesLayerD3D10.cpp
@@ -211,16 +211,22 @@ ThebesLayerD3D10::Validate()
   nsIntRect visibleRect = mVisibleRegion.GetBounds();
 
   if (!mTexture) {
     CreateNewTexture(gfxIntSize(visibleRect.width, visibleRect.height));
     mValidRegion.SetEmpty();
   }
 
   if (!mValidRegion.IsEqual(mVisibleRegion)) {
+    LayerManagerD3D10::CallbackInfo cbInfo = mD3DManager->GetCallbackInfo();
+    if (!cbInfo.Callback) {
+      NS_ERROR("D3D10 should never need to update ThebesLayers in an empty transaction");
+      return;
+    }
+
     /* We use the bounds of the visible region because we draw the bounds of
      * this region when we draw this entire texture. We have to make sure that
      * the areas that aren't filled with content get their background drawn.
      * This is an issue for opaque surfaces, which otherwise won't get their
      * background painted.
      */
     nsIntRegion region;
     region.Sub(mVisibleRegion, mValidRegion);