1 line
23 KiB
Plaintext
1 line
23 KiB
Plaintext
|
|
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["/// <reference path=\"../global.d.ts\" />\nimport { BaseTexture, Matrix, Rectangle, RenderTexture, Texture, utils } from '@pixi/core';\nimport { DisplayObject } from '@pixi/display';\nimport { Sprite } from '@pixi/sprite';\n\nimport type {\n ICanvasRenderingContext2D,\n IPointData,\n IRenderer,\n MaskData,\n MSAA_QUALITY,\n Renderer,\n} from '@pixi/core';\nimport type { Container, IDestroyOptions } from '@pixi/display';\n\n// Don't import CanvasRender to remove dependency on this optional package\n// this type should satisify these requirements for cacheAsBitmap types\ninterface CanvasRenderer extends IRenderer\n{\n canvasContext: {\n activeContext: ICanvasRenderingContext2D;\n }\n}\n\nconst _tempMatrix = new Matrix();\n\nDisplayObject.prototype._cacheAsBitmap = false;\nDisplayObject.prototype._cacheData = null;\nDisplayObject.prototype._cacheAsBitmapResolution = null;\nDisplayObject.prototype._cacheAsBitmapMultisample = null;\n\n// figured there's no point adding ALL the extra variables to prototype.\n// this model can hold the information needed. This can also be generated on demand as\n// most objects are not cached as bitmaps.\n/**\n * @class\n * @ignore\n * @private\n */\nexport class CacheData\n{\n public textureCacheId: string;\n public originalRender: (renderer: Renderer) => void;\n public originalRenderCanvas: (renderer: IRenderer) => void;\n public originalCalculateBounds: () => void;\n public originalGetLocalBounds: (rect?: Rectangle) => Rectangle;\n public originalUpdateTransform: () => void;\n public originalDestroy: (options?: IDestroyOptions | boolean) => void;\n public originalMask: Container | MaskData;\n public originalFilterArea: Rectangle;\n public originalContainsPoint: (point: IPointData) => boolean;\n public sprite: Sprite;\n\n constructor()\n {\n this.textureCacheId = null;\n\n this.originalRender = null;\n this.originalRenderCanvas = null;\n this.originalCalculateBounds = null;\n this.originalGetLocalBounds = null;\n\n this.originalUpdateTransform = null;\n this.originalDestroy = null;\n this.originalMask = null;\n this.originalFilterArea = null;\n this.originalContainsPoint = null;\n this.sprite = null;\n }\n}\n\nObject.defineProperties(DisplayObject.prototype, {\n /**\n * The resolution to use for cacheAsBitmap. By default this will use the renderer's resolution\n * but can be overriden for performance. Lower values will reduce memory usage at the expense\n * of render quality. A falsey value of `null` or `0` will default to the renderer's resolution.\n * If `cacheAsBitmap` is set to `true`, this will re-render with the new resolution.\n * @member {number|null} cacheAsBitmapResolution\n * @memberof PIXI.DisplayObject#\n * @default null\n */\n cacheAsBitmapResolution: {\n get(): number | null\n {\n return this._cacheAsBitmapResolution;\n },\n set(resolution: number | null): void\n {\n if (resolution === this._cacheAsBitmapResolution)\n {\n return;\n }\n\n this._cacheAsBitmapResolution = resolution;\n\n if (this.cacheAsBitmap)\n {\n // Toggle to re-render at the new resolution\n this.cacheAsBitmap = false;\n this.cacheAsBitmap = true;\n }\n },\n },\n\n /**\n * The number of samples to use for cacheAsBitmap. If set to `null`, the renderer's\n * sample count is used.\n * If `cacheAsBitmap` is set to `true`, this will re-render with the new number of samples.\n * @member {number|null} cacheAsBitmapMultisample\n * @memberof PIXI.DisplayObject#\n * @default null\n */\n cacheAsBitmapMultisample: {\n get(): MSAA_QUALITY | null\n {\n return this._cacheAsBitmapMultisample;\n },\n
|