Backed out changeset 08df10804c35 (bug 1101974)
authorWes Kocher <wkocher@mozilla.com>
Fri, 21 Nov 2014 10:52:17 -0800
changeset 241260 6ac6c1eabd76dc3c08a710f5ad854d9e93a5def8
parent 241259 2cae53b8f3f43f3a2f4feba43ed4856fc71a8437
child 241261 5b2f62c1faf9146e0d2673030fc9fb2b076f917c
push idunknown
push userunknown
push dateunknown
bugs1101974
milestone36.0a1
backs out08df10804c35859cb99a5637a45de0af467c7ca2
Backed out changeset 08df10804c35 (bug 1101974)
gfx/layers/ipc/CompositorParent.cpp
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPlatform.h
gfx/thebes/gfxPlatformMac.cpp
gfx/thebes/gfxPlatformMac.h
--- a/gfx/layers/ipc/CompositorParent.cpp
+++ b/gfx/layers/ipc/CompositorParent.cpp
@@ -389,17 +389,17 @@ CompositorParent::CompositorParent(nsIWi
   if (gfxPrefs::AsyncPanZoomEnabled()) {
     mApzcTreeManager = new APZCTreeManager();
   }
 
   gfxPlatform::GetPlatform()->ComputeTileSize();
 
   if (gfxPrefs::VsyncAlignedCompositor()) {
     nsRefPtr<VsyncSource> platformVsyncSource = gfxPlatform::GetPlatform()->GetVsyncSource();
-    mVsyncDispatcher = new VsyncDispatcher(this, platformVsyncSource);
+    mVsyncDispatcher = new VsyncDispatcher(this, platformVsyncSource.get());
   }
 }
 
 bool
 CompositorParent::IsInCompositorThread()
 {
   return CompositorThread() && CompositorThread()->thread_id() == PlatformThread::CurrentId();
 }
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -542,16 +542,20 @@ gfxPlatform::Init()
 
     // Request the imgITools service, implicitly initializing ImageLib.
     nsCOMPtr<imgITools> imgTools = do_GetService("@mozilla.org/image/tools;1");
     if (!imgTools) {
       NS_RUNTIMEABORT("Could not initialize ImageLib");
     }
 
     RegisterStrongMemoryReporter(new GfxMemoryImageReporter());
