Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions lime/src/renderer/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ lime.Renderer.CANVAS.drawCanvas = function() {

if (!this.domElement) return;

var context = this.domElement.getContext('2d');

if (this.boundsCache && this.boundsCache.contains(bounds) &&
(sizediff = this.boundsCache.size().area() / bounds.size().area()) &&
sizediff < 1.6 && sizediff > 0.5) {
Expand Down Expand Up @@ -69,17 +71,36 @@ lime.Renderer.CANVAS.drawCanvas = function() {

this.boundsCache = bounds; //save for later use

var bsize = bounds.size();
var pxsize = bsize.clone().ceil();
var bsize = bounds.size(),
pxsize = bsize.clone().ceil(),
width = this.domElement.width,
height = this.domElement.height;

if (this.pixelRatio) {
width /= this.pixelRatio;
height /= this.pixelRatio;
}

if (width != pxsize.width || height != pxsize.height) {

if (this.domElement.width != pxsize.width ||
this.domElement.height != pxsize.height) {
// High DPI canvas support: http://www.html5rocks.com/en/tutorials/canvas/hidpi/
var ratio = (goog.global['devicePixelRatio'] || 1) / (context.webkitBackingStorePixelRatio || 1);

if (ratio !== 1) {
this.domElement.width = pxsize.width * ratio;
this.domElement.height = pxsize.height * ratio;
this.domElement.style.width = pxsize.width + 'px';
this.domElement.style.height = pxsize.height + 'px';
context.scale(ratio, ratio);
this.pixelRatio = ratio;
} else {
this.domElement.width = pxsize.width;
this.domElement.height = pxsize.height;
this.redraw_ = 1;
// console.log('redraw');
}

this.redraw_ = 1;
}



var realScale = this.getScale().clone();
Expand Down Expand Up @@ -125,8 +146,6 @@ lime.Renderer.CANVAS.drawCanvas = function() {
}

if (this.redraw_) {
var context = this.domElement.getContext('2d');

context.clearRect(0, 0, pxsize.width, pxsize.height);
context.save();
context.translate(this.ax, this.ay);
Expand Down