@@ -72,25 +72,25 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{
72
72
_string : "" ,
73
73
_originalText : null ,
74
74
_isMultiLine : false ,
75
- _fontStyleStr : null ,
75
+ _fontStyleStr : null , //TODO move to render cmd
76
76
77
77
// font shadow
78
78
_shadowEnabled : false ,
79
79
_shadowOffset : null ,
80
80
_shadowOpacity : 0 ,
81
81
_shadowBlur : 0 ,
82
- _shadowColorStr : null ,
82
+ _shadowColorStr : null , //TODO move to render cmd
83
83
_shadowColor : null ,
84
84
85
85
// font stroke
86
86
_strokeEnabled : false ,
87
87
_strokeColor : null ,
88
88
_strokeSize : 0 ,
89
- _strokeColorStr : null ,
89
+ _strokeColorStr : null , // TODO move to render cmd
90
90
91
91
// font tint
92
92
_textFillColor : null ,
93
- _fillColorStr : null ,
93
+ _fillColorStr : null , // TODO move to render cmd
94
94
95
95
_strokeShadowOffsetX : 0 ,
96
96
_strokeShadowOffsetY : 0 ,
@@ -130,7 +130,6 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{
130
130
this . _hAlignment = hAlignment ;
131
131
this . _vAlignment = vAlignment ;
132
132
133
- //this._fontSize = (cc._renderType === cc._RENDER_TYPE_CANVAS) ? fontSize : fontSize * cc.contentScaleFactor();
134
133
this . _fontSize = fontSize ;
135
134
this . _fontStyleStr = this . _fontSize + "px '" + fontName + "'" ;
136
135
this . _fontClientHeight = cc . LabelTTF . __getFontHeightByDiv ( fontName , this . _fontSize ) ;
@@ -1002,85 +1001,9 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{
1002
1001
cc . Sprite . prototype . visit . call ( this , context ) ;
1003
1002
} ,
1004
1003
1005
- draw : null ,
1006
-
1007
- _setTextureCoords : function ( rect ) {
1008
- var tex = this . _batchNode ? this . textureAtlas . texture : this . _texture ;
1009
- if ( ! tex )
1010
- return ;
1011
-
1012
- var atlasWidth = tex . pixelsWidth ;
1013
- var atlasHeight = tex . pixelsHeight ;
1014
-
1015
- var left , right , top , bottom , tempSwap , locQuad = this . _quad ;
1016
- if ( this . _rectRotated ) {
1017
- if ( cc . FIX_ARTIFACTS_BY_STRECHING_TEXEL ) {
1018
- left = ( 2 * rect . x + 1 ) / ( 2 * atlasWidth ) ;
1019
- right = left + ( rect . height * 2 - 2 ) / ( 2 * atlasWidth ) ;
1020
- top = ( 2 * rect . y + 1 ) / ( 2 * atlasHeight ) ;
1021
- bottom = top + ( rect . width * 2 - 2 ) / ( 2 * atlasHeight ) ;
1022
- } else {
1023
- left = rect . x / atlasWidth ;
1024
- right = ( rect . x + rect . height ) / atlasWidth ;
1025
- top = rect . y / atlasHeight ;
1026
- bottom = ( rect . y + rect . width ) / atlasHeight ;
1027
- } // CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
1028
-
1029
- if ( this . _flippedX ) {
1030
- tempSwap = top ;
1031
- top = bottom ;
1032
- bottom = tempSwap ;
1033
- }
1034
-
1035
- if ( this . _flippedY ) {
1036
- tempSwap = left ;
1037
- left = right ;
1038
- right = tempSwap ;
1039
- }
1040
-
1041
- locQuad . bl . texCoords . u = left ;
1042
- locQuad . bl . texCoords . v = top ;
1043
- locQuad . br . texCoords . u = left ;
1044
- locQuad . br . texCoords . v = bottom ;
1045
- locQuad . tl . texCoords . u = right ;
1046
- locQuad . tl . texCoords . v = top ;
1047
- locQuad . tr . texCoords . u = right ;
1048
- locQuad . tr . texCoords . v = bottom ;
1049
- } else {
1050
- if ( cc . FIX_ARTIFACTS_BY_STRECHING_TEXEL ) {
1051
- left = ( 2 * rect . x + 1 ) / ( 2 * atlasWidth ) ;
1052
- right = left + ( rect . width * 2 - 2 ) / ( 2 * atlasWidth ) ;
1053
- top = ( 2 * rect . y + 1 ) / ( 2 * atlasHeight ) ;
1054
- bottom = top + ( rect . height * 2 - 2 ) / ( 2 * atlasHeight ) ;
1055
- } else {
1056
- left = rect . x / atlasWidth ;
1057
- right = ( rect . x + rect . width ) / atlasWidth ;
1058
- top = rect . y / atlasHeight ;
1059
- bottom = ( rect . y + rect . height ) / atlasHeight ;
1060
- } // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
1061
-
1062
- if ( this . _flippedX ) {
1063
- tempSwap = left ;
1064
- left = right ;
1065
- right = tempSwap ;
1066
- }
1067
-
1068
- if ( this . _flippedY ) {
1069
- tempSwap = top ;
1070
- top = bottom ;
1071
- bottom = tempSwap ;
1072
- }
1073
-
1074
- locQuad . bl . texCoords . u = left ;
1075
- locQuad . bl . texCoords . v = bottom ;
1076
- locQuad . br . texCoords . u = right ;
1077
- locQuad . br . texCoords . v = bottom ;
1078
- locQuad . tl . texCoords . u = left ;
1079
- locQuad . tl . texCoords . v = top ;
1080
- locQuad . tr . texCoords . u = right ;
1081
- locQuad . tr . texCoords . v = top ;
1082
- }
1083
- this . _quadDirty = true ;
1004
+ setTextureRect : function ( rect , rotated , untrimmedSize ) {
1005
+ //set needConvert to false
1006
+ cc . Sprite . prototype . setTextureRect . call ( this , rect , rotated , untrimmedSize , false ) ;
1084
1007
}
1085
1008
} ) ;
1086
1009
@@ -1154,40 +1077,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
1154
1077
}
1155
1078
} ;
1156
1079
1157
- _p . draw = cc . Sprite . prototype . draw ;
1158
-
1159
- _p . setTextureRect = function ( rect , rotated , untrimmedSize ) {
1160
- this . _rectRotated = rotated || false ;
1161
- untrimmedSize = untrimmedSize || rect ;
1162
-
1163
- this . setContentSize ( untrimmedSize ) ;
1164
- this . setVertexRect ( rect ) ;
1165
-
1166
- var locTextureCoordRect = this . _renderCmd . _textureCoord ;
1167
- locTextureCoordRect . x = rect . x ;
1168
- locTextureCoordRect . y = rect . y ;
1169
- locTextureCoordRect . renderX = rect . x ;
1170
- locTextureCoordRect . renderY = rect . y ;
1171
- locTextureCoordRect . width = rect . width ;
1172
- locTextureCoordRect . height = rect . height ;
1173
- locTextureCoordRect . validRect = ! ( locTextureCoordRect . width === 0 || locTextureCoordRect . height === 0
1174
- || locTextureCoordRect . x < 0 || locTextureCoordRect . y < 0 ) ;
1175
-
1176
- var relativeOffset = this . _unflippedOffsetPositionFromCenter ;
1177
- if ( this . _flippedX )
1178
- relativeOffset . x = - relativeOffset . x ;
1179
- if ( this . _flippedY )
1180
- relativeOffset . y = - relativeOffset . y ;
1181
- this . _offsetPosition . x = relativeOffset . x + ( this . _contentSize . width - this . _rect . width ) / 2 ;
1182
- this . _offsetPosition . y = relativeOffset . y + ( this . _contentSize . height - this . _rect . height ) / 2 ;
1183
-
1184
- // rendering using batch node
1185
- if ( this . _batchNode ) {
1186
- this . dirty = true ;
1187
- }
1188
- } ;
1189
1080
_p = null ;
1190
-
1191
1081
} else {
1192
1082
cc . assert ( cc . isFunction ( cc . _tmp . WebGLLabelTTF ) , cc . _LogInfos . MissingFile , "LabelTTFWebGL.js" ) ;
1193
1083
cc . _tmp . WebGLLabelTTF ( ) ;
@@ -1199,7 +1089,6 @@ cc._tmp.PrototypeLabelTTF();
1199
1089
delete cc . _tmp . PrototypeLabelTTF ;
1200
1090
1201
1091
cc . LabelTTF . _textAlign = [ "left" , "center" , "right" ] ;
1202
-
1203
1092
cc . LabelTTF . _textBaseline = [ "top" , "middle" , "bottom" ] ;
1204
1093
1205
1094
//check the first character
@@ -1259,7 +1148,6 @@ document.body ?
1259
1148
document . body . appendChild ( cc . LabelTTF . __labelHeightDiv ) ;
1260
1149
} , false ) ;
1261
1150
1262
-
1263
1151
cc . LabelTTF . __getFontHeightByDiv = function ( fontName , fontSize ) {
1264
1152
var clientHeight = cc . LabelTTF . __fontHeightCache [ fontName + "." + fontSize ] ;
1265
1153
if ( clientHeight > 0 ) return clientHeight ;
0 commit comments