@predy-js/render-interface 0.1.65 → 0.1.66-beta.10

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.65
5
+ * Version: v0.1.66-beta.10
6
6
  */
7
7
 
8
8
  // https://github.com/greggman/webgl-memory/blob/main/src/texture-utils.js
@@ -80,45 +80,26 @@ export declare class Texture implements IGPUResource {
80
80
  assignRenderer(renderer: GPURenderer): Texture;
81
81
  }
82
82
  type ImageSource = ImageBitmap | HTMLImageElement | HTMLCanvasElement;
83
+ export interface ImageData {
84
+ data: TypedArray;
85
+ width: number;
86
+ height: number;
87
+ }
83
88
  export type TextureSourceCubeData = [
84
- TEXTURE_CUBE_MAP_POSITIVE_X: ImageSource | {
85
- data: TypedArray;
86
- width: number;
87
- height: number;
88
- },
89
- TEXTURE_CUBE_MAP_NEGATIVE_X: ImageSource | {
90
- data: TypedArray;
91
- width: number;
92
- height: number;
93
- },
94
- TEXTURE_CUBE_MAP_POSITIVE_Y: ImageSource | {
95
- data: TypedArray;
96
- width: number;
97
- height: number;
98
- },
99
- TEXTURE_CUBE_MAP_NEGATIVE_Y: ImageSource | {
100
- data: TypedArray;
101
- width: number;
102
- height: number;
103
- },
104
- TEXTURE_CUBE_MAP_POSITIVE_Z: ImageSource | {
105
- data: TypedArray;
106
- width: number;
107
- height: number;
108
- },
109
- TEXTURE_CUBE_MAP_NEGATIVE_Z: ImageSource | {
110
- data: TypedArray;
111
- width: number;
112
- height: number;
113
- }
89
+ TEXTURE_CUBE_MAP_POSITIVE_X: ImageSource | ImageData,
90
+ TEXTURE_CUBE_MAP_NEGATIVE_X: ImageSource | ImageData,
91
+ TEXTURE_CUBE_MAP_POSITIVE_Y: ImageSource | ImageData,
92
+ TEXTURE_CUBE_MAP_NEGATIVE_Y: ImageSource | ImageData,
93
+ TEXTURE_CUBE_MAP_POSITIVE_Z: ImageSource | ImageData,
94
+ TEXTURE_CUBE_MAP_NEGATIVE_Z: ImageSource | ImageData
114
95
  ];
115
96
  export type TextureSourceOptions = Texture2DSourceOptions | TextureCubeSourceOptions;
116
97
  export interface Texture2DSourceOptionsNone extends TextureOptionsBase {
117
- sourceType?: TextureSourceType.none;
98
+ sourceType: TextureSourceType.none;
118
99
  target?: GLenum;
119
100
  }
