Bug 1270231 - avoid #define leakage of common symbols outside of Skia. r=jrmuizel
authorLee Salzman <lsalzman@mozilla.com>
Wed, 04 May 2016 21:05:26 -0400
changeset 296187 0b4b01734a94feeea56dc3ae8359b01d8523f9f1
parent 296186 65e4abd900f48e418517e45b9fb80844b750dbd1
child 296188 945893b62336d110c88f12b102502cf13361799e
push id30233
push userryanvm@gmail.com
push dateThu, 05 May 2016 18:57:26 +0000
treeherdermozilla-central@0177462aac74 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1270231
milestone49.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 1270231 - avoid #define leakage of common symbols outside of Skia. r=jrmuizel
gfx/skia/skia/include/core/SkRefCnt.h
gfx/skia/skia/include/core/SkTLazy.h
gfx/skia/skia/include/gpu/gl/GrGLFunctions.h
gfx/skia/skia/include/private/SkTArray.h
gfx/skia/skia/include/private/SkTLogic.h
--- a/gfx/skia/skia/include/core/SkRefCnt.h
+++ b/gfx/skia/skia/include/core/SkRefCnt.h
@@ -427,17 +427,17 @@ template <typename T> inline bool operat
     return !(a < nullptr);
 }
 template <typename T> inline bool operator>=(std::nullptr_t, const sk_sp<T>& b) {
     return !(nullptr < b);
 }
 
 template <typename T, typename... Args>
 sk_sp<T> sk_make_sp(Args&&... args) {
-    return sk_sp<T>(new T(std::forward<Args>(args)...));
+    return sk_sp<T>(new T(std__forward<Args>(args)...));
 }
 
 #ifdef SK_SUPPORT_TRANSITION_TO_SP_INTERFACES
 
 /*
  *  Returns a sk_sp wrapping the provided ptr AND calls ref on it (if not null).
  *
  *  This is different than the semantics of the constructor for sk_sp, which just wraps the ptr,
--- a/gfx/skia/skia/include/core/SkTLazy.h
+++ b/gfx/skia/skia/include/core/SkTLazy.h
@@ -46,17 +46,17 @@ public:
      *  If a previous instance had been initialized (either from init() or
      *  set()) it will first be destroyed, so that a freshly initialized
      *  instance is always returned.
      */
     template <typename... Args> T* init(Args&&... args) {
         if (this->isValid()) {
             fPtr->~T();
         }
-        fPtr = new (SkTCast<T*>(fStorage.get())) T(std::forward<Args>(args)...);
+        fPtr = new (SkTCast<T*>(fStorage.get())) T(std__forward<Args>(args)...);
         return fPtr;
     }
 
     /**
      *  Copy src into this, and return a pointer to a copy of it. Note this
      *  will always return the same pointer, so if it is called on a lazy that
      *  has already been initialized, then this will copy over the previous
      *  contents.
--- a/gfx/skia/skia/include/gpu/gl/GrGLFunctions.h
+++ b/gfx/skia/skia/include/gpu/gl/GrGLFunctions.h
@@ -354,11 +354,11 @@ typedef GrGLvoid (GR_GL_FUNCTION_TYPE* G
 
 /** EGL functions */
 typedef const char* (GR_GL_FUNCTION_TYPE* GrEGLQueryStringProc)(GrEGLDisplay dpy, GrEGLint name);
 typedef GrEGLDisplay (GR_GL_FUNCTION_TYPE* GrEGLGetCurrentDisplayProc)();
 typedef GrEGLImage (GR_GL_FUNCTION_TYPE* GrEGLCreateImageProc)(GrEGLDisplay dpy, GrEGLContext ctx, GrEGLenum target, GrEGLClientBuffer buffer, const GrEGLint *attrib_list);
 typedef GrEGLBoolean (GR_GL_FUNCTION_TYPE* GrEGLDestroyImageProc)(GrEGLDisplay dpy, GrEGLImage image);
 }  // extern "C"
 
-template <typename GLPTR> using GrGLFunction = std::function<skstd::remove_pointer_t<GLPTR>>;
+template <typename GLPTR> using GrGLFunction = std__function<skstd::remove_pointer_t<GLPTR>>;
 
 #endif
