Bug 939585 - Build gfx/thebes in unified mode; r=BenWa
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 27 Nov 2013 08:03:04 -0500
changeset 173416 32aa215becb49ba3218a509bd81a38e579fe08df
parent 173415 d85ff23b7d1b58441c2bb26c6d777b008fe64bfb
child 173417 30fe34b9ebf7292e7ca5333fc70b3ae34c4fc9af
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBenWa
bugs939585
milestone28.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 939585 - Build gfx/thebes in unified mode; r=BenWa
gfx/thebes/gfxCoreTextShaper.cpp
gfx/thebes/gfxGraphiteShaper.cpp
gfx/thebes/gfxHarfBuzzShaper.cpp
gfx/thebes/gfxUtils.cpp
gfx/thebes/moz.build
gfx/thebes/nsSurfaceTexture.cpp
--- a/gfx/thebes/gfxCoreTextShaper.cpp
+++ b/gfx/thebes/gfxCoreTextShaper.cpp
@@ -484,16 +484,18 @@ gfxCoreTextShaper::SetGlyphsFromRun(gfxS
 
         glyphStart = glyphEnd;
         charStart = charEnd;
     }
 
     return NS_OK;
 }
 
+#undef SMALL_GLYPH_RUN
+
 // Construct the font attribute descriptor that we'll apply by default when creating a CTFontRef.
 // This will turn off line-edge swashes by default, because we don't know the actual line breaks
 // when doing glyph shaping.
 void
 gfxCoreTextShaper::CreateDefaultFeaturesDescriptor()
 {
     if (sDefaultFeaturesDescriptor != nullptr) {
         return;
--- a/gfx/thebes/gfxGraphiteShaper.cpp
+++ b/gfx/thebes/gfxGraphiteShaper.cpp
@@ -331,16 +331,18 @@ gfxGraphiteShaper::SetGlyphsFromSegment(
             NS_ASSERTION(!g.IsSimpleGlyph(), "overwriting a simple glyph");
             g.SetComplex(g.IsClusterStart(), false, 0);
         }
     }
 
     return NS_OK;
 }
 
