@predy-js/render-interface 0.1.66-beta.9 → 0.1.67

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.66-beta.9
5
+ * Version: v0.1.67
6
6
  */
7
7
 
8
8
  // https://github.com/greggman/webgl-memory/blob/main/src/texture-utils.js
@@ -1,6 +1,12 @@
1
1
  import type { IGPURenderer, IGPUResource } from './IGPURenderer';
2
2
  import type { Immutable, TypedArray } from './type';
3
3
  import type { GPURenderer } from './Renderer';
4
+ /**
5
+ * 图片解码的格式,默认为 WebGL2RenderingContext['RGBA8']
6
+ * 如果图片解码格式和texture的不一致,在非Web环境下,会产生报错,无法上传数据
7
+ * 一般情况由系统根据图片文件解析出图片的像素格式
8
+ */
9
+ export type ImageBitmapPixelFormat = WebGL2RenderingContext['RGBA8'] | WebGL2RenderingContext['RGBA16F'] | WebGL2RenderingContext['RGBA32F'];
4
10
  export declare enum TextureSourceType {
5
11
  none = 0,
6
12
  data = 1,
@@ -57,6 +63,11 @@ export interface TextureFactorySource2DMipmapsFrom {
57
63
  }
58
64
  export type TextureFactorySourceFrom = TextureFactorySource2DBinaryMipmapsFrom | TextureFactorySourceCubeBinaryMipmapsFrom | TextureFactorySource2DFrom | TextureFactorySourceCubeFrom | TextureFactorySourceCubeMipmapsFrom | TextureFactorySource2DMipmapsFrom | TextureFactorySourceFromCompressed;
59
65
  export interface TextureFactory {
66
+ /**
67
+ * 通过TextureConfigOptions可以决定图片解码时使用的格式
68
+ * @param options
69
+ * @param config texture的属性
70
+ */
60
71
  loadSourceAsync(options: TextureFactorySourceFrom, config?: TextureConfigOptions): Promise<TextureOptions>;
61
72
  canOffloadTexture(texture: Texture): boolean;
62
73
  reloadTextureAsync(texture: Texture): Promise<Texture>;
@@ -1,18 +1,21 @@
1
+ import type { ImageBitmapPixelFormat } from '../Texture';
1
2
  export interface ImageBitmapConstructor {
3
+ premultiplyAlpha?: boolean;
2
4
  }
3
5
  export declare abstract class ImageBitmapInternal {
4
6
  /**
5
- * 释放内存,释放后不可再用,
6
- * 释放后 width,height,byteLength都为0
7
- */
7
+ * 释放内存,释放后不可再用,
8
+ * 释放后 width,height,byteLength都为0
9
+ */
8
10
  abstract close(): void;
9
11
  /**
10
- * 将内存拷贝到指定的Uint8Array中
11
- * @param target
12
- */
12
+ * 将内存拷贝到指定的Uint8Array中
13
+ * @param target
14
+ */
13
15
  abstract copyTo(target: Uint8Array): void;
14
16
  abstract readonly width: number;
15
17
  abstract readonly height: number;
16
18
  abstract readonly byteLength: number;
19
+ abstract readonly format: ImageBitmapPixelFormat;
17
20
  }
18
21
  export type ImageBitmapCallback = (error: Error | undefined, image: ImageBitmapInternal) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@predy-js/render-interface",
3
- "version": "0.1.66-beta.9",
3
+ "version": "0.1.67",
4
4
  "license": "MIT",
5
5
  "module": "./dist/index.mjs",
6
6
  "main": "./dist/index.js",
package/types/Texture.ts CHANGED
@@ -2,6 +2,15 @@ import type { IGPURenderer, IGPUResource } from './IGPURenderer';
2
2
  import type { Immutable, TypedArray } from './type';
3
3
  import type { GPURenderer } from './Renderer';
4
4
 
5
+ /**
6
+ * 图片解码的格式,默认为 WebGL2RenderingContext['RGBA8']
7
+ * 如果图片解码格式和texture的不一致,在非Web环境下,会产生报错,无法上传数据
8
+ * 一般情况由系统根据图片文件解析出图片的像素格式
9
+ */
10
+ export type ImageBitmapPixelFormat = WebGL2RenderingContext['RGBA8'] |
11
+ WebGL2RenderingContext['RGBA16F'] |
12
+ WebGL2RenderingContext['RGBA32F'] ;
13
+
5
14
  export enum TextureSourceType {
6
15
  none,
7
16
  data = 1,
@@ -75,6 +84,11 @@ export type TextureFactorySourceFrom =
75
84
  | TextureFactorySourceFromCompressed;
76
85
 
77
86
  export interface TextureFactory {
87
+ /**
88
+ * 通过TextureConfigOptions可以决定图片解码时使用的格式
89
+ * @param options
90
+ * @param config texture的属性
91
+ */
78
92
  loadSourceAsync (options: TextureFactorySourceFrom, config?: TextureConfigOptions): Promise<TextureOptions>,
79
93
 
80
94
  canOffloadTexture (texture: Texture): boolean,
@@ -1,21 +1,24 @@
1
+ import type { ImageBitmapPixelFormat } from '../Texture';
2
+
1
3
  export interface ImageBitmapConstructor {
4
+ premultiplyAlpha?: boolean,
2
5
  }
3
6
 
4
7
  export abstract class ImageBitmapInternal {
5
8
  /**
6
- * 释放内存,释放后不可再用,
7
- * 释放后 width,height,byteLength都为0
8
- */
9
+ * 释放内存,释放后不可再用,
10
+ * 释放后 width,height,byteLength都为0
11
+ */
9
12
  abstract close (): void;
10
-
11
13
  /**
12
- * 将内存拷贝到指定的Uint8Array中
13
- * @param target
14
- */
14
+ * 将内存拷贝到指定的Uint8Array中
15
+ * @param target
16
+ */
15
17
  abstract copyTo (target: Uint8Array): void;
16
18
  abstract readonly width: number;
17
19
  abstract readonly height: number;
18
20
  abstract readonly byteLength: number;
21
+ abstract readonly format: ImageBitmapPixelFormat;
19
22
  }
20
23
 
21
24
  export type ImageBitmapCallback = (