Bug 1315464 - Dynamically allocate test regions. r=jrmuizel, a=test-only
authorEric Rahm <erahm@mozilla.com>
Fri, 27 Jan 2017 11:58:14 -0800
changeset 375746 6fb0f2389a033a4fc491235ecce4030cca0107da
parent 375745 98935e905f5a96259723ac7e105351c8f7b47945
child 375747 d1ebb19a2f3986a90170ff549a38f04cbdea6521
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel, test-only
bugs1315464
milestone53.0a2
Bug 1315464 - Dynamically allocate test regions. r=jrmuizel, a=test-only Avoid allocating 720K on the stack.
gfx/tests/gtest/TestRegion.cpp
--- a/gfx/tests/gtest/TestRegion.cpp
+++ b/gfx/tests/gtest/TestRegion.cpp
@@ -7,16 +7,17 @@
 
 #include "PingPongRegion.h"
 #include "gtest/gtest.h"
 #include "gtest/MozGTestBench.h"
 #include "nsRect.h"
 #include "nsRegion.h"
 #include "RegionBuilder.h"
 #include "mozilla/gfx/TiledRegion.h"
+#include "mozilla/UniquePtr.h"
 
 using namespace std;
 using namespace mozilla::gfx;
 
 class TestLargestRegion {
 public:
   static void TestSingleRect(nsRect r) {
     nsRegion region(r);
@@ -447,20 +448,20 @@ void VisitEdge(void *closure, VisitSide 
       bitmap[x1 + y1 * width] = DILATE_VALUE;
       y1++;
     }
   }
 }
 
 void TestVisit(nsRegion &r)
 {
-  unsigned char reference[600 * 600];
-  unsigned char result[600 * 600];
-  RegionBitmap ref(reference, 600, 600);
-  RegionBitmap res(result, 600, 600);
+  auto reference = mozilla::MakeUnique<unsigned char[]>(600 * 600);
+  auto result = mozilla::MakeUnique<unsigned char[]>(600 * 600);
+  RegionBitmap ref(reference.get(), 600, 600);
+  RegionBitmap res(result.get(), 600, 600);
 
   ref.set(r);
   ref.dilate();
 
   res.set(r);
   r.VisitEdges(VisitEdge, &res);
   res.compare(ref);
 }