import '../../../assert/js/assert.js';
import '../../../globals.js';
// Copyright 2023-2024, University of Colorado Boulder
/**
 * RenderProgram to convert linear sRGB => linear Display P3
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */
import Vector4 from '../../../dot/js/Vector4.js';
import { alpenglow, RenderColor, RenderColorSpaceConversion, RenderInstruction, RenderLinearDisplayP3ToLinearSRGB } from '../imports.js';
export default class RenderLinearSRGBToLinearDisplayP3 extends RenderColorSpaceConversion {
    constructor(program) {
        super(program, RenderColor.linearToLinearDisplayP3);
    }
    getName() {
        return 'RenderLinearSRGBToLinearDisplayP3';
    }
    withChildren(children) {
        assert && assert(children.length === 1);
        return new RenderLinearSRGBToLinearDisplayP3(children[0]);
    }
    writeInstructions(instructions) {
        this.program.writeInstructions(instructions);
        instructions.push(RenderInstructionLinearSRGBToLinearDisplayP3.INSTANCE);
    }
}
RenderLinearSRGBToLinearDisplayP3.prototype.inverse = RenderLinearDisplayP3ToLinearSRGB;
RenderLinearDisplayP3ToLinearSRGB.prototype.inverse = RenderLinearSRGBToLinearDisplayP3;
alpenglow.register('RenderLinearSRGBToLinearDisplayP3', RenderLinearSRGBToLinearDisplayP3);
const scratchVector = new Vector4(0, 0, 0, 0);
export class RenderInstructionLinearSRGBToLinearDisplayP3 extends RenderInstruction {
    toString() {
        return 'RenderInstructionLinearSRGBToLinearDisplayP3()';
    }
    equals(other, areLocationsEqual) {
        return other instanceof RenderInstructionLinearSRGBToLinearDisplayP3;
    }
    execute(stack, context, executor) {
        const matrix = RenderColor.sRGBToDisplayP3Matrix;
        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.LinearSRGBToLinearDisplayP3Code);
    }
    getBinaryLength() {
        return 1;
    }
}
RenderInstructionLinearSRGBToLinearDisplayP3.INSTANCE = new RenderInstructionLinearSRGBToLinearDisplayP3();
//# sourceMappingURL=RenderLinearSRGBToLinearDisplayP3.js.map