From ad3b092299adc7ca033c0c87ea854b1a245f0170 Mon Sep 17 00:00:00 2001 From: Angelo Yazar Date: Wed, 28 Sep 2016 14:42:30 -0700 Subject: [PATCH 1/4] add in configureable WebGL context options --- src/platforms/browser/webgl/WebGLContext2D.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/platforms/browser/webgl/WebGLContext2D.js b/src/platforms/browser/webgl/WebGLContext2D.js index 95c5ad79..f6ab7af8 100644 --- a/src/platforms/browser/webgl/WebGLContext2D.js +++ b/src/platforms/browser/webgl/WebGLContext2D.js @@ -140,11 +140,12 @@ var GLManager = Class(function() { this._canvas = document.createElement('canvas'); this._canvas.width = this.width; this._canvas.height = this.height; - this._canvas.getWebGLContext = this._canvas.getContext.bind(this._canvas, 'webgl', { + this._canvas.getWebGLContext = this._canvas.getContext.bind(this._canvas, 'webgl', merge(CONFIG.webGLContextOptions, { alpha: true, premultipliedAlpha: true, - preserveDrawingBuffer: true - }); + preserveDrawingBuffer: true, + antialias: false + })); this._indexCache = new Uint16Array(MAX_BATCH_SIZE * 6); this._vertexCache = new ArrayBuffer(MAX_BATCH_SIZE * STRIDE * 4); From 8fb739f22324f0ea70b24f902745c52d4f28650b Mon Sep 17 00:00:00 2001 From: Angelo Yazar Date: Wed, 28 Sep 2016 14:46:01 -0700 Subject: [PATCH 2/4] Remove the skewx(0.00001deg) WebGL fix as it was introducing stuttering on desktop --- src/platforms/browser/doc.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/platforms/browser/doc.js b/src/platforms/browser/doc.js index 691dafe4..2893e92c 100644 --- a/src/platforms/browser/doc.js +++ b/src/platforms/browser/doc.js @@ -47,7 +47,6 @@ var Document = Class(lib.PubSub, function () { overflow: 'hidden', width: '100%', height: '100%', - transform: 'skewx(0.00001deg)' } }); From d66a03e2be531c05663558ffb065f43a4b0af59b Mon Sep 17 00:00:00 2001 From: Angelo Yazar Date: Wed, 28 Sep 2016 16:31:20 -0700 Subject: [PATCH 3/4] emit progress events in loader.js --- src/ui/resource/loader.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ui/resource/loader.js b/src/ui/resource/loader.js index ed5a94fd..9de0403a 100644 --- a/src/ui/resource/loader.js +++ b/src/ui/resource/loader.js @@ -418,7 +418,7 @@ var Loader = Class(Emitter, function () { return; } - var next = function (failed) { + var next = bind(this, function (failed) { // If already complete, stub this out if (numLoaded >= numResources) { return; } @@ -440,6 +440,11 @@ var Loader = Class(Emitter, function () { // Call the progress callback with isComplete == true cb && cb(src, failed, true, numLoaded, numResources); + // Emit progress event + this.emit('progress', { + progress: this.progress + }); + // If a timeout was set, clear it if (_timeout) { clearTimeout(_timeout); @@ -452,10 +457,15 @@ var Loader = Class(Emitter, function () { // Call the progress callback with the current progress cb && cb(src, failed, false, numLoaded, numResources); + // Emit progress event + this.emit('progress', { + progress: this.progress + }); + // Restart on next image in list setTimeout(loadResource, 0); } - }; + }); // IF this is the type of resource that has a reload method, if (res.reload && res.complete) { From 9601aae77799322807418a07977635300f4350c9 Mon Sep 17 00:00:00 2001 From: Angelo Yazar Date: Wed, 28 Sep 2016 17:14:39 -0700 Subject: [PATCH 4/4] move the WebGL context options merge to it's own line and make 'premultipliedAlpha: true' non-configurable --- src/platforms/browser/webgl/WebGLContext2D.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/platforms/browser/webgl/WebGLContext2D.js b/src/platforms/browser/webgl/WebGLContext2D.js index f6ab7af8..c9d20bd8 100644 --- a/src/platforms/browser/webgl/WebGLContext2D.js +++ b/src/platforms/browser/webgl/WebGLContext2D.js @@ -140,12 +140,14 @@ var GLManager = Class(function() { this._canvas = document.createElement('canvas'); this._canvas.width = this.width; this._canvas.height = this.height; - this._canvas.getWebGLContext = this._canvas.getContext.bind(this._canvas, 'webgl', merge(CONFIG.webGLContextOptions, { - alpha: true, - premultipliedAlpha: true, - preserveDrawingBuffer: true, - antialias: false - })); + + var webGLContextOptions = merge({ premultipliedAlpha: true }, CONFIG.webGLContextOptions, { + alpha: true, + preserveDrawingBuffer: true, + antialias: false + }); + + this._canvas.getWebGLContext = this._canvas.getContext.bind(this._canvas, 'webgl', webGLContextOptions); this._indexCache = new Uint16Array(MAX_BATCH_SIZE * 6); this._vertexCache = new ArrayBuffer(MAX_BATCH_SIZE * STRIDE * 4);