function decode(image, src) {
  if (src) {
    image.src = src;
  }
  return image.src && IMAGE_DECODE && CREATE_IMAGE_BITMAP
    ? image
        .decode()
        .then(() => createImageBitmap(image))
        .catch((e) => {
          if (image.complete && image.width) {
            return image;
          }
          throw e;
        })
    : decodeFallback(image);
}
Loads an image and decodes it to an `ImageBitmap` if `createImageBitmap()` is supported. Returns
the loaded image otherwise.
@param {HTMLImageElement} image Image, not yet loaded.
@param {string} [src] `src` attribute of the image. Optional, not required if already present.
@return {Promise<ImageBitmap|HTMLImageElement>} Promise resolving to an `ImageBitmap` or an
`HTMLImageElement` if `createImageBitmap()` is not supported.
@api