Bug 958596 - Allow gfx/2d/Logging.h to be used outside of gfx/2d. r=Bas
☠☠ backed out by c9f4f70e46e1 ☠ ☠
authorBotond Ballo <botond@mozilla.com>
Tue, 18 Feb 2014 21:59:34 -0500
changeset 170560 ad35d51d978158ca52ad58ffa46d8965ae6e4673
parent 170559 9cdf5a8140238aff4e9cca8822bca261b9151d82
child 170561 1d40b0b8036dc5022f0f2f4f824162926e370910
push id40251
push userbballo@mozilla.com
push dateWed, 26 Feb 2014 00:36:03 +0000
treeherdermozilla-inbound@e4c0e3d3a768 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas
bugs958596
milestone30.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 958596 - Allow gfx/2d/Logging.h to be used outside of gfx/2d. r=Bas
configure.in
gfx/2d/Factory.cpp
gfx/2d/Logging.h
gfx/2d/Rect.h
gfx/2d/Types.h
gfx/2d/moz.build
--- a/configure.in
+++ b/configure.in
@@ -7692,16 +7692,17 @@ dnl =
 dnl ========================================================
 MOZ_ARG_HEADER(Static build options)
 
 AC_SUBST(LIBXUL_LIBS)
 XPCOM_LIBS="$LIBXUL_LIBS"
 
 if test "$OS_ARCH" = "WINNT"; then
   GKMEDIAS_SHARED_LIBRARY=1
+  AC_DEFINE(GKMEDIAS_SHARED_LIBRARY)
 fi
 AC_SUBST(GKMEDIAS_SHARED_LIBRARY)
 
 if test -z "$MOZ_NATIVE_ZLIB"; then
 if test -n "$JS_SHARED_LIBRARY" -o "$GKMEDIAS_SHARED_LIBRARY"; then
   ZLIB_IN_MOZGLUE=1
   AC_DEFINE(ZLIB_IN_MOZGLUE)
 fi
--- a/gfx/2d/Factory.cpp
+++ b/gfx/2d/Factory.cpp
@@ -48,18 +48,18 @@
 #include "SourceSurfaceRawData.h"
 
 #include "DrawEventRecorder.h"
 
 #include "Logging.h"
 
 #include "mozilla/CheckedInt.h"
 
-#ifdef PR_LOGGING
-PRLogModuleInfo *
+#if defined(DEBUG) || defined(PR_LOGGING)
+GFX2D_API PRLogModuleInfo *
 GetGFX2DLog()
 {
   static PRLogModuleInfo *sLog;
   if (!sLog)
     sLog = PR_NewLogModule("gfx2d");
   return sLog;
 }
 #endif
@@ -151,17 +151,17 @@ HasCPUIDBit(unsigned int level, CPUIDReg
 }
 #endif
 #endif
 
 namespace mozilla {
 namespace gfx {
 
 // XXX - Need to define an API to set this.
-int sGfxLogLevel = LOG_DEBUG;
+GFX2D_API int sGfxLogLevel = LOG_DEBUG;
 
 #ifdef WIN32
 ID3D10Device1 *Factory::mD3D10Device;
 #ifdef USE_D2D1_1
 ID3D11Device *Factory::mD3D11Device;
 ID2D1Device *Factory::mD2D1Device;
 #endif
 #endif
--- a/gfx/2d/Logging.h
+++ b/gfx/2d/Logging.h
@@ -9,46 +9,53 @@
 #include <string>
 #include <sstream>
 #include <stdio.h>
 
 #include "Point.h"
 #include "Matrix.h"
 
 #ifdef WIN32
-#include <windows.h>
+// This file gets included from nsGlobalWindow.cpp, which doesn't like
+// having windows.h included in it. Since OutputDebugStringA is the only
+// thing we need from windows.h, we just declare it here directly.
+// Note: the function's documented signature is
+//  WINBASEAPI void WINAPI OutputDebugStringA(LPCSTR lpOutputString)
+// but if we don't include windows.h, the macros WINBASEAPI, WINAPI, and 
+// LPCSTR are not defined, so we need to replace them with their expansions.
+extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char* lpOutputString);
 #endif
 
-#ifdef PR_LOGGING
+#if defined(DEBUG) || defined(PR_LOGGING)
 #include <prlog.h>
 
-extern PRLogModuleInfo *GetGFX2DLog();
+extern GFX2D_API PRLogModuleInfo *GetGFX2DLog();
 #endif
 
 namespace mozilla {
 namespace gfx {
 
 const int LOG_DEBUG = 1;
 const int LOG_WARNING = 2;
 
-#ifdef PR_LOGGING
+#if defined(DEBUG) || defined(PR_LOGGING)
 
 inline PRLogModuleLevel PRLogLevelForLevel(int aLevel) {
   switch (aLevel) {
   case LOG_DEBUG:
     return PR_LOG_DEBUG;
   case LOG_WARNING:
     return PR_LOG_WARNING;
   }
   return PR_LOG_DEBUG;
 }
 
 #endif
 
-extern int sGfxLogLevel;
+extern GFX2D_API int sGfxLogLevel;
 
 static inline void OutputMessage(const std::string &aString, int aLevel) {
 #if defined(WIN32) && !defined(PR_LOGGING)
   if (aLevel >= sGfxLogLevel) {
     ::OutputDebugStringA(aString.c_str());
   }
 #elif defined(PR_LOGGING)
   if (PR_LOG_TEST(GetGFX2DLog(), PRLogLevelForLevel(aLevel))) {
--- a/gfx/2d/Rect.h
+++ b/gfx/2d/Rect.h
@@ -92,17 +92,17 @@ struct RectTyped :
     RectTyped(const PointTyped<units>& aPos, const SizeTyped<units>& aSize) :
         Super(aPos, aSize) {}
     RectTyped(Float _x, Float _y, Float _width, Float _height) :
         Super(_x, _y, _width, _height) {}
     explicit RectTyped(const IntRectTyped<units>& rect) :
         Super(float(rect.x), float(rect.y),
               float(rect.width), float(rect.height)) {}
 
-    GFX2D_API void NudgeToIntegers()
+    void NudgeToIntegers()
     {
       NudgeToInteger(&(this->x));
       NudgeToInteger(&(this->y));
       NudgeToInteger(&(this->width));
       NudgeToInteger(&(this->height));
     }
 
     bool ToIntRect(IntRectTyped<units> *aOut) const
--- a/gfx/2d/Types.h
+++ b/gfx/2d/Types.h
@@ -241,17 +241,17 @@ struct GradientStop
 
   Float offset;
   Color color;
 };
 
 }
 }
 
-#if defined(XP_WIN) && defined(MOZ_GFX)
+#if defined(XP_WIN) && defined(GKMEDIAS_SHARED_LIBRARY)
 #ifdef GFX2D_INTERNAL
 #define GFX2D_API __declspec(dllexport)
 #else
 #define GFX2D_API __declspec(dllimport)
 #endif
 #else
 #define GFX2D_API
 #endif
--- a/gfx/2d/moz.build
+++ b/gfx/2d/moz.build
@@ -16,16 +16,17 @@ EXPORTS.mozilla.gfx += [
     'BasePoint4D.h',
     'BaseRect.h',
     'BaseSize.h',
     'Blur.h',
     'BorrowedContext.h',
     'DataSurfaceHelpers.h',
     'Filters.h',
     'Helpers.h',
+    'Logging.h',
     'Matrix.h',
     'PathHelpers.h',
     'Point.h',
     'Rect.h',
     'Scale.h',
     'ScaleFactor.h',
     'Tools.h',
     'Types.h',