sdm: Add support for dynamic layer mixer resolution change.

1. Define binder API to change layer mixer resolution.
2. Honor layer mixer resolution change request only if the hardware
   supports destination scaler.
3. Give preference to panel scaling over destination scaling, as panel
   scaling requires less bandwidth.
4. Disable partial update for a frame on mixer resolution change.

CRs-Fixed: 1005180
Change-Id: I3d4e48c8853a941f12703915b33c3a0a4df09af2
diff --git a/sdm/libs/utils/rect.cpp b/sdm/libs/utils/rect.cpp
index e756464..1872df2 100644
--- a/sdm/libs/utils/rect.cpp
+++ b/sdm/libs/utils/rect.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -198,5 +198,40 @@
   }
 }
 
+void ScaleRect(const LayerRect &src_domain, const LayerRect &dst_domain, const LayerRect &in_rect,
+               LayerRect *out_rect) {
+  if (!IsValid(src_domain) || !IsValid(dst_domain) || !IsValid(in_rect)) {
+    return;
+  }
+
+  float src_domain_width = src_domain.right - src_domain.left;
+  float src_domain_height = src_domain.bottom - src_domain.top;
+  float dst_domain_width = dst_domain.right - dst_domain.left;
+  float dst_domain_height = dst_domain.bottom - dst_domain.top;
+
+  float width_ratio = dst_domain_width / src_domain_width;
+  float height_ratio = dst_domain_height / src_domain_height;
+
+  out_rect->left = width_ratio * in_rect.left;
+  out_rect->top = height_ratio * in_rect.top;
+  out_rect->right = width_ratio * in_rect.right;
+  out_rect->bottom = height_ratio * in_rect.bottom;
+}
+
+RectOrientation GetOrientation(const LayerRect &in_rect) {
+  if (!IsValid(in_rect)) {
+    return kOrientationUnknown;
+  }
+
+  float input_width = in_rect.right - in_rect.left;
+  float input_height = in_rect.bottom - in_rect.top;
+
+  if (input_width < input_height) {
+    return kOrientationPortrait;
+  }
+
+  return kOrientationLandscape;
+}
+
 }  // namespace sdm