Skip to content

Commit

Permalink
Use @types/dom-webcodecs
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSodaSea committed Sep 26, 2023
1 parent b5a7d88 commit c4d31b0
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"@pixi/settings": "file:../settings",
"@pixi/ticker": "file:../ticker",
"@pixi/utils": "file:../utils",
"@types/dom-webcodecs": "0.1.3",
"@types/offscreencanvas": "^2019.6.4"
}
}
6 changes: 3 additions & 3 deletions packages/core/src/textures/BaseTexture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const defaultBufferOptions = {
alphaMode: ALPHA_MODES.NPM,
};

export type ImageSource = HTMLImageElement | HTMLVideoElement | ImageBitmap | ICanvas;
export type ImageSource = HTMLImageElement | HTMLVideoElement | ImageBitmap | ICanvas | VideoFrame;

export interface IBaseTextureOptions<RO = any>
{
Expand Down Expand Up @@ -251,7 +251,7 @@ export class BaseTexture<R extends Resource = Resource, RO = IAutoDetectOptions>
};

/**
* @param {PIXI.Resource|HTMLImageElement|HTMLVideoElement|ImageBitmap|ICanvas|string} [resource=null] -
* @param {PIXI.Resource|PIXI.ImageSource|string} [resource=null] -
* The current resource to use, for things that aren't Resource objects, will be converted
* into a Resource.
* @param options - Collection of options, default options inherited from {@link PIXI.BaseTexture.defaultOptions}.
Expand Down Expand Up @@ -643,7 +643,7 @@ export class BaseTexture<R extends Resource = Resource, RO = IAutoDetectOptions>
* source is an image url or an image element and not in the base texture
* cache, it will be created and loaded.
* @static
* @param {HTMLImageElement|HTMLVideoElement|ImageBitmap|PIXI.ICanvas|string|string[]} source - The
* @param {PIXI.ImageSource|string|string[]} source - The
* source to create base texture from.
* @param options - See {@link PIXI.BaseTexture}'s constructor for options.
* @param {string} [options.pixiIdPrefix=pixiid] - If a source has no id, this is the prefix of the generated id
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/textures/resources/BaseImageResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class BaseImageResource extends Resource
{
/**
* The source element.
* @member {HTMLImageElement|HTMLVideoElement|ImageBitmap|PIXI.ICanvas}
* @member {PIXI.ImageSourcee}
* @readonly
*/
public source: ImageSource;
Expand All @@ -28,7 +28,7 @@ export class BaseImageResource extends Resource
public noSubImage: boolean;

/**
* @param {HTMLImageElement|HTMLVideoElement|ImageBitmap|PIXI.ICanvas} source
* @param {PIXI.ImageSourcee} source
*/
constructor(source: ImageSource)
{
Expand Down Expand Up @@ -65,7 +65,7 @@ export class BaseImageResource extends Resource
* @param renderer - Upload to the renderer
* @param baseTexture - Reference to parent texture
* @param glTexture
* @param {HTMLImageElement|HTMLVideoElement|ImageBitmap|PIXI.ICanvas} [source] - (optional)
* @param {PIXI.ImageSourcee} [source] - (optional)
* @returns - true is success
*/
override upload(renderer: Renderer, baseTexture: BaseTexture, glTexture: GLTexture, source?: ImageSource): boolean
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/textures/resources/VideoFrameResource.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { BaseImageResource } from './BaseImageResource';

type VideoFrame = any;

/**
* Resource type for VideoFrame.
* @memberof PIXI
Expand All @@ -24,6 +22,6 @@ export class VideoFrameResource extends BaseImageResource
*/
static test(source: unknown): source is VideoFrame
{
return !!(globalThis as any).VideoFrame && source instanceof (globalThis as any).VideoFrame;
return !!globalThis.VideoFrame && source instanceof globalThis.VideoFrame;
}
}
8 changes: 4 additions & 4 deletions packages/settings/src/ICanvasRenderingContext2D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export interface ICanvasRenderingContext2D extends
CanvasTextDrawingStyles,
CanvasPath
{
createPattern(image: CanvasImageSource | ICanvas, repetition: string | null): CanvasPattern | null;
createPattern(image: CanvasImageSource | ICanvas | VideoFrame, repetition: string | null): CanvasPattern | null;

drawImage(image: CanvasImageSource | ICanvas, dx: number, dy: number): void;
drawImage(image: CanvasImageSource | ICanvas, dx: number, dy: number, dw: number, dh: number): void;
drawImage(image: CanvasImageSource | ICanvas, sx: number, sy: number, sw: number, sh: number,
drawImage(image: CanvasImageSource | ICanvas | VideoFrame, dx: number, dy: number): void;
drawImage(image: CanvasImageSource | ICanvas | VideoFrame, dx: number, dy: number, dw: number, dh: number): void;
drawImage(image: CanvasImageSource | ICanvas | VideoFrame, sx: number, sy: number, sw: number, sh: number,
dx: number, dy: number, dw: number, dh: number): void;

letterSpacing?: string;
Expand Down

0 comments on commit c4d31b0

Please sign in to comment.