Bug 1156742 Part 2: Make gfx thebes/gl/2d work with UNICODE defined. r=bas, r=glandium
authorBob Owen <bobowencode@gmail.com>
Tue, 05 Jan 2016 10:08:56 +0000
changeset 300705 e9837ebf5d48f1f7a6f881d4120a47262d5b84c8
parent 300704 e3834d920c4abd86efc63d883d0bfa15d6ffc91b
child 300706 ef3078a358d8072dc4c04a9fb6880928884b5bae
push id8978
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 14:05:32 +0000
treeherdermozilla-aurora@b9a803752a2c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbas, glandium
bugs1156742
milestone46.0a1
Bug 1156742 Part 2: Make gfx thebes/gl/2d work with UNICODE defined. r=bas, r=glandium
gfx/2d/moz.build
gfx/gl/moz.build
gfx/skia/generate_mozbuild.py
gfx/skia/moz.build
gfx/thebes/gfxDWriteFontList.cpp
gfx/thebes/gfxDWriteFonts.cpp
gfx/thebes/gfxGDIFontList.cpp
gfx/thebes/moz.build
--- a/gfx/2d/moz.build
+++ b/gfx/2d/moz.build
@@ -181,15 +181,8 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('and
     DEFINES['MOZ_ENABLE_FREETYPE'] = True
 
 CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3', 'gonk', 'qt'):
     CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
 
 LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES']
-
-if CONFIG['OS_ARCH'] == 'WINNT':
-    # Due to bug 796023, we can't have -DUNICODE and -D_UNICODE; defining those
-    # macros changes the type of LOGFONT to LOGFONTW instead of LOGFONTA. This
-    # changes the symbol names of exported C++ functions that use LOGFONT.
-    del DEFINES['UNICODE']
-    del DEFINES['_UNICODE']
--- a/gfx/gl/moz.build
+++ b/gfx/gl/moz.build
@@ -165,13 +165,10 @@ if CONFIG['MOZ_D3DCOMPILER_XP_DLL']:
 
 CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
 CXXFLAGS += CONFIG['TK_CFLAGS']
 CFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
 CFLAGS += CONFIG['TK_CFLAGS']
 
 LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES']
 
-if CONFIG['OS_ARCH'] == 'WINNT':
-    del DEFINES['UNICODE']
-
 if CONFIG['CLANG_CXX']:
     CXXFLAGS += ['-Wshadow']
--- a/gfx/skia/generate_mozbuild.py
+++ b/gfx/skia/generate_mozbuild.py
@@ -64,16 +64,20 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] in {
     'android',
     'cocoa',
     'uikit',
     'gonk',
     'qt',
   } or CONFIG['MOZ_WIDGET_GTK']:
     DEFINES['SK_FONTHOST_DOES_NOT_USE_FONTMGR'] = 1
 
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
+    DEFINES['UNICODE'] = True
+    DEFINES['_UNICODE'] = True
+
 # We should autogenerate these SSE related flags.
 
 if CONFIG['_MSC_VER']:
     # MSVC doesn't need special compiler flags, but Skia needs to be told that these files should
     # be built with the required SSE level or it will simply compile in stubs and cause runtime crashes
     SOURCES['skia/src/opts/SkBitmapFilter_opts_SSE2.cpp'].flags += ['/arch:SSE2 -DSK_CPU_SSE_LEVEL=20']
     SOURCES['skia/src/opts/SkBitmapProcState_opts_SSE2.cpp'].flags += ['/arch:SSE2 -DSK_CPU_SSE_LEVEL=20']
     SOURCES['skia/src/opts/SkBitmapProcState_opts_SSSE3.cpp'].flags += ['/arch:SSE2 -DSK_CPU_SSE_LEVEL=31']
--- a/gfx/skia/moz.build
+++ b/gfx/skia/moz.build
@@ -680,16 +680,20 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] in {
     'android',
     'cocoa',
     'uikit',
     'gonk',
     'qt',
   } or CONFIG['MOZ_WIDGET_GTK']:
     DEFINES['SK_FONTHOST_DOES_NOT_USE_FONTMGR'] = 1
 
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
+    DEFINES['UNICODE'] = True
+    DEFINES['_UNICODE'] = True
+
 # We should autogenerate these SSE related flags.
 
 if CONFIG['_MSC_VER']:
     # MSVC doesn't need special compiler flags, but Skia needs to be told that these files should
     # be built with the required SSE level or it will simply compile in stubs and cause runtime crashes
     SOURCES['skia/src/opts/SkBitmapFilter_opts_SSE2.cpp'].flags += ['/arch:SSE2 -DSK_CPU_SSE_LEVEL=20']
     SOURCES['skia/src/opts/SkBitmapProcState_opts_SSE2.cpp'].flags += ['/arch:SSE2 -DSK_CPU_SSE_LEVEL=20']
     SOURCES['skia/src/opts/SkBitmapProcState_opts_SSSE3.cpp'].flags += ['/arch:SSE2 -DSK_CPU_SSE_LEVEL=31']
