hwc: Use viewframe to compute display position and crop.

1. Use viewframe of external display to compute Aspect ratio position
   for external.
2. Use viewframe to find the crop rectangle of the frame buffer to
   configure rotator for external orientation usecase.

Change-Id: I564c70f202176c8b1f707cbafc08cbbb2abde383
diff --git a/libhwcomposer/hwc_fbupdate.cpp b/libhwcomposer/hwc_fbupdate.cpp
index bb9adbf..0ca5ad9 100644
--- a/libhwcomposer/hwc_fbupdate.cpp
+++ b/libhwcomposer/hwc_fbupdate.cpp
@@ -78,13 +78,17 @@
     if(mDpy && (extOrient & HWC_TRANSFORM_ROT_90)) {
         mRot = ctx->mRotMgr->getNext();
         if(mRot == NULL) return false;
+        // Composed FB content will have black bars, if the viewFrame of the
+        // external is different from {0, 0, fbWidth, fbHeight}, so intersect
+        // viewFrame with sourceCrop to avoid those black bars
+        sourceCrop = getIntersection(sourceCrop, ctx->mViewFrame[mDpy]);
         //Configure rotator for pre-rotation
         if(configRotator(mRot, info, sourceCrop, mdpFlags, orient, 0) < 0) {
             ALOGE("%s: configRotator Failed!", __FUNCTION__);
             mRot = NULL;
             return false;
         }
-       ctx->mLayerRotMap[mDpy]->add(layer, mRot);
+        ctx->mLayerRotMap[mDpy]->add(layer, mRot);
         info.format = (mRot)->getDstFormat();
         updateSource(orient, info, sourceCrop);
         rotFlags |= ovutils::ROT_PREROTATED;