Bug 1197315 - remove PR_snprintf calls in gfx/; r=froydnj
authorAniket Vyas <vyas45@mozilla.com>
Mon, 12 Oct 2015 14:06:19 -0700
changeset 268032 4fda345579d439eabcc83745accc2eeac9fbb56f
parent 268031 8a58db3e939c67d939d760fbe01cacbf85a87b94
child 268033 e8133cb912d3b41c4418c7195c758c3203f644e5
push id29538
push userkwierso@gmail.com
push dateFri, 16 Oct 2015 18:52:30 +0000
treeherdermozilla-central@0d5765f295a8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1197315
milestone44.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 1197315 - remove PR_snprintf calls in gfx/; r=froydnj
gfx/layers/composite/FPSCounter.cpp
gfx/tests/gtest/TestColorNames.cpp
--- a/gfx/layers/composite/FPSCounter.cpp
+++ b/gfx/layers/composite/FPSCounter.cpp
@@ -13,17 +13,17 @@
 #include "mozilla/layers/Compositor.h"  // for Compositor
 #include "mozilla/layers/CompositorTypes.h"
 #include "mozilla/layers/Effects.h"     // for Effect, EffectChain, etc
 #include "mozilla/TimeStamp.h"          // for TimeStamp, TimeDuration
 #include "nsPoint.h"                    // for nsIntPoint
 #include "nsRect.h"                     // for mozilla::gfx::IntRect
 #include "nsIFile.h"                    // for nsIFile
 #include "nsDirectoryServiceDefs.h"     // for NS_OS_TMP_DIR
-#include "prprf.h"                      // for PR_snprintf
+#include "mozilla/Snprintf.h"
 #include "FPSCounter.h"
 
 namespace mozilla {
 namespace layers {
 
 using namespace mozilla::gfx;
 
 FPSCounter::FPSCounter(const char* aName)
@@ -204,32 +204,32 @@ FPSCounter::BuildHistogram(std::map<int,
 }
 
 // Iterate the same way we do in GetFPS()
 void
 FPSCounter::WriteFrameTimeStamps(PRFileDesc* fd)
 {
   const int bufferSize = 256;
   char buffer[bufferSize];
-  int writtenCount = PR_snprintf(buffer, bufferSize, "FPS Data for: %s\n", mFPSName);
+  int writtenCount = snprintf_literal(buffer, "FPS Data for: %s\n", mFPSName);
   MOZ_ASSERT(writtenCount >= 0);
   PR_Write(fd, buffer, writtenCount);
 
   ResetReverseIterator();
   TimeStamp startTimeStamp = GetLatestTimeStamp();
 
   MOZ_ASSERT(HasNext(startTimeStamp));
   TimeStamp previousSample = GetNextTimeStamp();
 
   MOZ_ASSERT(HasNext(startTimeStamp));
   TimeStamp nextTimeStamp = GetNextTimeStamp();
 
   while (HasNext(startTimeStamp)) {
     TimeDuration duration = previousSample - nextTimeStamp;
-    writtenCount = PR_snprintf(buffer, bufferSize, "%f,\n", duration.ToMilliseconds());
+    writtenCount = snprintf_literal(buffer, "%f,\n", duration.ToMilliseconds());
 
     MOZ_ASSERT(writtenCount >= 0);
     PR_Write(fd, buffer, writtenCount);
 
     previousSample = nextTimeStamp;
     nextTimeStamp = GetNextTimeStamp();
   }
 }
@@ -304,18 +304,18 @@ FPSCounter::PrintHistogram(std::map<int,
   char buffer[kBufferLength];
 
   for (std::map<int, int>::iterator iter = aHistogram.begin();
     iter != aHistogram.end(); iter++)
   {
     int fps = iter->first;
     int count = iter->second;
 
-    length += PR_snprintf(buffer + length, kBufferLength - length,
-                        "FPS: %d = %d. ", fps, count);
+    length += snprintf(buffer + length, kBufferLength - length,
+                       "FPS: %d = %d. ", fps, count);
     NS_ASSERTION(length >= kBufferLength, "Buffer overrun while printing FPS histogram.");
   }
 
   printf_stderr("%s\n", buffer);
   printf_stderr("Mean: %f , std dev %f\n", GetMean(aHistogram), GetStdDev(aHistogram));
 }
 
 // Write FPS timestamp data to a file only if
--- a/gfx/tests/gtest/TestColorNames.cpp
+++ b/gfx/tests/gtest/TestColorNames.cpp
@@ -3,17 +3,17 @@
  * 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 "gtest/gtest.h"
 
 #include <string.h>
 #include "nsColor.h"
 #include "nsColorNames.h"
-#include "prprf.h"
+#include "mozilla/Snprintf.h"
 #include "nsString.h"
 #include "mozilla/ArrayUtils.h"
 
 // define an array of all color names
 #define GFX_COLOR(_name, _value) #_name,
 static const char* const kColorNames[] = {
 #include "nsColorNameList.h"
 };
@@ -66,17 +66,17 @@ void RunColorTests() {
     uint8_t g = NS_GET_G(rgb);
     uint8_t b = NS_GET_B(rgb);
     uint8_t a = NS_GET_A(rgb);
     if (a != UINT8_MAX) {
       // NS_HexToRGB() can not handle a color with alpha channel
       rgb = NS_RGB(r, g, b);
     }
     char cbuf[50];
-    PR_snprintf(cbuf, sizeof(cbuf), "%02x%02x%02x", r, g, b);
+    snprintf_literal(cbuf, "%02x%02x%02x", r, g, b);
     nscolor hexrgb;
     ASSERT_TRUE(NS_HexToRGB(NS_ConvertASCIItoUTF16(cbuf), &hexrgb)) <<
       "hex conversion to color of '" << cbuf << "'";
     ASSERT_TRUE(hexrgb == rgb);
   }
 }
 
 static