import { TextureSource } from './TextureSource.mjs';

class BufferImageSource extends TextureSource {
  constructor() {
    super(...arguments);
    this.uploadMethodId = "buffer";
  }
  static from(options) {
    const buffer = options.resource || new Float32Array(options.width * options.height * 4);
    let format = options.format;
    if (!format) {
      if (buffer instanceof Float32Array) {
        format = "rgba32float";
      } else if (buffer instanceof Int32Array) {
        format = "rgba32uint";
      } else if (buffer instanceof Uint32Array) {
        format = "rgba32uint";
      } else if (buffer instanceof Int16Array) {
        format = "rgba16uint";
      } else if (buffer instanceof Uint16Array) {
        format = "rgba16uint";
      } else if (buffer instanceof Int8Array) {
        format = "bgra8unorm";
      } else {
        format = "bgra8unorm";
      }
    }
    return new BufferImageSource({
      ...options,
      format
    });
  }
}

export { BufferImageSource };
//# sourceMappingURL=BufferImageSource.mjs.map
