Bug 1101974. Part 2: Initialize vsync source during compositor creation. r=mstange

This commit is contained in:
Mason Chang 2014-11-21 09:16:19 -08:00
Родитель bc4ddfe26e
Коммит a288f3be7d
5 изменённых файлов: 27 добавлений и 20 удалений

Просмотреть файл

@ -394,7 +394,7 @@ CompositorParent::CompositorParent(nsIWidget* aWidget,
if (gfxPrefs::VsyncAlignedCompositor()) {
nsRefPtr<VsyncSource> platformVsyncSource = gfxPlatform::GetPlatform()->GetVsyncSource();
mVsyncDispatcher = new VsyncDispatcher(this, platformVsyncSource.get());
mVsyncDispatcher = new VsyncDispatcher(this, platformVsyncSource);
}
}

Просмотреть файл

@ -547,10 +547,6 @@ gfxPlatform::Init()
}
RegisterStrongMemoryReporter(new GfxMemoryImageReporter());
if (gfxPrefs::HardwareVsyncEnabled() && gfxPrefs::VsyncAlignedCompositor()) {
gPlatform->InitHardwareVsync();
}
}
static bool sLayersIPCIsUp = false;
@ -1640,6 +1636,13 @@ gfxPlatform::AppendCJKPrefLangs(eFontPrefLang aPrefLangs[], uint32_t &aLen, eFon
}
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)
{

Просмотреть файл

@ -44,6 +44,9 @@ namespace gl {
class GLContext;
class SkiaGLGlue;
}
namespace layers {
class VsyncSource;
}
namespace gfx {
class DrawTarget;
class SourceSurface;
@ -583,6 +586,12 @@ public:
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();
@ -590,11 +599,6 @@ protected:
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.

Просмотреть файл

@ -17,7 +17,6 @@
#include "nsTArray.h"
#include "mozilla/Preferences.h"
#include "mozilla/VsyncDispatcher.h"
#include "qcms.h"
#include "gfx2DGlue.h"
#include "gfxPrefs.h"
@ -26,6 +25,7 @@
#include <CoreVideo/CoreVideo.h>
#include "nsCocoaFeatures.h"
#include "mozilla/layers/CompositorParent.h"
using namespace mozilla;
using namespace mozilla::gfx;
@ -38,7 +38,7 @@ typedef uint32_t AutoActivationSetting;
// bug 567552 - disable auto-activation of fonts
static void
static void
DisableFontActivation()
{
// get the main bundle identifier
@ -429,21 +429,21 @@ static CVReturn VsyncCallback(CVDisplayLinkRef aDisplayLink,
CVOptionFlags* aFlagsOut,
void* aDisplayLinkContext)
{
mozilla::VsyncSource* vsyncSource = (mozilla::VsyncSource*) aDisplayLinkContext;
mozilla::layers::VsyncSource* vsyncSource = (mozilla::layers::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::VsyncDispatcher::GetInstance()->NotifyVsync(vsyncTime);
mozilla::layers::VsyncDispatcher::NotifyVsync(vsyncTime);
return kCVReturnSuccess;
} else {
return kCVReturnDisplayLinkNotRunning;
}
}
class OSXVsyncSource MOZ_FINAL : public mozilla::VsyncSource
class OSXVsyncSource MOZ_FINAL : public mozilla::layers::VsyncSource
{
public:
OSXVsyncSource()
@ -499,11 +499,11 @@ private:
CVDisplayLinkRef mDisplayLink;
}; // OSXVsyncSource
void
gfxPlatformMac::InitHardwareVsync()
already_AddRefed<mozilla::layers::VsyncSource>
gfxPlatformMac::GetVsyncSource()
{
nsRefPtr<VsyncSource> osxVsyncSource = new OSXVsyncSource();
mozilla::VsyncDispatcher::GetInstance()->SetVsyncSource(osxVsyncSource);
nsRefPtr<mozilla::layers::VsyncSource> osxVsyncSource = new OSXVsyncSource();
return osxVsyncSource.forget();
}
void

Просмотреть файл

@ -72,7 +72,7 @@ public:
virtual bool UseTiling() MOZ_OVERRIDE;
virtual bool UseProgressivePaint() MOZ_OVERRIDE;
virtual void InitHardwareVsync() MOZ_OVERRIDE;
virtual already_AddRefed<mozilla::layers::VsyncSource> GetVsyncSource() MOZ_OVERRIDE;
// lower threshold on font anti-aliasing
uint32_t GetAntiAliasingThreshold() { return mFontAntiAliasingThreshold; }