diff --git a/include/display.js b/include/display.js index c6b81302..dc5085c3 100644 --- a/include/display.js +++ b/include/display.js @@ -23,7 +23,7 @@ var that = {}, // Public API methods // Predefine function variables (jslint) imageDataCreate, imageDataGet, rgbxImageData, cmapImageData, - rgbxImageFill, cmapImageFill, setFillColor, rescale, flush, + rgbxImageFill, cmapImageFill, setFillColor, rescale, rescaleAuto, flush, c_width = 0, c_height = 0, @@ -223,15 +223,53 @@ rescale = function(factor) { factor = 0.1; } - /* if (conf.scale === factor) { + if (conf.scale === factor) { //Util.Debug("Display already scaled to '" + factor + "'"); + UI.message("Display already scaled to '" + factor + "'"); return; - } */ + } - conf.scale = factor; x = c.width - c.width * factor; y = c.height - c.height * factor; c.style[tp] = "scale(" + conf.scale + ") translate(-" + x + "px, -" + y + "px)"; + UI.message("scale: "+conf.scale+", x: "+x+", y: "+y); +}; + +rescaleAuto = function() { + var c, tp, x, y, xFactor, yFactor, factor, + properties = ['transform', 'WebkitTransform', 'MozTransform', null]; + + c = conf.target; + tp = properties.shift(); + while (tp) { + if (typeof c.style[tp] !== 'undefined') { + break; + } + tp = properties.shift(); + } + + if (tp === null) { + Util.Debug("No scaling support"); + return; + } + + xFactor=viewport.w/fb_width; + yFactor=viewport.h/fb_height; + UI.message("xFactor: "+xFactor+", yFactor: "+yFactor+", viewport.h: "+viewport.h+", fb_height: "+fb_height); + + if (xFactor > 1.0) {xFactor = 1.0;} + else if (xFactor < 0.1) {xFactor = 0.1;} + + if (yFactor > 1.0) {yFactor = 1.0;} + else if (yFactor < 0.1) {yFactor = 0.1;} + + /* Rescale screen to whichever factor that is smaller (so we get to see the whole screen). */ + factor=xFactorLoading...

- Results:
+ Log: