forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextureSource.js
More file actions
130 lines (111 loc) · 2.96 KB
/
Copy pathTextureSource.js
File metadata and controls
130 lines (111 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var CONST = require('../const');
var ScaleModes = require('../renderer/ScaleModes');
var IsSizePowerOfTwo = require('../math/pow2/IsSizePowerOfTwo');
/**
*
* @class Phaser.TextureSource
* @constructor
* @param {object} source
* @param {number} scaleMode
*/
var TextureSource = function (texture, source)
{
this.texture = texture;
this.image = source;
this.compressionAlgorithm = null;
/**
* The Resolution of the texture.
*
* @property resolution
* @type Number
*/
this.resolution = 1;
/**
* The width of the Texture.
*
* @property width
* @type Number
* @readOnly
*/
this.width = source.naturalWidth || source.width || 0;
/**
* The height of the Texture.
*
* @property height
* @type Number
* @readOnly
*/
this.height = source.naturalHeight || source.height || 0;
/**
* The scale mode to apply when scaling this texture.
* NEAREST or DEFAULT
*
* @property scaleMode
* @type {Number}
* @default Phaser.scaleModes.DEFAULT;
*/
this.scaleMode = ScaleModes.DEFAULT;
/**
* Controls if RGB channels should be pre-multiplied by Alpha (WebGL only)
*
* @property premultipliedAlpha
* @type Boolean
* @default true
*/
this.premultipliedAlpha = true;
/**
* Set this to true if a mipmap of this texture needs to be generated. This value needs to be set before the texture is used
* Also the texture must be a power of two size to work
*
* @property mipmapLevel
* @type {integer}
*/
this.mipmapLevel = 0;
/**
* A BaseTexture can be set to skip the rendering phase in the WebGL Sprite Batch.
*
* You may want to do this if you have a parent Sprite with no visible texture (i.e. uses the internal `__default` texture)
* that has children that you do want to render, without causing a batch flush in the process.
*
* @property renderable
* @type Boolean
*/
this.renderable = true;
/**
* @property isPowerOf2
* @type boolean
*/
this.isPowerOf2 = IsSizePowerOfTwo(this.width, this.height);
/**
* @property glTexture
*/
this.glTexture = null;
/**
* The multi texture batching index number.
* @property glTextureIndex
* @type Number
*/
this.glTextureIndex = 0;
/**
* The timestamp when this texture was last used by the WebGL renderer.
* Can be used to purge out 'dead' textures from GPU memory.
* @property glLastUsed
* @type Number
*/
this.glLastUsed = 0;
/**
* @property glDirty
*/
this.glDirty = true;
var game = texture.manager.game;
if (game.config.renderType === CONST.WEBGL)
{
game.renderer.createTexture(this);
}
};
module.exports = TextureSource;