index.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import GCanvas from './env/canvas';
  2. import GImage from './env/image';
  3. import GWebGLRenderingContext from './context-webgl/RenderingContext';
  4. import GContext2D from './context-2d/RenderingContext';
  5. import GBridgeWeex from './bridge/bridge-weex';
  6. export let Image = GImage;
  7. export let WeexBridge = GBridgeWeex;
  8. export function enable(el, { bridge, debug, disableAutoSwap, disableComboCommands } = {}) {
  9. const GBridge = GImage.GBridge = GCanvas.GBridge = GWebGLRenderingContext.GBridge = GContext2D.GBridge = bridge;
  10. GBridge.callEnable(el.ref, [
  11. 0, // renderMode: 0--RENDERMODE_WHEN_DIRTY, 1--RENDERMODE_CONTINUOUSLY
  12. -1, // hybridLayerType: 0--LAYER_TYPE_NONE 1--LAYER_TYPE_SOFTWARE 2--LAYER_TYPE_HARDWARE
  13. false, // supportScroll
  14. false, // newCanvasMode
  15. 1, // compatible
  16. 'white',// clearColor
  17. false // sameLevel: newCanvasMode = true && true => GCanvasView and Webview is same level
  18. ]);
  19. if (debug === true) {
  20. GBridge.callEnableDebug();
  21. }
  22. if (disableComboCommands) {
  23. GBridge.callEnableDisableCombo();
  24. }
  25. var canvas = new GCanvas(el.ref, { disableAutoSwap });
  26. canvas.width = el.style.width;
  27. canvas.height = el.style.height;
  28. return canvas;
  29. };