hwc: virtual display: Use outbuf handle width to configure xres

Use outbuf handle width to configure display xres, since that would
have the necessary alignment. The outbuf is guaranteed to be valid
by the framework during hwc_prepare.

We use the framebuffer layer's display frame to obtain the actual
width. For example, the actual width could be 720 but the aligned
width would be 736.

Change-Id: I5afe38001be8116e1ad6a9f46c7ecaa50b5f25a2
diff --git a/libhwcomposer/hwc_virtual.cpp b/libhwcomposer/hwc_virtual.cpp
index fec5222..51ade32 100644
--- a/libhwcomposer/hwc_virtual.cpp
+++ b/libhwcomposer/hwc_virtual.cpp
@@ -90,7 +90,7 @@
     hwc_context_t* ctx = (hwc_context_t*)(dev);
     const int dpy = HWC_DISPLAY_VIRTUAL;
 
-    if (list && list->numHwLayers > 0) {
+    if (list && list->outbuf && list->numHwLayers > 0) {
         reset_layer_prop(ctx, dpy, list->numHwLayers - 1);
         uint32_t last = list->numHwLayers - 1;
         hwc_layer_1_t *fbLayer = &list->hwLayers[last];
@@ -108,7 +108,8 @@
 
         ctx->dpyAttr[dpy].isConfiguring = false;
         ctx->dpyAttr[dpy].fd = Writeback::getInstance()->getFbFd();
-        Writeback::getInstance()->configureDpyInfo(fbWidth, fbHeight);
+        private_handle_t *ohnd = (private_handle_t *)list->outbuf;
+        Writeback::getInstance()->configureDpyInfo(ohnd->width, ohnd->height);
         setListStats(ctx, list, dpy);
 
         if(ctx->mMDPComp[dpy]->prepare(ctx, list) < 0) {