+
+    if (gfxPrefs::HardwareVsyncEnabled() && gfxPrefs::VsyncAlignedCompositor()) {
+      gPlatform->InitHardwareVsync();
+    }
 }
 
 static bool sLayersIPCIsUp = false;
 
 void
 gfxPlatform::Shutdown()
 {
     if (!gPlatform) {
@@ -1631,23 +1635,16 @@ gfxPlatform::AppendCJKPrefLangs(eFontPre
     uint32_t  i, numCJKlangs = mCJKPrefLangs.Length();
 
     for (i = 0; i < numCJKlangs; i++) {
         AppendPrefLang(aPrefLangs, aLen, (eFontPrefLang) (mCJKPrefLangs[i]));
     }
 
 }
 
-already_AddRefed<mozilla::layers::VsyncSource>
-gfxPlatform::GetVsyncSource()
-{
-  MOZ_CRASH("Vsync support not yet implemented\n");
-  return nullptr;
-}
-
 void
 gfxPlatform::AppendPrefLang(eFontPrefLang aPrefLangs[], uint32_t& aLen, eFontPrefLang aAddLang)
 {
     if (aLen >= kMaxLenPrefLangList) return;
 
     // make sure
     uint32_t  i = 0;
     while (i < aLen && aPrefLangs[i] != aAddLang) {
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -39,19 +39,16 @@ class nsIAtom;
 class nsIObserver;
 struct gfxRGBA;
 
 namespace mozilla {
 namespace gl {
 class GLContext;
 class SkiaGLGlue;
 }
-namespace layers {
-class VsyncSource;
-}
 namespace gfx {
 class DrawTarget;
 class SourceSurface;
 class DataSourceSurface;
 class ScaledFont;
 class DrawEventRecorder;
 
 inline uint32_t
@@ -581,30 +578,29 @@ public:
     mozilla::gl::SkiaGLGlue* GetSkiaGLGlue();
     void PurgeSkiaCache();
 
     virtual bool IsInGonkEmulator() const { return false; }
 
     static bool UsesOffMainThreadCompositing();
 
     bool HasEnoughTotalSystemMemoryForSkiaGL();
-
-    /**
-     * Initialize and get hardware vsync based on each platform.
-     */
-    virtual already_AddRefed<mozilla::layers::VsyncSource> GetVsyncSource();
-
 protected:
     gfxPlatform();
     virtual ~gfxPlatform();
 
     void AppendCJKPrefLangs(eFontPrefLang aPrefLangs[], uint32_t &aLen,
                             eFontPrefLang aCharLang, eFontPrefLang aPageLang);
 
     /**
+     * Initialized hardware vsync based on each platform.
+     */
+    virtual void InitHardwareVsync() {}
+
+    /**
      * Helper method, creates a draw target for a specific Azure backend.
      * Used by CreateOffscreenDrawTarget.
      */
     mozilla::TemporaryRef<DrawTarget>
       CreateDrawTargetForBackend(mozilla::gfx::BackendType aBackend,
                                  const mozilla::gfx::IntSize& aSize,
                                  mozilla::gfx::SurfaceFormat aFormat);
 
--- a/gfx/thebes/gfxPlatformMac.cpp
+++ b/gfx/thebes/gfxPlatformMac.cpp
@@ -12,38 +12,38 @@
 #include "gfxMacPlatformFontList.h"
 #include "gfxMacFont.h"
 #include "gfxCoreTextShaper.h"
 #include "gfxTextRun.h"
 #include "gfxUserFontSet.h"
 
 #include "nsTArray.h"
 #include "mozilla/Preferences.h"
+#include "mozilla/VsyncDispatcher.h"
 #include "qcms.h"
 #include "gfx2DGlue.h"
 #include "gfxPrefs.h"
 
 #include <dlfcn.h>
 #include <CoreVideo/CoreVideo.h>
 
 #include "nsCocoaFeatures.h"
-#include "mozilla/layers/CompositorParent.h"
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 
 // cribbed from CTFontManager.h
 enum {
    kAutoActivationDisabled = 1
 };
 typedef uint32_t AutoActivationSetting;
 
 // bug 567552 - disable auto-activation of fonts
 
-static void
+static void 
 DisableFontActivation()
 {
     // get the main bundle identifier
     CFBundleRef mainBundle = ::CFBundleGetMainBundle();
     CFStringRef mainBundleID = nullptr;
 
     if (mainBundle) {
         mainBundleID = ::CFBundleGetIdentifier(mainBundle);
@@ -424,31 +424,31 @@ gfxPlatformMac::UseProgressivePaint()
 // This is the renderer output callback function, called on the vsync thread
 static CVReturn VsyncCallback(CVDisplayLinkRef aDisplayLink,
                               const CVTimeStamp* aNow,
                               const CVTimeStamp* aOutputTime,
                               CVOptionFlags aFlagsIn,
                               CVOptionFlags* aFlagsOut,
                               void* aDisplayLinkContext)
 {
-  mozilla::layers::VsyncSource* vsyncSource = (mozilla::layers::VsyncSource*) aDisplayLinkContext;
+  mozilla::VsyncSource* vsyncSource = (mozilla::VsyncSource*) aDisplayLinkContext;
   if (vsyncSource->IsVsyncEnabled()) {
     // Now refers to "Now" as in when this callback is called or when the current frame
     // is displayed. aOutputTime is when the next frame should be displayed.
     // Now is VERY VERY noisy, aOutputTime is in the future though.
     int64_t timestamp = aOutputTime->hostTime;
     mozilla::TimeStamp vsyncTime = mozilla::TimeStamp::FromSystemTime(timestamp);
-    mozilla::layers::VsyncDispatcher::NotifyVsync(vsyncTime);
+    mozilla::VsyncDispatcher::GetInstance()->NotifyVsync(vsyncTime);
     return kCVReturnSuccess;
   } else {
     return kCVReturnDisplayLinkNotRunning;
   }
 }
 
-class OSXVsyncSource MOZ_FINAL : public mozilla::layers::VsyncSource
+class OSXVsyncSource MOZ_FINAL : public mozilla::VsyncSource
 {
 public:
   OSXVsyncSource()
   {
     EnableVsync();
   }
 
   virtual void EnableVsync() MOZ_OVERRIDE
@@ -494,21 +494,21 @@ private:
   {
     DisableVsync();
   }
 
   // Manages the display link render thread
   CVDisplayLinkRef   mDisplayLink;
 }; // OSXVsyncSource
 
-already_AddRefed<mozilla::layers::VsyncSource>
-gfxPlatformMac::GetVsyncSource()
+void
+gfxPlatformMac::InitHardwareVsync()
 {
-  nsRefPtr<mozilla::layers::VsyncSource> osxVsyncSource = new OSXVsyncSource();
-  return osxVsyncSource.forget();
+  nsRefPtr<VsyncSource> osxVsyncSource = new OSXVsyncSource();
+  mozilla::VsyncDispatcher::GetInstance()->SetVsyncSource(osxVsyncSource);
 }
 
 void
 gfxPlatformMac::GetPlatformCMSOutputProfile(void* &mem, size_t &size)
 {
     mem = nullptr;
     size = 0;
 
--- a/gfx/thebes/gfxPlatformMac.h
+++ b/gfx/thebes/gfxPlatformMac.h
@@ -67,17 +67,17 @@ public:
     virtual bool CanRenderContentToDataSurface() const MOZ_OVERRIDE {
       return true;
     }
 
     bool UseAcceleratedCanvas();
 
     virtual bool UseTiling() MOZ_OVERRIDE;
     virtual bool UseProgressivePaint() MOZ_OVERRIDE;
-    virtual already_AddRefed<mozilla::layers::VsyncSource> GetVsyncSource() MOZ_OVERRIDE;
+    virtual void InitHardwareVsync() MOZ_OVERRIDE;
 
     // lower threshold on font anti-aliasing
     uint32_t GetAntiAliasingThreshold() { return mFontAntiAliasingThreshold; }
 
 private:
     virtual void GetPlatformCMSOutputProfile(void* &mem, size_t &size);
 
     // read in the pref value for the lower threshold on font anti-aliasing