Bug 958596 - Allow gfx/2d/Logging.h to be used outside of gfx/2d. r=Bas
☠☠ backed out by ecfb4d63943f ☠ ☠
authorBotond Ballo <botond@mozilla.com>
Tue, 18 Feb 2014 21:59:34 -0500
changeset 170753 07f3cfaa79004858f4466a71b0b83f2ed035e472
parent 170752 758fef09a7277bbe2caec27c3344817e715d7bd5
child 170754 dfadc8e2c38e88bcc0abedf7ed085d78c37472f8
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersBas
bugs958596
milestone30.0a1
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
@@ -7714,16 +7714,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,17 +48,17 @@
 #include "SourceSurfaceRawData.h"
 
 #include "DrawEventRecorder.h"
 
 #include "Logging.h"
 
 #include "mozilla/CheckedInt.h"
 
-#ifdef PR_LOGGING
+#if defined(DEBUG) || defined(PR_LOGGING)
 PRLogModuleInfo *
 GetGFX2DLog()
 {
   static PRLogModuleInfo *sLog;
   if (!sLog)
     sLog = PR_NewLogModule("gfx2d");
   return sLog;
 }
@@ -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();
 #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',