@@ -58,23 +58,32 @@ var CanvasRenderer = new Class({
5858 */
5959 this . drawCount = 0 ;
6060
61+ /**
62+ * The core Scale Manager.
63+ *
64+ * @name Phaser.Renderer.Canvas.CanvasRenderer#scaleManager
65+ * @type {Phaser.DOM.ScaleManager }
66+ * @since 3.16.0
67+ */
68+ this . scaleManager = game . scale ;
69+
6170 /**
6271 * The width of the canvas being rendered to.
6372 *
6473 * @name Phaser.Renderer.Canvas.CanvasRenderer#width
65- * @type {number }
74+ * @type {integer }
6675 * @since 3.0.0
6776 */
68- this . width = game . config . width ;
77+ this . width = this . scaleManager . baseSize . width ;
6978
7079 /**
7180 * The height of the canvas being rendered to.
7281 *
7382 * @name Phaser.Renderer.Canvas.CanvasRenderer#height
74- * @type {number }
83+ * @type {integer }
7584 * @since 3.0.0
7685 */
77- this . height = game . config . height ;
86+ this . height = this . scaleManager . baseSize . height ;
7887
7988 /**
8089 * The local configuration settings of the CanvasRenderer.
@@ -87,7 +96,6 @@ var CanvasRenderer = new Class({
8796 clearBeforeRender : game . config . clearBeforeRender ,
8897 backgroundColor : game . config . backgroundColor ,
8998 resolution : game . config . resolution ,
90- autoResize : game . config . autoResize ,
9199 antialias : game . config . antialias ,
92100 roundPixels : game . config . roundPixels
93101 } ;
@@ -233,7 +241,7 @@ var CanvasRenderer = new Class({
233241 */
234242 init : function ( )
235243 {
236- this . resize ( this . width , this . height ) ;
244+ this . resize ( ) ;
237245 } ,
238246
239247 /**
@@ -242,30 +250,19 @@ var CanvasRenderer = new Class({
242250 * @method Phaser.Renderer.Canvas.CanvasRenderer#resize
243251 * @since 3.0.0
244252 *
245- * @param {integer } width - The new width of the canvas.
246- * @param {integer } height - The new height of the canvas.
253+ * @param {number } [width] - The new width of the renderer. If not specified it uses the base size from the Scale Manager.
254+ * @param {number } [height] - The new height of the renderer. If not specified it uses the base size from the Scale Manager.
255+ * @param {number } [resolution] - The new resolution of the renderer. If not specified it uses the resolution from the Scale Manager.
247256 */
248- resize : function ( width , height )
257+ resize : function ( width , height , resolution )
249258 {
259+ if ( width === undefined ) { width = this . scaleManager . baseSize . width ; }
260+ if ( height === undefined ) { height = this . scaleManager . baseSize . height ; }
261+ if ( resolution === undefined ) { resolution = this . scaleManager . resolution ; }
262+
250263 this . width = width ;
251264 this . height = height ;
252265
253- /*
254- var resolution = this.config.resolution;
255-
256- this.width = width * resolution;
257- this.height = height * resolution;
258-
259- this.gameCanvas.width = this.width;
260- this.gameCanvas.height = this.height;
261-
262- if (this.config.autoResize)
263- {
264- this.gameCanvas.style.width = (this.width / resolution) + 'px';
265- this.gameCanvas.style.height = (this.height / resolution) + 'px';
266- }
267- */
268-
269266 // Resizing a canvas will reset imageSmoothingEnabled (and probably other properties)
270267 if ( this . scaleMode === ScaleModes . NEAREST )
271268 {
0 commit comments