mirror of https://github.com/stella-emu/stella.git
Wait for frame handling to stabilize before drawing.
This commit is contained in:
parent
c2ce1943ca
commit
bdded5e600
|
@ -35,7 +35,9 @@ enum Metrics: uInt32 {
|
||||||
maxUnderscan = 10,
|
maxUnderscan = 10,
|
||||||
tvModeDetectionTolerance = 20,
|
tvModeDetectionTolerance = 20,
|
||||||
initialGarbageFrames = 10,
|
initialGarbageFrames = 10,
|
||||||
framesForModeConfirmation = 5
|
framesForModeConfirmation = 5,
|
||||||
|
minStableFrames = 10,
|
||||||
|
maxStabilizationFrames = 20
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr uInt32
|
static constexpr uInt32
|
||||||
|
@ -92,6 +94,9 @@ void FrameManager::reset()
|
||||||
myVsyncLines = 0;
|
myVsyncLines = 0;
|
||||||
myY = 0;
|
myY = 0;
|
||||||
myFramePending = false;
|
myFramePending = false;
|
||||||
|
myStabilizationFrames = 0;
|
||||||
|
myStableFrames = 0;
|
||||||
|
myHasStabilized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -192,8 +197,22 @@ void FrameManager::setState(FrameManager::State state)
|
||||||
|
|
||||||
switch (myState) {
|
switch (myState) {
|
||||||
case State::waitForFrameStart:
|
case State::waitForFrameStart:
|
||||||
|
if (!myHasStabilized) {
|
||||||
|
myHasStabilized =
|
||||||
|
myStableFrames >= Metrics::minStableFrames ||
|
||||||
|
myStabilizationFrames >= Metrics::maxStabilizationFrames;
|
||||||
|
|
||||||
|
myStabilizationFrames++;
|
||||||
|
|
||||||
|
if (myVblankManager.isStable())
|
||||||
|
myStableFrames++;
|
||||||
|
else
|
||||||
|
myStableFrames = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (myFramePending) finalizeFrame();
|
if (myFramePending) finalizeFrame();
|
||||||
if (myOnFrameStart) myOnFrameStart();
|
if (myOnFrameStart) myOnFrameStart();
|
||||||
|
|
||||||
myVblankManager.start();
|
myVblankManager.start();
|
||||||
myFramePending = true;
|
myFramePending = true;
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ class FrameManager : public Serializable
|
||||||
|
|
||||||
void setVsync(bool vsync);
|
void setVsync(bool vsync);
|
||||||
|
|
||||||
bool isRendering() const { return myState == State::frame; }
|
bool isRendering() const { return myState == State::frame && myHasStabilized; }
|
||||||
|
|
||||||
FrameLayout layout() const { return myLayout; }
|
FrameLayout layout() const { return myLayout; }
|
||||||
|
|
||||||
|
@ -160,6 +160,10 @@ class FrameManager : public Serializable
|
||||||
uInt32 myFramesInMode;
|
uInt32 myFramesInMode;
|
||||||
bool myModeConfirmed;
|
bool myModeConfirmed;
|
||||||
|
|
||||||
|
uInt32 myStableFrames;
|
||||||
|
uInt32 myStabilizationFrames;
|
||||||
|
bool myHasStabilized;
|
||||||
|
|
||||||
bool myVsync;
|
bool myVsync;
|
||||||
|
|
||||||
uInt32 myVblankLines;
|
uInt32 myVblankLines;
|
||||||
|
|
|
@ -52,6 +52,8 @@ class VblankManager : public Serializable
|
||||||
void setJitter(Int32 jitter);
|
void setJitter(Int32 jitter);
|
||||||
void setJitterFactor(uInt8 jitterFactor) { myJitterFactor = jitterFactor; }
|
void setJitterFactor(uInt8 jitterFactor) { myJitterFactor = jitterFactor; }
|
||||||
|
|
||||||
|
bool isStable() const { return myMode != VblankMode::floating; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Serializable methods (see that class for more information).
|
Serializable methods (see that class for more information).
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue