runtime platform fix (#7139)

This commit is contained in:
ChiaNing
2020-08-14 15:17:02 +08:00
committed by GitHub
parent 359e864750
commit bdb39fbe65
3 changed files with 15 additions and 12 deletions
+4 -4
View File
@@ -625,7 +625,7 @@ export class Game extends EventTarget {
inputManager.registerSystemEvent(game.canvas);
}
const useSplash = (!JSB && !EDITOR && !PREVIEW && legacyCC.internal.SplashScreen);
const useSplash = (!EDITOR && !PREVIEW && legacyCC.internal.SplashScreen);
// Load render pipeline if needed
const renderPipeline = this.config.renderPipeline;
@@ -750,7 +750,7 @@ export class Game extends EventTarget {
const frameRate = legacyCC.game.config.frameRate;
this._frameTime = 1000 / frameRate;
if (JSB) {
if (JSB || RUNTIME_BASED) {
jsb.setPreferredFramesPerSecond(frameRate);
window.rAF = window.requestAnimationFrame;
window.cAF = window.cancelAnimationFrame;
@@ -811,7 +811,7 @@ export class Game extends EventTarget {
callback = (time: number) => {
if (this._paused) { return; }
this._intervalId = window.rAF(callback);
if (!JSB && frameRate === 30) {
if (!JSB && !RUNTIME_BASED && frameRate === 30) {
skip = !skip;
if (skip) {
return;
@@ -907,7 +907,7 @@ export class Game extends EventTarget {
if (this.renderType === Game.RENDER_TYPE_WEBGL) {
const ctors: Constructor<GFXDevice>[] = [];
if (!RUNTIME_BASED && JSB && window.gfx) {
if (JSB && window.gfx) {
if (gfx.CCVKDevice) { ctors.push(gfx.CCVKDevice); }
if (gfx.CCMTLDevice) { ctors.push(gfx.CCMTLDevice); }
if (gfx.GLES3Device) { ctors.push(gfx.GLES3Device); }
+6 -3
View File
@@ -28,7 +28,7 @@
* @category core
*/
import { EDITOR, TEST, WECHAT, ALIPAY, XIAOMI, BAIDU, COCOSPLAY, JSB, MINIGAME, HUAWEI, OPPO, VIVO } from 'internal:constants';
import { EDITOR, TEST, WECHAT, ALIPAY, XIAOMI, BAIDU, COCOSPLAY, JSB, MINIGAME, HUAWEI, OPPO, VIVO, RUNTIME_BASED } from 'internal:constants';
import { legacyCC } from '../global-exports';
import { warnID, log, logID } from './debug';
@@ -496,7 +496,7 @@ export const sys: { [x: string]: any; } = {
* @en Whether the running platform is browser
* @zh 指示运行平台是否是浏览器
*/
isBrowser: typeof window === 'object' && typeof document === 'object' && !MINIGAME && !JSB,
isBrowser: typeof window === 'object' && typeof document === 'object' && !MINIGAME && !JSB && !RUNTIME_BASED,
/**
* @en Indicate whether the current running context is a mobile system
@@ -661,7 +661,7 @@ export const sys: { [x: string]: any; } = {
* @zh 尝试打开一个 web 页面,并非在所有平台都有效
*/
openURL (url) {
if (JSB) {
if (JSB || RUNTIME_BASED) {
// @ts-ignore
jsb.openURL(url);
}
@@ -971,6 +971,9 @@ else {
else if (WECHAT) {
_supportWebGL = true;
}
else if (RUNTIME_BASED) {
_supportWebGL = true;
}
else if (win.WebGLRenderingContext) {
// @ts-ignore
if (create3DContext(document.createElement('CANVAS'))) {
+5 -5
View File
@@ -34,7 +34,7 @@ import { EventTarget } from '../event/event-target';
import '../game';
import { Rect, Size, Vec2 } from '../math';
import visibleRect from './visible-rect';
import { EDITOR, MINIGAME, WECHAT, JSB } from 'internal:constants';
import { EDITOR, MINIGAME, WECHAT, JSB, RUNTIME_BASED } from 'internal:constants';
import { legacyCC } from '../global-exports';
import { logID, errorID } from './debug';
@@ -172,7 +172,7 @@ export class View extends EventTarget {
this._autoFullScreen = false;
// The device's pixel ratio (for retina displays)
this._devicePixelRatio = 1;
if (JSB) {
if (JSB || RUNTIME_BASED) {
this._maxPixelRatio = 4;
} else {
this._maxPixelRatio = 2;
@@ -656,7 +656,7 @@ export class View extends EventTarget {
* @param resolutionPolicy The resolution policy desired
*/
public setRealPixelResolution (width: number, height: number, resolutionPolicy: ResolutionPolicy|number) {
if (!JSB && !MINIGAME) {
if (!JSB && !RUNTIME_BASED && !MINIGAME) {
// Set viewport's width
this._setViewportMeta({width}, true);
@@ -759,7 +759,7 @@ export class View extends EventTarget {
_view._initFrameSize();
}
if (!JSB && !_view._orientationChanging && _view._isRotated === prevRotated && _view._frameSize.width === prevFrameW && _view._frameSize.height === prevFrameH) {
if (!JSB && !RUNTIME_BASED && !_view._orientationChanging && _view._isRotated === prevRotated && _view._frameSize.width === prevFrameW && _view._frameSize.height === prevFrameH) {
return;
}
@@ -874,7 +874,7 @@ export class View extends EventTarget {
}
private _adjustViewportMeta () {
if (this._isAdjustViewport && !JSB && !MINIGAME) {
if (this._isAdjustViewport && !JSB && !RUNTIME_BASED && !MINIGAME) {
this._setViewportMeta(__BrowserGetter.meta, false);
this._isAdjustViewport = false;
}