Merge "gralloc: Default camera buffers to full range" into dev-2.0
diff --git a/sdm/libs/hwc/hwc_display.cpp b/sdm/libs/hwc/hwc_display.cpp
index ba4c23c..0948663 100644
--- a/sdm/libs/hwc/hwc_display.cpp
+++ b/sdm/libs/hwc/hwc_display.cpp
@@ -609,6 +609,10 @@
   }
 
   size_t num_hw_layers = content_list->numHwLayers;
+  if (num_hw_layers <= 1) {
+    flush_ = true;
+    return 0;
+  }
 
   if (!skip_prepare_) {
     DisplayError error = display_intf_->Prepare(&layer_stack_);
diff --git a/sdm/libs/hwc/hwc_display_external.cpp b/sdm/libs/hwc/hwc_display_external.cpp
old mode 100755
new mode 100644
index 3fe283f..9b175d9
--- a/sdm/libs/hwc/hwc_display_external.cpp
+++ b/sdm/libs/hwc/hwc_display_external.cpp
@@ -150,13 +150,16 @@
     return;
   }
 
+  uint32_t new_panel_width = panel_width * (1.0f - width_ratio);
+  uint32_t new_panel_height = panel_height * (1.0f - height_ratio);
+
   int x_offset = INT((FLOAT(panel_width) * width_ratio) / 2.0f);
   int y_offset = INT((FLOAT(panel_height) * height_ratio) / 2.0f);
 
-  display_frame->left = display_frame->left + x_offset;
-  display_frame->top = display_frame->top + y_offset;
-  display_frame->right = display_frame->right - x_offset;
-  display_frame->bottom = display_frame->bottom - y_offset;
+  display_frame->left = ((display_frame->left * new_panel_width) / panel_width) + x_offset;
+  display_frame->top = ((display_frame->top * new_panel_height) / panel_height) + y_offset;
+  display_frame->right = ((display_frame->right * new_panel_width) / panel_width) + x_offset;
+  display_frame->bottom = ((display_frame->bottom * new_panel_height) / panel_height) + y_offset;
 }
 
 void HWCDisplayExternal::SetSecureDisplay(bool secure_display_active) {