shadow$provide.module$node_modules$pixi_DOT_js$lib$rendering$renderers$canvas$CanvasContextSystem = function(global, require, module, exports) {
  var Color = require("module$node_modules$pixi_DOT_js$lib$color$Color");
  global = require("module$node_modules$pixi_DOT_js$lib$extensions$Extensions");
  var Matrix = require("module$node_modules$pixi_DOT_js$lib$maths$matrix$Matrix"), mapCanvasBlendModesToPixi = require("module$node_modules$pixi_DOT_js$lib$rendering$renderers$canvas$utils$mapCanvasBlendModesToPixi");
  "use strict";
  const tempMatrix = new Matrix.Matrix();
  class CanvasContextSystem {
    constructor(renderer) {
      this.activeResolution = 1;
      this.smoothProperty = "imageSmoothingEnabled";
      this.blendModes = mapCanvasBlendModesToPixi.mapCanvasBlendModesToPixi();
      this._activeBlendMode = "normal";
      this._projTransform = null;
      this._outerBlend = !1;
      this._warnedBlendModes = new Set();
      this._renderer = renderer;
    }
    resolutionChange(resolution) {
      this.activeResolution = resolution;
    }
    init() {
      this.activeContext = this.rootContext = this._renderer.canvas.getContext("2d", {alpha:1 > this._renderer.background.alpha});
      this.activeResolution = this._renderer.resolution;
      if (!this.rootContext.imageSmoothingEnabled) {
        const rc = this.rootContext;
        rc.webkitImageSmoothingEnabled ? this.smoothProperty = "webkitImageSmoothingEnabled" : rc.mozImageSmoothingEnabled ? this.smoothProperty = "mozImageSmoothingEnabled" : rc.oImageSmoothingEnabled ? this.smoothProperty = "oImageSmoothingEnabled" : rc.msImageSmoothingEnabled && (this.smoothProperty = "msImageSmoothingEnabled");
      }
    }
    setContextTransform(transform, roundPixels, localResolution, skipGlobalTransform) {
      let mat = tempMatrix;
      mat.copyFrom(skipGlobalTransform ? Matrix.Matrix.IDENTITY : this._renderer.globalUniforms.globalUniformData?.worldTransformMatrix || Matrix.Matrix.IDENTITY);
      mat.append(transform);
      transform = this._projTransform;
      skipGlobalTransform = this.activeResolution;
      localResolution = localResolution || skipGlobalTransform;
      if (transform) {
        const finalMat = Matrix.Matrix.shared;
        finalMat.copyFrom(mat);
        finalMat.prepend(transform);
        mat = finalMat;
      }
      roundPixels ? this.activeContext.setTransform(mat.a * localResolution, mat.b * localResolution, mat.c * localResolution, mat.d * localResolution, mat.tx * skipGlobalTransform | 0, mat.ty * skipGlobalTransform | 0) : this.activeContext.setTransform(mat.a * localResolution, mat.b * localResolution, mat.c * localResolution, mat.d * localResolution, mat.tx * skipGlobalTransform, mat.ty * skipGlobalTransform);
    }
    clear(clearColor, alpha) {
      const context = this.activeContext, renderer = this._renderer;
      context.clearRect(0, 0, renderer.width, renderer.height);
      clearColor && (clearColor = Color.Color.shared.setValue(clearColor), context.globalAlpha = alpha ?? clearColor.alpha, context.fillStyle = clearColor.toHex(), context.fillRect(0, 0, renderer.width, renderer.height), context.globalAlpha = 1);
    }
    setBlendMode(blendMode) {
      if (this._activeBlendMode !== blendMode) {
        this._activeBlendMode = blendMode;
        this._outerBlend = !1;
        var mappedBlend = this.blendModes[blendMode];
        mappedBlend ? this.activeContext.globalCompositeOperation = mappedBlend : (this._warnedBlendModes.has(blendMode) || (console.warn(`CanvasRenderer: blend mode "${blendMode}" is not supported in Canvas2D; falling back to "source-over".`), this._warnedBlendModes.add(blendMode)), this.activeContext.globalCompositeOperation = "source-over");
      }
    }
    destroy() {
      this.activeContext = this.rootContext = null;
      this._warnedBlendModes.clear();
    }
  }
  CanvasContextSystem.extension = {type:[global.ExtensionType.CanvasSystem], name:"canvasContext"};
  exports.CanvasContextSystem = CanvasContextSystem;
};

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