display : Add wormholeRegion Calculation

For copybit cases we should clear wormhole region
rather than nonwormhole. Adding support to calculate
and clear the same.

Change-Id: Ie85d1b484174199e35f43ce95b30de1fac9c30b2
diff --git a/libhwcomposer/hwc_copybit.cpp b/libhwcomposer/hwc_copybit.cpp
index f819264..6488173 100644
--- a/libhwcomposer/hwc_copybit.cpp
+++ b/libhwcomposer/hwc_copybit.cpp
@@ -2,8 +2,7 @@
  * Copyright (C) 2010 The Android Open Source Project
  * Copyright (C) 2012-2013, The Linux Foundation. All rights reserved.
  *
- * Not a Contribution, Apache license notifications and license are retained
- * for attribution purposes only.
+ * Not a Contribution.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,7 +24,9 @@
 #include "hwc_copybit.h"
 #include "comptype.h"
 #include "gr.h"
+#include "cb_utils.h"
 
+using namespace qdutils;
 namespace qhwc {
 
 struct range {
@@ -275,20 +276,18 @@
             close(mRelFd[0]);
             mRelFd[0] = -1;
         }
-
-        //Clear the visible region on the render buffer
-        //XXX: Do this only when needed.
-        hwc_rect_t clearRegion;
-        getNonWormholeRegion(list, clearRegion);
-        clear(renderBuffer, clearRegion);
     } else {
         if(mRelFd[0] >=0) {
             copybit_device_t *copybit = getCopyBitDevice();
             copybit->set_sync(copybit, mRelFd[0]);
         }
-        hwc_rect_t clearRegion = {0,0,0,0};
-        clear(renderBuffer, clearRegion);
     }
+
+    //Clear the transparent or left out region on the render buffer
+    hwc_rect_t clearRegion = {0,0,0,0};
+    if(CBUtils::getuiClearRegion(list, clearRegion, layerProp))
+        clear(renderBuffer, clearRegion);
+
     // numAppLayers-1, as we iterate from 0th layer index with HWC_COPYBIT flag
     for (int i = 0; i <= (ctx->listStats[dpy].numAppLayers-1); i++) {
         hwc_layer_1_t *layer = &list->hwLayers[i];