Bug 1257288 - Move IntersectMaybeRects() to gfx/2d/Rect.h. r=kats
authorBotond Ballo <botond@mozilla.com>
Wed, 20 Apr 2016 17:16:09 -0400
changeset 332438 f579f80a80b9a15f7551d36b94ef7264969a3f7d
parent 332437 cf2cff1fd1942412e36586ab9c42d5baed7cb454
child 332439 2d88322c06d8f6504d5bef899bbb91d0fa79a989
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1257288
milestone48.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 1257288 - Move IntersectMaybeRects() to gfx/2d/Rect.h. r=kats MozReview-Commit-ID: C99GwsLN7Zg
gfx/2d/Rect.h
gfx/layers/composite/AsyncCompositionManager.cpp
gfx/layers/composite/LayerManagerComposite.cpp
--- a/gfx/2d/Rect.h
+++ b/gfx/2d/Rect.h
@@ -6,16 +6,17 @@
 #ifndef MOZILLA_GFX_RECT_H_
 #define MOZILLA_GFX_RECT_H_
 
 #include "BaseRect.h"
 #include "BaseMargin.h"
 #include "NumericTools.h"
 #include "Point.h"
 #include "Tools.h"
+#include "mozilla/Maybe.h"
 
 #include <cmath>
 
 namespace mozilla {
 
 template <typename> struct IsPixel;
 
 namespace gfx {
@@ -239,12 +240,27 @@ IntRectTyped<units> TruncatedToInt(const
 }
 
 template<class units>
 RectTyped<units> IntRectToRect(const IntRectTyped<units>& aRect)
 {
   return RectTyped<units>(aRect.x, aRect.y, aRect.width, aRect.height);
 }
 
+// Convenience function for intersecting two IntRects wrapped in Maybes.
+template <typename Units>
+Maybe<IntRectTyped<Units>>
+IntersectMaybeRects(const Maybe<IntRectTyped<Units>>& a,
+                    const Maybe<IntRectTyped<Units>>& b)
+{
+  if (!a) {
+    return b;
+  } else if (!b) {
+    return a;
+  } else {
+    return Some(a->Intersect(*b));
+  }
+}
+
 } // namespace gfx
 } // namespace mozilla
 
 #endif /* MOZILLA_GFX_RECT_H_ */
--- a/gfx/layers/composite/AsyncCompositionManager.cpp
+++ b/gfx/layers/composite/AsyncCompositionManager.cpp
@@ -777,30 +777,16 @@ MoveScrollbarForLayerMargin(Layer* aRoot
       // assuming a particular layer tree structure but short of adding more
       // flags to the layer there doesn't appear to be a good way to do this.
       ExpandRootClipRect(scrollbar->GetParent(), aFixedLayerMargins);
     }
   }
 }
 #endif
 
-template <typename Units>
-Maybe<IntRectTyped<Units>>
-IntersectMaybeRects(const Maybe<IntRectTyped<Units>>& a,
-                    const Maybe<IntRectTyped<Units>>& b)
-{
-  if (!a) {
-    return b;
-  } else if (!b) {
-    return a;
-  } else {
-    return Some(a->Intersect(*b));
-  }
-}
-
 bool
 AsyncCompositionManager::ApplyAsyncContentTransformToTree(Layer *aLayer,
                                                           bool* aOutFoundRoot,
                                                           Maybe<ParentLayerIntRect>& aClipDeferredToParent)
 {
   Maybe<ParentLayerIntRect> clipDeferredFromChildren;
   bool appliedTransform = false;
   for (Layer* child = aLayer->GetFirstChild();
--- a/gfx/layers/composite/LayerManagerComposite.cpp
+++ b/gfx/layers/composite/LayerManagerComposite.cpp
@@ -192,29 +192,16 @@ LayerManagerComposite::BeginTransactionW
   }
 
   mIsCompositorReady = true;
   mCompositor->SetTargetContext(aTarget, aRect);
   mTarget = aTarget;
   mTargetBounds = aRect;
 }
 
-template<typename RectType>
-Maybe<RectType>
-IntersectMaybeRects(const Maybe<RectType>& aRect1, const Maybe<RectType>& aRect2)
-{
-  if (aRect1) {
-    if (aRect2) {
-      return Some(aRect1->Intersect(*aRect2));
-    }
-    return aRect1;
-  }
-  return aRect2;
-}
-
 /**
  * Get accumulated transform of from the context creating layer to the
  * given layer.
  */
 static Matrix4x4
 GetAccTransformIn3DContext(Layer* aLayer) {
   Matrix4x4 transform = aLayer->GetLocalTransform();
   for (Layer* layer = aLayer->GetParent();