--- a/gfx/skia/skia/include/private/SkTArray.h
+++ b/gfx/skia/skia/include/private/SkTArray.h
@@ -155,26 +155,26 @@ public:
         return *newT;
     }
 
     /**
      * Version of above that uses a move constructor to initialize the new item
      */
     T& push_back(T&& t) {
         T* newT = reinterpret_cast<T*>(this->push_back_raw(1));
-        new (newT) T(std::move(t));
+        new (newT) T(std__move(t));
         return *newT;
     }
 
     /**
      *  Construct a new T at the back of this array.
      */
     template<class... Args> T& emplace_back(Args&&... args) {
         T* newT = reinterpret_cast<T*>(this->push_back_raw(1));
-        return *new (newT) T(std::forward<Args>(args)...);
+        return *new (newT) T(std__forward<Args>(args)...);
     }
 
     /**
      * Allocates n more default-initialized T values, and returns the address of
      * the start of that new range. Note: this address is only valid until the
      * next API call made on the array that might add or remove elements.
      */
     T* push_back_n(int n) {
@@ -410,22 +410,22 @@ private:
     }
 
     template <bool E = MEM_COPY> SK_WHEN(!E, void) copy(const T* src) {
         for (int i = 0; i < fCount; ++i) {
             new (fItemArray + i) T(src[i]);
         }
     }
     template <bool E = MEM_COPY> SK_WHEN(!E, void) move(int dst, int src) {
-        new (&fItemArray[dst]) T(std::move(fItemArray[src]));
+        new (&fItemArray[dst]) T(std__move(fItemArray[src]));
         fItemArray[src].~T();
     }
     template <bool E = MEM_COPY> SK_WHEN(!E, void) move(char* dst) {
         for (int i = 0; i < fCount; ++i) {
-            new (dst + sizeof(T) * i) T(std::move(fItemArray[i]));
+            new (dst + sizeof(T) * i) T(std__move(fItemArray[i]));
             fItemArray[i].~T();
         }
     }
 
     static const int gMIN_ALLOC_COUNT = 8;
 
     // Helper function that makes space for n objects, adjusts the count, but does not initialize
     // the new objects.
--- a/gfx/skia/skia/include/private/SkTLogic.h
+++ b/gfx/skia/skia/include/private/SkTLogic.h
@@ -23,27 +23,34 @@
 
 #if MOZ_SKIA_AVOID_CXX11
 #include "mozilla/Function.h"
 #include "mozilla/Move.h"
 #include "mozilla/TypeTraits.h"
 #include "mozilla/UniquePtr.h"
 
 namespace std {
+  #define std__forward mozilla::Forward
+  #define std__move mozilla::Move
+#if SKIA_IMPLEMENTATION
   using mozilla::Forward;
   using mozilla::Move;
   #define forward Forward
   #define move Move
+#endif
 
   // If we have 'using mozilla::function', we're going to collide with
   // 'std::function' on platforms that have it. Therefore we use a macro
   // work around.
   template<typename Signature>
   using moz_function = mozilla::function<Signature>;
+  #define std__function std::moz_function
+#if SKIA_IMPLEMENTATION
   #define function moz_function
+#endif
 
   typedef decltype(nullptr) moz_nullptr_t;
   #define nullptr_t moz_nullptr_t
 
   using mozilla::DefaultDelete;
   using mozilla::UniquePtr;
   #define default_delete DefaultDelete
   #define unique_ptr UniquePtr
@@ -83,16 +90,20 @@ template <typename T> struct underlying_
     using type = __underlying_type(T);
 };
 template <typename T> using underlying_type_t = typename skstd::underlying_type<T>::type;
 
 }
 
 #else /* !MOZ_SKIA_AVOID_CXX11 */
 
+#define std__forward std::forward
+#define std__move std::move
+#define std__function std::function
+
 #include <type_traits>
 
 namespace skstd {
 
 template <bool B> using bool_constant = std::integral_constant<bool, B>;
 
 template <bool B, typename T, typename F> using conditional_t = typename std::conditional<B, T, F>::type;
 template <bool B, typename T = void> using enable_if_t = typename std::enable_if<B, T>::type;