Add check for bad values for Display.autoscale()

This commit is contained in:
Samuel Mannehed 2019-03-08 16:30:43 +01:00
parent 9a823732a0
commit 6e7e6f9c9e
1 changed files with 5 additions and 0 deletions

View File

@ -495,6 +495,11 @@ export default class Display {
} }
autoscale(containerWidth, containerHeight) { autoscale(containerWidth, containerHeight) {
if (containerWidth === 0 || containerHeight === 0) {
Log.Warn("Autoscale doesn't work when width or height is zero");
return;
}
const vp = this._viewportLoc; const vp = this._viewportLoc;
const targetAspectRatio = containerWidth / containerHeight; const targetAspectRatio = containerWidth / containerHeight;
const fbAspectRatio = vp.w / vp.h; const fbAspectRatio = vp.w / vp.h;