Bug 1461782 - Remove unused PingPongRegion. r=bas
authorRyan Hunt <rhunt@eqrion.net>
Thu, 19 Apr 2018 15:10:54 -0500
changeset 418619 2e9352e10a99c81fd9035228e5a6f8f6308286b5
parent 418618 aedc574b31739703b26cb398d4be31a2ac4f43eb
child 418620 1f14b04db9a4d1c99aa03d5884942d3aea6a0a0c
push id34007
push usercsabou@mozilla.com
push dateThu, 17 May 2018 09:47:02 +0000
treeherdermozilla-central@8fb36531f7d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbas
bugs1461782
milestone62.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 1461782 - Remove unused PingPongRegion. r=bas
gfx/src/PingPongRegion.h
gfx/src/moz.build
gfx/tests/gtest/TestRegion.cpp
deleted file mode 100644
--- a/gfx/src/PingPongRegion.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef PingPongRegion_h__
-#define PingPongRegion_h__
-
-/* This class uses a pair of regions and swaps between them while
- * accumulating to avoid the heap allocations associated with
- * modifying a region in place.
- *
- * It is sizeof(T)*2 + sizeof(T*) and can use end up using
- * approximately double the amount of memory as using single
- * region so use it sparingly.
- */
-
-template <typename T>
-class PingPongRegion
-{
-  typedef typename T::RectType RectType;
-public:
-  PingPongRegion()
-  {
-    rgn = &rgn1;
-  }
-
-  void SubOut(const RectType& aOther)
-  {
-    T* nextRgn = nextRegion();
-    nextRgn->Sub(*rgn, aOther);
-    rgn = nextRgn;
-  }
-
-  void OrWith(const RectType& aOther)
-  {
-    T* nextRgn = nextRegion();
-    nextRgn->Or(*rgn, aOther);
-    rgn = nextRgn;
-  }
-
-  T& Region()
-  {
-    return *rgn;
-  }
-
-private:
-
-  T* nextRegion()
-  {
-    if (rgn == &rgn1) {
-      return &rgn2;
-    } else {
-      return &rgn1;
-    }
-  }
-
-  T* rgn;
-  T rgn1;
-  T rgn2;
-};
-
-#endif
--- a/gfx/src/moz.build
+++ b/gfx/src/moz.build
@@ -32,17 +32,16 @@ EXPORTS += [
     'nsPoint.h',
     'nsRect.h',
     'nsRectAbsolute.h',
     'nsRegion.h',
     'nsRegionFwd.h',
     'nsSize.h',
     'nsThemeConstants.h',
     'nsTransform2D.h',
-    'PingPongRegion.h',
     'RegionBuilder.h',
     'X11UndefineNone.h'
 ]
 
 EXPORTS.mozilla += [
     'AppUnits.h',
     'ArrayView.h',
     'FontPropertyTypes.h',
--- a/gfx/tests/gtest/TestRegion.cpp
+++ b/gfx/tests/gtest/TestRegion.cpp
@@ -1,17 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <algorithm>
 
-#include "PingPongRegion.h"
 #include "gtest/gtest.h"
 #include "nsRegion.h"
 #include "RegionBuilder.h"
 #include "mozilla/gfx/TiledRegion.h"
 #include "mozilla/UniquePtr.h"
 
 using namespace std;
 using namespace mozilla::gfx;
@@ -1323,47 +1322,16 @@ TEST(Gfx, RegionVisitEdges) {
     r.Or(r, nsRect(25, 50, 28, 5));
     r.Or(r, nsRect(115, 50, 99, 5));
     r.Or(r, nsRect(115, 55, 99, 12));
 
     TestVisit(r);
   }
 }
 
-TEST(Gfx, PingPongRegion) {
-  nsRect rects[] = {
-    nsRect(4, 1, 61, 49),
-    nsRect(115, 1, 99, 49),
-    nsRect(115, 49, 99, 1),
-    nsRect(12, 50, 11, 5),
-    nsRect(25, 50, 28, 5),
-    nsRect(115, 50, 99, 5),
-    nsRect(115, 55, 99, 12),
-  };
-
-  // Test accumulations of various sizes to make sure
-  // the ping-pong behavior of PingPongRegion is working.
-  for (size_t size = 0; size < mozilla::ArrayLength(rects); size++) {
-    // bug 1130978.
-    nsRegion r;
-    PingPongRegion<nsRegion> ar;
-    for (size_t i = 0; i < size; i++) {
-      r.Or(r, rects[i]);
-      ar.OrWith(rects[i]);
-      EXPECT_TRUE(ar.Region().IsEqual(r));
-    }
-
-    for (size_t i = 0; i < size; i++) {
-      ar.SubOut(rects[i]);
-      r.SubOut(rects[i]);
-      EXPECT_TRUE(ar.Region().IsEqual(r));
-    }
-  }
-}
-
 // The TiledRegion tests use nsIntRect / IntRegion because nsRect doesn't have
 // InflateToMultiple which is required by TiledRegion.
 TEST(Gfx, TiledRegionNoSimplification2Rects) {
   // Add two rectangles, both rectangles are completely inside
   // different tiles.
   nsIntRegion region;
   region.OrWith(nsIntRect(50, 50, 50, 50));
   region.OrWith(nsIntRect(300, 50, 50, 50));