// skia/public/mojom/hdr_metadata.mojom.js is auto generated by mojom_bindings_generator.py, do not edit

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

'use strict';

(function() {
  var mojomId = 'skia/public/mojom/hdr_metadata.mojom';
  if (mojo.internal.isMojomLoaded(mojomId)) {
    console.warn('The following mojom is loaded multiple times: ' + mojomId);
    return;
  }
  mojo.internal.markMojomLoaded(mojomId);
  var bindings = mojo;
  var associatedBindings = mojo;
  var codec = mojo.internal;
  var validator = mojo.internal;

  var exports = mojo.internal.exposeNamespace('skia.mojom');
  var skcolorspace_primaries$ =
      mojo.internal.exposeNamespace('skia.mojom');
  if (mojo.config.autoLoadMojomDeps) {
    mojo.internal.loadMojomIfNecessary(
        'skia/public/mojom/skcolorspace_primaries.mojom', 'skcolorspace_primaries.mojom.js');
  }



  function SkHdrContentLightLevelInformation(values) {
    this.initDefaults_();
    this.initFields_(values);
  }


  SkHdrContentLightLevelInformation.prototype.initDefaults_ = function() {
    this.maxCll = 0;
    this.maxFall = 0;
  };
  SkHdrContentLightLevelInformation.prototype.initFields_ = function(fields) {
    for(var field in fields) {
        if (this.hasOwnProperty(field))
          this[field] = fields[field];
    }
  };

  SkHdrContentLightLevelInformation.validate = function(messageValidator, offset) {
    var err;
    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
    if (err !== validator.validationError.NONE)
        return err;

    var kVersionSizes = [
      {version: 0, numBytes: 16}
    ];
    err = messageValidator.validateStructVersion(offset, kVersionSizes);
    if (err !== validator.validationError.NONE)
        return err;



    return validator.validationError.NONE;
  };

  SkHdrContentLightLevelInformation.encodedSize = codec.kStructHeaderSize + 8;

  SkHdrContentLightLevelInformation.decode = function(decoder) {
    var packed;
    var val = new SkHdrContentLightLevelInformation();
    var numberOfBytes = decoder.readUint32();
    var version = decoder.readUint32();
    val.maxCll =
        decoder.decodeStruct(codec.Float);
    val.maxFall =
        decoder.decodeStruct(codec.Float);
    return val;
  };

  SkHdrContentLightLevelInformation.encode = function(encoder, val) {
    var packed;
    encoder.writeUint32(SkHdrContentLightLevelInformation.encodedSize);
    encoder.writeUint32(0);
    encoder.encodeStruct(codec.Float, val.maxCll);
    encoder.encodeStruct(codec.Float, val.maxFall);
  };
  function SkHdrMasteringDisplayColorVolume(values) {
    this.initDefaults_();
    this.initFields_(values);
  }


  SkHdrMasteringDisplayColorVolume.prototype.initDefaults_ = function() {
    this.primaries = null;
    this.maxLuminance = 0;
    this.minLuminance = 0;
  };
  SkHdrMasteringDisplayColorVolume.prototype.initFields_ = function(fields) {
    for(var field in fields) {
        if (this.hasOwnProperty(field))
          this[field] = fields[field];
    }
  };

  SkHdrMasteringDisplayColorVolume.validate = function(messageValidator, offset) {
    var err;
    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
    if (err !== validator.validationError.NONE)
        return err;

    var kVersionSizes = [
      {version: 0, numBytes: 24}
    ];
    err = messageValidator.validateStructVersion(offset, kVersionSizes);
    if (err !== validator.validationError.NONE)
        return err;


    // validate SkHdrMasteringDisplayColorVolume.primaries
    err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 0, skcolorspace_primaries$.SkColorSpacePrimaries, false);
    if (err !== validator.validationError.NONE)
        return err;



    return validator.validationError.NONE;
  };

  SkHdrMasteringDisplayColorVolume.encodedSize = codec.kStructHeaderSize + 16;

  SkHdrMasteringDisplayColorVolume.decode = function(decoder) {
    var packed;
    var val = new SkHdrMasteringDisplayColorVolume();
    var numberOfBytes = decoder.readUint32();
    var version = decoder.readUint32();
    val.primaries =
        decoder.decodeStructPointer(skcolorspace_primaries$.SkColorSpacePrimaries);
    val.maxLuminance =
        decoder.decodeStruct(codec.Float);
    val.minLuminance =
        decoder.decodeStruct(codec.Float);
    return val;
  };

  SkHdrMasteringDisplayColorVolume.encode = function(encoder, val) {
    var packed;
    encoder.writeUint32(SkHdrMasteringDisplayColorVolume.encodedSize);
    encoder.writeUint32(0);
    encoder.encodeStructPointer(skcolorspace_primaries$.SkColorSpacePrimaries, val.primaries);
    encoder.encodeStruct(codec.Float, val.maxLuminance);
    encoder.encodeStruct(codec.Float, val.minLuminance);
  };
  function SkHdrAgtmGainCurveControlPoint(values) {
    this.initDefaults_();
    this.initFields_(values);
  }


  SkHdrAgtmGainCurveControlPoint.prototype.initDefaults_ = function() {
    this.x = 0;
    this.y = 0;
    this.m = 0;
  };
  SkHdrAgtmGainCurveControlPoint.prototype.initFields_ = function(fields) {
    for(var field in fields) {
        if (this.hasOwnProperty(field))
          this[field] = fields[field];
    }
  };

  SkHdrAgtmGainCurveControlPoint.validate = function(messageValidator, offset) {
    var err;
    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
    if (err !== validator.validationError.NONE)
        return err;

    var kVersionSizes = [
      {version: 0, numBytes: 24}
    ];
    err = messageValidator.validateStructVersion(offset, kVersionSizes);
    if (err !== validator.validationError.NONE)
        return err;




    return validator.validationError.NONE;
  };

  SkHdrAgtmGainCurveControlPoint.encodedSize = codec.kStructHeaderSize + 16;

  SkHdrAgtmGainCurveControlPoint.decode = function(decoder) {
    var packed;
    var val = new SkHdrAgtmGainCurveControlPoint();
    var numberOfBytes = decoder.readUint32();
    var version = decoder.readUint32();
    val.x =
        decoder.decodeStruct(codec.Float);
    val.y =
        decoder.decodeStruct(codec.Float);
    val.m =
        decoder.decodeStruct(codec.Float);
    decoder.skip(1);
    decoder.skip(1);
    decoder.skip(1);
    decoder.skip(1);
    return val;
  };

  SkHdrAgtmGainCurveControlPoint.encode = function(encoder, val) {
    var packed;
    encoder.writeUint32(SkHdrAgtmGainCurveControlPoint.encodedSize);
    encoder.writeUint32(0);
    encoder.encodeStruct(codec.Float, val.x);
    encoder.encodeStruct(codec.Float, val.y);
    encoder.encodeStruct(codec.Float, val.m);
    encoder.skip(1);
    encoder.skip(1);
    encoder.skip(1);
    encoder.skip(1);
  };
  function SkHdrAgtmGainCurve(values) {
    this.initDefaults_();
    this.initFields_(values);
  }


  SkHdrAgtmGainCurve.prototype.initDefaults_ = function() {
    this.controlPoints = null;
  };
  SkHdrAgtmGainCurve.prototype.initFields_ = function(fields) {
    for(var field in fields) {
        if (this.hasOwnProperty(field))
          this[field] = fields[field];
    }
  };

  SkHdrAgtmGainCurve.validate = function(messageValidator, offset) {
    var err;
    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
    if (err !== validator.validationError.NONE)
        return err;

    var kVersionSizes = [
      {version: 0, numBytes: 16}
    ];
    err = messageValidator.validateStructVersion(offset, kVersionSizes);
    if (err !== validator.validationError.NONE)
        return err;


    // validate SkHdrAgtmGainCurve.controlPoints
    err = messageValidator.validateArrayPointer(offset + codec.kStructHeaderSize + 0, 8, new codec.PointerTo(SkHdrAgtmGainCurveControlPoint), false, [0], 0);
    if (err !== validator.validationError.NONE)
        return err;

    return validator.validationError.NONE;
  };

  SkHdrAgtmGainCurve.encodedSize = codec.kStructHeaderSize + 8;

  SkHdrAgtmGainCurve.decode = function(decoder) {
    var packed;
    var val = new SkHdrAgtmGainCurve();
    var numberOfBytes = decoder.readUint32();
    var version = decoder.readUint32();
    val.controlPoints =
        decoder.decodeArrayPointer(new codec.PointerTo(SkHdrAgtmGainCurveControlPoint));
    return val;
  };

  SkHdrAgtmGainCurve.encode = function(encoder, val) {
    var packed;
    encoder.writeUint32(SkHdrAgtmGainCurve.encodedSize);
    encoder.writeUint32(0);
    encoder.encodeArrayPointer(new codec.PointerTo(SkHdrAgtmGainCurveControlPoint), val.controlPoints);
  };
  function SkHdrAgtmComponentMixingFunction(values) {
    this.initDefaults_();
    this.initFields_(values);
  }


  SkHdrAgtmComponentMixingFunction.prototype.initDefaults_ = function() {
    this.red = 0;
    this.green = 0;
    this.blue = 0;
    this.max = 0;
    this.min = 0;
    this.component = 0;
  };
  SkHdrAgtmComponentMixingFunction.prototype.initFields_ = function(fields) {
    for(var field in fields) {
        if (this.hasOwnProperty(field))
          this[field] = fields[field];
    }
  };

  SkHdrAgtmComponentMixingFunction.validate = function(messageValidator, offset) {
    var err;
    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
    if (err !== validator.validationError.NONE)
        return err;

    var kVersionSizes = [
      {version: 0, numBytes: 32}
    ];
    err = messageValidator.validateStructVersion(offset, kVersionSizes);
    if (err !== validator.validationError.NONE)
        return err;







    return validator.validationError.NONE;
  };

  SkHdrAgtmComponentMixingFunction.encodedSize = codec.kStructHeaderSize + 24;

  SkHdrAgtmComponentMixingFunction.decode = function(decoder) {
    var packed;
    var val = new SkHdrAgtmComponentMixingFunction();
    var numberOfBytes = decoder.readUint32();
    var version = decoder.readUint32();
    val.red =
        decoder.decodeStruct(codec.Float);
    val.green =
        decoder.decodeStruct(codec.Float);
    val.blue =
        decoder.decodeStruct(codec.Float);
    val.max =
        decoder.decodeStruct(codec.Float);
    val.min =
        decoder.decodeStruct(codec.Float);
    val.component =
        decoder.decodeStruct(codec.Float);
    return val;
  };

  SkHdrAgtmComponentMixingFunction.encode = function(encoder, val) {
    var packed;
    encoder.writeUint32(SkHdrAgtmComponentMixingFunction.encodedSize);
    encoder.writeUint32(0);
    encoder.encodeStruct(codec.Float, val.red);
    encoder.encodeStruct(codec.Float, val.green);
    encoder.encodeStruct(codec.Float, val.blue);
    encoder.encodeStruct(codec.Float, val.max);
    encoder.encodeStruct(codec.Float, val.min);
    encoder.encodeStruct(codec.Float, val.component);
  };
  function SkHdrAgtmColorGainFunction(values) {
    this.initDefaults_();
    this.initFields_(values);
  }


  SkHdrAgtmColorGainFunction.prototype.initDefaults_ = function() {
    this.componentMixing = null;
    this.gainCurve = null;
  };
  SkHdrAgtmColorGainFunction.prototype.initFields_ = function(fields) {
    for(var field in fields) {
        if (this.hasOwnProperty(field))
          this[field] = fields[field];
    }
  };

  SkHdrAgtmColorGainFunction.validate = function(messageValidator, offset) {
    var err;
    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
    if (err !== validator.validationError.NONE)
        return err;

    var kVersionSizes = [
      {version: 0, numBytes: 24}
    ];
    err = messageValidator.validateStructVersion(offset, kVersionSizes);
    if (err !== validator.validationError.NONE)
        return err;


    // validate SkHdrAgtmColorGainFunction.componentMixing
    err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 0, SkHdrAgtmComponentMixingFunction, false);
    if (err !== validator.validationError.NONE)
        return err;


    // validate SkHdrAgtmColorGainFunction.gainCurve
    err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 8, SkHdrAgtmGainCurve, false);
    if (err !== validator.validationError.NONE)
        return err;

    return validator.validationError.NONE;
  };

  SkHdrAgtmColorGainFunction.encodedSize = codec.kStructHeaderSize + 16;

  SkHdrAgtmColorGainFunction.decode = function(decoder) {
    var packed;
    var val = new SkHdrAgtmColorGainFunction();
    var numberOfBytes = decoder.readUint32();
    var version = decoder.readUint32();
    val.componentMixing =
        decoder.decodeStructPointer(SkHdrAgtmComponentMixingFunction);
    val.gainCurve =
        decoder.decodeStructPointer(SkHdrAgtmGainCurve);
    return val;
  };

  SkHdrAgtmColorGainFunction.encode = function(encoder, val) {
    var packed;
    encoder.writeUint32(SkHdrAgtmColorGainFunction.encodedSize);
    encoder.writeUint32(0);
    encoder.encodeStructPointer(SkHdrAgtmComponentMixingFunction, val.componentMixing);
    encoder.encodeStructPointer(SkHdrAgtmGainCurve, val.gainCurve);
  };
  function SkHdrAgtmAlternateImage(values) {
    this.initDefaults_();
    this.initFields_(values);
  }


  SkHdrAgtmAlternateImage.prototype.initDefaults_ = function() {
    this.hdrHeadroom = 0;
    this.colorGainFunction = null;
  };
  SkHdrAgtmAlternateImage.prototype.initFields_ = function(fields) {
    for(var field in fields) {
        if (this.hasOwnProperty(field))
          this[field] = fields[field];
    }
  };

  SkHdrAgtmAlternateImage.validate = function(messageValidator, offset) {
    var err;
    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
    if (err !== validator.validationError.NONE)
        return err;

    var kVersionSizes = [
      {version: 0, numBytes: 24}
    ];
    err = messageValidator.validateStructVersion(offset, kVersionSizes);
    if (err !== validator.validationError.NONE)
        return err;



    // validate SkHdrAgtmAlternateImage.colorGainFunction
    err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 8, SkHdrAgtmColorGainFunction, false);
    if (err !== validator.validationError.NONE)
        return err;

    return validator.validationError.NONE;
  };

  SkHdrAgtmAlternateImage.encodedSize = codec.kStructHeaderSize + 16;

  SkHdrAgtmAlternateImage.decode = function(decoder) {
    var packed;
    var val = new SkHdrAgtmAlternateImage();
    var numberOfBytes = decoder.readUint32();
    var version = decoder.readUint32();
    val.hdrHeadroom =
        decoder.decodeStruct(codec.Float);
    decoder.skip(1);
    decoder.skip(1);
    decoder.skip(1);
    decoder.skip(1);
    val.colorGainFunction =
        decoder.decodeStructPointer(SkHdrAgtmColorGainFunction);
    return val;
  };

  SkHdrAgtmAlternateImage.encode = function(encoder, val) {
    var packed;
    encoder.writeUint32(SkHdrAgtmAlternateImage.encodedSize);
    encoder.writeUint32(0);
    encoder.encodeStruct(codec.Float, val.hdrHeadroom);
    encoder.skip(1);
    encoder.skip(1);
    encoder.skip(1);
    encoder.skip(1);
    encoder.encodeStructPointer(SkHdrAgtmColorGainFunction, val.colorGainFunction);
  };
  function SkHdrAgtmHeadroomAdaptiveToneMap(values) {
    this.initDefaults_();
    this.initFields_(values);
  }


  SkHdrAgtmHeadroomAdaptiveToneMap.prototype.initDefaults_ = function() {
    this.baselineHdrHeadroom = 0;
    this.gainApplicationSpacePrimaries = null;
    this.alternateImages = null;
  };
  SkHdrAgtmHeadroomAdaptiveToneMap.prototype.initFields_ = function(fields) {
    for(var field in fields) {
        if (this.hasOwnProperty(field))
          this[field] = fields[field];
    }
  };

  SkHdrAgtmHeadroomAdaptiveToneMap.validate = function(messageValidator, offset) {
    var err;
    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
    if (err !== validator.validationError.NONE)
        return err;

    var kVersionSizes = [
      {version: 0, numBytes: 32}
    ];
    err = messageValidator.validateStructVersion(offset, kVersionSizes);
    if (err !== validator.validationError.NONE)
        return err;



    // validate SkHdrAgtmHeadroomAdaptiveToneMap.gainApplicationSpacePrimaries
    err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 8, skcolorspace_primaries$.SkColorSpacePrimaries, false);
    if (err !== validator.validationError.NONE)
        return err;


    // validate SkHdrAgtmHeadroomAdaptiveToneMap.alternateImages
    err = messageValidator.validateArrayPointer(offset + codec.kStructHeaderSize + 16, 8, new codec.PointerTo(SkHdrAgtmAlternateImage), false, [0], 0);
    if (err !== validator.validationError.NONE)
        return err;

    return validator.validationError.NONE;
  };

  SkHdrAgtmHeadroomAdaptiveToneMap.encodedSize = codec.kStructHeaderSize + 24;

  SkHdrAgtmHeadroomAdaptiveToneMap.decode = function(decoder) {
    var packed;
    var val = new SkHdrAgtmHeadroomAdaptiveToneMap();
    var numberOfBytes = decoder.readUint32();
    var version = decoder.readUint32();
    val.baselineHdrHeadroom =
        decoder.decodeStruct(codec.Float);
    decoder.skip(1);
    decoder.skip(1);
    decoder.skip(1);
    decoder.skip(1);
    val.gainApplicationSpacePrimaries =
        decoder.decodeStructPointer(skcolorspace_primaries$.SkColorSpacePrimaries);
    val.alternateImages =
        decoder.decodeArrayPointer(new codec.PointerTo(SkHdrAgtmAlternateImage));
    return val;
  };

  SkHdrAgtmHeadroomAdaptiveToneMap.encode = function(encoder, val) {
    var packed;
    encoder.writeUint32(SkHdrAgtmHeadroomAdaptiveToneMap.encodedSize);
    encoder.writeUint32(0);
    encoder.encodeStruct(codec.Float, val.baselineHdrHeadroom);
    encoder.skip(1);
    encoder.skip(1);
    encoder.skip(1);
    encoder.skip(1);
    encoder.encodeStructPointer(skcolorspace_primaries$.SkColorSpacePrimaries, val.gainApplicationSpacePrimaries);
    encoder.encodeArrayPointer(new codec.PointerTo(SkHdrAgtmAlternateImage), val.alternateImages);
  };
  function SkHdrAdaptiveGlobalToneMap(values) {
    this.initDefaults_();
    this.initFields_(values);
  }


  SkHdrAdaptiveGlobalToneMap.prototype.initDefaults_ = function() {
    this.hdrReferenceWhite = 0;
    this.headroomAdaptiveToneMap = null;
  };
  SkHdrAdaptiveGlobalToneMap.prototype.initFields_ = function(fields) {
    for(var field in fields) {
        if (this.hasOwnProperty(field))
          this[field] = fields[field];
    }
  };

  SkHdrAdaptiveGlobalToneMap.validate = function(messageValidator, offset) {
    var err;
    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
    if (err !== validator.validationError.NONE)
        return err;

    var kVersionSizes = [
      {version: 0, numBytes: 24}
    ];
    err = messageValidator.validateStructVersion(offset, kVersionSizes);
    if (err !== validator.validationError.NONE)
        return err;



    // validate SkHdrAdaptiveGlobalToneMap.headroomAdaptiveToneMap
    err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 8, SkHdrAgtmHeadroomAdaptiveToneMap, true);
    if (err !== validator.validationError.NONE)
        return err;

    return validator.validationError.NONE;
  };

  SkHdrAdaptiveGlobalToneMap.encodedSize = codec.kStructHeaderSize + 16;

  SkHdrAdaptiveGlobalToneMap.decode = function(decoder) {
    var packed;
    var val = new SkHdrAdaptiveGlobalToneMap();
    var numberOfBytes = decoder.readUint32();
    var version = decoder.readUint32();
    val.hdrReferenceWhite =
        decoder.decodeStruct(codec.Float);
    decoder.skip(1);
    decoder.skip(1);
    decoder.skip(1);
    decoder.skip(1);
    val.headroomAdaptiveToneMap =
        decoder.decodeStructPointer(SkHdrAgtmHeadroomAdaptiveToneMap);
    return val;
  };

  SkHdrAdaptiveGlobalToneMap.encode = function(encoder, val) {
    var packed;
    encoder.writeUint32(SkHdrAdaptiveGlobalToneMap.encodedSize);
    encoder.writeUint32(0);
    encoder.encodeStruct(codec.Float, val.hdrReferenceWhite);
    encoder.skip(1);
    encoder.skip(1);
    encoder.skip(1);
    encoder.skip(1);
    encoder.encodeStructPointer(SkHdrAgtmHeadroomAdaptiveToneMap, val.headroomAdaptiveToneMap);
  };
  exports.SkHdrContentLightLevelInformation = SkHdrContentLightLevelInformation;
  exports.SkHdrMasteringDisplayColorVolume = SkHdrMasteringDisplayColorVolume;
  exports.SkHdrAgtmGainCurveControlPoint = SkHdrAgtmGainCurveControlPoint;
  exports.SkHdrAgtmGainCurve = SkHdrAgtmGainCurve;
  exports.SkHdrAgtmComponentMixingFunction = SkHdrAgtmComponentMixingFunction;
  exports.SkHdrAgtmColorGainFunction = SkHdrAgtmColorGainFunction;
  exports.SkHdrAgtmAlternateImage = SkHdrAgtmAlternateImage;
  exports.SkHdrAgtmHeadroomAdaptiveToneMap = SkHdrAgtmHeadroomAdaptiveToneMap;
  exports.SkHdrAdaptiveGlobalToneMap = SkHdrAdaptiveGlobalToneMap;
})();