Snap for 6300905 from 95ca2cbe4d480dbd98927f8a9930e6a65d132897 to qt-d4-release

Change-Id: I6bcca226434768cdbf15d0b2593116bcf4e01970
diff --git a/sdm/include/utils/constants.h b/sdm/include/utils/constants.h
index ffa8d12..f97f539 100644
--- a/sdm/include/utils/constants.h
+++ b/sdm/include/utils/constants.h
@@ -79,6 +79,12 @@
   const int kPageSize = 4096;
   const uint32_t kGridSize = 129;  // size used for non-linear transformation before Tone-mapping
   const uint32_t kLutDim = 17;  // Dim of the 3d LUT for tone-mapping.
+  constexpr int kColorTransformMatrixSize = 16;
+  constexpr float kIdentityMatrix[kColorTransformMatrixSize] = { 1.0, 0.0, 0.0, 0.0,
+                                                                 0.0, 1.0, 0.0, 0.0,
+                                                                 0.0, 0.0, 1.0, 0.0,
+                                                                 0.0, 0.0, 0.0, 1.0 };
+
 
   typedef void * Handle;
 
diff --git a/sdm/libs/hwc2/hwc_display.cpp b/sdm/libs/hwc2/hwc_display.cpp
index 8c14a4c..25c6d8d 100644
--- a/sdm/libs/hwc2/hwc_display.cpp
+++ b/sdm/libs/hwc2/hwc_display.cpp
@@ -669,6 +669,10 @@
       layer->flags.skip = true;
     }
 
+    if (hwc_layer->IsColorTransformSet()) {
+      layer->flags.skip = true;
+    }
+
     // set default composition as GPU for SDM
     layer->composition = kCompositionGPU;
 
diff --git a/sdm/libs/hwc2/hwc_layers.cpp b/sdm/libs/hwc2/hwc_layers.cpp
index 68f6838..b8bcf76 100644
--- a/sdm/libs/hwc2/hwc_layers.cpp
+++ b/sdm/libs/hwc2/hwc_layers.cpp
@@ -545,6 +545,12 @@
   return HWC2::Error::None;
 }
 
+HWC2::Error HWCLayer::SetLayerColorTransform(const float *matrix) {
+  color_transform_matrix_set_ =
+      (std::memcmp(matrix, kIdentityMatrix, sizeof(kIdentityMatrix)) != 0);
+  return HWC2::Error::None;
+}
+
 HWC2::Error HWCLayer::SetLayerPerFrameMetadata(uint32_t num_elements,
                                                const PerFrameMetadataKey *keys,
                                                const float *metadata) {
diff --git a/sdm/libs/hwc2/hwc_layers.h b/sdm/libs/hwc2/hwc_layers.h
index cef4937..d1287c6 100644
--- a/sdm/libs/hwc2/hwc_layers.h
+++ b/sdm/libs/hwc2/hwc_layers.h
@@ -91,6 +91,7 @@
   HWC2::Error SetLayerPerFrameMetadata(uint32_t num_elements, const PerFrameMetadataKey *keys,
                                        const float *metadata);
   HWC2::Error SetLayerZOrder(uint32_t z);
+  HWC2::Error SetLayerColorTransform(const float *matrix);
   void SetComposition(const LayerComposition &sdm_composition);
   HWC2::Composition GetClientRequestedCompositionType() { return client_requested_; }
   void UpdateClientCompositionType(HWC2::Composition type) { client_requested_ = type; }
@@ -112,6 +113,7 @@
   void SetPartialUpdate(bool enabled) { partial_update_enabled_ = enabled; }
   bool IsNonIntegralSourceCrop() { return non_integral_source_crop_; }
   bool HasMetaDataRefreshRate() { return has_metadata_refresh_rate_; }
+  bool IsColorTransformSet() const { return color_transform_matrix_set_; }
   void SetLayerAsMask();
   bool BufferLatched() { return buffer_flipped_; }
   void ResetBufferFlip() { buffer_flipped_ = false; }
@@ -134,6 +136,7 @@
   bool surface_updated_ = true;
   bool non_integral_source_crop_ = false;
   bool has_metadata_refresh_rate_ = false;
+  bool color_transform_matrix_set_ = false;
   bool buffer_flipped_ = false;
 
   // Composition requested by client(SF)
diff --git a/sdm/libs/hwc2/hwc_session.cpp b/sdm/libs/hwc2/hwc_session.cpp
index 58d1653..3b5a4af 100644
--- a/sdm/libs/hwc2/hwc_session.cpp
+++ b/sdm/libs/hwc2/hwc_session.cpp
@@ -1009,6 +1009,12 @@
   return HWCSession::CallDisplayFunction(device, display, &HWCDisplay::SetLayerZOrder, layer, z);
 }
 
+static int32_t SetLayerColorTransform(hwc2_device_t *device, hwc2_display_t display,
+                                      hwc2_layer_t layer, const float *matrix) {
+  return HWCSession::CallLayerFunction(device, display, layer, &HWCLayer::SetLayerColorTransform,
+                                       matrix);
+}
+
 int32_t HWCSession::SetOutputBuffer(hwc2_device_t *device, hwc2_display_t display,
                                     buffer_handle_t buffer, int32_t releaseFence) {
   if (!device) {
@@ -1321,6 +1327,8 @@
       return AsFP<HWC2_PFN_SET_LAYER_VISIBLE_REGION>(SetLayerVisibleRegion);
     case HWC2::FunctionDescriptor::SetLayerZOrder:
       return AsFP<HWC2_PFN_SET_LAYER_Z_ORDER>(SetLayerZOrder);
+    case HWC2::FunctionDescriptor::SetLayerColorTransform:
+      return AsFP<HWC2_PFN_SET_LAYER_COLOR_TRANSFORM>(SetLayerColorTransform);
     case HWC2::FunctionDescriptor::SetOutputBuffer:
       return AsFP<HWC2_PFN_SET_OUTPUT_BUFFER>(SetOutputBuffer);
     case HWC2::FunctionDescriptor::SetPowerMode: