Bug 958596 - Allow gfx/2d/Logging.h to be used outside of gfx/2d. r=Bas
authorBotond Ballo <botond@mozilla.com>
Tue, 18 Feb 2014 21:59:34 -0500
changeset 189756 1e198a326d40b42bab2000be4f33093272915291
parent 189755 9f7e35574313ad6c0c42644448d141ae23e331ec
child 189757 6d773a03f6809a5376c0d3f3eddd12ec335a129c
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [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
@@ -7735,16 +7735,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',