surfaceflinger: add BT2020_PQ support to RenderEngine

Add Key::Y410_BT2020_ON which performs Y410/BT2020 YUV -> RGB
conversion.

Add Key::{INPUT,OUTPUT}_TF_ST2084 which performs ST2084 EOTF and
OETF conversions.

Add Key::TONE_MAP_ON which performs tone-mapping.

Flip proper bits on when the source buffer has BT2020_PQ as its
dataspace.  That means,

  1. convert YUV to RGB
  2. apply ST 2084 EOTF
  3. apply tone-mapping
  4. convert to DisplayP3
  5. apply relative rendering intent (i.e., clamp)
  6. finally apply sRGB OETF

We still use hardcoded parameters rather than the ones from HDR
metadata.  It is also likely that we will need to switch to a LUT
for better perf.

Test: manual
Change-Id: I53556a2acfc34ef55e88c5b139000be94072dd3e
diff --git a/services/surfaceflinger/RenderEngine/Description.h b/services/surfaceflinger/RenderEngine/Description.h
index b0b08fe..75c1981 100644
--- a/services/surfaceflinger/RenderEngine/Description.h
+++ b/services/surfaceflinger/RenderEngine/Description.h
@@ -45,13 +45,18 @@
     void setColorMatrix(const mat4& mtx);
     const mat4& getColorMatrix() const;
 
+    void setY410BT2020(bool enable);
+
     enum class TransferFunction : int {
         LINEAR,
         SRGB,
+        ST2084,
     };
     void setInputTransferFunction(TransferFunction transferFunction);
     void setOutputTransferFunction(TransferFunction transferFunction);
 
+    void enableToneMapping(bool enable);
+
 private:
     friend class Program;
     friend class ProgramCache;
@@ -73,9 +78,15 @@
     bool mColorMatrixEnabled = false;
     mat4 mColorMatrix;
 
+    // true if the sampled pixel values are in Y410/BT2020 rather than RGBA
+    bool mY410BT2020 = false;
+
     // transfer functions for the input/output
     TransferFunction mInputTransferFunction = TransferFunction::LINEAR;
     TransferFunction mOutputTransferFunction = TransferFunction::LINEAR;
+
+    // tone-map the color
+    bool mToneMappingEnabled = false;
 };
 
 } /* namespace android */