Merge "hwc: vds: Display HAL changes for VDS based solution"
diff --git a/libhwcomposer/hwc_virtual.cpp b/libhwcomposer/hwc_virtual.cpp
index b4c61b0..c081400 100644
--- a/libhwcomposer/hwc_virtual.cpp
+++ b/libhwcomposer/hwc_virtual.cpp
@@ -104,9 +104,14 @@
 
         if(ctx->dpyAttr[dpy].connected == false) {
             ctx->dpyAttr[dpy].connected = true;
+            // We set the vsync period to the primary refresh rate, leaving
+            // it up to the consumer to decide how fast to consume frames.
+            ctx->dpyAttr[dpy].vsync_period
+                              = ctx->dpyAttr[HWC_DISPLAY_PRIMARY].vsync_period;
             init(ctx);
-            //First round, just setup and return so primary can free pipes
-            return 0;
+            // XXX: for architectures with limited resources we would normally
+            // allow one padding round to free up resources but this breaks
+            // certain use cases.
         }
 
         ctx->dpyAttr[dpy].isConfiguring = false;
@@ -132,8 +137,7 @@
         uint32_t last = list->numHwLayers - 1;
         hwc_layer_1_t *fbLayer = &list->hwLayers[last];
 
-        if(fbLayer->handle && !isSecondaryConfiguring(ctx) &&
-                !ctx->mMDPComp[dpy]->isGLESOnlyComp()) {
+        if(ctx->dpyAttr[dpy].connected) {
             private_handle_t *ohnd = (private_handle_t *)list->outbuf;
             int format = ohnd->format;
             if (format == HAL_PIXEL_FORMAT_RGBA_8888)
@@ -157,7 +161,13 @@
                 ALOGE("%s: MDPComp draw failed", __FUNCTION__);
                 ret = -1;
             }
-            if (!ctx->mFBUpdate[dpy]->draw(ctx,
+            // We need an FB layer handle check to cater for this usecase:
+            // Video is playing in landscape on primary, then launch
+            // ScreenRecord app.
+            // In this scenario, the first VDS draw call will have HWC
+            // composition and VDS does nit involve GPU to get eglSwapBuffer
+            // to get valid fb handle.
+            if (fbLayer->handle && !ctx->mFBUpdate[dpy]->draw(ctx,
                         (private_handle_t *)fbLayer->handle)) {
                 ALOGE("%s: FBUpdate::draw fail!", __FUNCTION__);
                 ret = -1;