import '../../../assert/js/assert.js';
import '../../../globals.js';
// Copyright 2023-2024, University of Colorado Boulder
/**
 * RenderProgram to convert linear Display P3 => linear sRGB
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */
import { alpenglow, RenderColor, RenderColorSpaceConversion, RenderInstruction } from '../imports.js';
import Vector4 from '../../../dot/js/Vector4.js';
export default class RenderLinearDisplayP3ToLinearSRGB extends RenderColorSpaceConversion {
    constructor(program) {
        super(program, RenderColor.linearDisplayP3ToLinear);
    }
    getName() {
        return 'RenderLinearDisplayP3ToLinearSRGB';
    }
    withChildren(children) {
        assert && assert(children.length === 1);
        return new RenderLinearDisplayP3ToLinearSRGB(children[0]);
    }
    writeInstructions(instructions) {
        this.program.writeInstructions(instructions);
        instructions.push(RenderInstructionLinearDisplayP3ToLinearSRGB.INSTANCE);
    }
}
alpenglow.register('RenderLinearDisplayP3ToLinearSRGB', RenderLinearDisplayP3ToLinearSRGB);
const scratchVector = new Vector4(0, 0, 0, 0);
export class RenderInstructionLinearDisplayP3ToLinearSRGB extends RenderInstruction {
    toString() {
        return 'RenderInstructionLinearDisplayP3ToLinearSRGB()';
    }
    equals(other, areLocationsEqual) {
        return other instanceof RenderInstructionLinearDisplayP3ToLinearSRGB;
    }
    execute(stack, context, executor) {
        const matrix = RenderColor.displayP3TosRGBMatrix;
        stack.readTop(scratchVector);
        stack.writeTopValues(matrix.m00() * scratchVector.x + matrix.m01() * scratchVector.y + matrix.m02() * scratchVector.z, matrix.m10() * scratchVector.x + matrix.m11() * scratchVector.y + matrix.m12() * scratchVector.z, matrix.m20() * scratchVector.x + matrix.m21() * scratchVector.y + matrix.m22() * scratchVector.z, scratchVector.w);
    }
    writeBinary(encoder, getOffset) {
        encoder.pushU32(RenderInstruction.LinearDisplayP3ToLinearSRGBCode);
    }
    getBinaryLength() {
        return 1;
    }
}
RenderInstructionLinearDisplayP3ToLinearSRGB.INSTANCE = new RenderInstructionLinearDisplayP3ToLinearSRGB();
//# sourceMappingURL=RenderLinearDisplayP3ToLinearSRGB.js.map