UNPKG

pixi.js

Version:

<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">

34 lines (30 loc) 925 B
'use strict'; var CanvasSource = require('../sources/CanvasSource.js'); var Texture = require('../Texture.js'); "use strict"; const canvasCache = /* @__PURE__ */ new Map(); function getCanvasTexture(canvas, options) { if (!canvasCache.has(canvas)) { const texture = new Texture.Texture({ source: new CanvasSource.CanvasSource({ resource: canvas, ...options }) }); const onDestroy = () => { if (canvasCache.get(canvas) === texture) { canvasCache.delete(canvas); } }; texture.once("destroy", onDestroy); texture.source.once("destroy", onDestroy); canvasCache.set(canvas, texture); } return canvasCache.get(canvas); } function hasCachedCanvasTexture(canvas) { return canvasCache.has(canvas); } exports.getCanvasTexture = getCanvasTexture; exports.hasCachedCanvasTexture = hasCachedCanvasTexture; //# sourceMappingURL=getCanvasTexture.js.map