/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module WebGL
 */
import { assert, expectDefined } from "@itwin/core-bentley";
import { FloatRgba } from "./FloatRGBA";
/* Describes a primitive's basic color properties
 * @internal
 */
export class ColorInfo {
    _uniform;
    hasTranslucency;
    constructor(hasTranslucency, uniform) {
        this.hasTranslucency = hasTranslucency;
        this._uniform = uniform;
    }
    static createUniform(color) { return new ColorInfo(color.hasTranslucency, color); }
    static createNonUniform(hasTranslucency) { return hasTranslucency ? this._nonUniformTranslucent : this._nonUniformOpaque; }
    static createFromColorDef(color) { return this.createUniform(FloatRgba.fromColorDef(color)); }
    static createFromColorIndex(colorIndex) {
        return undefined !== colorIndex.uniform ? this.createFromColorDef(colorIndex.uniform) : this.createNonUniform(colorIndex.hasAlpha);
    }
    static createFromVertexTable(vt) {
        return undefined !== vt.uniformColor ? this.createFromColorDef(vt.uniformColor) : this.createNonUniform(vt.hasTranslucency);
    }
    get isUniform() { return undefined !== this._uniform; }
    get isNonUniform() { return !this.isUniform; }
    get uniform() {
        assert(this.isUniform);
        return expectDefined(this._uniform);
    }
    static _nonUniformTranslucent = new ColorInfo(true);
    static _nonUniformOpaque = new ColorInfo(false);
}
//# sourceMappingURL=ColorInfo.js.map