zhangwei
2024-09-29 94384dcf5066aa1a7b2e37874fe331e148bc9249
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// 本文件由FirstUI授权予四川政采招投标咨询有限公司(会员ID:1  63,营业执照号:9 1 5  101   31   332 00  6 1  9 3K)专用,请尊重知识产权,勿私下传播,违者追究法律责任。
import GCanvas from './env/canvas';
import GImage from './env/image';
 
import GWebGLRenderingContext from './context-webgl/RenderingContext';
import GContext2D from './context-2d/RenderingContext';
 
import GBridgeWeex from './bridge/bridge-weex';
 
export let Image = GImage;
 
export let WeexBridge = GBridgeWeex;
 
export function enable(el, {
    bridge,
    debug,
    disableAutoSwap,
    disableComboCommands
} = {}) {
 
    const GBridge = GImage.GBridge = GCanvas.GBridge = GWebGLRenderingContext.GBridge = GContext2D.GBridge = bridge;
 
    GBridge.callEnable(el.ref, [
        0, // renderMode: 0--RENDERMODE_WHEN_DIRTY, 1--RENDERMODE_CONTINUOUSLY
        -1, // hybridLayerType:  0--LAYER_TYPE_NONE 1--LAYER_TYPE_SOFTWARE 2--LAYER_TYPE_HARDWARE
        false, // supportScroll
        false, // newCanvasMode
        1, // compatible
        'white', // clearColor
        false // sameLevel: newCanvasMode = true && true => GCanvasView and Webview is same level
    ]);
 
    if (debug === true) {
        GBridge.callEnableDebug();
    }
    if (disableComboCommands) {
        GBridge.callEnableDisableCombo();
    }
 
    var canvas = new GCanvas(el.ref, {
        disableAutoSwap
    });
    let pixelRatio = uni.getSystemInfoSync().pixelRatio;
    canvas.width = el.style.width * pixelRatio;
    canvas.height = el.style.height * pixelRatio;
 
    return canvas;
};