Bug 1125422 - Add a flag on ContainerLayer to indicate when the entire subtree of layers needs to be in the dispatch-to-content region. r=roc
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 10 Feb 2015 16:28:07 -0500
changeset 255594 d0a1dd3fbf766de545e920dbccb6c19e95b4b200
parent 255593 22ab837efb3450a6311a0b600e0724caade046f1
child 255595 4a22149431ef9b83fcb2e86f81017d491fd461b7
push id4610
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:32:55 +0000
treeherdermozilla-beta@4df54044d9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1125422
milestone38.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 1125422 - Add a flag on ContainerLayer to indicate when the entire subtree of layers needs to be in the dispatch-to-content region. r=roc
gfx/layers/Layers.cpp
gfx/layers/Layers.h
gfx/layers/ipc/LayerTransactionParent.cpp
gfx/layers/ipc/LayersMessages.ipdlh
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -919,17 +919,18 @@ ContainerLayer::ContainerLayer(LayerMana
     mPreYScale(1.0f),
     mInheritedXScale(1.0f),
     mInheritedYScale(1.0f),
     mPresShellResolution(1.0f),
     mScaleToResolution(false),
     mUseIntermediateSurface(false),
     mSupportsComponentAlphaChildren(false),
     mMayHaveReadbackChild(false),
-    mChildrenChanged(false)
+    mChildrenChanged(false),
+    mForceDispatchToContentRegion(false)
 {
   mContentFlags = 0; // Clear NO_TEXT, NO_TEXT_OVER_TRANSPARENT
 }
 
 ContainerLayer::~ContainerLayer() {}
 
 bool
 ContainerLayer::InsertAfter(Layer* aChild, Layer* aAfter)
@@ -1076,16 +1077,17 @@ ContainerLayer::RepositionChild(Layer* a
 }
 
 void
 ContainerLayer::FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
 {
   aAttrs = ContainerLayerAttributes(mPreXScale, mPreYScale,
                                     mInheritedXScale, mInheritedYScale,
                                     mPresShellResolution, mScaleToResolution,
+                                    mForceDispatchToContentRegion,
                                     reinterpret_cast<uint64_t>(mHMDInfo.get()));
 }
 
 bool
 ContainerLayer::HasMultipleChildren()
 {
   uint32_t count = 0;
   for (Layer* child = GetFirstChild(); child; child = child->GetNextSibling()) {
@@ -1743,16 +1745,19 @@ ContainerLayer::PrintInfo(std::stringstr
     aStream << " [usesTmpSurf]";
   }
   if (1.0 != mPreXScale || 1.0 != mPreYScale) {
     aStream << nsPrintfCString(" [preScale=%g, %g]", mPreXScale, mPreYScale).get();
   }
   if (mScaleToResolution) {
     aStream << nsPrintfCString(" [presShellResolution=%g]", mPresShellResolution).get();
   }
+  if (mForceDispatchToContentRegion) {
+    aStream << " [force-dtc]";
+  }
   if (mHMDInfo) {
     aStream << nsPrintfCString(" [hmd=%p]", mHMDInfo.get()).get();
   }
 }
 
 void
 ContainerLayer::DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent)
 {
--- a/gfx/layers/Layers.h
+++ b/gfx/layers/Layers.h
@@ -911,16 +911,20 @@ public:
    * to be ignored. If a layer has a mask layer, and that mask layer's alpha
    * value is zero at the event point, then the layer and its subtree should
    * be ignored.
    * For each layer, if the point is outside its hit region, we ignore the layer
    * and move onto the next. If the point is inside its hit region but
    * outside the dispatch-to-content region, we can initiate a gesture without
    * consulting the content thread. Otherwise we must dispatch the event to
    * content.
+   * Note that if a layer or any ancestor layer returns true for
+   * GetForceDispatchToContentRegion() then we must treat the dispatch-to-content
+   * region as encompassing the hit region, and therefore must consult the
+   * content thread before initiating a gesture.
    */
   /**
    * CONSTRUCTION PHASE ONLY
    * Set the event handling region.
    */
   void SetEventRegions(const EventRegions& aRegions)
   {
     if (mEventRegions != aRegions) {
@@ -1962,16 +1966,30 @@ public:
    * content flag set.
    */
   static bool HasOpaqueAncestorLayer(Layer* aLayer);
 
   void SetChildrenChanged(bool aVal) {
     mChildrenChanged = aVal;
   }
 
+  void SetForceDispatchToContentRegion(bool aVal) {
+    if (mForceDispatchToContentRegion == aVal) {
+      return;
+    }
+
+    MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ForceDispatchToContentRegion", this));
+    mForceDispatchToContentRegion = aVal;
+    Mutated();
+  }
+
+  bool GetForceDispatchToContentRegion() const {
+    return mForceDispatchToContentRegion;
+  }
+
   /**
    * VR
    */
   void SetVRHMDInfo(gfx::VRHMDInfo* aHMD) { mHMDInfo = aHMD; }
   gfx::VRHMDInfo* GetVRHMDInfo() { return mHMDInfo; }
 
 protected:
   friend class ReadbackProcessor;
@@ -2018,16 +2036,17 @@ protected:
   // Whether the compositor should scale to mPresShellResolution.
   bool mScaleToResolution;
   bool mUseIntermediateSurface;
   bool mSupportsComponentAlphaChildren;
   bool mMayHaveReadbackChild;
   // This is updated by ComputeDifferences. This will be true if we need to invalidate
   // the intermediate surface.
   bool mChildrenChanged;
+  bool mForceDispatchToContentRegion;
   nsRefPtr<gfx::VRHMDInfo> mHMDInfo;
 };
 
 /**
  * A Layer which just renders a solid color in its visible region. It actually
  * can fill any area that contains the visible region, so if you need to
  * restrict the area filled, set a clip region on this layer.
  */
--- a/gfx/layers/ipc/LayerTransactionParent.cpp
+++ b/gfx/layers/ipc/LayerTransactionParent.cpp
@@ -381,16 +381,17 @@ LayerTransactionParent::RecvUpdate(Infal
           return false;
         }
         const ContainerLayerAttributes& attrs =
           specific.get_ContainerLayerAttributes();
         containerLayer->SetPreScale(attrs.preXScale(), attrs.preYScale());
         containerLayer->SetInheritedScale(attrs.inheritedXScale(), attrs.inheritedYScale());
         containerLayer->SetScaleToResolution(attrs.scaleToResolution(),
                                              attrs.presShellResolution());
+        containerLayer->SetForceDispatchToContentRegion(attrs.forceDispatchToContentRegion());
 
         if (attrs.hmdInfo()) {
           if (!IsSameProcess()) {
             NS_WARNING("VR layers currently not supported with cross-process compositing");
             return false;
           }
           containerLayer->SetVRHMDInfo(reinterpret_cast<mozilla::gfx::VRHMDInfo*>(attrs.hmdInfo()));
         }
--- a/gfx/layers/ipc/LayersMessages.ipdlh
+++ b/gfx/layers/ipc/LayersMessages.ipdlh
@@ -229,16 +229,17 @@ struct PaintedLayerAttributes {
 };
 struct ContainerLayerAttributes {
   float preXScale;
   float preYScale;
   float inheritedXScale;
   float inheritedYScale;
   float presShellResolution;
   bool scaleToResolution;
+  bool forceDispatchToContentRegion;
   // This is a bare pointer; LayerTransactionParent::RecvUpdate prevents this
   // from being used when !IsSameProcess(), but we should make this truly
   // cross process at some point by passing the HMDConfig
   uint64_t hmdInfo;
 };
 struct ColorLayerAttributes     { LayerColor color; nsIntRect bounds; };
 struct CanvasLayerAttributes    { GraphicsFilterType filter; nsIntRect bounds; };
 struct RefLayerAttributes       { int64_t id; };