mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 12:43:26 +00:00
Added { willReadFrequently }
to every canvas context, no matter where it comes from
This commit is contained in:
parent
f3028118d3
commit
c8acb16fa7
9 changed files with 61 additions and 60 deletions
|
@ -74,7 +74,7 @@ var GenerateTexture = function (config)
|
|||
canvas.height = height;
|
||||
}
|
||||
|
||||
var ctx = canvas.getContext('2d');
|
||||
var ctx = canvas.getContext('2d', { willReadFrequently: true });
|
||||
|
||||
if (clearCanvas)
|
||||
{
|
||||
|
|
|
@ -82,7 +82,7 @@ var CanvasPool = function ()
|
|||
|
||||
if (_disableContextSmoothing && canvasType === CONST.CANVAS)
|
||||
{
|
||||
Smoothing.disable(canvas.getContext('2d'));
|
||||
Smoothing.disable(canvas.getContext('2d', { willReadFrequently: false }));
|
||||
}
|
||||
|
||||
return canvas;
|
||||
|
|
|
@ -1498,6 +1498,7 @@ var Graphics = new Class({
|
|||
|
||||
var texture;
|
||||
var ctx;
|
||||
var willRead = { willReadFrequently: true };
|
||||
|
||||
if (typeof key === 'string')
|
||||
{
|
||||
|
@ -1511,7 +1512,7 @@ var Graphics = new Class({
|
|||
|
||||
if (src instanceof HTMLCanvasElement)
|
||||
{
|
||||
ctx = src.getContext('2d');
|
||||
ctx = src.getContext('2d', willRead);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1520,14 +1521,14 @@ var Graphics = new Class({
|
|||
|
||||
texture = sys.textures.createCanvas(key, width, height);
|
||||
|
||||
ctx = texture.getSourceImage().getContext('2d');
|
||||
ctx = texture.getSourceImage().getContext('2d', willRead);
|
||||
}
|
||||
}
|
||||
else if (key instanceof HTMLCanvasElement)
|
||||
{
|
||||
// Key is a Canvas, so draw to it
|
||||
|
||||
ctx = key.getContext('2d');
|
||||
ctx = key.getContext('2d', willRead);
|
||||
}
|
||||
|
||||
if (ctx)
|
||||
|
|
|
@ -144,7 +144,7 @@ var Text = new Class({
|
|||
* @type {CanvasRenderingContext2D}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.context = this.canvas.getContext('2d');
|
||||
this.context = this.canvas.getContext('2d', { willReadFrequently: true });
|
||||
|
||||
/**
|
||||
* The Text Style object.
|
||||
|
|
|
@ -187,7 +187,7 @@ var TileSprite = new Class({
|
|||
* @type {CanvasRenderingContext2D}
|
||||
* @since 3.12.0
|
||||
*/
|
||||
this.context = this.canvas.getContext('2d');
|
||||
this.context = this.canvas.getContext('2d', { willReadFrequently: false });
|
||||
|
||||
/**
|
||||
* The Texture the TileSprite is using as its fill pattern.
|
||||
|
@ -272,7 +272,7 @@ var TileSprite = new Class({
|
|||
* @type {CanvasRenderingContext2D}
|
||||
* @since 3.12.0
|
||||
*/
|
||||
this.fillContext = this.fillCanvas.getContext('2d');
|
||||
this.fillContext = this.fillCanvas.getContext('2d', { willReadFrequently: false });
|
||||
|
||||
/**
|
||||
* The texture that the Tile Sprite is rendered to, which is then rendered to a Scene.
|
||||
|
|
|
@ -86,7 +86,7 @@ var Vector = require('../geometry/Vector');
|
|||
render.mouse = options.mouse;
|
||||
render.engine = options.engine;
|
||||
render.canvas = render.canvas || _createCanvas(render.options.width, render.options.height);
|
||||
render.context = render.canvas.getContext('2d');
|
||||
render.context = render.canvas.getContext('2d', { willReadFrequently: true });
|
||||
render.textures = {};
|
||||
|
||||
render.bounds = render.bounds || {
|
||||
|
@ -1339,7 +1339,7 @@ var Vector = require('../geometry/Vector');
|
|||
* @return {Number} pixel ratio
|
||||
*/
|
||||
var _getPixelRatio = function(canvas) {
|
||||
var context = canvas.getContext('2d'),
|
||||
var context = canvas.getContext('2d', { willReadFrequently: true }),
|
||||
devicePixelRatio = window.devicePixelRatio || 1,
|
||||
backingStorePixelRatio = context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio
|
||||
|| context.msBackingStorePixelRatio || context.oBackingStorePixelRatio
|
||||
|
|
|
@ -33,7 +33,7 @@ var CanvasSnapshot = function (canvas, config)
|
|||
|
||||
if (getPixel)
|
||||
{
|
||||
var context = canvas.getContext('2d');
|
||||
var context = canvas.getContext('2d', { willReadFrequently: false });
|
||||
var imageData = context.getImageData(x, y, 1, 1);
|
||||
var data = imageData.data;
|
||||
|
||||
|
@ -43,7 +43,7 @@ var CanvasSnapshot = function (canvas, config)
|
|||
{
|
||||
// Area Grab
|
||||
var copyCanvas = CanvasPool.createWebGL(this, width, height);
|
||||
var ctx = copyCanvas.getContext('2d');
|
||||
var ctx = copyCanvas.getContext('2d', { willReadFrequently: true });
|
||||
|
||||
if (width > 0 && height > 0)
|
||||
{
|
||||
|
|
|
@ -127,7 +127,7 @@ var DynamicTexture = new Class({
|
|||
* @type {CanvasRenderingContext2D}
|
||||
* @since 3.7.0
|
||||
*/
|
||||
this.context = (isCanvas) ? source.getContext('2d') : null;
|
||||
this.context = (isCanvas) ? source.getContext('2d', { willReadFrequently: true }) : null;
|
||||
|
||||
/**
|
||||
* Is this Dynamic Texture dirty or not? If not it won't spend time clearing or filling itself.
|
||||
|
|
|
@ -397,7 +397,7 @@ var TextureManager = new Class({
|
|||
var cd = textureFrame.canvasData;
|
||||
|
||||
var canvas = CanvasPool.create2D(this, cd.width, cd.height);
|
||||
var ctx = canvas.getContext('2d');
|
||||
var ctx = canvas.getContext('2d', { willReadFrequently: true });
|
||||
|
||||
if (cd.width > 0 && cd.height > 0)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue