shadow$provide.module$node_modules$pixi_DOT_js$lib$rendering$renderers$canvas$renderTarget$CanvasRenderTargetAdaptor = function(global, require, module, exports) {
  var Color = require("module$node_modules$pixi_DOT_js$lib$color$Color"), adapter = require("module$node_modules$pixi_DOT_js$lib$environment$adapter"), CanvasSource = require("module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$texture$sources$CanvasSource");
  "use strict";
  class CanvasRenderTargetAdaptor {
    init(renderer, renderTargetSystem) {
      this._renderer = renderer;
      this._renderTargetSystem = renderTargetSystem;
    }
    initGpuRenderTarget(renderTarget) {
      const {canvas, context} = this._ensureCanvas(renderTarget.colorTexture);
      return {canvas, context, width:canvas.width, height:canvas.height};
    }
    resizeGpuRenderTarget(renderTarget) {
      const {canvas} = this._ensureCanvas(renderTarget.colorTexture);
      canvas.width = renderTarget.pixelWidth;
      canvas.height = renderTarget.pixelHeight;
    }
    startRenderPass(renderTarget, clear, clearColor, viewport) {
      const gpuRenderTarget = this._renderTargetSystem.getGpuRenderTarget(renderTarget);
      this._renderer.canvasContext.activeContext = gpuRenderTarget.context;
      this._renderer.canvasContext.activeResolution = renderTarget.resolution;
      clear && this.clear(renderTarget, clear, clearColor, viewport);
    }
    clear(renderTarget, _clear, clearColor, viewport) {
      _clear = this._renderTargetSystem.getGpuRenderTarget(renderTarget).context;
      renderTarget = viewport || {x:0, y:0, width:renderTarget.pixelWidth, height:renderTarget.pixelHeight};
      _clear.setTransform(1, 0, 0, 1, 0, 0);
      _clear.clearRect(renderTarget.x, renderTarget.y, renderTarget.width, renderTarget.height);
      clearColor && (clearColor = Color.Color.shared.setValue(clearColor), 0 < clearColor.alpha && (_clear.globalAlpha = clearColor.alpha, _clear.fillStyle = clearColor.toHex(), _clear.fillRect(renderTarget.x, renderTarget.y, renderTarget.width, renderTarget.height), _clear.globalAlpha = 1));
    }
    finishRenderPass() {
    }
    copyToTexture(sourceRenderSurfaceTexture, destinationTexture, originSrc, size, originDest) {
      sourceRenderSurfaceTexture = this._renderTargetSystem.getGpuRenderTarget(sourceRenderSurfaceTexture).canvas;
      const destSource = destinationTexture.source, {context} = this._ensureCanvas(destSource);
      context.drawImage(sourceRenderSurfaceTexture, originSrc.x, originSrc.y, size.width, size.height, originDest?.x ?? 0, originDest?.y ?? 0, size.width, size.height);
      destSource.update();
      return destinationTexture;
    }
    destroyGpuRenderTarget(_gpuRenderTarget) {
    }
    _ensureCanvas(source) {
      let canvas = source.resource;
      canvas && CanvasSource.CanvasSource.test(canvas) || (canvas = adapter.DOMAdapter.get().createCanvas(source.pixelWidth, source.pixelHeight), source.resource = canvas);
      if (canvas.width !== source.pixelWidth || canvas.height !== source.pixelHeight) {
        canvas.width = source.pixelWidth, canvas.height = source.pixelHeight;
      }
      source = canvas.getContext("2d");
      return {canvas, context:source};
    }
  }
  exports.CanvasRenderTargetAdaptor = CanvasRenderTargetAdaptor;
};

//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$rendering$renderers$canvas$renderTarget$CanvasRenderTargetAdaptor.js.map
