@predy-js/render-interface 0.1.62-beta.4 → 0.1.62

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/dist/statistic.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Name: @predy-js/render-interface
3
3
  * Description: undefined
4
4
  * Author: undefined
5
- * Version: v0.1.62-beta.4
5
+ * Version: v0.1.62
6
6
  */
7
7
 
8
8
  // https://github.com/greggman/webgl-memory/blob/main/src/texture-utils.js
@@ -0,0 +1,18 @@
1
+ export declare abstract class AndGLContext {
2
+ abstract isEnabled(param: GLenum): boolean;
3
+ /**
4
+ * 获取gl的参数, 返回值为4个int 数组
5
+ * @param param
6
+ */
7
+ abstract getParameter_i4(param: GLenum): [number, number, number, number];
8
+ /**
9
+ * 获取gl的参数, 返回值为4个bool 数组
10
+ * @param param
11
+ */
12
+ abstract getParameter_b4(param: GLenum): [boolean, boolean, boolean, boolean];
13
+ /**
14
+ * 获取gl的参数, 返回值为1个int
15
+ * @param param
16
+ */
17
+ abstract getParameter_i1(param: GLenum): number;
18
+ }
@@ -10,6 +10,7 @@ import type { RenderFrameInternal, RenderFrameInternalOptions } from './RenderFr
10
10
  import type { GPUCapability } from '../GPUCapability';
11
11
  import type { TextureInternal, TextureInternalConstructOptions } from './TextureInternal';
12
12
  import type { ImageBitmapCallback, ImageBitmapConstructor } from './ImageBitmapInternal';
13
+ import type { AndGLContext } from './AndGLContext';
13
14
  /**
14
15
  * renderer 内部创建的对象,用来统计信息,排查资源泄漏的问题
15
16
  */
@@ -23,6 +24,11 @@ export interface InternalResInfo {
23
24
  renderPass: number;
24
25
  frame: number;
25
26
  }
27
+ export interface RendererInternalCompleteInfo {
28
+ gpuTime?: number;
29
+ frame: number;
30
+ cpuTime?: number;
31
+ }
26
32
  export declare abstract class RendererInternal implements ResourceInternal {
27
33
  readonly isDestroyed: boolean;
28
34
  readonly platform: ResourcePlatform;
@@ -30,6 +36,7 @@ export declare abstract class RendererInternal implements ResourceInternal {
30
36
  readonly shaderLibrary: ShaderLibraryInternal;
31
37
  readonly width: number;
32
38
  readonly height: number;
39
+ readonly gl?: AndGLContext;
33
40
  abstract destroy(): void;
34
41
  /**
35
42
  * 需要进行重新渲染
@@ -44,8 +51,13 @@ export declare abstract class RendererInternal implements ResourceInternal {
44
51
  abstract createRenderFrame(options: RenderFrameInternalOptions): RenderFrameInternal;
45
52
  abstract createTexture(options: TextureInternalConstructOptions): TextureInternal;
46
53
  abstract getResourceInfo(): InternalResInfo;
47
- abstract requestAnimationFrame(callback: (timestamp: number) => void): number;
54
+ abstract requestAnimationFrame(callback: FrameRequestCallback): number;
48
55
  abstract cancelAnimationFrame(id: number): void;
56
+ /**
57
+ * 下一帧渲染完成后的回调,在调用removeRenderCompleteCallback前,不需要重复注册
58
+ */
59
+ abstract addRenderCompleteCallback(callback: (info: RendererInternalCompleteInfo) => void): number;
60
+ abstract removeRenderCompleteCallback(id: number): void;
49
61
  /**
50
62
  * 获取错误信息,目前支持最大获取5条,
51
63
  * 每次调用此函数后,清空错误队列
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@predy-js/render-interface",
3
- "version": "0.1.62-beta.4",
3
+ "version": "0.1.62",
4
4
  "license": "MIT",
5
5
  "module": "./dist/index.mjs",
6
6
  "main": "./dist/index.js",
@@ -0,0 +1,22 @@
1
+
2
+ export abstract class AndGLContext {
3
+ abstract isEnabled (param: GLenum): boolean;
4
+
5
+ /**
6
+ * 获取gl的参数, 返回值为4个int 数组
7
+ * @param param
8
+ */
9
+ abstract getParameter_i4 (param: GLenum): [number, number, number, number];
10
+
11
+ /**
12
+ * 获取gl的参数, 返回值为4个bool 数组
13
+ * @param param
14
+ */
15
+ abstract getParameter_b4 (param: GLenum): [boolean, boolean, boolean, boolean];
16
+
17
+ /**
18
+ * 获取gl的参数, 返回值为1个int
19
+ * @param param
20
+ */
21
+ abstract getParameter_i1 (param: GLenum): number;
22
+ }
@@ -10,6 +10,7 @@ import type { RenderFrameInternal, RenderFrameInternalOptions } from './RenderFr
10
10
  import type { GPUCapability } from '../GPUCapability';
11
11
  import type { TextureInternal, TextureInternalConstructOptions } from './TextureInternal';
12
12
  import type { ImageBitmapCallback, ImageBitmapConstructor } from './ImageBitmapInternal';
13
+ import type { AndGLContext } from './AndGLContext';
13
14
 
14
15
  /**
15
16
  * renderer 内部创建的对象,用来统计信息,排查资源泄漏的问题
@@ -25,6 +26,15 @@ export interface InternalResInfo {
25
26
  frame: number,
26
27
  }
27
28
 
29
+ export interface RendererInternalCompleteInfo {
30
+ //gpu耗时,单位ms
31
+ gpuTime?: number,
32
+ //渲染了多少个frame
33
+ frame: number,
34
+ //cpu耗时
35
+ cpuTime?: number,
36
+ }
37
+
28
38
  export abstract class RendererInternal implements ResourceInternal {
29
39
  readonly isDestroyed: boolean;
30
40
  readonly platform: ResourcePlatform;
@@ -32,6 +42,7 @@ export abstract class RendererInternal implements ResourceInternal {
32
42
  readonly shaderLibrary: ShaderLibraryInternal;
33
43
  readonly width: number;
34
44
  readonly height: number;
45
+ readonly gl?: AndGLContext;
35
46
 
36
47
  abstract destroy (): void;
37
48
 
@@ -58,10 +69,16 @@ export abstract class RendererInternal implements ResourceInternal {
58
69
 
59
70
  abstract getResourceInfo (): InternalResInfo;
60
71
 
61
- abstract requestAnimationFrame (callback: (timestamp: number) => void): number;
72
+ abstract requestAnimationFrame (callback: FrameRequestCallback): number;
62
73
 
63
74
  abstract cancelAnimationFrame (id: number): void;
64
75
 
76
+ /**
77
+ * 下一帧渲染完成后的回调,在调用removeRenderCompleteCallback前,不需要重复注册
78
+ */
79
+ abstract addRenderCompleteCallback (callback: (info: RendererInternalCompleteInfo) => void): number;
80
+
81
+ abstract removeRenderCompleteCallback (id: number): void;
65
82
  /**
66
83
  * 获取错误信息,目前支持最大获取5条,
67
84
  * 每次调用此函数后,清空错误队列