Skip to content

Commit

Permalink
Keep rendering for some time before break
Browse files Browse the repository at this point in the history
  • Loading branch information
maurhofer-ubique committed Jan 22, 2024
1 parent 9e9a2bd commit c96c45f
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class GLThread constructor(
}

while (!finished) {
if ((!isDirty.get() && glRunList.isEmpty()) || isPaused) {
if ((!isDirty.get() && glRunList.isEmpty()) && (isPaused || System.currentTimeMillis() - lastDirtyTimestamp.get() > BREAK_MIN_FINISH_MS)) {
var wasPaused = false
do {
var firstPause = false
Expand All @@ -119,12 +119,13 @@ class GLThread constructor(
wasPaused = true
firstPause = true
}
val preFinish = System.currentTimeMillis()
if (firstPause || (!hasFinishedSinceDirty && preFinish - lastDirtyTimestamp.get() > BREAK_MIN_FINISH_MS)) {
var finishDuration = 0L
if (firstPause || !hasFinishedSinceDirty) {
finishDuration = System.currentTimeMillis()
GLES32.glFinish()
hasFinishedSinceDirty = true
finishDuration = System.currentTimeMillis() - System.currentTimeMillis()
}
val finishDuration = System.currentTimeMillis() - preFinish

try {
if (finishDuration < BREAK_RENDER_INTERVAL) {
Expand Down Expand Up @@ -154,7 +155,6 @@ class GLThread constructor(
glRunList.poll()?.invoke()
i++
}

renderer.onDrawFrame(gl10)
if (BuildConfig.DEBUG) {
GLES32.glGetError().let {
Expand Down Expand Up @@ -381,7 +381,6 @@ class GLThread constructor(
lastDirtyTimestamp.set(System.currentTimeMillis())
hasFinishedSinceDirty = false
isDirty.set(true)

synchronized(runNotifier) { runNotifier.notify() }
}

Expand Down

0 comments on commit c96c45f

Please sign in to comment.