Bug 776429: Unify scattered M_PI definitions into mfbt/Constants.h r=dRdR
authorSergey Glushchenko <gsserge@gmail.com>
Mon, 06 Aug 2012 13:32:11 -0700
changeset 107038 6beb523ebcb572d9f09b3416c2bf39dec2507540
parent 107037 ef62a9a2ee425de0ae494159190d4e51eaf8f09a
child 107039 0fbe36ab89647d36fd262ad8b7697d32a2268746
push id1490
push userakeybl@mozilla.com
push dateMon, 08 Oct 2012 18:29:50 +0000
treeherdermozilla-beta@f335e7dacdc1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdRdR
bugs776429
milestone17.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 776429: Unify scattered M_PI definitions into mfbt/Constants.h r=dRdR
gfx/2d/Blur.cpp
gfx/2d/DrawTargetD2D.cpp
gfx/2d/PathD2D.cpp
gfx/2d/PathHelpers.h
gfx/layers/ipc/AsyncPanZoomController.cpp
gfx/thebes/gfxContext.cpp
js/src/jsmath.cpp
layout/svg/base/src/nsSVGUtils.h
mfbt/Constants.h
mfbt/exported_headers.mk
widget/windows/nsWinGesture.cpp
--- a/gfx/2d/Blur.cpp
+++ b/gfx/2d/Blur.cpp
@@ -4,22 +4,19 @@
 
 #include "mozilla/gfx/Blur.h"
 
 #include <algorithm>
 #include <math.h>
 #include <string.h>
 
 #include "mozilla/CheckedInt.h"
+#include "mozilla/Constants.h"
 #include "mozilla/Util.h"
 
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
 using namespace std;
 
 namespace mozilla {
 namespace gfx {
 
 /**
  * Box blur involves looking at one pixel, and setting its value to the average
  * of its neighbouring pixels.
--- a/gfx/2d/DrawTargetD2D.cpp
+++ b/gfx/2d/DrawTargetD2D.cpp
@@ -9,23 +9,20 @@
 #include "ShadersD2D.h"
 #include "PathD2D.h"
 #include "GradientStopsD2D.h"
 #include "ScaledFontDWrite.h"
 #include "ImageScaling.h"
 #include "Logging.h"
 #include "Tools.h"
 #include <algorithm>
+#include "mozilla/Constants.h"
 
 #include <dwrite.h>
 
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
 typedef HRESULT (WINAPI*D2D1CreateFactoryFunc)(
     D2D1_FACTORY_TYPE factoryType,
     REFIID iid,
     CONST D2D1_FACTORY_OPTIONS *pFactoryOptions,
     void **factory
 );
 
 typedef HRESULT (WINAPI*D3D10CreateEffectFromMemoryFunc)(
--- a/gfx/2d/PathD2D.cpp
+++ b/gfx/2d/PathD2D.cpp
@@ -3,20 +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 "PathD2D.h"
 #include "HelpersD2D.h"
 #include <math.h>
 #include "DrawTargetD2D.h"
 #include "Logging.h"
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
+#include "mozilla/Constants.h"
 
 namespace mozilla {
 namespace gfx {
 
 // This class exists as a wrapper for ID2D1SimplifiedGeometry sink, it allows
 // a geometry to be duplicated into a geometry sink, while removing the final
 // figure end and thus allowing a figure that was implicitly closed to be
 // continued.
--- a/gfx/2d/PathHelpers.h
+++ b/gfx/2d/PathHelpers.h
@@ -2,20 +2,17 @@
  * 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 MOZILLA_GFX_PATHHELPERS_H_
 #define MOZILLA_GFX_PATHHELPERS_H_
 
 #include "2D.h"
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
+#include "mozilla/Constants.h"
 
 namespace mozilla {
 namespace gfx {
 
 template <typename T>
 void ArcToBezier(T* aSink, const Point &aOrigin, float aRadius, float aStartAngle,
                  float aEndAngle, bool aAntiClockwise)
 {
--- a/gfx/layers/ipc/AsyncPanZoomController.cpp
+++ b/gfx/layers/ipc/AsyncPanZoomController.cpp
@@ -1,32 +1,29 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set sw=4 ts=8 et 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 "CompositorParent.h"
 #include "mozilla/gfx/2D.h"
+#include "mozilla/Constants.h"
 #include "mozilla/Util.h"
 #include "mozilla/XPCOM.h"
 #include "mozilla/Monitor.h"
 #include "AsyncPanZoomController.h"
 #include "GestureEventListener.h"
 #include "nsIThreadManager.h"
 #include "nsThreadUtils.h"
 #include "Layers.h"
 
 namespace mozilla {
 namespace layers {
 
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
 static const float EPSILON = 0.0001;
 
 /**
  * Maximum amount of time while panning before sending a viewport change. This
  * will asynchronously repaint the page. It is also forced when panning stops.
  */
 static const PRInt32 PAN_REPAINT_INTERVAL = 250;
 
--- a/gfx/thebes/gfxContext.cpp
+++ b/gfx/thebes/gfxContext.cpp
@@ -3,19 +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/. */
 
 #ifdef _MSC_VER
 #define _USE_MATH_DEFINES
 #endif
 #include <math.h>
 
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
+#include "mozilla/Constants.h"
 
 #include "cairo.h"
 
 #include "gfxContext.h"
 
 #include "gfxColor.h"
 #include "gfxMatrix.h"
 #include "gfxASurface.h"
--- a/js/src/jsmath.cpp
+++ b/js/src/jsmath.cpp
@@ -3,16 +3,17 @@
  * 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/. */
 
 /*
  * JS math package.
  */
 
+#include "mozilla/Constants.h"
 #include "mozilla/FloatingPoint.h"
 
 #include <stdlib.h>
 #include "jstypes.h"
 #include "prmjtime.h"
 #include "jsapi.h"
 #include "jsatom.h"
 #include "jscntxt.h"
@@ -38,19 +39,16 @@ using namespace js;
 #define M_LOG10E        0.43429448190325182765
 #endif
 #ifndef M_LN2
 #define M_LN2           0.69314718055994530942
 #endif
 #ifndef M_LN10
 #define M_LN10          2.30258509299404568402
 #endif
-#ifndef M_PI
-#define M_PI            3.14159265358979323846
-#endif
 #ifndef M_SQRT2
 #define M_SQRT2         1.41421356237309504880
 #endif
 #ifndef M_SQRT1_2
 #define M_SQRT1_2       0.70710678118654752440
 #endif
 
 static JSConstDoubleSpec math_constants[] = {
--- a/layout/svg/base/src/nsSVGUtils.h
+++ b/layout/svg/base/src/nsSVGUtils.h
@@ -17,16 +17,17 @@
 #include "nsChangeHint.h"
 #include "nsColor.h"
 #include "nsCOMPtr.h"
 #include "nsID.h"
 #include "nsISupportsBase.h"
 #include "nsMathUtils.h"
 #include "nsPoint.h"
 #include "nsRect.h"
+#include "mozilla/Constants.h"
 
 class gfxASurface;
 class gfxContext;
 class gfxImageSurface;
 class gfxPattern;
 class nsFrameList;
 class nsIContent;
 class nsIDocument;
@@ -51,20 +52,16 @@ struct nsStyleSVGPaint;
 namespace mozilla {
 class SVGAnimatedPreserveAspectRatio;
 class SVGPreserveAspectRatio;
 namespace dom {
 class Element;
 } // namespace dom
 } // namespace mozilla
 
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
 // SVG Frame state bits
 #define NS_STATE_IS_OUTER_SVG                    NS_FRAME_STATE_BIT(20)
 
 /* are we the child of a non-display container? */
 #define NS_STATE_SVG_NONDISPLAY_CHILD            NS_FRAME_STATE_BIT(22)
 
 // If this bit is set, we are a <clipPath> element or descendant.
 #define NS_STATE_SVG_CLIPPATH_CHILD              NS_FRAME_STATE_BIT(23)
new file mode 100644
--- /dev/null
+++ b/mfbt/Constants.h
@@ -0,0 +1,15 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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/. */
+
+/* mfbt math constants. */
+
+#ifndef mozilla_Constants_h_
+#define mozilla_Constants_h_
+
+#ifndef M_PI
+#  define M_PI 3.14159265358979323846
+#endif
+
+#endif  /* mozilla_Constants_h_ */
--- a/mfbt/exported_headers.mk
+++ b/mfbt/exported_headers.mk
@@ -8,16 +8,17 @@
 
 EXPORTS_NAMESPACES += mozilla
 
 EXPORTS_mozilla += \
   Assertions.h \
   Attributes.h \
   BloomFilter.h \
   CheckedInt.h \
+  Constants.h \
   FloatingPoint.h \
   GuardObjects.h \
   HashFunctions.h \
   Likely.h \
   LinkedList.h \
   MSStdInt.h \
   RangedPtr.h \
   RefPtr.h \
--- a/widget/windows/nsWinGesture.cpp
+++ b/widget/windows/nsWinGesture.cpp
@@ -7,24 +7,21 @@
  * nsWinGesture - Touch input handling for tablet displays.
  */
 
 #include "nscore.h"
 #include "nsWinGesture.h"
 #include "nsUXThemeData.h"
 #include "nsIDOMSimpleGestureEvent.h"
 #include "nsGUIEvent.h"
+#include "mozilla/Constants.h"
 #include "mozilla/Preferences.h"
 
 using namespace mozilla;
 
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
 #ifdef PR_LOGGING
 extern PRLogModuleInfo* gWindowsLog;
 #endif
 
 const PRUnichar nsWinGesture::kGestureLibraryName[] =  L"user32.dll";
 HMODULE nsWinGesture::sLibraryHandle = nullptr;
 nsWinGesture::GetGestureInfoPtr nsWinGesture::getGestureInfo = nullptr;
 nsWinGesture::CloseGestureInfoHandlePtr nsWinGesture::closeGestureInfoHandle = nullptr;