Merge pull request #9018 from ctrlaltdavid/21098

Display "content loading" while there are pending GPU texture transfers
This commit is contained in:
Ryan Huffman 2016-11-07 09:09:30 -08:00 committed by GitHub
commit 710e038737

View file

@ -248,7 +248,7 @@
} }
function update() { function update() {
var viewport, diff, x; var viewport, diff, x, gpuTextures;
initialDelayCooldown -= 30; initialDelayCooldown -= 30;
@ -261,26 +261,28 @@
} }
} }
gpuTextures = Render.getConfig("Stats").textureGPUTransferCount;
// Update state // Update state
if (!visible) { // Not visible because no recent downloads if (!visible) { // Not visible because no recent downloads
if (displayProgress < 100) { // Have started downloading so fade in if (displayProgress < 100 || gpuTextures > 0) { // Have started downloading so fade in
visible = true; visible = true;
alphaDelta = ALPHA_DELTA_IN; alphaDelta = ALPHA_DELTA_IN;
fadeTimer = Script.setInterval(fade, FADE_INTERVAL); fadeTimer = Script.setInterval(fade, FADE_INTERVAL);
} }
} else if (alphaDelta !== 0.0) { // Fading in or out } else if (alphaDelta !== 0.0) { // Fading in or out
if (alphaDelta > 0) { if (alphaDelta > 0) {
if (rawProgress === 100) { // Was downloading but now have finished so fade out if (rawProgress === 100 && gpuTextures === 0) { // Was downloading but now have finished so fade out
alphaDelta = ALPHA_DELTA_OUT; alphaDelta = ALPHA_DELTA_OUT;
} }
} else { } else {
if (displayProgress < 100) { // Was finished downloading but have resumed so fade in if (displayProgress < 100 || gpuTextures > 0) { // Was finished downloading but have resumed so fade in
alphaDelta = ALPHA_DELTA_IN; alphaDelta = ALPHA_DELTA_IN;
} }
} }
} else { // Fully visible because downloading or recently so } else { // Fully visible because downloading or recently so
if (fadeWaitTimer === null) { if (fadeWaitTimer === null) {
if (rawProgress === 100) { // Was downloading but have finished so fade out soon if (rawProgress === 100 && gpuTextures === 0) { // Was downloading but have finished so fade out soon
fadeWaitTimer = Script.setTimeout(function () { fadeWaitTimer = Script.setTimeout(function () {
alphaDelta = ALPHA_DELTA_OUT; alphaDelta = ALPHA_DELTA_OUT;
fadeTimer = Script.setInterval(fade, FADE_INTERVAL); fadeTimer = Script.setInterval(fade, FADE_INTERVAL);
@ -288,7 +290,8 @@
}, FADE_OUT_WAIT); }, FADE_OUT_WAIT);
} }
} else { } else {
if (displayProgress < 100) { // Was finished and waiting to fade out but have resumed so don't fade out if (displayProgress < 100 || gpuTextures > 0) { // Was finished and waiting to fade out but have resumed so
// don't fade out
Script.clearInterval(fadeWaitTimer); Script.clearInterval(fadeWaitTimer);
fadeWaitTimer = null; fadeWaitTimer = null;
} }