Skip to content
  • Ell's avatar
    app: future-proof XCF layer blend/composite props · e7d781ff
    Ell authored
    The layer blend space, composite space, and composite mode
    properties have a special AUTO value, which may map to different
    concrete values based on the layer mode.  Make sure we can change
    this mapping in the future, without affecting existing XCFs (saved
    after this commit), by encoding these properties as follows:
    
    When saving an XCF, if the property has a concrete (non-AUTO)
    value, which is always positive, encode it as is.  If the property
    is AUTO, which is always 0, encode it as the negative of the value
    it actually maps to at the time of saving (note that in some cases
    AUTO may map to AUTO, in which case it's encoded as 0).
    
    When loading an XCF, if the encoded property (stored in the file)
    is nonnegative, use it as is.  Otherwise, compare the negative of
    the encoded property to the value AUTO maps to at the time of
    loading.  If the values are equal, set the property to AUTO;
    otherwise, use the concrete value (i.e., the negative of the value
    stored in the XCF).
    
    Note that XCFs saved prior to this commit still load fine, it's
    simply that if we change the AUTO mapping in the future, all their
    AUTO properties will keep being loaded as AUTO, even if the
    resulting concrete values will have changed.
    e7d781ff