mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Send vsync rates to the compositor to avoid querying gfxPlatform. (bug 1288822, r=mchang)
This commit is contained in:
parent
644c65db8f
commit
d3cb1d23af
@ -100,11 +100,12 @@ OpenParent(RefPtr<CompositorBridgeParent> aParent,
|
||||
bool
|
||||
GPUParent::RecvNewWidgetCompositor(Endpoint<layers::PCompositorBridgeParent>&& aEndpoint,
|
||||
const CSSToLayoutDeviceScale& aScale,
|
||||
const TimeDuration& aVsyncRate,
|
||||
const bool& aUseExternalSurfaceSize,
|
||||
const IntSize& aSurfaceSize)
|
||||
{
|
||||
RefPtr<CompositorBridgeParent> cbp =
|
||||
new CompositorBridgeParent(aScale, aUseExternalSurfaceSize, aSurfaceSize);
|
||||
new CompositorBridgeParent(aScale, aVsyncRate, aUseExternalSurfaceSize, aSurfaceSize);
|
||||
|
||||
MessageLoop* loop = CompositorThreadHolder::Loop();
|
||||
loop->PostTask(NewRunnableFunction(OpenParent, cbp, Move(aEndpoint)));
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
bool RecvNewWidgetCompositor(
|
||||
Endpoint<PCompositorBridgeParent>&& aEndpoint,
|
||||
const CSSToLayoutDeviceScale& aScale,
|
||||
const TimeDuration& aVsyncRate,
|
||||
const bool& aUseExternalSurface,
|
||||
const IntSize& aSurfaceSize) override;
|
||||
bool RecvNewContentCompositorBridge(Endpoint<PCompositorBridgeParent>&& aEndpoint) override;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "VRManagerParent.h"
|
||||
#include "VsyncBridgeChild.h"
|
||||
#include "VsyncIOThreadHolder.h"
|
||||
#include "VsyncSource.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
@ -352,9 +353,13 @@ GPUProcessManager::CreateRemoteSession(nsBaseWidget* aWidget,
|
||||
CompositorWidgetInitData initData;
|
||||
aWidget->GetCompositorWidgetInitData(&initData);
|
||||
|
||||
TimeDuration vsyncRate =
|
||||
gfxPlatform::GetPlatform()->GetHardwareVsync()->GetGlobalDisplay().GetVsyncRate();
|
||||
|
||||
bool ok = mGPUChild->SendNewWidgetCompositor(
|
||||
Move(parentPipe),
|
||||
aScale,
|
||||
vsyncRate,
|
||||
aUseExternalSurfaceSize,
|
||||
aSurfaceSize);
|
||||
if (!ok) {
|
||||
|
@ -8,6 +8,7 @@ include protocol PImageBridge;
|
||||
include protocol PVRManager;
|
||||
include protocol PVsyncBridge;
|
||||
|
||||
using mozilla::TimeDuration from "mozilla/TimeStamp.h";
|
||||
using mozilla::CSSToLayoutDeviceScale from "Units.h";
|
||||
using mozilla::gfx::IntSize from "mozilla/gfx/2D.h";
|
||||
|
||||
@ -42,6 +43,7 @@ parent:
|
||||
// Create a new top-level compositor.
|
||||
async NewWidgetCompositor(Endpoint<PCompositorBridgeParent> endpoint,
|
||||
CSSToLayoutDeviceScale scale,
|
||||
TimeDuration vsyncRate,
|
||||
bool useExternalSurface,
|
||||
IntSize surfaceSize);
|
||||
|
||||
|
@ -1465,6 +1465,7 @@ AsyncCompositionManager::GetFrameUniformity(FrameUniformityData* aOutData)
|
||||
|
||||
bool
|
||||
AsyncCompositionManager::TransformShadowTree(TimeStamp aCurrentFrame,
|
||||
TimeDuration aVsyncRate,
|
||||
TransformsToSkip aSkip)
|
||||
{
|
||||
PROFILER_LABEL("AsyncCompositionManager", "TransformShadowTree",
|
||||
@ -1529,10 +1530,12 @@ AsyncCompositionManager::TransformShadowTree(TimeStamp aCurrentFrame,
|
||||
// Advance APZ animations to the next expected vsync timestamp, if we can
|
||||
// get it.
|
||||
TimeStamp nextFrame = aCurrentFrame;
|
||||
TimeDuration vsyncrate = gfxPlatform::GetPlatform()->GetHardwareVsync()->GetGlobalDisplay().GetVsyncRate();
|
||||
if (vsyncrate != TimeDuration::Forever()) {
|
||||
nextFrame += vsyncrate;
|
||||
|
||||
MOZ_ASSERT(aVsyncRate != TimeDuration::Forever());
|
||||
if (aVsyncRate != TimeDuration::Forever()) {
|
||||
nextFrame += aVsyncRate;
|
||||
}
|
||||
|
||||
wantNextFrame |= SampleAPZAnimations(LayerMetricsWrapper(root), nextFrame);
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,8 @@ public:
|
||||
// another animation frame.
|
||||
enum class TransformsToSkip : uint8_t { NoneOfThem = 0, APZ = 1 };
|
||||
bool TransformShadowTree(TimeStamp aCurrentFrame,
|
||||
TransformsToSkip aSkip = TransformsToSkip::NoneOfThem);
|
||||
TimeDuration aVsyncRate,
|
||||
TransformsToSkip aSkip = TransformsToSkip::NoneOfThem);
|
||||
|
||||
// Calculates the correct rotation and applies the transform to
|
||||
// our layer manager
|
||||
|
@ -36,6 +36,7 @@
|
||||
#ifdef MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING
|
||||
# include "mozilla/widget/CompositorWidgetChild.h"
|
||||
#endif
|
||||
#include "VsyncSource.h"
|
||||
|
||||
using mozilla::layers::LayerTransactionChild;
|
||||
using mozilla::dom::TabChildBase;
|
||||
@ -197,8 +198,11 @@ CompositorBridgeChild::InitSameProcess(widget::CompositorWidget* aWidget,
|
||||
bool aUseExternalSurface,
|
||||
const gfx::IntSize& aSurfaceSize)
|
||||
{
|
||||
TimeDuration vsyncRate =
|
||||
gfxPlatform::GetPlatform()->GetHardwareVsync()->GetGlobalDisplay().GetVsyncRate();
|
||||
|
||||
mCompositorBridgeParent =
|
||||
new CompositorBridgeParent(aScale, aUseExternalSurface, aSurfaceSize);
|
||||
new CompositorBridgeParent(aScale, vsyncRate, aUseExternalSurface, aSurfaceSize);
|
||||
|
||||
mCanSend = Open(mCompositorBridgeParent->GetIPCChannel(),
|
||||
CompositorThreadHolder::Loop(),
|
||||
|
@ -597,10 +597,12 @@ CompositorLoop()
|
||||
}
|
||||
|
||||
CompositorBridgeParent::CompositorBridgeParent(CSSToLayoutDeviceScale aScale,
|
||||
const TimeDuration& aVsyncRate,
|
||||
bool aUseExternalSurfaceSize,
|
||||
const gfx::IntSize& aSurfaceSize)
|
||||
: mWidget(nullptr)
|
||||
, mScale(aScale)
|
||||
, mVsyncRate(aVsyncRate)
|
||||
, mIsTesting(false)
|
||||
, mPendingTransaction(0)
|
||||
, mPaused(false)
|
||||
@ -1242,7 +1244,7 @@ CompositorBridgeParent::CompositeToTarget(DrawTarget* aTarget, const gfx::IntRec
|
||||
mCompositionManager->ComputeRotation();
|
||||
|
||||
TimeStamp time = mIsTesting ? mTestTime : mCompositorScheduler->GetLastComposeTime();
|
||||
bool requestNextFrame = mCompositionManager->TransformShadowTree(time);
|
||||
bool requestNextFrame = mCompositionManager->TransformShadowTree(time, mVsyncRate);
|
||||
if (requestNextFrame) {
|
||||
ScheduleComposition();
|
||||
#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
|
||||
@ -1437,7 +1439,7 @@ CompositorBridgeParent::SetTestSampleTime(LayerTransactionParent* aLayerTree,
|
||||
// Update but only if we were already scheduled to animate
|
||||
if (testComposite) {
|
||||
AutoResolveRefLayers resolve(mCompositionManager);
|
||||
bool requestNextFrame = mCompositionManager->TransformShadowTree(aTime);
|
||||
bool requestNextFrame = mCompositionManager->TransformShadowTree(aTime, mVsyncRate);
|
||||
if (!requestNextFrame) {
|
||||
CancelCurrentCompositeTask();
|
||||
// Pretend we composited in case someone is wating for this event.
|
||||
@ -1469,7 +1471,7 @@ CompositorBridgeParent::ApplyAsyncProperties(LayerTransactionParent* aLayerTree)
|
||||
|
||||
TimeStamp time = mIsTesting ? mTestTime : mCompositorScheduler->GetLastComposeTime();
|
||||
bool requestNextFrame =
|
||||
mCompositionManager->TransformShadowTree(time,
|
||||
mCompositionManager->TransformShadowTree(time, mVsyncRate,
|
||||
AsyncCompositionManager::TransformsToSkip::APZ);
|
||||
if (!requestNextFrame) {
|
||||
CancelCurrentCompositeTask();
|
||||
|
@ -213,6 +213,7 @@ class CompositorBridgeParent final : public PCompositorBridgeParent,
|
||||
|
||||
public:
|
||||
explicit CompositorBridgeParent(CSSToLayoutDeviceScale aScale,
|
||||
const TimeDuration& aVsyncRate,
|
||||
bool aUseExternalSurfaceSize,
|
||||
const gfx::IntSize& aSurfaceSize);
|
||||
|
||||
@ -604,6 +605,7 @@ protected:
|
||||
widget::CompositorWidget* mWidget;
|
||||
TimeStamp mTestTime;
|
||||
CSSToLayoutDeviceScale mScale;
|
||||
TimeDuration mVsyncRate;
|
||||
bool mIsTesting;
|
||||
|
||||
uint64_t mPendingTransaction;
|
||||
|
Loading…
Reference in New Issue
Block a user