import '../../../assert/js/assert.js';
import '../../../globals.js';
// Copyright 2023-2024, University of Colorado Boulder
/**
 * RenderProgram to premultiply the input color
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */
import Vector4 from '../../../dot/js/Vector4.js';
import { alpenglow, RenderColor, RenderColorSpaceConversion, RenderInstruction } from '../imports.js';
export default class RenderPremultiply extends RenderColorSpaceConversion {
    constructor(program) {
        super(program, RenderColor.premultiply);
    }
    getName() {
        return 'RenderPremultiply';
    }
    withChildren(children) {
        assert && assert(children.length === 1);
        return new RenderPremultiply(children[0]);
    }
    writeInstructions(instructions) {
        this.program.writeInstructions(instructions);
        instructions.push(RenderInstructionPremultiply.INSTANCE);
    }
}
alpenglow.register('RenderPremultiply', RenderPremultiply);
const scratchVector = new Vector4(0, 0, 0, 0);
export class RenderInstructionPremultiply extends RenderInstruction {
    toString() {
        return 'RenderInstructionPremultiply()';
    }
    equals(other, areLocationsEqual) {
        return other instanceof RenderInstructionPremultiply;
    }
    execute(stack, context, executor) {
        stack.readTop(scratchVector);
        stack.writeTopValues(scratchVector.x * scratchVector.w, scratchVector.y * scratchVector.w, scratchVector.z * scratchVector.w, scratchVector.w);
    }
    writeBinary(encoder, getOffset) {
        encoder.pushU32(RenderInstruction.PremultiplyCode);
    }
    getBinaryLength() {
        return 1;
    }
}
RenderInstructionPremultiply.INSTANCE = new RenderInstructionPremultiply();
//# sourceMappingURL=RenderPremultiply.js.map