hwc: consider landscape panels for calculating aspect ratio

Need to consider the primary panel native orientation(portrait or
landscape) while calculating the aspect ratio for external display

Change-Id: Ic37c719fe736b6957d975ebefa9972b1ba3ccf7f
CRs-fixed: 497272
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index e8641ff..7bea65e 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -308,12 +308,19 @@
     switch(orientation) {
         case HAL_TRANSFORM_ROT_90:
         case HAL_TRANSFORM_ROT_270:
-            x = (fbWidth - (ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres
-                        * fbHeight/ctx->dpyAttr[HWC_DISPLAY_PRIMARY].yres))/2;
             y = 0;
-            w = (ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres *
-                    fbHeight/ctx->dpyAttr[HWC_DISPLAY_PRIMARY].yres);
             h = fbHeight;
+            if (ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres <
+                ctx->dpyAttr[HWC_DISPLAY_PRIMARY].yres) {
+                // Portrait primary panel
+                w = (ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres *
+                     fbHeight/ctx->dpyAttr[HWC_DISPLAY_PRIMARY].yres);
+            } else {
+                //Landscape primary panel
+                w = (ctx->dpyAttr[HWC_DISPLAY_PRIMARY].yres *
+                     fbHeight/ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres);
+            }
+            x = (fbWidth - w)/2;
             break;
         default:
             //Do nothing