--- a/gfx/thebes/gfxDWriteFontList.cpp
+++ b/gfx/thebes/gfxDWriteFontList.cpp
@@ -855,19 +855,19 @@ nsresult
 gfxDWriteFontList::InitFontList()
 {
     LARGE_INTEGER frequency;          // ticks per second
     LARGE_INTEGER t1, t2, t3, t4, t5; // ticks
     double elapsedTime, upTime;
     char nowTime[256], nowDate[256];
 
     if (LOG_FONTINIT_ENABLED()) {
-        GetTimeFormat(LOCALE_INVARIANT, TIME_FORCE24HOURFORMAT,
+        GetTimeFormatA(LOCALE_INVARIANT, TIME_FORCE24HOURFORMAT,
                       nullptr, nullptr, nowTime, 256);
-        GetDateFormat(LOCALE_INVARIANT, 0, nullptr, nullptr, nowDate, 256);
+        GetDateFormatA(LOCALE_INVARIANT, 0, nullptr, nullptr, nowDate, 256);
         upTime = (double) GetTickCount();
     }
     QueryPerformanceFrequency(&frequency);
     QueryPerformanceCounter(&t1); // start
 
     HRESULT hr;
     mGDIFontTableAccess =
         Preferences::GetBool("gfx.font_rendering.directwrite.use_gdi_table_loading",
--- a/gfx/thebes/gfxDWriteFonts.cpp
+++ b/gfx/thebes/gfxDWriteFonts.cpp
@@ -227,17 +227,17 @@ gfxDWriteFont::ComputeMetrics(AntialiasO
         }
     }
 
     mMetrics->internalLeading = std::max(mMetrics->maxHeight - mMetrics->emHeight, 0.0);
     mMetrics->externalLeading = ceil(fontMetrics.lineGap * mFUnitsConvFactor);
 
     UINT32 ucs = L' ';
     UINT16 glyph;
-    HRESULT hr = mFontFace->GetGlyphIndicesA(&ucs, 1, &glyph);
+    HRESULT hr = mFontFace->GetGlyphIndicesW(&ucs, 1, &glyph);
     if (FAILED(hr)) {
         mMetrics->spaceWidth = 0;
     } else {
         mSpaceGlyph = glyph;
         mMetrics->spaceWidth = MeasureGlyphWidth(glyph);
     }
 
     // try to get aveCharWidth from the OS/2 table, fall back to measuring 'x'
@@ -257,27 +257,27 @@ gfxDWriteFont::ComputeMetrics(AntialiasO
                 mMetrics->aveCharWidth =
                     int16_t(os2->xAvgCharWidth) * mFUnitsConvFactor;
             }
         }
     }
 
     if (mMetrics->aveCharWidth < 1) {
         ucs = L'x';
-        if (SUCCEEDED(mFontFace->GetGlyphIndicesA(&ucs, 1, &glyph))) {
+        if (SUCCEEDED(mFontFace->GetGlyphIndicesW(&ucs, 1, &glyph))) {
             mMetrics->aveCharWidth = MeasureGlyphWidth(glyph);
         }
         if (mMetrics->aveCharWidth < 1) {
             // Let's just assume the X is square.
             mMetrics->aveCharWidth = fontMetrics.xHeight * mFUnitsConvFactor;
         }
     }
 
     ucs = L'0';
-    if (SUCCEEDED(mFontFace->GetGlyphIndicesA(&ucs, 1, &glyph))) {
+    if (SUCCEEDED(mFontFace->GetGlyphIndicesW(&ucs, 1, &glyph))) {
         mMetrics->zeroOrAveCharWidth = MeasureGlyphWidth(glyph);
     }
     if (mMetrics->zeroOrAveCharWidth < 1) {
         mMetrics->zeroOrAveCharWidth = mMetrics->aveCharWidth;
     }
 
     mMetrics->underlineOffset =
         fontMetrics.underlinePosition * mFUnitsConvFactor;
--- a/gfx/thebes/gfxGDIFontList.cpp
+++ b/gfx/thebes/gfxGDIFontList.cpp
@@ -1112,17 +1112,17 @@ gfxGDIFontList::ActivateBundledFonts()
         nsCOMPtr<nsISupports> entry;
         if (NS_FAILED(e->GetNext(getter_AddRefs(entry)))) {
             break;
         }
         nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
         if (!file) {
             continue;
         }
-        nsCString path;
-        if (NS_FAILED(file->GetNativePath(path))) {
+        nsAutoString path;
+        if (NS_FAILED(file->GetPath(path))) {
             continue;
         }
-        AddFontResourceEx(path.get(), FR_PRIVATE, nullptr);
+        AddFontResourceExW(path.get(), FR_PRIVATE, nullptr);
     }
 }
 
 #endif
--- a/gfx/thebes/moz.build
+++ b/gfx/thebes/moz.build
@@ -302,11 +302,8 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'andr
     DEFINES['MOZ_USING_ANDROID_JAVA_WIDGETS'] = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'qt'):
     CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS']
 
 LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES']
 
 DEFINES['GRAPHITE2_STATIC'] = True
-
-if CONFIG['OS_ARCH'] == 'WINNT':
-    del DEFINES['UNICODE']