hwc: Minor bug fixes.

Some minor bug fixes.

Change-Id: Ie8c2f58b9c6db6e77739e4693da503f6f963827d
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index a28750d..ab55ea6 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -75,16 +75,23 @@
     init_uevent_thread(ctx);
 }
 
+//Helper
+static void reset() {
+    //reset for this draw round
+    VideoOverlay::reset();
+    ExtOnly::reset();
+    UIMirrorOverlay::reset();
+    ExtOnly::reset();
+    //TODO MDPComp
+}
+
 static int hwc_prepare(hwc_composer_device_1 *dev, size_t numDisplays,
                        hwc_display_contents_1_t** displays)
 {
     hwc_context_t* ctx = (hwc_context_t*)(dev);
     ctx->overlayInUse = false;
 
-    //reset for this draw round
-    VideoOverlay::reset();
-    ExtOnly::reset();
-    UIMirrorOverlay::reset();
+    reset();
 
     //If securing of h/w in progress skip comp using overlay.
     if(ctx->mSecuring == true) return 0;
diff --git a/libhwcomposer/hwc_uevents.cpp b/libhwcomposer/hwc_uevents.cpp
index f9e8a2d..3c1707b 100644
--- a/libhwcomposer/hwc_uevents.cpp
+++ b/libhwcomposer/hwc_uevents.cpp
@@ -17,9 +17,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#define DEBUG 0
-#ifndef HWC_OBSERVER_H
-#define HWC_OBSERVER_H
+#define UEVENT_DEBUG 0
 #include <hardware_legacy/uevent.h>
 #include <utils/Log.h>
 #include <sys/resource.h>
@@ -43,7 +41,7 @@
     int hdmiconnected = ctx->mExtDisplay->getExternalDisplay();
 
     if(!strcasestr(str, "@/devices/virtual/graphics/fb")) {
-        ALOGD_IF(DEBUG, "%s: Not Ext Disp Event ", __FUNCTION__);
+        ALOGD_IF(UEVENT_DEBUG, "%s: Not Ext Disp Event ", __FUNCTION__);
         return;
     }
 
@@ -113,4 +111,3 @@
 }
 
 }; //namespace
-#endif //HWC_OBSERVER_H
diff --git a/libhwcomposer/hwc_video.cpp b/libhwcomposer/hwc_video.cpp
index 141d83b..daf3f80 100644
--- a/libhwcomposer/hwc_video.cpp
+++ b/libhwcomposer/hwc_video.cpp
@@ -52,7 +52,7 @@
             ccLayer = &list->hwLayers[sCCLayerIndex];
 
         if(configure(ctx, yuvLayer, ccLayer)) {
-            markFlags(&list->hwLayers[sYuvLayerIndex]);
+            markFlags(yuvLayer, ccLayer);
             sIsModeOn = true;
         }
     }
@@ -90,15 +90,23 @@
             ovutils::getStateString(sState));
 }
 
-void VideoOverlay::markFlags(hwc_layer_1_t *layer) {
+void VideoOverlay::markFlags(hwc_layer_1_t *yuvLayer, hwc_layer_1_t *ccLayer) {
     switch(sState) {
         case ovutils::OV_2D_VIDEO_ON_PANEL:
         case ovutils::OV_2D_VIDEO_ON_PANEL_TV:
-            layer->compositionType = HWC_OVERLAY;
-            layer->hints |= HWC_HINT_CLEAR_FB;
+            if(yuvLayer) {
+                yuvLayer->compositionType = HWC_OVERLAY;
+                yuvLayer->hints |= HWC_HINT_CLEAR_FB;
+            }
+            if(ccLayer) {
+                ccLayer->compositionType = HWC_OVERLAY;
+            }
             break;
         case ovutils::OV_2D_VIDEO_ON_TV:
-            break; //dont update flags.
+            if(ccLayer) {
+                ccLayer->compositionType = HWC_OVERLAY;
+            }
+            break; //dont update video layer flags.
         default:
             break;
     }
diff --git a/libhwcomposer/hwc_video.h b/libhwcomposer/hwc_video.h
index 40a7c14..ec8fa21 100644
--- a/libhwcomposer/hwc_video.h
+++ b/libhwcomposer/hwc_video.h
@@ -41,7 +41,7 @@
     static bool configure(hwc_context_t *ctx, hwc_layer_1_t *yuvlayer,
             hwc_layer_1_t *ccLayer);
     //Marks layer flags if this feature is used
-    static void markFlags(hwc_layer_1_t *layer);
+    static void markFlags(hwc_layer_1_t *yuvLayer, hwc_layer_1_t *ccLayer);
     //returns yuv count
     static int getYuvCount();