-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Encapsulating PAL/ImageData #15485
Encapsulating PAL/ImageData #15485
Changes from 27 commits
861d9ff
51a2632
8c48d24
0215a1c
b8408b6
5c34e5a
641808c
ace9911
29f07a5
97a0645
906676c
750a332
36524ac
6981e2a
ea77a5d
d9a979f
2d67b2d
fb788ad
c74993c
556caee
7315c72
8d4ce62
e7bc49f
7ed95d2
33eca30
43055bb
4771e1a
2941de2
432011c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
declare module 'pal/image' { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's better we add more comment on every 'pal/image' public interface the comment sometimes is necessary like what's the difference between
|
||
|
||
export type ImageSource = import('pal/image/types').ImageSource; | ||
export type IMemoryImageSource = import('pal/image/types').IMemoryImageSource; | ||
export type PixelFormat = import('cocos/asset/assets/asset-enum').PixelFormat; | ||
export type RawDataType = import('pal/image/types').RawDataType; | ||
export class ImageData { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not call it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DOM's Image is in global namespace, but our encapsulated |
||
constructor (source?: ImageSource | ArrayBufferView); | ||
/** | ||
* Destroy resources. | ||
*/ | ||
destroy (): void; | ||
|
||
/** | ||
* @en Get raw image data.Return `ImageBitmap` if source is `ImageBitmap`. | ||
* @zh 获取原始图像数据。如果source是`ImageBitmap`类型,则返回ImageBitmap。 | ||
*/ | ||
get data(): RawDataType | null; | ||
|
||
/** | ||
* Get and set image data source. | ||
* @param value Image data source. | ||
* @engineinternal | ||
*/ | ||
get source(): ImageSource; | ||
set source(value: ImageSource); | ||
|
||
/** | ||
* Get image width. | ||
*/ | ||
get width(): number; | ||
|
||
/** | ||
* Get image height. | ||
*/ | ||
get height(): number; | ||
|
||
/** | ||
* Load image via local url or web url. | ||
*/ | ||
static loadImage (urlAndBase64: string): Promise<ImageData> | ||
|
||
/** | ||
* Set image data source. | ||
* @param data Image data source. | ||
*/ | ||
reset(data?: ImageSource | ArrayBufferView): void; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why export it? Does developers need to use it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to declare the type, if the type is not declared, the return would need to be of type any.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we don't want to export it to developers. So should find a way to export internally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The jsb namespace is deprecated and will be used internally as an engine.