Wait for frame handling to stabilize before drawing.

This commit is contained in:
Christian Speckner 2017-06-15 17:12:39 +02:00
parent c2ce1943ca
commit bdded5e600
3 changed files with 27 additions and 2 deletions

View File

@ -35,7 +35,9 @@ enum Metrics: uInt32 {
maxUnderscan = 10,
tvModeDetectionTolerance = 20,
initialGarbageFrames = 10,
framesForModeConfirmation = 5
framesForModeConfirmation = 5,
minStableFrames = 10,
maxStabilizationFrames = 20
};
static constexpr uInt32
@ -92,6 +94,9 @@ void FrameManager::reset()
myVsyncLines = 0;
myY = 0;
myFramePending = false;
myStabilizationFrames = 0;
myStableFrames = 0;
myHasStabilized = false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -192,8 +197,22 @@ void FrameManager::setState(FrameManager::State state)
switch (myState) {
case State::waitForFrameStart:
if (!myHasStabilized) {
myHasStabilized =
myStableFrames >= Metrics::minStableFrames ||
myStabilizationFrames >= Metrics::maxStabilizationFrames;
myStabilizationFrames++;
if (myVblankManager.isStable())
myStableFrames++;
else
myStableFrames = 0;
}
if (myFramePending) finalizeFrame();
if (myOnFrameStart) myOnFrameStart();
myVblankManager.start();
myFramePending = true;

View File

@ -53,7 +53,7 @@ class FrameManager : public Serializable
void setVsync(bool vsync);
bool isRendering() const { return myState == State::frame; }
bool isRendering() const { return myState == State::frame && myHasStabilized; }
FrameLayout layout() const { return myLayout; }
@ -160,6 +160,10 @@ class FrameManager : public Serializable
uInt32 myFramesInMode;
bool myModeConfirmed;
uInt32 myStableFrames;
uInt32 myStabilizationFrames;
bool myHasStabilized;
bool myVsync;
uInt32 myVblankLines;

View File

@ -52,6 +52,8 @@ class VblankManager : public Serializable
void setJitter(Int32 jitter);
void setJitterFactor(uInt8 jitterFactor) { myJitterFactor = jitterFactor; }
bool isStable() const { return myMode != VblankMode::floating; }
/**
Serializable methods (see that class for more information).
*/