Bug 1256373 - Simplify mMaybeHitRegion. r?tn draft
authorBenoit Girard <b56girard@gmail.com>
Mon, 14 Mar 2016 18:45:58 -0400
changeset 340039 6087bbcea58d0a0090b3e6d375969d67a6f1ecf5
parent 340038 618928f007775e90cb0ba5e96d023214d36900c9
child 516130 1fc1889812db1e0647cbd69ebbd3399754d88d9b
push id12891
push userb56girard@gmail.com
push dateMon, 14 Mar 2016 22:46:16 +0000
reviewerstn
bugs1256373
milestone48.0a1
Bug 1256373 - Simplify mMaybeHitRegion. r?tn MozReview-Commit-ID: D34S5iEczPp
layout/base/FrameLayerBuilder.cpp
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -3063,16 +3063,17 @@ SetBackfaceHiddenForLayer(bool aBackface
     aLayer->SetContentFlags(aLayer->GetContentFlags() &
                             ~Layer::CONTENT_BACKFACE_HIDDEN);
   }
 }
 
 template<typename FindOpaqueBackgroundColorCallbackType>
 void ContainerState::FinishPaintedLayerData(PaintedLayerData& aData, FindOpaqueBackgroundColorCallbackType aFindOpaqueBackgroundColor)
 {
+  PROFILER_LABEL("Layout", "FinishPaintedLayerData", js::ProfileEntry::Category::OTHER);
   PaintedLayerData* data = &aData;
 
   if (!data->mLayer) {
     // No layer was recycled, so we create a new one.
     RefPtr<PaintedLayer> paintedLayer = CreatePaintedLayer(data);
     data->mLayer = paintedLayer;
 
     NS_ASSERTION(FindIndexOfLayerIn(mNewChildLayers, paintedLayer) < 0,
@@ -3254,32 +3255,38 @@ void ContainerState::FinishPaintedLayerD
   if (data->mDisableFlattening) {
     flags |= Layer::CONTENT_DISABLE_FLATTENING;
   }
   layer->SetContentFlags(flags);
 
   PaintedLayerData* containingPaintedLayerData =
      mLayerBuilder->GetContainingPaintedLayerData();
   if (containingPaintedLayerData) {
+    PROFILER_LABEL("Layout", "CombineRegion", js::ProfileEntry::Category::OTHER);
     if (!data->mDispatchToContentHitRegion.GetBounds().IsEmpty()) {
+      PROFILER_LABEL("Layout", "CombineRegion1", js::ProfileEntry::Category::OTHER);
       nsRect rect = nsLayoutUtils::TransformFrameRectToAncestor(
         mContainerReferenceFrame,
         data->mDispatchToContentHitRegion.GetBounds(),
         containingPaintedLayerData->mReferenceFrame);
       containingPaintedLayerData->mDispatchToContentHitRegion.Or(
         containingPaintedLayerData->mDispatchToContentHitRegion, rect);
     }
-    if (!data->mMaybeHitRegion.GetBounds().IsEmpty()) {
+    if (!data->mMaybeHitRegion.IsEmpty()) {
+      PROFILER_LABEL("Layout", "CombineRegion2", js::ProfileEntry::Category::OTHER);
       nsRect rect = nsLayoutUtils::TransformFrameRectToAncestor(
         mContainerReferenceFrame,
         data->mMaybeHitRegion.GetBounds(),
         containingPaintedLayerData->mReferenceFrame);
       containingPaintedLayerData->mMaybeHitRegion.Or(
         containingPaintedLayerData->mMaybeHitRegion, rect);
+      printf("Size: %i\n", (int)containingPaintedLayerData->mMaybeHitRegion.GetNumRects());
+      containingPaintedLayerData->mMaybeHitRegion.SimplifyOutward(8);
     }
+    PROFILER_LABEL("Layout", "CombineRegion3", js::ProfileEntry::Category::OTHER);
     nsLayoutUtils::TransformToAncestorAndCombineRegions(
       data->mHitRegion.GetBounds(),
       mContainerReferenceFrame,
       containingPaintedLayerData->mReferenceFrame,
       &containingPaintedLayerData->mHitRegion,
       &containingPaintedLayerData->mMaybeHitRegion);
     nsLayoutUtils::TransformToAncestorAndCombineRegions(
       data->mNoActionRegion.GetBounds(),
@@ -3296,16 +3303,17 @@ void ContainerState::FinishPaintedLayerD
     nsLayoutUtils::TransformToAncestorAndCombineRegions(
       data->mVerticalPanRegion.GetBounds(),
       mContainerReferenceFrame,
       containingPaintedLayerData->mReferenceFrame,
       &containingPaintedLayerData->mVerticalPanRegion,
       &containingPaintedLayerData->mDispatchToContentHitRegion);
 
   } else {
+    PROFILER_LABEL("Layout", "HitRegion", js::ProfileEntry::Category::OTHER);
     EventRegions regions;
     regions.mHitRegion = ScaleRegionToOutsidePixels(data->mHitRegion);
     regions.mNoActionRegion = ScaleRegionToOutsidePixels(data->mNoActionRegion);
     regions.mHorizontalPanRegion = ScaleRegionToOutsidePixels(data->mHorizontalPanRegion);
     regions.mVerticalPanRegion = ScaleRegionToOutsidePixels(data->mVerticalPanRegion);
     // Points whose hit-region status we're not sure about need to be dispatched
     // to the content thread. If a point is in both maybeHitRegion and hitRegion
     // then it's not a "maybe" any more, and doesn't go into the dispatch-to-