Add SkJpegGainmapEncoder::EncodeJpegR and EncodeHDRGM

Add a SkJpegGainmapEncoder class that is a friend of SkJpegEncoder and
add the functions SkJpegGainmapEncoder::EncodeJpegR and EncodeHDRGM.

This requires adding two new pieces of data to the SkJpegEncoder.
First is a list of new segments. For both JpegR and HDRGM, this
includes the XMP metadata. For HDRM this includes segments for the
encoded gainmap image. Second is a "suffix" to append to the end of
the base image. For JpegR, this is the encoded gainmap image.

Send the new segments to jpeg_write_marker (just like is currently
done for the ICC profile).

Plumb the "suffix" through to the skjpeg_destination_mgr, to be
appended after image is done writing (but before the stream is
flushed).

In both EncodeJpegR and EncodeHDRGM function, hard-code the XMP
metadata string (rather than constructing and serializing an SkDOM).

Include the math to transcode from any gainmap representation to
JpegR.

Add a test that transcodes an MPF gainmap image to a JpegR and
HDRGM image, and ensures that the rendered results are the same (up
to rounding error).

Bug: skia:14031
Change-Id: I7222fba2770da050cddd46f10c139b4d33db20cc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/631103
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Christopher Cameron <ccameron@google.com>
8 files changed