Skip to content

Commit 64b20ea

Browse files
authored
Merge pull request #3368 from pandamicro/develop
Improve mobile browser adaptation
2 parents cff0147 + f0511de commit 64b20ea

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

CCBoot.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,7 @@ var _initSys = function () {
17421742
sys.browserType = sys.BROWSER_TYPE_UNKNOWN;
17431743
/* Determine the browser type */
17441744
(function(){
1745-
var typeReg1 = /mqqbrowser|sogou|qzone|liebao|micromessenger|ucbrowser|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|mxbrowser|trident|miuibrowser/i;
1745+
var typeReg1 = /micromessenger|mqqbrowser|sogou|qzone|liebao|ucbrowser|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|mxbrowser|trident|miuibrowser/i;
17461746
var typeReg2 = /qqbrowser|chrome|safari|firefox|opr|oupeng|opera/i;
17471747
var browserTypes = typeReg1.exec(ua);
17481748
if(!browserTypes) browserTypes = typeReg2.exec(ua);
@@ -1859,10 +1859,17 @@ var _initSys = function () {
18591859
var tmpCanvas = document.createElement("CANVAS");
18601860
try{
18611861
var context = cc.create3DContext(tmpCanvas, {'stencil': true});
1862-
if(context) {
1862+
if (context && context.getShaderPrecisionFormat) {
18631863
_supportWebGL = true;
18641864
}
18651865

1866+
if (_supportWebGL && sys.os === sys.OS_IOS) {
1867+
// Not activating WebGL in iOS UIWebView because it may crash when entering background
1868+
if (!window.indexedDB) {
1869+
_supportWebGL = false;
1870+
}
1871+
}
1872+
18661873
if (_supportWebGL && sys.os === sys.OS_ANDROID) {
18671874
var browserVer = parseFloat(sys.browserVersion);
18681875
switch (sys.browserType) {

cocos2d/core/platform/CCEGLView.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
138138
_viewName: "",
139139
// Custom callback for resize event
140140
_resizeCallback: null,
141+
142+
_orientationChanging: true,
143+
141144
_scaleX: 1,
142145
_originalScaleX: 1,
143146
_scaleY: 1,
@@ -224,6 +227,11 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
224227
}
225228
},
226229

230+
_orientationChange: function () {
231+
this._orientationChanging = true;
232+
this._resizeEvent();
233+
},
234+
227235
/**
228236
* <p>
229237
* Sets view's target-densitydpi for android mobile browser. it can be set to: <br/>
@@ -259,14 +267,14 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
259267
if (!this.__resizeWithBrowserSize) {
260268
this.__resizeWithBrowserSize = true;
261269
window.addEventListener('resize', this._resizeEvent);
262-
window.addEventListener('orientationchange', this._resizeEvent);
270+
window.addEventListener('orientationchange', this._orientationChange);
263271
}
264272
} else {
265273
//disable
266274
if (this.__resizeWithBrowserSize) {
267275
this.__resizeWithBrowserSize = false;
268276
window.removeEventListener('resize', this._resizeEvent);
269-
window.removeEventListener('orientationchange', this._resizeEvent);
277+
window.removeEventListener('orientationchange', this._orientationChange);
270278
}
271279
}
272280
},
@@ -305,7 +313,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
305313
var h = __BrowserGetter.availHeight(this._frame);
306314
var isLandscape = w >= h;
307315

308-
if (!cc.sys.isMobile ||
316+
if (!this._orientationChanging || !cc.sys.isMobile ||
309317
(isLandscape && this._orientation & cc.ORIENTATION_LANDSCAPE) ||
310318
(!isLandscape && this._orientation & cc.ORIENTATION_PORTRAIT)) {
311319
locFrameSize.width = w;
@@ -323,6 +331,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
323331
cc.container.style.transformOrigin = '0px 0px 0px';
324332
this._isRotated = true;
325333
}
334+
this._orientationChanging = false;
326335
},
327336

328337
// hack

extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
break;
7878
case ccs.DISPLAY_TYPE_ARMATURE:
7979
selNode.setShaderProgram(this._shaderProgram);
80+
this._updateColorAndOpacity(cmd, selBone);
8081
cmd._parentCmd = this;
8182
// Continue rendering in default
8283
default:

0 commit comments

Comments
 (0)