@hxa-rn/react-native-gcanvas 6.0.24-beta.1 → 6.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -2
- package/LICENSE +203 -21
- package/README.md +207 -207
- package/harmony/gcanvas/LICENSE +203 -21
- package/harmony/gcanvas/NOTICE +32 -32
- package/harmony/gcanvas/OAT.xml +37 -37
- package/harmony/gcanvas/build-profile.json5 +16 -16
- package/harmony/gcanvas/hvigorfile.ts +1 -1
- package/harmony/gcanvas/index.ets +1 -1
- package/harmony/gcanvas/oh-package.json5 +14 -14
- package/harmony/gcanvas/src/main/cpp/CMakeLists.txt +126 -126
- package/harmony/gcanvas/src/main/cpp/GCanvasNapi.cpp +485 -485
- package/harmony/gcanvas/src/main/cpp/GCanvasXComponent.cpp +106 -106
- package/harmony/gcanvas/src/main/cpp/GcanvasPackage.h +24 -24
- package/harmony/gcanvas/src/main/ets/GCanvasModuleTurboModule.ts +448 -448
- package/harmony/gcanvas/src/main/ets/GCanvasNativeEngine.ts +206 -206
- package/harmony/gcanvas/src/main/ets/components/GCanvasView.ets +64 -64
- package/harmony/gcanvas/src/main/module.json5 +21 -21
- package/harmony/gcanvas/src/main/resources/base/element/string.json +12 -12
- package/harmony/gcanvas/src/main/resources/en_US/element/string.json +8 -8
- package/harmony/gcanvas/src/main/resources/zh_CN/element/string.json +12 -12
- package/harmony/gcanvas.har +0 -0
- package/package.json +4 -4
- package/packages/gcanvas/.babelrc +4 -4
- package/packages/gcanvas/.eslintrc.js +133 -133
- package/packages/gcanvas/package.json +19 -19
- package/packages/gcanvas/rollup.config.js +13 -13
- package/packages/gcanvas/src/bridge/react-native.js +286 -286
- package/packages/gcanvas/src/bridge/weex.js +210 -210
- package/packages/gcanvas/src/context/2d/FillStyleLinearGradient.js +16 -16
- package/packages/gcanvas/src/context/2d/FillStylePattern.js +7 -7
- package/packages/gcanvas/src/context/2d/FillStyleRadialGradient.js +16 -16
- package/packages/gcanvas/src/context/2d/OffScreenRenderingContext.js +48 -48
- package/packages/gcanvas/src/context/2d/RenderingContext.js +787 -787
- package/packages/gcanvas/src/context/webgl/ActiveInfo.js +10 -10
- package/packages/gcanvas/src/context/webgl/Buffer.js +20 -20
- package/packages/gcanvas/src/context/webgl/Framebuffer.js +20 -20
- package/packages/gcanvas/src/context/webgl/GLenum.js +300 -300
- package/packages/gcanvas/src/context/webgl/GLmethod.js +141 -141
- package/packages/gcanvas/src/context/webgl/GLtype.js +22 -22
- package/packages/gcanvas/src/context/webgl/Program.js +20 -20
- package/packages/gcanvas/src/context/webgl/Renderbuffer.js +20 -20
- package/packages/gcanvas/src/context/webgl/RenderingContext.js +1479 -1479
- package/packages/gcanvas/src/context/webgl/Shader.js +21 -21
- package/packages/gcanvas/src/context/webgl/ShaderPrecisionFormat.js +10 -10
- package/packages/gcanvas/src/context/webgl/Texture.js +21 -21
- package/packages/gcanvas/src/context/webgl/UniformLocation.js +21 -21
- package/packages/gcanvas/src/context/webgl/classUtils.js +2 -2
- package/packages/gcanvas/src/env/canvas.js +210 -210
- package/packages/gcanvas/src/env/image.js +76 -76
- package/packages/gcanvas/src/env/off-screen-canvas.js +74 -74
- package/packages/gcanvas/src/index.js +56 -56
- package/src/components/CanvasView.js +20 -20
- package/src/components/GCanvasComponent.js +408 -408
- package/src/index.js +69 -69
- package/src/packages/gcanvas/.babelrc +4 -4
- package/src/packages/gcanvas/.eslintrc.js +133 -133
- package/src/packages/gcanvas/package.json +19 -19
- package/src/packages/gcanvas/rollup.config.js +13 -13
- package/src/packages/gcanvas/src/bridge/react-native.js +288 -288
- package/src/packages/gcanvas/src/bridge/weex.js +210 -210
- package/src/packages/gcanvas/src/context/2d/FillStyleLinearGradient.js +16 -16
- package/src/packages/gcanvas/src/context/2d/FillStylePattern.js +7 -7
- package/src/packages/gcanvas/src/context/2d/FillStyleRadialGradient.js +16 -16
- package/src/packages/gcanvas/src/context/2d/OffScreenRenderingContext.js +48 -48
- package/src/packages/gcanvas/src/context/2d/RenderingContext.js +801 -801
- package/src/packages/gcanvas/src/context/webgl/ActiveInfo.js +10 -10
- package/src/packages/gcanvas/src/context/webgl/Buffer.js +20 -20
- package/src/packages/gcanvas/src/context/webgl/Framebuffer.js +20 -20
- package/src/packages/gcanvas/src/context/webgl/GLenum.js +300 -300
- package/src/packages/gcanvas/src/context/webgl/GLmethod.js +141 -141
- package/src/packages/gcanvas/src/context/webgl/GLtype.js +22 -22
- package/src/packages/gcanvas/src/context/webgl/Program.js +20 -20
- package/src/packages/gcanvas/src/context/webgl/Renderbuffer.js +20 -20
- package/src/packages/gcanvas/src/context/webgl/RenderingContext.js +1479 -1479
- package/src/packages/gcanvas/src/context/webgl/Shader.js +21 -21
- package/src/packages/gcanvas/src/context/webgl/ShaderPrecisionFormat.js +10 -10
- package/src/packages/gcanvas/src/context/webgl/Texture.js +21 -21
- package/src/packages/gcanvas/src/context/webgl/UniformLocation.js +21 -21
- package/src/packages/gcanvas/src/context/webgl/classUtils.js +2 -2
- package/src/packages/gcanvas/src/env/canvas.js +210 -210
- package/src/packages/gcanvas/src/env/image.js +76 -76
- package/src/packages/gcanvas/src/env/off-screen-canvas.js +74 -74
- package/src/packages/gcanvas/src/index.js +56 -56
- package/src/specs/v1/GCanvasViewNativeComponent.ts +42 -42
- package/src/specs/v1/NativeGCanvasModule.ts +140 -140
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
import Element from '@flyskywhy/react-native-browser-polyfill/src/DOM/Element';
|
|
2
|
-
import {defineEventAttribute} from 'event-target-shim';
|
|
3
|
-
|
|
4
|
-
// use srcs to [Call drawImage() in loop with only one GImage instance](https://github.com/flyskywhy/react-native-gcanvas/issues/41)
|
|
5
|
-
// just like what Web can do
|
|
6
|
-
let srcs = {};
|
|
7
|
-
|
|
8
|
-
let id = 0;
|
|
9
|
-
|
|
10
|
-
class GImage extends Element {
|
|
11
|
-
static GBridge = null;
|
|
12
|
-
|
|
13
|
-
constructor() {
|
|
14
|
-
super('img');
|
|
15
|
-
this._id = 0;
|
|
16
|
-
this.width = 0;
|
|
17
|
-
this.height = 0;
|
|
18
|
-
this._src = undefined;
|
|
19
|
-
this.complete = false;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
get src() {
|
|
23
|
-
return this._src;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
set src(value) {
|
|
27
|
-
if (value.startsWith('//')) {
|
|
28
|
-
value = 'http:' + value;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
this._src = value;
|
|
32
|
-
|
|
33
|
-
if (srcs[value]) {
|
|
34
|
-
this._id = srcs[value].id;
|
|
35
|
-
this.width = srcs[value].width;
|
|
36
|
-
this.height = srcs[value].height;
|
|
37
|
-
|
|
38
|
-
// in case another `new GImage()` set same src, so we also need `this.complete = true` here
|
|
39
|
-
this.complete = true;
|
|
40
|
-
|
|
41
|
-
var evt = {type: 'load', target: this};
|
|
42
|
-
this.dispatchEvent(evt);
|
|
43
|
-
} else {
|
|
44
|
-
// TODO: remove useless `0` arg in preloadImage of js and native
|
|
45
|
-
GImage.GBridge.preloadImage([this._src, 0], (data) => {
|
|
46
|
-
if (typeof data === 'string') {
|
|
47
|
-
data = JSON.parse(data);
|
|
48
|
-
}
|
|
49
|
-
if (data.error) {
|
|
50
|
-
var evt = {type: 'error', target: this, message: data.error};
|
|
51
|
-
this.dispatchEvent(evt);
|
|
52
|
-
} else {
|
|
53
|
-
id++;
|
|
54
|
-
this._id = id;
|
|
55
|
-
this.width = typeof data.width === 'number' ? data.width : 0;
|
|
56
|
-
this.height = typeof data.height === 'number' ? data.height : 0;
|
|
57
|
-
srcs[value] = {
|
|
58
|
-
id: this._id,
|
|
59
|
-
width: this.width,
|
|
60
|
-
height: this.height,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
this.complete = true;
|
|
64
|
-
|
|
65
|
-
var evt = {type: 'load', target: this};
|
|
66
|
-
this.dispatchEvent(evt);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
defineEventAttribute(GImage.prototype, 'onload');
|
|
74
|
-
defineEventAttribute(GImage.prototype, 'error');
|
|
75
|
-
|
|
76
|
-
export default GImage;
|
|
1
|
+
import Element from '@flyskywhy/react-native-browser-polyfill/src/DOM/Element';
|
|
2
|
+
import {defineEventAttribute} from 'event-target-shim';
|
|
3
|
+
|
|
4
|
+
// use srcs to [Call drawImage() in loop with only one GImage instance](https://github.com/flyskywhy/react-native-gcanvas/issues/41)
|
|
5
|
+
// just like what Web can do
|
|
6
|
+
let srcs = {};
|
|
7
|
+
|
|
8
|
+
let id = 0;
|
|
9
|
+
|
|
10
|
+
class GImage extends Element {
|
|
11
|
+
static GBridge = null;
|
|
12
|
+
|
|
13
|
+
constructor() {
|
|
14
|
+
super('img');
|
|
15
|
+
this._id = 0;
|
|
16
|
+
this.width = 0;
|
|
17
|
+
this.height = 0;
|
|
18
|
+
this._src = undefined;
|
|
19
|
+
this.complete = false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get src() {
|
|
23
|
+
return this._src;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
set src(value) {
|
|
27
|
+
if (value.startsWith('//')) {
|
|
28
|
+
value = 'http:' + value;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
this._src = value;
|
|
32
|
+
|
|
33
|
+
if (srcs[value]) {
|
|
34
|
+
this._id = srcs[value].id;
|
|
35
|
+
this.width = srcs[value].width;
|
|
36
|
+
this.height = srcs[value].height;
|
|
37
|
+
|
|
38
|
+
// in case another `new GImage()` set same src, so we also need `this.complete = true` here
|
|
39
|
+
this.complete = true;
|
|
40
|
+
|
|
41
|
+
var evt = {type: 'load', target: this};
|
|
42
|
+
this.dispatchEvent(evt);
|
|
43
|
+
} else {
|
|
44
|
+
// TODO: remove useless `0` arg in preloadImage of js and native
|
|
45
|
+
GImage.GBridge.preloadImage([this._src, 0], (data) => {
|
|
46
|
+
if (typeof data === 'string') {
|
|
47
|
+
data = JSON.parse(data);
|
|
48
|
+
}
|
|
49
|
+
if (data.error) {
|
|
50
|
+
var evt = {type: 'error', target: this, message: data.error};
|
|
51
|
+
this.dispatchEvent(evt);
|
|
52
|
+
} else {
|
|
53
|
+
id++;
|
|
54
|
+
this._id = id;
|
|
55
|
+
this.width = typeof data.width === 'number' ? data.width : 0;
|
|
56
|
+
this.height = typeof data.height === 'number' ? data.height : 0;
|
|
57
|
+
srcs[value] = {
|
|
58
|
+
id: this._id,
|
|
59
|
+
width: this.width,
|
|
60
|
+
height: this.height,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
this.complete = true;
|
|
64
|
+
|
|
65
|
+
var evt = {type: 'load', target: this};
|
|
66
|
+
this.dispatchEvent(evt);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
defineEventAttribute(GImage.prototype, 'onload');
|
|
74
|
+
defineEventAttribute(GImage.prototype, 'error');
|
|
75
|
+
|
|
76
|
+
export default GImage;
|
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
import GContext2D from '../context/2d/OffScreenRenderingContext';
|
|
2
|
-
import GContextWebGL from '../context/webgl/RenderingContext';
|
|
3
|
-
|
|
4
|
-
function sleepMs(ms) {
|
|
5
|
-
for (var start = new Date(); new Date() - start <= ms; ) {}
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default class GOffScreenCanvas {
|
|
9
|
-
static GBridge = null;
|
|
10
|
-
|
|
11
|
-
id = null;
|
|
12
|
-
_context = null;
|
|
13
|
-
|
|
14
|
-
_needRender = true;
|
|
15
|
-
|
|
16
|
-
constructor(id, {isAutoClearRectBeforePutImageData, devicePixelRatio, disableAutoSwap}) {
|
|
17
|
-
this.id = id;
|
|
18
|
-
this.className = 'GOffScreenCanvas';
|
|
19
|
-
|
|
20
|
-
this._isAutoClearRectBeforePutImageData = isAutoClearRectBeforePutImageData;
|
|
21
|
-
if (devicePixelRatio !== undefined) {
|
|
22
|
-
this._devicePixelRatio = parseInt(devicePixelRatio, 10);
|
|
23
|
-
}
|
|
24
|
-
this._disableAutoSwap = disableAutoSwap;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
getContext(type) {
|
|
28
|
-
if (type.match(/webgl/i)) {
|
|
29
|
-
this._context = new GContextWebGL(this);
|
|
30
|
-
this._context.componentId = this.id;
|
|
31
|
-
|
|
32
|
-
if (!this._disableAutoSwap) {
|
|
33
|
-
const render = () => {
|
|
34
|
-
if (this._needRender) {
|
|
35
|
-
this._context.flushJsCommands2CallNative();
|
|
36
|
-
this._needRender = false;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
setInterval(render, 16);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
GOffScreenCanvas.GBridge.callSetContextType(this.id, 1); // 0 for 2d; 1 for webgl
|
|
43
|
-
|
|
44
|
-
sleepMs(100);
|
|
45
|
-
if (this._devicePixelRatio > 0) {
|
|
46
|
-
GOffScreenCanvas.GBridge.callSetDevicePixelRatio(this.id, this._devicePixelRatio);
|
|
47
|
-
}
|
|
48
|
-
} else if (type.match(/2d/i)) {
|
|
49
|
-
if (this.context2d) {
|
|
50
|
-
this._context = this.context2d;
|
|
51
|
-
} else {
|
|
52
|
-
this.context2d = this._context = new GContext2D(this);
|
|
53
|
-
this._context.componentId = this.id;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
sleepMs(100);
|
|
57
|
-
if (this._devicePixelRatio > 0) {
|
|
58
|
-
GOffScreenCanvas.GBridge.callSetDevicePixelRatio(this.id, this._devicePixelRatio);
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
throw new Error('not supported context ' + type);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return this._context;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
get drawCommands() {
|
|
68
|
-
return this.context2d._drawCommands;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
get images() {
|
|
72
|
-
return this.context2d.images;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
1
|
+
import GContext2D from '../context/2d/OffScreenRenderingContext';
|
|
2
|
+
import GContextWebGL from '../context/webgl/RenderingContext';
|
|
3
|
+
|
|
4
|
+
function sleepMs(ms) {
|
|
5
|
+
for (var start = new Date(); new Date() - start <= ms; ) {}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default class GOffScreenCanvas {
|
|
9
|
+
static GBridge = null;
|
|
10
|
+
|
|
11
|
+
id = null;
|
|
12
|
+
_context = null;
|
|
13
|
+
|
|
14
|
+
_needRender = true;
|
|
15
|
+
|
|
16
|
+
constructor(id, {isAutoClearRectBeforePutImageData, devicePixelRatio, disableAutoSwap}) {
|
|
17
|
+
this.id = id;
|
|
18
|
+
this.className = 'GOffScreenCanvas';
|
|
19
|
+
|
|
20
|
+
this._isAutoClearRectBeforePutImageData = isAutoClearRectBeforePutImageData;
|
|
21
|
+
if (devicePixelRatio !== undefined) {
|
|
22
|
+
this._devicePixelRatio = parseInt(devicePixelRatio, 10);
|
|
23
|
+
}
|
|
24
|
+
this._disableAutoSwap = disableAutoSwap;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getContext(type) {
|
|
28
|
+
if (type.match(/webgl/i)) {
|
|
29
|
+
this._context = new GContextWebGL(this);
|
|
30
|
+
this._context.componentId = this.id;
|
|
31
|
+
|
|
32
|
+
if (!this._disableAutoSwap) {
|
|
33
|
+
const render = () => {
|
|
34
|
+
if (this._needRender) {
|
|
35
|
+
this._context.flushJsCommands2CallNative();
|
|
36
|
+
this._needRender = false;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
setInterval(render, 16);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
GOffScreenCanvas.GBridge.callSetContextType(this.id, 1); // 0 for 2d; 1 for webgl
|
|
43
|
+
|
|
44
|
+
sleepMs(100);
|
|
45
|
+
if (this._devicePixelRatio > 0) {
|
|
46
|
+
GOffScreenCanvas.GBridge.callSetDevicePixelRatio(this.id, this._devicePixelRatio);
|
|
47
|
+
}
|
|
48
|
+
} else if (type.match(/2d/i)) {
|
|
49
|
+
if (this.context2d) {
|
|
50
|
+
this._context = this.context2d;
|
|
51
|
+
} else {
|
|
52
|
+
this.context2d = this._context = new GContext2D(this);
|
|
53
|
+
this._context.componentId = this.id;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
sleepMs(100);
|
|
57
|
+
if (this._devicePixelRatio > 0) {
|
|
58
|
+
GOffScreenCanvas.GBridge.callSetDevicePixelRatio(this.id, this._devicePixelRatio);
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
throw new Error('not supported context ' + type);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return this._context;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
get drawCommands() {
|
|
68
|
+
return this.context2d._drawCommands;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
get images() {
|
|
72
|
+
return this.context2d.images;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import GCanvas from './env/canvas';
|
|
2
|
-
import GImage from './env/image';
|
|
3
|
-
|
|
4
|
-
import GWebGLRenderingContext from './context/webgl/RenderingContext';
|
|
5
|
-
import GContext2D from './context/2d/RenderingContext';
|
|
6
|
-
|
|
7
|
-
import GBridgeWeex from './bridge/weex';
|
|
8
|
-
import GBridgeReactNative from './bridge/react-native';
|
|
9
|
-
|
|
10
|
-
export let Image = GImage;
|
|
11
|
-
|
|
12
|
-
export let WeexBridge = GBridgeWeex;
|
|
13
|
-
export let ReactNativeBridge = GBridgeReactNative;
|
|
14
|
-
|
|
15
|
-
export function enable(
|
|
16
|
-
el,
|
|
17
|
-
{
|
|
18
|
-
bridge,
|
|
19
|
-
debug,
|
|
20
|
-
isAutoClearRectBeforePutImageData,
|
|
21
|
-
isResetGlViewportAfterSetWidthOrHeight,
|
|
22
|
-
devicePixelRatio,
|
|
23
|
-
disableAutoSwap,
|
|
24
|
-
disableComboCommands,
|
|
25
|
-
} = {},
|
|
26
|
-
) {
|
|
27
|
-
const GBridge = GImage.GBridge = GCanvas.GBridge = GWebGLRenderingContext.GBridge = GContext2D.GBridge = bridge;
|
|
28
|
-
|
|
1
|
+
import GCanvas from './env/canvas';
|
|
2
|
+
import GImage from './env/image';
|
|
3
|
+
|
|
4
|
+
import GWebGLRenderingContext from './context/webgl/RenderingContext';
|
|
5
|
+
import GContext2D from './context/2d/RenderingContext';
|
|
6
|
+
|
|
7
|
+
import GBridgeWeex from './bridge/weex';
|
|
8
|
+
import GBridgeReactNative from './bridge/react-native';
|
|
9
|
+
|
|
10
|
+
export let Image = GImage;
|
|
11
|
+
|
|
12
|
+
export let WeexBridge = GBridgeWeex;
|
|
13
|
+
export let ReactNativeBridge = GBridgeReactNative;
|
|
14
|
+
|
|
15
|
+
export function enable(
|
|
16
|
+
el,
|
|
17
|
+
{
|
|
18
|
+
bridge,
|
|
19
|
+
debug,
|
|
20
|
+
isAutoClearRectBeforePutImageData,
|
|
21
|
+
isResetGlViewportAfterSetWidthOrHeight,
|
|
22
|
+
devicePixelRatio,
|
|
23
|
+
disableAutoSwap,
|
|
24
|
+
disableComboCommands,
|
|
25
|
+
} = {},
|
|
26
|
+
) {
|
|
27
|
+
const GBridge = GImage.GBridge = GCanvas.GBridge = GWebGLRenderingContext.GBridge = GContext2D.GBridge = bridge;
|
|
28
|
+
|
|
29
29
|
GBridge.callEnable(el.ref, [
|
|
30
30
|
0, // renderMode: 0--RENDERMODE_WHEN_DIRTY, 1--RENDERMODE_CONTINUOUSLY
|
|
31
31
|
-1, // hybridLayerType: 0--LAYER_TYPE_NONE 1--LAYER_TYPE_SOFTWARE 2--LAYER_TYPE_HARDWARE
|
|
@@ -35,31 +35,31 @@ export function enable(
|
|
|
35
35
|
0xffffffff, // clearColor: opaque white ARGB
|
|
36
36
|
0, // sameLevel: newCanvasMode = true && true => GCanvasView and Webview is same level
|
|
37
37
|
]);
|
|
38
|
-
|
|
39
|
-
if (debug === true) {
|
|
40
|
-
GBridge.callEnableDebug();
|
|
41
|
-
}
|
|
42
|
-
if (disableComboCommands) {
|
|
43
|
-
GBridge.callEnableDisableCombo();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
var canvas = new GCanvas(el.ref, {
|
|
47
|
-
isAutoClearRectBeforePutImageData,
|
|
48
|
-
isResetGlViewportAfterSetWidthOrHeight,
|
|
49
|
-
devicePixelRatio,
|
|
50
|
-
disableAutoSwap,
|
|
51
|
-
style: el.style,
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
return canvas;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function disable(canvas) {
|
|
58
|
-
canvas.disabled = true;
|
|
59
|
-
if (canvas.webglInterval) {
|
|
60
|
-
clearInterval(canvas.webglInterval);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const ref = canvas.id;
|
|
64
|
-
GCanvas.GBridge.callDisable(ref);
|
|
65
|
-
}
|
|
38
|
+
|
|
39
|
+
if (debug === true) {
|
|
40
|
+
GBridge.callEnableDebug();
|
|
41
|
+
}
|
|
42
|
+
if (disableComboCommands) {
|
|
43
|
+
GBridge.callEnableDisableCombo();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
var canvas = new GCanvas(el.ref, {
|
|
47
|
+
isAutoClearRectBeforePutImageData,
|
|
48
|
+
isResetGlViewportAfterSetWidthOrHeight,
|
|
49
|
+
devicePixelRatio,
|
|
50
|
+
disableAutoSwap,
|
|
51
|
+
style: el.style,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
return canvas;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function disable(canvas) {
|
|
58
|
+
canvas.disabled = true;
|
|
59
|
+
if (canvas.webglInterval) {
|
|
60
|
+
clearInterval(canvas.webglInterval);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const ref = canvas.id;
|
|
64
|
+
GCanvas.GBridge.callDisable(ref);
|
|
65
|
+
}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
2
|
-
import type {
|
|
3
|
-
Float,
|
|
4
|
-
WithDefault,
|
|
5
|
-
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
6
|
-
import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* GCanvasView Fabric 组件 Spec(鸿蒙适配)。
|
|
10
|
-
*
|
|
11
|
-
* 对齐原 Android GReactViewManager(GCanvasView,@ReactProp isEnableFboMsaa)
|
|
12
|
-
* 与 iOS RCTGCanvasViewManager(isOffscreen)。组件内嵌 XComponent(SURFACE)
|
|
13
|
-
* 获取 OHNativeWindow 并交 C++ GCanvas 引擎做 GL 渲染。
|
|
14
|
-
*
|
|
15
|
-
* 事件:
|
|
16
|
-
* - onChange:对应 JS 侧 _onIsReady 的 nativeEvent.value(与 Android topChange 一致),
|
|
17
|
-
* 复刻 Android RCTEventEmitter topChange。
|
|
18
|
-
* - onIsReady:GL 表面就绪/销毁时由 OH_NativeXComponent OnSurfaceCreated/Destroyed
|
|
19
|
-
* 回调经 EventEmitter 上抛。
|
|
20
|
-
*
|
|
21
|
-
* codegen 类型约束:数值必须用 Float/Int32/Double;事件用 DirectEventHandler;
|
|
1
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
2
|
+
import type {
|
|
3
|
+
Float,
|
|
4
|
+
WithDefault,
|
|
5
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
6
|
+
import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* GCanvasView Fabric 组件 Spec(鸿蒙适配)。
|
|
10
|
+
*
|
|
11
|
+
* 对齐原 Android GReactViewManager(GCanvasView,@ReactProp isEnableFboMsaa)
|
|
12
|
+
* 与 iOS RCTGCanvasViewManager(isOffscreen)。组件内嵌 XComponent(SURFACE)
|
|
13
|
+
* 获取 OHNativeWindow 并交 C++ GCanvas 引擎做 GL 渲染。
|
|
14
|
+
*
|
|
15
|
+
* 事件:
|
|
16
|
+
* - onChange:对应 JS 侧 _onIsReady 的 nativeEvent.value(与 Android topChange 一致),
|
|
17
|
+
* 复刻 Android RCTEventEmitter topChange。
|
|
18
|
+
* - onIsReady:GL 表面就绪/销毁时由 OH_NativeXComponent OnSurfaceCreated/Destroyed
|
|
19
|
+
* 回调经 EventEmitter 上抛。
|
|
20
|
+
*
|
|
21
|
+
* codegen 类型约束:数值必须用 Float/Int32/Double;事件用 DirectEventHandler;
|
|
22
22
|
* 布尔用 WithDefault<boolean, ...>。禁止裸 number。
|
|
23
|
-
*/
|
|
24
|
-
interface GCanvasViewNativeComponentProps extends ViewProps {
|
|
25
|
-
/** 是否启用 FBO 多重采样抗锯齿(原 Android ViewManager 唯一 @ReactProp)。 */
|
|
23
|
+
*/
|
|
24
|
+
interface GCanvasViewNativeComponentProps extends ViewProps {
|
|
25
|
+
/** 是否启用 FBO 多重采样抗锯齿(原 Android ViewManager 唯一 @ReactProp)。 */
|
|
26
26
|
isEnableFboMsaa?: WithDefault<boolean, true>;
|
|
27
|
-
/** 是否离屏渲染(原 iOS RCTViewManager prop)。 */
|
|
28
|
-
isOffscreen?: WithDefault<boolean, false>;
|
|
29
|
-
/** 设备像素比,透传至 enable();undefined 时 JS 侧用 PixelRatio.get()。 */
|
|
30
|
-
devicePixelRatio?: WithDefault<Float, 1>;
|
|
31
|
-
/** 仅 webgl;控制自动 swap。 */
|
|
32
|
-
disableAutoSwap?: WithDefault<boolean, false>;
|
|
33
|
-
/** GL 就绪/命令执行结果事件(对齐 Android topChange)。 */
|
|
34
|
-
onChange?: DirectEventHandler<OnChangeEvent>;
|
|
35
|
-
/** GL 表面就绪事件。 */
|
|
36
|
-
onIsReady?: DirectEventHandler<OnIsReadyEvent>;
|
|
37
|
-
}
|
|
38
|
-
|
|
27
|
+
/** 是否离屏渲染(原 iOS RCTViewManager prop)。 */
|
|
28
|
+
isOffscreen?: WithDefault<boolean, false>;
|
|
29
|
+
/** 设备像素比,透传至 enable();undefined 时 JS 侧用 PixelRatio.get()。 */
|
|
30
|
+
devicePixelRatio?: WithDefault<Float, 1>;
|
|
31
|
+
/** 仅 webgl;控制自动 swap。 */
|
|
32
|
+
disableAutoSwap?: WithDefault<boolean, false>;
|
|
33
|
+
/** GL 就绪/命令执行结果事件(对齐 Android topChange)。 */
|
|
34
|
+
onChange?: DirectEventHandler<OnChangeEvent>;
|
|
35
|
+
/** GL 表面就绪事件。 */
|
|
36
|
+
onIsReady?: DirectEventHandler<OnIsReadyEvent>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
39
|
interface OnChangeEvent {
|
|
40
40
|
value: WithDefault<boolean, false>;
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
interface OnIsReadyEvent {
|
|
44
|
-
isReady: WithDefault<boolean, false>;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export default codegenNativeComponent<GCanvasViewNativeComponentProps>('GCanvasView');
|
|
42
|
+
|
|
43
|
+
interface OnIsReadyEvent {
|
|
44
|
+
isReady: WithDefault<boolean, false>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default codegenNativeComponent<GCanvasViewNativeComponentProps>('GCanvasView');
|