Bug 853867 - Allow --enable-gtest on Android and fix build issues. NPOTB r=bas,bgirard
authorChris Lord <chrislord.net@gmail.com>
Thu, 25 Apr 2013 15:39:33 -0400
changeset 140918 5fb2a77bb0db11a291205c0d0d752b38301fc37e
parent 140917 ebf1b0f1920c0628bb250519aa4a1ae9a14ef406
child 140919 aa1e31f9cfa4baeebbcff4fa8712d6a37cced384
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbas, bgirard
bugs853867
milestone23.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 853867 - Allow --enable-gtest on Android and fix build issues. NPOTB r=bas,bgirard
configure.in
gfx/2d/unittest/TestScaling.cpp
--- a/configure.in
+++ b/configure.in
@@ -6390,26 +6390,34 @@ MOZ_ARG_DISABLE_BOOL(tests,
 # be compiled along with ENABLE_TESTS
 MOZ_ARG_ENABLE_BOOL(gtest,
 [  --enable-gtest
                           Enable GTest libxul unit test.],
     MOZ_ENABLE_GTEST=1,
     MOZ_ENABLE_GTEST= )
 
 if test -n "$MOZ_ENABLE_GTEST"; then
-    if test "${OS_TARGET}" = "WINNT" -o "${OS_TARGET}" = "Darwin" -o "${OS_TARGET}" = "Linux"; then
+    if test "${OS_TARGET}" = "WINNT" -o "${OS_TARGET}" = "Darwin" -o "${OS_TARGET}" = "Linux" -o "${OS_TARGET}" = "Android"; then
         MOZ_ENABLE_GTEST=1
         GTEST_HAS_RTTI=0
         AC_DEFINE(MOZ_ENABLE_GTEST)
         AC_DEFINE_UNQUOTED(GTEST_HAS_RTTI, 0)
         AC_SUBST(MOZ_ENABLE_GTEST)
         AC_SUBST(GTEST_HAS_RTTI)
     else
         AC_MSG_ERROR([Cannot build with --enable-gtest on this platform.])
     fi
+    if test "${OS_TARGET}" = "Android"; then
+        AC_DEFINE(GTEST_OS_LINUX_ANDROID)
+        AC_DEFINE(GTEST_USE_OWN_TR1_TUPLE)
+        AC_DEFINE_UNQUOTED(GTEST_HAS_CLONE, 0)
+        AC_SUBST(GTEST_OS_LINUX_ANDROID)
+        AC_SUBST(GTEST_USE_OWN_TR1_TUPLE)
+        AC_SUBST(GTEST_HAS_CLONE)
+    fi
 fi
 
 dnl ========================================================
 dnl parental controls (for Windows Vista)
 dnl ========================================================
 MOZ_ARG_DISABLE_BOOL(parental-controls,
 [  --disable-parental-controls
                           Do not build parental controls],
--- a/gfx/2d/unittest/TestScaling.cpp
+++ b/gfx/2d/unittest/TestScaling.cpp
@@ -21,26 +21,26 @@ TestScaling::TestScaling()
 }
 
 void
 TestScaling::BasicHalfScale()
 {
   std::vector<uint8_t> data;
   data.resize(500 * 500 * 4);
 
-  uint32_t *pixels = (uint32_t*)data.data();
+  uint32_t *pixels = reinterpret_cast<uint32_t*>(&data.front());
   for (int y = 0; y < 500; y += 2) {
     for (int x = 0; x < 500; x += 2) {
       pixels[y * 500 + x] = 0xff00ff00;
       pixels[y * 500 + x + 1] = 0xff00ffff;
       pixels[(y + 1) * 500 + x] = 0xff000000;
       pixels[(y + 1) * 500 + x + 1] = 0xff0000ff;
     }
   }
-  ImageHalfScaler scaler(data.data(), 500 * 4, IntSize(500, 500));
+  ImageHalfScaler scaler(&data.front(), 500 * 4, IntSize(500, 500));
 
   scaler.ScaleForSize(IntSize(220, 240));
 
   VERIFY(scaler.GetSize().width == 250);
   VERIFY(scaler.GetSize().height == 250);
 
   pixels = (uint32_t*)scaler.GetScaledData();
 
@@ -52,26 +52,26 @@ TestScaling::BasicHalfScale()
 }
 
 void
 TestScaling::DoubleHalfScale()
 {
   std::vector<uint8_t> data;
   data.resize(500 * 500 * 4);
 
-  uint32_t *pixels = (uint32_t*)data.data();
+  uint32_t *pixels = reinterpret_cast<uint32_t*>(&data.front());
   for (int y = 0; y < 500; y += 2) {
     for (int x = 0; x < 500; x += 2) {
       pixels[y * 500 + x] = 0xff00ff00;
       pixels[y * 500 + x + 1] = 0xff00ffff;
       pixels[(y + 1) * 500 + x] = 0xff000000;
       pixels[(y + 1) * 500 + x + 1] = 0xff0000ff;
     }
   }
-  ImageHalfScaler scaler(data.data(), 500 * 4, IntSize(500, 500));
+  ImageHalfScaler scaler(&data.front(), 500 * 4, IntSize(500, 500));
 
   scaler.ScaleForSize(IntSize(120, 110));
   VERIFY(scaler.GetSize().width == 125);
   VERIFY(scaler.GetSize().height == 125);
 
   pixels = (uint32_t*)scaler.GetScaledData();
 
   for (int y = 0; y < 125; y++) {
@@ -84,32 +84,32 @@ TestScaling::DoubleHalfScale()
 void
 TestScaling::UnevenHalfScale()
 {
   std::vector<uint8_t> data;
   // Use a 16-byte aligned stride still, we test none-aligned strides
   // separately.
   data.resize(499 * 500 * 4);
 
-  uint32_t *pixels = (uint32_t*)data.data();
+  uint32_t *pixels = reinterpret_cast<uint32_t*>(&data.front());
   for (int y = 0; y < 500; y += 2) {
     for (int x = 0; x < 500; x += 2) {
       pixels[y * 500 + x] = 0xff00ff00;
       if (x < 498) {
         pixels[y * 500 + x + 1] = 0xff00ffff;
       }
       if (y < 498) {
         pixels[(y + 1) * 500 + x] = 0xff000000;
         if (x < 498) {
           pixels[(y + 1) * 500 + x + 1] = 0xff0000ff;
         }
       }
     }
   }
-  ImageHalfScaler scaler(data.data(), 500 * 4, IntSize(499, 499));
+  ImageHalfScaler scaler(&data.front(), 500 * 4, IntSize(499, 499));
 
   scaler.ScaleForSize(IntSize(220, 220));
   VERIFY(scaler.GetSize().width == 249);
   VERIFY(scaler.GetSize().height == 249);
 
   pixels = (uint32_t*)scaler.GetScaledData();
 
   for (int y = 0; y < 249; y++) {
@@ -121,32 +121,32 @@ TestScaling::UnevenHalfScale()
 
 void
 TestScaling::OddStrideHalfScale()
 {
   std::vector<uint8_t> data;
   // Use a 4-byte aligned stride to test if that doesn't cause any issues.
   data.resize(499 * 499 * 4);
 
-  uint32_t *pixels = (uint32_t*)data.data();
+  uint32_t *pixels = reinterpret_cast<uint32_t*>(&data.front());
   for (int y = 0; y < 500; y += 2) {
     for (int x = 0; x < 500; x += 2) {
       pixels[y * 499 + x] = 0xff00ff00;
       if (x < 498) {
         pixels[y * 499 + x + 1] = 0xff00ffff;
       }
       if (y < 498) {
         pixels[(y + 1) * 499 + x] = 0xff000000;
         if (x < 498) {
           pixels[(y + 1) * 499 + x + 1] = 0xff0000ff;
         }
       }
     }
   }
-  ImageHalfScaler scaler(data.data(), 499 * 4, IntSize(499, 499));
+  ImageHalfScaler scaler(&data.front(), 499 * 4, IntSize(499, 499));
 
   scaler.ScaleForSize(IntSize(220, 220));
   VERIFY(scaler.GetSize().width == 249);
   VERIFY(scaler.GetSize().height == 249);
 
   pixels = (uint32_t*)scaler.GetScaledData();
 
   for (int y = 0; y < 249; y++) {
@@ -156,26 +156,26 @@ TestScaling::OddStrideHalfScale()
   }
 }
 void
 TestScaling::VerticalHalfScale()
 {
   std::vector<uint8_t> data;
   data.resize(500 * 500 * 4);
 
-  uint32_t *pixels = (uint32_t*)data.data();
+  uint32_t *pixels = reinterpret_cast<uint32_t*>(&data.front());
   for (int y = 0; y < 500; y += 2) {
     for (int x = 0; x < 500; x += 2) {
       pixels[y * 500 + x] = 0xff00ff00;
       pixels[y * 500 + x + 1] = 0xff00ffff;
       pixels[(y + 1) * 500 + x] = 0xff000000;
       pixels[(y + 1) * 500 + x + 1] = 0xff0000ff;
     }
   }
-  ImageHalfScaler scaler(data.data(), 500 * 4, IntSize(500, 500));
+  ImageHalfScaler scaler(&data.front(), 500 * 4, IntSize(500, 500));
 
   scaler.ScaleForSize(IntSize(400, 240));
   VERIFY(scaler.GetSize().width == 500);
   VERIFY(scaler.GetSize().height == 250);
 
   pixels = (uint32_t*)scaler.GetScaledData();
 
   for (int y = 0; y < 250; y++) {
@@ -187,30 +187,30 @@ TestScaling::VerticalHalfScale()
 }
 
 void
 TestScaling::HorizontalHalfScale()
 {
   std::vector<uint8_t> data;
   data.resize(520 * 500 * 4);
 
-  uint32_t *pixels = (uint32_t*)data.data();
+  uint32_t *pixels = reinterpret_cast<uint32_t*>(&data.front());
   for (int y = 0; y < 500; y ++) {
     for (int x = 0; x < 520; x += 8) {
       pixels[y * 520 + x] = 0xff00ff00;
       pixels[y * 520 + x + 1] = 0xff00ffff;
       pixels[y * 520 + x + 2] = 0xff000000;
       pixels[y * 520 + x + 3] = 0xff0000ff;
       pixels[y * 520 + x + 4] = 0xffff00ff;
       pixels[y * 520 + x + 5] = 0xff0000ff;
       pixels[y * 520 + x + 6] = 0xffffffff;
       pixels[y * 520 + x + 7] = 0xff0000ff;
     }
   }
-  ImageHalfScaler scaler(data.data(), 520 * 4, IntSize(520, 500));
+  ImageHalfScaler scaler(&data.front(), 520 * 4, IntSize(520, 500));
 
   scaler.ScaleForSize(IntSize(240, 400));
   VERIFY(scaler.GetSize().width == 260);
   VERIFY(scaler.GetSize().height == 500);
 
   pixels = (uint32_t*)scaler.GetScaledData();
 
   for (int y = 0; y < 500; y++) {
@@ -224,26 +224,26 @@ TestScaling::HorizontalHalfScale()
 }
 
 void
 TestScaling::MixedHalfScale()
 {
   std::vector<uint8_t> data;
   data.resize(500 * 500 * 4);
 
-  uint32_t *pixels = (uint32_t*)data.data();
+  uint32_t *pixels = reinterpret_cast<uint32_t*>(&data.front());
   for (int y = 0; y < 500; y += 2) {
     for (int x = 0; x < 500; x += 2) {
       pixels[y * 500 + x] = 0xff00ff00;
       pixels[y * 500 + x + 1] = 0xff00ffff;
       pixels[(y + 1) * 500 + x] = 0xff000000;
       pixels[(y + 1) * 500 + x + 1] = 0xff0000ff;
     }
   }
-  ImageHalfScaler scaler(data.data(), 500 * 4, IntSize(500, 500));
+  ImageHalfScaler scaler(&data.front(), 500 * 4, IntSize(500, 500));
 
   scaler.ScaleForSize(IntSize(120, 240));
   VERIFY(scaler.GetSize().width == 125);
   VERIFY(scaler.GetSize().height == 250);
   scaler.ScaleForSize(IntSize(240, 120));
   VERIFY(scaler.GetSize().width == 250);
   VERIFY(scaler.GetSize().height == 125);
 }