Merge pull request #932 from pandamicro/master

修复 Scale9Sprite 显示合图时的边缘黑线
This commit is contained in:
pandamicro
2016-07-21 11:30:17 +08:00
committed by GitHub
5 changed files with 91 additions and 58 deletions
+1
View File
@@ -740,6 +740,7 @@ else {
case sys.BROWSER_TYPE_UNKNOWN:
case sys.BROWSER_TYPE_360:
case sys.BROWSER_TYPE_MIUI:
case sys.BROWSER_TYPE_UC:
_supportWebGL = false;
}
}
+8 -3
View File
@@ -886,16 +886,21 @@ var View = cc._Class.extend({
selTouch, selPoint, selPrePoint, selStartPoint;
for( var i = 0; i < touches.length; i ++){
selTouch = touches[i];
hasStartPoint = selTouch._startPointCaptured;
selPoint = selTouch._point;
selPrePoint = selTouch._prevPoint;
selStartPoint = selTouch._startPoint;
selPoint.x = (selPoint.x - locViewPortRect.x) / locScaleX;
selPoint.y = (selPoint.y - locViewPortRect.y) / locScaleY;
selPrePoint.x = (selPrePoint.x - locViewPortRect.x) / locScaleX;
selPrePoint.y = (selPrePoint.y - locViewPortRect.y) / locScaleY;
selStartPoint.x = (selStartPoint.x - locViewPortRect.x) / locScaleX;
selStartPoint.y = (selStartPoint.y - locViewPortRect.y) / locScaleY;
if (!hasStartPoint) {
selStartPoint = selTouch._startPoint;
selStartPoint.x = selPoint.x;
selStartPoint.y = selPoint.y;
selTouch._startPointCaptured = true;
}
}
}
});
+56 -51
View File
@@ -55,7 +55,8 @@ var dataPool = {
}
};
var webgl,
var FIX_ARTIFACTS_BY_STRECHING_TEXEL = cc.macro.FIX_ARTIFACTS_BY_STRECHING_TEXEL,
webgl,
vl, vb, vt, vr,
cornerId = [];
@@ -162,22 +163,23 @@ var simpleQuadGenerator = {
//uv computation should take spritesheet into account.
var l, b, r, t;
var texelCorrect = FIX_ARTIFACTS_BY_STRECHING_TEXEL ? 0.5 : 0;
if (spriteFrame._rotated) {
l = textureRect.x / atlasWidth;
b = (textureRect.y + textureRect.width) / atlasHeight;
r = (textureRect.x + textureRect.height) / atlasWidth;
t = textureRect.y / atlasHeight;
l = (textureRect.x + texelCorrect) / atlasWidth;
b = (textureRect.y + textureRect.width - texelCorrect) / atlasHeight;
r = (textureRect.x + textureRect.height - texelCorrect) / atlasWidth;
t = (textureRect.y + texelCorrect) / atlasHeight;
uvs[0] = l; uvs[1] = t;
uvs[2] = l; uvs[3] = b;
uvs[4] = r; uvs[5] = t;
uvs[6] = r; uvs[7] = b;
}
else {
l = textureRect.x / atlasWidth;
b = (textureRect.y + textureRect.height) / atlasHeight;
r = (textureRect.x + textureRect.width) / atlasWidth;
t = textureRect.y / atlasHeight;
l = (textureRect.x + texelCorrect) / atlasWidth;
b = (textureRect.y + textureRect.height - texelCorrect) / atlasHeight;
r = (textureRect.x + textureRect.width - texelCorrect) / atlasWidth;
t = (textureRect.y + texelCorrect) / atlasHeight;
uvs[0] = l; uvs[1] = b;
uvs[2] = r; uvs[3] = b;
uvs[4] = l; uvs[5] = t;
@@ -288,17 +290,18 @@ var scale9QuadGenerator = {
var u = new Array(4);
var v = new Array(4);
var offset = 0, row, col;
var texelCorrect = FIX_ARTIFACTS_BY_STRECHING_TEXEL ? 0.5 : 0;
if (spriteFrame._rotated) {
u[0] = textureRect.x / atlasWidth;
u[1] = (bottomHeight + textureRect.x) / atlasWidth;
u[2] = (bottomHeight + centerHeight + textureRect.x) / atlasWidth;
u[3] = (textureRect.x + textureRect.height) / atlasWidth;
u[0] = (textureRect.x + texelCorrect) / atlasWidth;
u[1] = (bottomHeight + textureRect.x - texelCorrect) / atlasWidth;
u[2] = (bottomHeight + centerHeight + textureRect.x - texelCorrect) / atlasWidth;
u[3] = (textureRect.x + textureRect.height - texelCorrect) / atlasWidth;
v[3] = textureRect.y / atlasHeight;
v[2] = (leftWidth + textureRect.y) / atlasHeight;
v[1] = (leftWidth + centerWidth + textureRect.y) / atlasHeight;
v[0] = (textureRect.y + textureRect.width) / atlasHeight;
v[3] = (textureRect.y + texelCorrect) / atlasHeight;
v[2] = (leftWidth + textureRect.y - texelCorrect) / atlasHeight;
v[1] = (leftWidth + centerWidth + textureRect.y - texelCorrect) / atlasHeight;
v[0] = (textureRect.y + textureRect.width - texelCorrect) / atlasHeight;
for (row = 0; row < 4; row++) {
for (col = 0; col < 4; col++) {
@@ -309,15 +312,15 @@ var scale9QuadGenerator = {
}
}
else {
u[0] = textureRect.x / atlasWidth;
u[1] = (leftWidth + textureRect.x) / atlasWidth;
u[2] = (leftWidth + centerWidth + textureRect.x) / atlasWidth;
u[3] = (textureRect.x + textureRect.width) / atlasWidth;
u[0] = (textureRect.x + texelCorrect) / atlasWidth;
u[1] = (leftWidth + textureRect.x - texelCorrect) / atlasWidth;
u[2] = (leftWidth + centerWidth + textureRect.x - texelCorrect) / atlasWidth;
u[3] = (textureRect.x + textureRect.width - texelCorrect) / atlasWidth;
v[3] = textureRect.y / atlasHeight;
v[2] = (topHeight + textureRect.y) / atlasHeight;
v[1] = (topHeight + centerHeight + textureRect.y) / atlasHeight;
v[0] = (textureRect.y + textureRect.height) / atlasHeight;
v[3] = (textureRect.y + texelCorrect) / atlasHeight;
v[2] = (topHeight + textureRect.y - texelCorrect) / atlasHeight;
v[1] = (topHeight + centerHeight + textureRect.y - texelCorrect) / atlasHeight;
v[0] = (textureRect.y + textureRect.height - texelCorrect) / atlasHeight;
for (row = 0; row < 4; row++) {
for (col = 0; col < 4; col++) {
@@ -342,17 +345,18 @@ var tiledQuadGenerator = {
//uv computation should take spritesheet into account.
var u0, v0, u1, v1;
var texelCorrect = FIX_ARTIFACTS_BY_STRECHING_TEXEL ? 0.5 : 0;
if (spriteFrame._rotated) {
u0 = textureRect.x / atlasWidth;
u1 = (textureRect.x + textureRect.height) / atlasWidth;
v0 = (textureRect.y + textureRect.width) / atlasHeight;
v1 = textureRect.y / atlasHeight;
u0 = (textureRect.x + texelCorrect) / atlasWidth;
u1 = (textureRect.x + textureRect.height - texelCorrect) / atlasWidth;
v0 = (textureRect.y + textureRect.width - texelCorrect) / atlasHeight;
v1 = (textureRect.y + texelCorrect) / atlasHeight;
}
else {
u0 = textureRect.x / atlasWidth;
u1 = (textureRect.x + textureRect.width) / atlasWidth;
v0 = (textureRect.y + textureRect.height) / atlasHeight;
v1 = textureRect.y / atlasHeight;
u0 = (textureRect.x + texelCorrect) / atlasWidth;
u1 = (textureRect.x + textureRect.width - texelCorrect) / atlasWidth;
v0 = (textureRect.y + textureRect.height - texelCorrect) / atlasHeight;
v1 = (textureRect.y + texelCorrect) / atlasHeight;
}
//build quads
@@ -455,17 +459,18 @@ var fillQuadGeneratorBar = {
var textureRect = spriteFrame._rect;
//uv computation should take spritesheet into account.
var ul, vb, ur, vt;
var texelCorrect = FIX_ARTIFACTS_BY_STRECHING_TEXEL ? 0.5 : 0;
if (spriteFrame._rotated) {
ul = textureRect.x / atlasWidth;
vb = (textureRect.y + textureRect.width) / atlasHeight;
ur = (textureRect.x + textureRect.height) / atlasWidth;
vt = textureRect.y / atlasHeight;
ul = (textureRect.x + texelCorrect) / atlasWidth;
vb = (textureRect.y + textureRect.width - texelCorrect) / atlasHeight;
ur = (textureRect.x + textureRect.height - texelCorrect) / atlasWidth;
vt = (textureRect.y + texelCorrect) / atlasHeight;
}
else {
ul = textureRect.x / atlasWidth;
vb = (textureRect.y + textureRect.height) / atlasHeight;
ur = (textureRect.x + textureRect.width) / atlasWidth;
vt = textureRect.y / atlasHeight;
ul = (textureRect.x + texelCorrect) / atlasWidth;
vb = (textureRect.y + textureRect.height - texelCorrect) / atlasHeight;
ur = (textureRect.x + textureRect.width - texelCorrect) / atlasWidth;
vt = (textureRect.y + texelCorrect) / atlasHeight;
}
if (vertices.length < 8) {
@@ -894,22 +899,22 @@ var fillQuadGeneratorRadial = {
var textureRect = spriteFrame._rect;
//uv computation should take spritesheet into account.
var u0, u3;
var v0, v3;
var u0, u3, v0, v3;
var texelCorrect = FIX_ARTIFACTS_BY_STRECHING_TEXEL ? 0.5 : 0;
if (spriteFrame._rotated) {
u0 = textureRect.x / atlasWidth;
u3 = (textureRect.x + textureRect.height) / atlasWidth;
u0 = (textureRect.x + texelCorrect) / atlasWidth;
u3 = (textureRect.x + textureRect.height - texelCorrect) / atlasWidth;
v0 = textureRect.y / atlasHeight;
v3 = (textureRect.y + textureRect.width) / atlasHeight;
v0 = (textureRect.y + texelCorrect) / atlasHeight;
v3 = (textureRect.y + textureRect.width - texelCorrect) / atlasHeight;
}
else {
u0 = textureRect.x / atlasWidth;
u3 = (textureRect.x + textureRect.width) / atlasWidth;
u0 = (textureRect.x + texelCorrect) / atlasWidth;
u3 = (textureRect.x + textureRect.width - texelCorrect) / atlasWidth;
v0 = textureRect.y / atlasHeight;
v3 = (textureRect.y + textureRect.height) / atlasHeight;
v0 = (textureRect.y + texelCorrect) / atlasHeight;
v3 = (textureRect.y + textureRect.height - texelCorrect) / atlasHeight;
}
this._uvs[0].x = u0;
+18
View File
@@ -63,6 +63,22 @@ cc.loader.addDownloadHandlers({
'mp4' : downloadAudio,
'm4a' : downloadAudio,
// Txt
'txt' : empty,
'xml' : empty,
'vsh' : empty,
'fsh' : empty,
'atlas' : empty,
'tmx' : empty,
'tsx' : empty,
'json' : empty,
'ExportJson' : empty,
'plist' : empty,
'fnt' : empty,
// Font
'font' : empty,
'eot' : empty,
@@ -70,6 +86,8 @@ cc.loader.addDownloadHandlers({
'woff' : empty,
'svg' : empty,
'ttc' : empty,
'default' : empty
});
+8 -4
View File
@@ -51,18 +51,22 @@ cc.textureCache.getTextureForKey = function (key) {
cc.Class._fastDefine('cc.Texture2D', cc.Texture2D, []);
cc.Texture2D.$super = cc.RawAsset;
cc.Texture2D.prototype.isLoaded = function () {
var prototype = cc.Texture2D.prototype;
prototype.isLoaded = function () {
return true;
};
cc.Texture2D.prototype.getPixelWidth = cc.Texture2D.prototype.getPixelsWide;
cc.Texture2D.prototype.getPixelHeight = cc.Texture2D.prototype.getPixelsHigh;
prototype.getPixelWidth = prototype.getPixelsWide;
prototype.getPixelHeight = prototype.getPixelsHigh;
cc.js.get(prototype, 'pixelWidth', prototype.getPixelWidth);
cc.js.get(prototype, 'pixelHeight', prototype.getPixelHeight);
// cc.SpriteFrame
cc.Class._fastDefine('cc.SpriteFrame', cc.SpriteFrame, []);
cc.SpriteFrame.$super = cc.Asset;
var prototype = cc.SpriteFrame.prototype;
prototype = cc.SpriteFrame.prototype;
cc.js.mixin(prototype, cc.EventTarget.prototype);
prototype.textureLoaded = function () {