+#undef SMALL_GLYPH_RUN
+
 // for language tag validation - include list of tags from the IANA registry
 #include "gfxLanguageTagList.cpp"
 
 nsTHashtable<nsUint32HashKey> *gfxGraphiteShaper::sLanguageTags;
 
 /*static*/ uint32_t
 gfxGraphiteShaper::GetGraphiteTagForLang(const nsCString& aLang)
 {
--- a/gfx/thebes/gfxHarfBuzzShaper.cpp
+++ b/gfx/thebes/gfxHarfBuzzShaper.cpp
@@ -774,17 +774,17 @@ HBUnicodeDecompose(hb_unicode_funcs_t *u
                    hb_codepoint_t     *a,
                    hb_codepoint_t     *b,
                    void               *user_data)
 {
     return nsUnicodeNormalizer::DecomposeNonRecursively(ab, a, b);
 }
 
 static PLDHashOperator
-AddFeature(const uint32_t& aTag, uint32_t& aValue, void *aUserArg)
+AddOpenTypeFeature(const uint32_t& aTag, uint32_t& aValue, void *aUserArg)
 {
     nsTArray<hb_feature_t>* features = static_cast<nsTArray<hb_feature_t>*> (aUserArg);
 
     hb_feature_t feat = { 0, 0, 0, UINT_MAX };
     feat.tag = aTag;
     feat.value = aValue;
     features->AppendElement(feat);
     return PL_DHASH_NEXT;
@@ -927,17 +927,17 @@ gfxHarfBuzzShaper::ShapeText(gfxContext 
 
     if (MergeFontFeatures(style,
                           entry->mFeatureSettings,
                           aShapedText->DisableLigatures(),
                           entry->FamilyName(),
                           mergedFeatures))
     {
         // enumerate result and insert into hb_feature array
-        mergedFeatures.Enumerate(AddFeature, &features);
+        mergedFeatures.Enumerate(AddOpenTypeFeature, &features);
     }
 
     bool isRightToLeft = aShapedText->IsRightToLeft();
     hb_buffer_t *buffer = hb_buffer_create();
     hb_buffer_set_unicode_funcs(buffer, sHBUnicodeFuncs);
     hb_buffer_set_direction(buffer, isRightToLeft ? HB_DIRECTION_RTL :
                                                     HB_DIRECTION_LTR);
     // For unresolved "common" or "inherited" runs, default to Latin for now.
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -520,17 +520,17 @@ static void
 ClipToRegionInternal(gfxContext* aContext, const nsIntRegion& aRegion,
                      bool aSnap)
 {
   PathFromRegionInternal(aContext, aRegion, aSnap);
   aContext->Clip();
 }
 
 static TemporaryRef<Path>
-PathFromRegionInternal(gfx::DrawTarget* aTarget, const nsIntRegion& aRegion,
+PathFromRegionInternal(DrawTarget* aTarget, const nsIntRegion& aRegion,
                        bool aSnap)
 {
   Matrix mat = aTarget->GetTransform();
   const gfxFloat epsilon = 0.000001;
 #define WITHIN_E(a,b) (fabs((a)-(b)) < epsilon)
   // We're essentially duplicating the logic in UserToDevicePixelSnapped here.
   bool shouldNotSnap = !aSnap || (WITHIN_E(mat._11,1.0) &&
                                   WITHIN_E(mat._22,1.0) &&
@@ -562,17 +562,17 @@ PathFromRegionInternal(gfx::DrawTarget* 
       pb->Close();
     }
   }
   RefPtr<Path> path = pb->Finish();
   return path;
 }
 
 static void
-ClipToRegionInternal(gfx::DrawTarget* aTarget, const nsIntRegion& aRegion,
+ClipToRegionInternal(DrawTarget* aTarget, const nsIntRegion& aRegion,
                      bool aSnap)
 {
   RefPtr<Path> path = PathFromRegionInternal(aTarget, aRegion, aSnap);
   aTarget->PushClip(path);
 }
 
 /*static*/ void
 gfxUtils::ClipToRegion(gfxContext* aContext, const nsIntRegion& aRegion)
@@ -685,39 +685,39 @@ gfxUtils::GfxRectToIntRect(const gfxRect
   return gfxRect(aOut->x, aOut->y, aOut->width, aOut->height).IsEqualEdges(aIn);
 }
 
 void
 gfxUtils::GetYCbCrToRGBDestFormatAndSize(const PlanarYCbCrData& aData,
                                          gfxImageFormat& aSuggestedFormat,
                                          gfxIntSize& aSuggestedSize)
 {
-  gfx::YUVType yuvtype =
-    gfx::TypeFromSize(aData.mYSize.width,
+  YUVType yuvtype =
+    TypeFromSize(aData.mYSize.width,
                       aData.mYSize.height,
                       aData.mCbCrSize.width,
                       aData.mCbCrSize.height);
 
   // 'prescale' is true if the scaling is to be done as part of the
   // YCbCr to RGB conversion rather than on the RGB data when rendered.
   bool prescale = aSuggestedSize.width > 0 && aSuggestedSize.height > 0 &&
                     aSuggestedSize != aData.mPicSize;
 
   if (aSuggestedFormat == gfxImageFormatRGB16_565) {
 #if defined(HAVE_YCBCR_TO_RGB565)
     if (prescale &&
-        !gfx::IsScaleYCbCrToRGB565Fast(aData.mPicX,
+        !IsScaleYCbCrToRGB565Fast(aData.mPicX,
                                        aData.mPicY,
                                        aData.mPicSize.width,
                                        aData.mPicSize.height,
                                        aSuggestedSize.width,
                                        aSuggestedSize.height,
                                        yuvtype,
-                                       gfx::FILTER_BILINEAR) &&
-        gfx::IsConvertYCbCrToRGB565Fast(aData.mPicX,
+                                       FILTER_BILINEAR) &&
+        IsConvertYCbCrToRGB565Fast(aData.mPicX,
                                         aData.mPicY,
                                         aData.mPicSize.width,
                                         aData.mPicSize.height,
                                         yuvtype)) {
       prescale = false;
     }
 #else
     // yuv2rgb16 function not available
@@ -726,17 +726,17 @@ gfxUtils::GetYCbCrToRGBDestFormatAndSize
   }
   else if (aSuggestedFormat != gfxImageFormatRGB24) {
     // No other formats are currently supported.
     aSuggestedFormat = gfxImageFormatRGB24;
   }
   if (aSuggestedFormat == gfxImageFormatRGB24) {
     /* ScaleYCbCrToRGB32 does not support a picture offset, nor 4:4:4 data.
        See bugs 639415 and 640073. */
-    if (aData.mPicX != 0 || aData.mPicY != 0 || yuvtype == gfx::YV24)
+    if (aData.mPicX != 0 || aData.mPicY != 0 || yuvtype == YV24)
       prescale = false;
   }
   if (!prescale) {
     aSuggestedSize = aData.mPicSize;
   }
 }
 
 void
@@ -747,75 +747,75 @@ gfxUtils::ConvertYCbCrToRGB(const Planar
                             int32_t aStride)
 {
   // ConvertYCbCrToRGB et al. assume the chroma planes are rounded up if the
   // luma plane is odd sized.
   MOZ_ASSERT((aData.mCbCrSize.width == aData.mYSize.width ||
               aData.mCbCrSize.width == (aData.mYSize.width + 1) >> 1) &&
              (aData.mCbCrSize.height == aData.mYSize.height ||
               aData.mCbCrSize.height == (aData.mYSize.height + 1) >> 1));
-  gfx::YUVType yuvtype =
-    gfx::TypeFromSize(aData.mYSize.width,
+  YUVType yuvtype =
+    TypeFromSize(aData.mYSize.width,
                       aData.mYSize.height,
                       aData.mCbCrSize.width,
                       aData.mCbCrSize.height);
 
   // Convert from YCbCr to RGB now, scaling the image if needed.
   if (aDestSize != aData.mPicSize) {
 #if defined(HAVE_YCBCR_TO_RGB565)
     if (aDestFormat == gfxImageFormatRGB16_565) {
-      gfx::ScaleYCbCrToRGB565(aData.mYChannel,
+      ScaleYCbCrToRGB565(aData.mYChannel,
                               aData.mCbChannel,
                               aData.mCrChannel,
                               aDestBuffer,
                               aData.mPicX,
                               aData.mPicY,
                               aData.mPicSize.width,
                               aData.mPicSize.height,
                               aDestSize.width,
                               aDestSize.height,
                               aData.mYStride,
                               aData.mCbCrStride,
                               aStride,
                               yuvtype,
-                              gfx::FILTER_BILINEAR);
+                              FILTER_BILINEAR);
     } else
 #endif
-      gfx::ScaleYCbCrToRGB32(aData.mYChannel,
+      ScaleYCbCrToRGB32(aData.mYChannel,
                              aData.mCbChannel,
                              aData.mCrChannel,
                              aDestBuffer,
                              aData.mPicSize.width,
                              aData.mPicSize.height,
                              aDestSize.width,
                              aDestSize.height,
                              aData.mYStride,
                              aData.mCbCrStride,
                              aStride,
                              yuvtype,
-                             gfx::ROTATE_0,
-                             gfx::FILTER_BILINEAR);
+                             ROTATE_0,
+                             FILTER_BILINEAR);
   } else { // no prescale
 #if defined(HAVE_YCBCR_TO_RGB565)
     if (aDestFormat == gfxImageFormatRGB16_565) {
-      gfx::ConvertYCbCrToRGB565(aData.mYChannel,
+      ConvertYCbCrToRGB565(aData.mYChannel,
                                 aData.mCbChannel,
                                 aData.mCrChannel,
                                 aDestBuffer,
                                 aData.mPicX,
                                 aData.mPicY,
                                 aData.mPicSize.width,
                                 aData.mPicSize.height,
                                 aData.mYStride,
                                 aData.mCbCrStride,
                                 aStride,
                                 yuvtype);
     } else // aDestFormat != gfxImageFormatRGB16_565
 #endif
-      gfx::ConvertYCbCrToRGB32(aData.mYChannel,
+      ConvertYCbCrToRGB32(aData.mYChannel,
                                aData.mCbChannel,
                                aData.mCrChannel,
                                aDestBuffer,
                                aData.mPicX,
                                aData.mPicY,
                                aData.mPicSize.width,
                                aData.mPicSize.height,
                                aData.mYStride,
--- a/gfx/thebes/moz.build
+++ b/gfx/thebes/moz.build
@@ -198,79 +198,95 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wi
         'gfxGDIFont.h',
         'gfxGDIFontList.h',
         'gfxPDFSurface.h',
         'gfxPlatformFontList.h',
         'gfxWindowsNativeDrawing.h',
         'gfxWindowsPlatform.h',
         'gfxWindowsSurface.h',
     ]
+    # gfxGDIFontList.cpp and gfxGDIShaper.cpp force NSPR logging, so they cannot be built in unified mode.
     SOURCES += [
         'gfxGDIFont.cpp',
         'gfxGDIFontList.cpp',
         'gfxGDIShaper.cpp',
         'gfxPDFSurface.cpp',
         'gfxUniscribeShaper.cpp',
         'gfxWindowsNativeDrawing.cpp',
         'gfxWindowsPlatform.cpp',
         'gfxWindowsSurface.cpp',
         'nsUnicodeRange.cpp',
     ]
     if CONFIG['MOZ_ENABLE_DWRITE_FONT']:
+        # gfxDWriteFontList.cpp forces NSPR logging, so it cannot be built in unified mode.
         SOURCES += [
             'gfxD2DSurface.cpp',
             'gfxDWriteCommon.cpp',
             'gfxDWriteFontList.cpp',
             'gfxDWriteFonts.cpp',
             'gfxDWriteShaper.cpp',
             'gfxDWriteTextAnalysis.cpp',
         ]
 
 # Are we targeting x86 or x64?  If so, build gfxAlphaRecoverySSE2.cpp.
 if CONFIG['INTEL_ARCHITECTURE']:
     SOURCES += [
         'gfxAlphaRecoverySSE2.cpp',
     ]
 
 SOURCES += [
+    # Includes mac system header conflicting with point/size,
+    # and includes glxXlibSurface.h which drags in Xrender.h
+    'gfxASurface.cpp',
+    # on X11, gfxDrawable.cpp includes X headers for an old workaround which
+    # we could consider removing soon (affects Ubuntus older than 10.04 LTS)
+    # which currently prevent it from joining UNIFIED_SOURCES.
+    'gfxDrawable.cpp',
+    # Uses FORCE_PR_LOG
+    'gfxFont.cpp',
+    # Uses FORCE_PR_LOG
+    'gfxFontUtils.cpp',
+    # Includes mac system header conflicting with point/size, and also uses FORCE_PR_LOG
+    'gfxPlatform.cpp',
+    # Uses FORCE_PR_LOG
+    'gfxPlatformFontList.cpp',
+    # Uses FORCE_PR_LOG
+    'gfxUserFontSet.cpp',
+]
+
+UNIFIED_SOURCES += [
     'gfx3DMatrix.cpp',
     'gfxAlphaRecovery.cpp',
-    'gfxASurface.cpp',
     'gfxBaseSharedMemorySurface.cpp',
     'gfxBlur.cpp',
     'gfxCachedTempSurface.cpp',
     'gfxContext.cpp',
-    'gfxDrawable.cpp',
-    'gfxFont.cpp',
     'gfxFontFeatures.cpp',
     'gfxFontMissingGlyphs.cpp',
     'gfxFontTest.cpp',
-    'gfxFontUtils.cpp',
     'gfxGradientCache.cpp',
     'gfxGraphiteShaper.cpp',
     'gfxHarfBuzzShaper.cpp',
     'gfxImageSurface.cpp',
     'gfxMatrix.cpp',
     'gfxPath.cpp',
     'gfxPattern.cpp',
-    'gfxPlatform.cpp',
-    'gfxPlatformFontList.cpp',
     'gfxRect.cpp',
     'gfxReusableImageSurfaceWrapper.cpp',
     'gfxReusableSharedImageSurfaceWrapper.cpp',
     'gfxScriptItemizer.cpp',
     'gfxSkipChars.cpp',
     'gfxSVGGlyphs.cpp',
     'gfxTeeSurface.cpp',
-    'gfxUserFontSet.cpp',
     'gfxUtils.cpp',
     'nsSurfaceTexture.cpp',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
+    # gfxMacPlatformFontList.mm forces NSPR logging so it cannot be built in unified mode.
     SOURCES += [
         'gfxMacPlatformFontList.mm',
     ]
 
 FAIL_ON_WARNINGS = not CONFIG['_MSC_VER']
 
 MSVC_ENABLE_PGO = True
 
--- a/gfx/thebes/nsSurfaceTexture.cpp
+++ b/gfx/thebes/nsSurfaceTexture.cpp
@@ -11,18 +11,16 @@
 #include <android/log.h>
 #include "nsSurfaceTexture.h"
 #include "gfxImageSurface.h"
 #include "AndroidBridge.h"
 #include "nsThreadUtils.h"
 
 using namespace mozilla;
 
-#define LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "nsSurfaceTexture" , ## args)
-
 // UGH
 static std::map<int, nsSurfaceTexture*> sInstances;
 static int sNextID = 0;
 
 static class JNIFunctions {
 public:
 
   JNIFunctions() : mInitialized(false)
@@ -136,17 +134,17 @@ nsSurfaceTexture::Create(GLuint aTexture
 {
   // Right now we only support creating this on the main thread because
   // of the JNIEnv assumptions in JNIHelper and elsewhere
   if (!NS_IsMainThread())
     return nullptr;
 
   nsSurfaceTexture* st = new nsSurfaceTexture();
   if (!st->Init(aTexture)) {
-    LOG("Failed to initialize nsSurfaceTexture");
+    printf_stderr("Failed to initialize nsSurfaceTexture");
     delete st;
     st = nullptr;
   }
 
   return st;
 }
 
 nsSurfaceTexture*