Bug 1130328 - Part 1: Add support for an optional frame-space damage rect to nsIFrame::InvalidateLayer. r=mattwoodrow, a=sledru
authorSeth Fowler <seth@mozilla.com>
Wed, 11 Feb 2015 01:11:41 -0800
changeset 243765 eb77152f1233
parent 243764 6c0ded9eb9aa
child 243766 95d83f3422fc
push id4468
push userryanvm@gmail.com
push date2015-02-12 16:23 +0000
treeherdermozilla-beta@57f79302248f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow, sledru
bugs1130328
milestone36.0
Bug 1130328 - Part 1: Add support for an optional frame-space damage rect to nsIFrame::InvalidateLayer. r=mattwoodrow, a=sledru
dom/media/VideoFrameContainer.cpp
layout/generic/nsFrame.cpp
layout/generic/nsIFrame.h
--- a/dom/media/VideoFrameContainer.cpp
+++ b/dom/media/VideoFrameContainer.cpp
@@ -136,17 +136,17 @@ void VideoFrameContainer::InvalidateWith
   bool asyncInvalidate = mImageContainer &&
                          mImageContainer->IsAsync() &&
                          !(aFlags & INVALIDATE_FORCE);
 
   if (frame) {
     if (invalidateFrame) {
       frame->InvalidateFrame();
     } else {
-      frame->InvalidateLayer(nsDisplayItem::TYPE_VIDEO, nullptr,
+      frame->InvalidateLayer(nsDisplayItem::TYPE_VIDEO, nullptr, nullptr,
                              asyncInvalidate ? nsIFrame::UPDATE_IS_ASYNC : 0);
     }
   }
 
   nsSVGEffects::InvalidateDirectRenderingObservers(mElement);
 }
 
 }
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -5171,51 +5171,62 @@ nsIFrame::SchedulePaint(PaintType aType)
   if (shell) {
     shell->AddInvalidateHiddenPresShellObserver(pres->RefreshDriver());
   }
 }
 
 Layer*
 nsIFrame::InvalidateLayer(uint32_t aDisplayItemKey,
                           const nsIntRect* aDamageRect,
+                          const nsRect* aFrameDamageRect,
                           uint32_t aFlags /* = 0 */)
 {
   NS_ASSERTION(aDisplayItemKey > 0, "Need a key");
 
   Layer* layer = FrameLayerBuilder::GetDedicatedLayer(this, aDisplayItemKey);
 
   // If the layer is being updated asynchronously, and it's being forwarded
   // to a compositor, then we don't need to invalidate.
   if ((aFlags & UPDATE_IS_ASYNC) && layer &&
       layer->Manager()->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
     return layer;
   }
 
-  if (aDamageRect && aDamageRect->IsEmpty()) {
-    return layer;
-  }
-
   if (!layer) {
+    if (aFrameDamageRect && aFrameDamageRect->IsEmpty()) {
+      return nullptr;
+    }
+
     // Plugins can transition from not rendering anything to rendering,
     // and still only call this. So always invalidate, with specifying
     // the display item type just in case.
     //
     // In the bug 930056, dialer app startup but not shown on the
     // screen because sometimes we don't have any retainned data
     // for remote type displayitem and thus Repaint event is not
     // triggered. So, always invalidate here as well.
+    uint32_t displayItemKey = aDisplayItemKey;
     if (aDisplayItemKey == nsDisplayItem::TYPE_PLUGIN ||
         aDisplayItemKey == nsDisplayItem::TYPE_REMOTE) {
-      InvalidateFrame();
+      displayItemKey = 0;
+    }
+
+    if (aFrameDamageRect) {
+      InvalidateFrameWithRect(*aFrameDamageRect, displayItemKey);
     } else {
-      InvalidateFrame(aDisplayItemKey);
-    }
+      InvalidateFrame(displayItemKey);
+    }
+
     return nullptr;
   }
 
+  if (aDamageRect && aDamageRect->IsEmpty()) {
+    return layer;
+  }
+
   if (aDamageRect) {
     layer->AddInvalidRect(*aDamageRect);
   } else {
     layer->SetInvalidRectToVisibleRegion();
   }
 
   SchedulePaint(PAINT_COMPOSITE_ONLY);
   return layer;
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -2222,26 +2222,32 @@ public:
   /**
    * Checks if the layer tree includes a dedicated layer for this 
    * frame/display item key pair, and invalidates at least aDamageRect
    * area within that layer.
    *
    * If no layer is found, calls InvalidateFrame() instead.
    *
    * @param aDamageRect Area of the layer to invalidate.
+   * @param aFrameDamageRect If no layer is found, the area of the frame to
+   *                         invalidate. If null, the entire frame will be
+   *                         invalidated.
    * @param aDisplayItemKey Display item type.
    * @param aFlags UPDATE_IS_ASYNC : Will skip the invalidation
    * if the found layer is being composited by a remote
    * compositor.
    * @return Layer, if found, nullptr otherwise.
    */
   enum {
     UPDATE_IS_ASYNC = 1 << 0
   };
-  Layer* InvalidateLayer(uint32_t aDisplayItemKey, const nsIntRect* aDamageRect = nullptr, uint32_t aFlags = 0);
+  Layer* InvalidateLayer(uint32_t aDisplayItemKey,
+                         const nsIntRect* aDamageRect = nullptr,
+                         const nsRect* aFrameDamageRect = nullptr,
+                         uint32_t aFlags = 0);
 
   /**
    * Returns a rect that encompasses everything that might be painted by
    * this frame.  This includes this frame, all its descendent frames, this
    * frame's outline, and descentant frames' outline, but does not include
    * areas clipped out by the CSS "overflow" and "clip" properties.
    *
    * HasOverflowRects() (below) will return true when this overflow