120
101
  export interface Texture2DSourceOptionsImage extends TextureOptionsBase {
121
- sourceType?: TextureSourceType.image;
102
+ sourceType: TextureSourceType.image;
122
103
  image: ImageSource;
123
104
  target?: WebGLRenderingContext['TEXTURE_2D'];
124
105
  generateMipmap?: boolean;
@@ -132,7 +113,7 @@ export interface Texture2DSourceOptionsFrameBuffer extends TextureOptionsBase {
132
113
  target?: WebGLRenderingContext['TEXTURE_2D'];
133
114
  }
134
115
  export interface Texture2DSourceOptionsData extends TextureOptionsBase {
135
- sourceType?: TextureSourceType.data;
116
+ sourceType: TextureSourceType.data;
136
117
  data: {
137
118
  data: TypedArray;
138
119
  width: number;
@@ -141,13 +122,13 @@ export interface Texture2DSourceOptionsData extends TextureOptionsBase {
141
122
  target?: WebGLRenderingContext['TEXTURE_2D'];
142
123
  }
143
124
  export interface Texture2DSourceOptionsVideo extends TextureOptionsBase {
144
- sourceType?: TextureSourceType.video;
125
+ sourceType: TextureSourceType.video;
145
126
  video: HTMLVideoElement;
146
127
  target?: WebGLRenderingContext['TEXTURE_2D'];
147
128
  generateMipmap?: boolean;
148
129
  }
149
130
  export interface Texture2DSourceOptionsImageMipmaps extends TextureOptionsBase {
150
- sourceType?: TextureSourceType.mipmaps;
131
+ sourceType: TextureSourceType.mipmaps;
151
132
  mipmaps: Array<ImageSource | {
152
133
  data: TypedArray;
153
134
  width: number;
@@ -156,7 +137,7 @@ export interface Texture2DSourceOptionsImageMipmaps extends TextureOptionsBase {
156
137
  target?: WebGLRenderingContext['TEXTURE_2D'];
157
138
  }
158
139
  export interface Texture2DSourceOptionsCompressed extends TextureOptionsBase {
159
- sourceType?: TextureSourceType.compressed;
140
+ sourceType: TextureSourceType.compressed;
160
141
  mipmaps: Array<{
161
142
  data: TypedArray;
162
143
  width: number;
@@ -171,7 +152,7 @@ export interface TextureCubeSourceOptionsImage extends TextureOptionsBase {
171
152
  generateMipmap?: boolean;
172
153
  }
173
154
  export interface TextureCubeSourceOptionsImageMipmaps extends TextureOptionsBase {
174
- sourceType?: TextureSourceType.mipmaps;
155
+ sourceType: TextureSourceType.mipmaps;
175
156
  mipmaps: Array<TextureSourceCubeData>;
176
157
  target: WebGLRenderingContext['TEXTURE_CUBE_MAP'];
177
158
  }
@@ -203,7 +184,7 @@ export interface TextureFormatOptions {
203
184
  type?: GLenum;
204
185
  }
205
186
  export interface TextureOptionsBase extends TextureConfigOptions, TextureFormatOptions {
206
- sourceType?: TextureSourceType;
187
+ sourceType: TextureSourceType;
207
188
  }
208
189
  export type TextureCubeSourceOptions = TextureCubeSourceOptionsImage | TextureCubeSourceOptionsImageMipmaps;
209
190
  export type Texture2DSourceOptions = Texture2DSourceOptionsImage | Texture2DSourceOptionsData | Texture2DSourceOptionsVideo | Texture2DSourceOptionsImageMipmaps | Texture2DSourceOptionsCompressed | Texture2DSourceOptionsFrameBuffer;
@@ -1,4 +1,14 @@
1
1
  import type { MaterialInternal } from './MaterialInternal';
2
+ import type { vec2 } from '../type';
3
+ import type { TextureInternal } from './TextureInternal';
4
+ import type { RenderPassInternal } from './RenderPassInternal';
5
+ export interface TextureGpuInfo {
6
+ format: number;
7
+ type: number;
8
+ target: number;
9
+ mipmaps: vec2[];
10
+ handle: number;
11
+ }
2
12
  export declare abstract class AndGLContext {
3
13
  abstract isEnabled(param: GLenum): boolean;
4
14
  /**
@@ -24,4 +34,7 @@ export declare abstract class AndGLContext {
24
34
  * 为了Android 测试,会主动调用设置状态到GPU, IOS 暂不调用
25
35
  */
26
36
  abstract setupStates(mtl: MaterialInternal): void;
37
+ abstract getTextureGpuInfo(texture: TextureInternal): TextureGpuInfo;
38
+ abstract getTexParameter(target: GLenum, pname: GLenum): number;
39
+ abstract bindRenderPass(renderPass: RenderPassInternal): void;
27
40
  }
@@ -1,6 +1,4 @@
1
1
  export interface ImageBitmapConstructor {
2
- resizeWidth?: number;
3
- resizeHeight?: number;
4
2
  }
5
3
  export declare abstract class ImageBitmapInternal {
6
4
  /**
@@ -1,8 +1,6 @@
1
1
  import type { ImageBitmapCallback, ImageBitmapConstructor } from './ImageBitmapInternal';
2
+ import type { TypedArray } from '../type';
2
3
  export declare abstract class PredyNativeInternal {
3
- abstract createImageBitmap(data: ArrayBuffer | string, //图片文件的数据
4
+ abstract createImageBitmap(data: TypedArray | string, //图片文件的数据
4
5
  options: ImageBitmapConstructor, callback: ImageBitmapCallback): void;
5
6
  }
6
- declare global {
7
- let predyNative: PredyNativeInternal;
8
- }
@@ -11,6 +11,7 @@ import type { GPUCapability } from '../GPUCapability';
11
11
  import type { TextureInternal, TextureInternalConstructOptions } from './TextureInternal';
12
12
  import type { ImageBitmapCallback, ImageBitmapConstructor } from './ImageBitmapInternal';
13
13
  import type { AndGLContext } from './AndGLContext';
14
+ import type { TypedArray } from '../type';
14
15
  /**
15
16
  * renderer 内部创建的对象,用来统计信息,排查资源泄漏的问题
16
17
  */
@@ -67,6 +68,6 @@ export declare abstract class RendererInternal implements ResourceInternal {
67
68
  */
68
69
  abstract getErrors(): string[];
69
70
  abstract resize(width: number, height: number): void;
70
- abstract createImageBitmap(data: ArrayBuffer | string, //图片文件的数据
71
+ abstract createImageBitmap(data: TypedArray | string, //图片文件的数据
71
72
  options: ImageBitmapConstructor, callback: ImageBitmapCallback): void;
72
73
  }
@@ -1,18 +1,15 @@
1
- import type { TextureFormatOptions, TextureConfigOptionsBase } from '../Texture';
1
+ import type { TextureFormatOptions, TextureConfigOptionsBase, ImageData } from '../Texture';
2
2
  import type { ResourceInternal } from './ResourceInternal';
3
- import type { TypedArray } from '../type';
4
3
  import type { ImageBitmapInternal } from './ImageBitmapInternal';
5
4
  export interface TextureInternalOptions extends TextureFormatOptions, Omit<TextureConfigOptionsBase, 'keepImageSource'> {
6
5
  target: WebGLRenderingContext['TEXTURE_CUBE_MAP'] | WebGLRenderingContext['TEXTURE_2D'];
7
- noMipmap?: boolean;
6
+ mipmapCount?: number;
8
7
  }
9
8
  export interface TextureInternalConstructOptions extends TextureInternalOptions {
10
9
  width: number;
11
10
  height: number;
12
- image?: ImageBitmapInternal;
13
- cubeImages?: Array<TextureInternalCubeImages>;
14
11
  }
15
- export type TextureInternalCubeImages<T extends ImageBitmapInternal | TypedArray = ImageBitmapInternal> = [
12
+ export type TextureInternalCubeImages<T extends ImageBitmapInternal | ImageData = ImageBitmapInternal> = [
16
13
  positiveX: T,
17
14
  nagtiveX: T,
18
15
  positiveY: T,
@@ -32,7 +29,7 @@ export declare abstract class TextureInternal implements ResourceInternal {
32
29
  /**
33
30
  * 上传cubeImage解码后的数据
34
31
  */
35
- abstract updateCubeImagesData(images: TextureInternalCubeImages<TypedArray>, mipmapLevel?: number): void;
32
+ abstract updateCubeImagesData(images: TextureInternalCubeImages<ImageData>, mipmapLevel?: number): void;
36
33
  /**
37
34
  * 上传cubeImage
38
35
  */
@@ -40,11 +37,11 @@ export declare abstract class TextureInternal implements ResourceInternal {
40
37
  /**
41
38
  * 上传整张解码后图片数据,数据尺寸必须和Texture尺寸定义相同
42
39
  */
43
- abstract update2DImageData(data: TypedArray, mipmapLevel?: number): void;
40
+ abstract update2DImageData(data: ImageData, mipmapLevel?: number): void;
44
41
  /**
45
42
  * 上传压缩纹理数据
46
43
  */
47
- abstract update2DCompressedImage(data: TypedArray, mipmapLevel?: number): void;
44
+ abstract update2DCompressedImage(data: ImageData, mipmapLevel?: number): void;
48
45
  /**
49
46
  * imageBitmap的尺寸也必须和Texture相同
50
47
  * @param image
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@predy-js/render-interface",
3
- "version": "0.1.65",
3
+ "version": "0.1.66-beta.10",
4
4
  "license": "MIT",
5
5
  "module": "./dist/index.mjs",
6
6
  "main": "./dist/index.js",
package/types/Texture.ts CHANGED
@@ -112,13 +112,19 @@ export declare class Texture implements IGPUResource {
112
112
 
113
113
  type ImageSource = ImageBitmap | HTMLImageElement | HTMLCanvasElement;
114
114
 
115
+ export interface ImageData {
116
+ data: TypedArray,
117
+ width: number,
118
+ height: number,
119
+ }
120
+
115
121
  export type TextureSourceCubeData = [
116
- TEXTURE_CUBE_MAP_POSITIVE_X: ImageSource | { data: TypedArray, width: number, height: number },
117
- TEXTURE_CUBE_MAP_NEGATIVE_X: ImageSource | { data: TypedArray, width: number, height: number },
118
- TEXTURE_CUBE_MAP_POSITIVE_Y: ImageSource | { data: TypedArray, width: number, height: number },
119
- TEXTURE_CUBE_MAP_NEGATIVE_Y: ImageSource | { data: TypedArray, width: number, height: number },
120
- TEXTURE_CUBE_MAP_POSITIVE_Z: ImageSource | { data: TypedArray, width: number, height: number },
121
- TEXTURE_CUBE_MAP_NEGATIVE_Z: ImageSource | { data: TypedArray, width: number, height: number }
122
+ TEXTURE_CUBE_MAP_POSITIVE_X: ImageSource | ImageData,
123
+ TEXTURE_CUBE_MAP_NEGATIVE_X: ImageSource | ImageData,
124
+ TEXTURE_CUBE_MAP_POSITIVE_Y: ImageSource | ImageData,
125
+ TEXTURE_CUBE_MAP_NEGATIVE_Y: ImageSource | ImageData,
126
+ TEXTURE_CUBE_MAP_POSITIVE_Z: ImageSource | ImageData,
127
+ TEXTURE_CUBE_MAP_NEGATIVE_Z: ImageSource | ImageData
122
128
  ];
123
129
 
124
130
  // 为减少内存消耗,除了video之外,其余的数据内容会在texture生成后被置为undefined
@@ -128,12 +134,12 @@ export type TextureSourceCubeData = [
128
134
  export type TextureSourceOptions = Texture2DSourceOptions | TextureCubeSourceOptions;
129
135
 
130
136
  export interface Texture2DSourceOptionsNone extends TextureOptionsBase {
131
- sourceType?: TextureSourceType.none,
137
+ sourceType: TextureSourceType.none,
132
138
  target?: GLenum,
133
139
  }
134
140
 
135
141
  export interface Texture2DSourceOptionsImage extends TextureOptionsBase {
136
- sourceType?: TextureSourceType.image,
142
+ sourceType: TextureSourceType.image,
137
143
  image: ImageSource,
138
144
  target?: WebGLRenderingContext['TEXTURE_2D'],
139
145
  generateMipmap?: boolean,
@@ -146,26 +152,26 @@ export interface Texture2DSourceOptionsFrameBuffer extends TextureOptionsBase {
146
152
  }
147
153
 
148
154
  export interface Texture2DSourceOptionsData extends TextureOptionsBase {
149
- sourceType?: TextureSourceType.data,
155
+ sourceType: TextureSourceType.data,
150
156
  data: { data: TypedArray, width: number, height: number },
151
157
  target?: WebGLRenderingContext['TEXTURE_2D'],
152
158
  }
153
159
 
154
160
  export interface Texture2DSourceOptionsVideo extends TextureOptionsBase {
155
- sourceType?: TextureSourceType.video,
161
+ sourceType: TextureSourceType.video,
156
162
  video: HTMLVideoElement,
157
163
  target?: WebGLRenderingContext['TEXTURE_2D'],
158
164
  generateMipmap?: boolean,
159
165
  }
160
166
 
161
167
  export interface Texture2DSourceOptionsImageMipmaps extends TextureOptionsBase {
162
- sourceType?: TextureSourceType.mipmaps,
168
+ sourceType: TextureSourceType.mipmaps,
163
169
  mipmaps: Array<ImageSource | { data: TypedArray, width: number, height: number }>,
164
170
  target?: WebGLRenderingContext['TEXTURE_2D'],
165
171
  }
166
172
 
167
173
  export interface Texture2DSourceOptionsCompressed extends TextureOptionsBase {
168
- sourceType?: TextureSourceType.compressed,
174
+ sourceType: TextureSourceType.compressed,
169
175
  mipmaps: Array<{ data: TypedArray, width: number, height: number }>,
170
176
  target?: WebGLRenderingContext['TEXTURE_2D'],
171
177
  }
@@ -178,7 +184,7 @@ export interface TextureCubeSourceOptionsImage extends TextureOptionsBase {
178
184
  }
179
185
 
180
186
  export interface TextureCubeSourceOptionsImageMipmaps extends TextureOptionsBase {
181
- sourceType?: TextureSourceType.mipmaps,
187
+ sourceType: TextureSourceType.mipmaps,
182
188
  mipmaps: Array<TextureSourceCubeData>,
183
189
  target: WebGLRenderingContext['TEXTURE_CUBE_MAP'],
184
190
  }
@@ -216,7 +222,7 @@ export interface TextureFormatOptions {
216
222
  }
217
223
 
218
224
  export interface TextureOptionsBase extends TextureConfigOptions, TextureFormatOptions {
219
- sourceType?: TextureSourceType,
225
+ sourceType: TextureSourceType,
220
226
  }
221
227
 
222
228
  export type TextureCubeSourceOptions = TextureCubeSourceOptionsImage | TextureCubeSourceOptionsImageMipmaps;
@@ -1,4 +1,15 @@
1
1
  import type { MaterialInternal } from './MaterialInternal';
2
+ import type { vec2 } from '../type';
3
+ import type { TextureInternal } from './TextureInternal';
4
+ import type { RenderPassInternal } from './RenderPassInternal';
5
+
6
+ export interface TextureGpuInfo {
7
+ format: number,
8
+ type: number,
9
+ target: number,
10
+ mipmaps: vec2[],
11
+ handle: number,
12
+ }
2
13
 
3
14
  export abstract class AndGLContext {
4
15
  abstract isEnabled (param: GLenum): boolean;
@@ -31,4 +42,10 @@ export abstract class AndGLContext {
31
42
  * 为了Android 测试,会主动调用设置状态到GPU, IOS 暂不调用
32
43
  */
33
44
  abstract setupStates (mtl: MaterialInternal): void;
45
+
46
+ abstract getTextureGpuInfo (texture: TextureInternal): TextureGpuInfo;
47
+
48
+ abstract getTexParameter (target: GLenum, pname: GLenum): number;
49
+
50
+ abstract bindRenderPass (renderPass: RenderPassInternal): void;
34
51
  }
@@ -1,6 +1,4 @@
1
1
  export interface ImageBitmapConstructor {
2
- resizeWidth?: number,
3
- resizeHeight?: number,
4
2
  }
5
3
 
6
4
  export abstract class ImageBitmapInternal {
@@ -1,10 +1,7 @@
1
1
  import type { ImageBitmapCallback, ImageBitmapConstructor } from './ImageBitmapInternal';
2
+ import type { TypedArray } from '../type';
2
3
 
3
4
  export declare abstract class PredyNativeInternal {
4
- abstract createImageBitmap (data: ArrayBuffer | string, //图片文件的数据
5
+ abstract createImageBitmap (data: TypedArray | string, //图片文件的数据
5
6
  options: ImageBitmapConstructor, callback: ImageBitmapCallback): void;
6
7
  }
7
- // 给全局global 添加 predyNative: PredyNativeInternal
8
- declare global {
9
- let predyNative: PredyNativeInternal;
10
- }
@@ -11,6 +11,7 @@ import type { GPUCapability } from '../GPUCapability';
11
11
  import type { TextureInternal, TextureInternalConstructOptions } from './TextureInternal';
12
12
  import type { ImageBitmapCallback, ImageBitmapConstructor } from './ImageBitmapInternal';
13
13
  import type { AndGLContext } from './AndGLContext';
14
+ import type { TypedArray } from '../type';
14
15
 
15
16
  /**
16
17
  * renderer 内部创建的对象,用来统计信息,排查资源泄漏的问题
@@ -91,7 +92,7 @@ export abstract class RendererInternal implements ResourceInternal {
91
92
  abstract resize (width: number, height: number): void;
92
93
 
93
94
  abstract createImageBitmap (
94
- data: ArrayBuffer | string, //图片文件的数据
95
+ data: TypedArray | string, //图片文件的数据
95
96
  options: ImageBitmapConstructor,
96
97
  callback: ImageBitmapCallback
97
98
  ): void;
@@ -1,22 +1,18 @@
1
- import type { TextureFormatOptions, TextureConfigOptionsBase } from '../Texture';
1
+ import type { TextureFormatOptions, TextureConfigOptionsBase, ImageData } from '../Texture';
2
2
  import type { ResourceInternal } from './ResourceInternal';
3
- import type { TypedArray } from '../type';
4
3
  import type { ImageBitmapInternal } from './ImageBitmapInternal';
5
4
 
6
5
  export interface TextureInternalOptions extends TextureFormatOptions, Omit<TextureConfigOptionsBase, 'keepImageSource'> {
7
6
  target: WebGLRenderingContext['TEXTURE_CUBE_MAP'] | WebGLRenderingContext['TEXTURE_2D'],
8
- noMipmap?: boolean,
7
+ mipmapCount?: number,
9
8
  }
10
9
 
11
10
  export interface TextureInternalConstructOptions extends TextureInternalOptions {
12
11
  width: number,
13
12
  height: number,
14
- image?: ImageBitmapInternal,
15
- //mipmap cube images
16
- cubeImages?: Array<TextureInternalCubeImages>,
17
13
  }
18
14
 
19
- export type TextureInternalCubeImages<T extends ImageBitmapInternal | TypedArray = ImageBitmapInternal> = [
15
+ export type TextureInternalCubeImages<T extends ImageBitmapInternal | ImageData = ImageBitmapInternal> = [
20
16
  positiveX: T,
21
17
  nagtiveX: T,
22
18
  positiveY: T,
@@ -46,7 +42,7 @@ export abstract class TextureInternal implements ResourceInternal {
46
42
  /**
47
43
  * 上传cubeImage解码后的数据
48
44
  */
49
- abstract updateCubeImagesData (images: TextureInternalCubeImages<TypedArray>, mipmapLevel?: number): void;
45
+ abstract updateCubeImagesData (images: TextureInternalCubeImages<ImageData>, mipmapLevel?: number): void;
50
46
 
51
47
  /**
52
48
  * 上传cubeImage
@@ -56,13 +52,13 @@ export abstract class TextureInternal implements ResourceInternal {
56
52
  /**
57
53
  * 上传整张解码后图片数据,数据尺寸必须和Texture尺寸定义相同
58
54
  */
59
- abstract update2DImageData (data: TypedArray, mipmapLevel?: number): void;
55
+ abstract update2DImageData (data: ImageData, mipmapLevel?: number): void;
60
56
 
61
57
  /**
62
58
  * 上传压缩纹理数据
63
59
  */
64
60
 
65
- abstract update2DCompressedImage (data: TypedArray, mipmapLevel?: number): void;
61
+ abstract update2DCompressedImage (data: ImageData, mipmapLevel?: number): void;
66
62
 
67
63
  /**
68
64
  * imageBitmap的尺寸也必须和Texture相同
@@ -0,0 +1,5 @@
1
+ // 给全局global 添加 predyNative: PredyNativeInternal
2
+ import { PredyNativeInternal } from './PredyNativeInternal';
3
+ declare global {
4
+ let predyNative: PredyNativeInternal;
5
+ }