Merge pull request #1365 from knoxHuang/v1.3_fixBug

fix load webp error for fireball/issues/4904
This commit is contained in:
Jare Guo
2016-12-15 15:23:09 +08:00
committed by GitHub
2 changed files with 14 additions and 2 deletions
+11 -1
View File
@@ -63,6 +63,16 @@ function downloadScript (item, callback, isAsync) {
d.body.appendChild(s);
}
function downloadWebp (item, callback, isCrossOrigin, img) {
if (!cc.sys.capabilities.webp) {
setTimeout(function () {
callback('Load Webp ( ' + item.url + ' ) failed')
}, 0);
return;
}
downloadImage(item, callback, isCrossOrigin, img);
}
function downloadImage (item, callback, isCrossOrigin, img) {
if (isCrossOrigin === undefined) {
isCrossOrigin = true;
@@ -232,7 +242,7 @@ var defaultMap = {
'gif' : downloadImage,
'ico' : downloadImage,
'tiff' : downloadImage,
'webp' : downloadImage,
'webp' : downloadWebp,
'image' : downloadImage,
// Audio
+3 -1
View File
@@ -729,6 +729,7 @@ else {
};
}
var _supportWebp = _tmpCanvas1.toDataURL('image/webp').startsWith('data:image/webp');
var _supportCanvas = !!_tmpCanvas1.getContext("2d");
var _supportWebGL = false;
if (win.WebGLRenderingContext) {
@@ -792,7 +793,8 @@ else {
*/
var capabilities = sys.capabilities = {
"canvas": _supportCanvas,
"opengl": _supportWebGL
"opengl": _supportWebGL,
"webp": _supportWebp,
};
if (docEle['ontouchstart'] !== undefined || doc['ontouchstart'] !== undefined || nav.msPointerEnabled)
capabilities["touches"] = true;