import{B as l,n,t as c}from"./chunk-MN3WRWXI.js";var r=class{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){let a=l.get().createCanvas();a.width=t,a.height=e;let s=a.getContext("2d");return{canvas:a,context:s}}getOptimalCanvasAndContext(t,e,a=1){t=Math.ceil(t*a-1e-6),e=Math.ceil(e*a-1e-6),t=c(t),e=c(e);let s=(t<<17)+(e<<1);this._canvasPool[s]||(this._canvasPool[s]=[]);let o=this._canvasPool[s].pop();return o||(o=this._createCanvasAndContext(t,e)),o}returnCanvasAndContext(t){let e=t.canvas,{width:a,height:s}=e,o=(a<<17)+(s<<1);t.context.resetTransform(),t.context.clearRect(0,0,a,s),this._canvasPool[o].push(t)}clear(){this._canvasPool={}}},v=new r;n.register(v);export{v as a};
