hwc: Support for windowboxing feature on external

1. This feature is targeted to remove any window/pillar boxing on
   external display when zoom mode is enabled.
2. Preserve the aspect ratio of the external display by cropping and
   upscaling the tagged video layer during video playback on external.
3. User can tag the layers to be displayed on external display.
4. Set sys.hwc.windowbox_feature to true to enable this feature

Assumptions & Limitation:
    1. Tagged layers for external display will also be displayed on
       primary display along with untagged layers
    2. When zoom in mode is enabled, source crop left and source crop
       top of a tagged video layer is always assumed to be set to
       positive integer value. So pinch zoom feature or zooming in top
       left corner of the video use case cannot be supported.
    3. Except tagged video layers, all other tagged UI layers will
       use GPU for composition on external display, So all tagged UI
       layers cannot be secure layer.
    4. Rotation animation cannot be supported for this feature.

Change-Id: I8b934cf616ec23b4359d0120f9a291178a2781c6
diff --git a/libhwcomposer/hwc_utils.h b/libhwcomposer/hwc_utils.h
index 3d97319..c443bf8 100644
--- a/libhwcomposer/hwc_utils.h
+++ b/libhwcomposer/hwc_utils.h
@@ -182,6 +182,12 @@
     HWC_COPYBIT = 0x00000002,
 };
 
+// AIV specific flags
+enum {
+    HWC_AIV_VIDEO = 0x80000000,
+    HWC_AIV_CC    = 0x40000000,
+};
+
 // HAL specific features
 enum {
     HWC_COLOR_FILL = 0x00000008,
@@ -372,6 +378,12 @@
 void updateSource(ovutils::eTransform& orient, ovutils::Whf& whf,
         hwc_rect_t& crop, overlay::Rotator *rot);
 
+bool isZoomModeEnabled(hwc_rect_t crop);
+void updateCropAIVVideoMode(hwc_context_t *ctx, hwc_rect_t& crop, int dpy);
+void updateDestAIVVideoMode(hwc_context_t *ctx, hwc_rect_t& dst, int dpy);
+void updateExtDisplayCoordinates(hwc_context_t *ctx, hwc_rect_t& crop,
+                           hwc_rect_t& dst, int dpy);
+
 //Routine to configure low resolution panels (<= 2048 width)
 int configureNonSplit(hwc_context_t *ctx, hwc_layer_1_t *layer, const int& dpy,
         ovutils::eMdpFlags& mdpFlags, ovutils::eZorder& z,
@@ -419,6 +431,14 @@
     return (UNLIKELY(l && (l->flags & HWC_SKIP_LAYER)));
 }
 
+static inline bool isAIVVideoLayer(const hwc_layer_1_t* l) {
+    return (UNLIKELY(l && (l->flags & HWC_AIV_VIDEO)));
+}
+
+static inline bool isAIVCCLayer(const hwc_layer_1_t* l) {
+    return (UNLIKELY(l && (l->flags & HWC_AIV_CC)));
+}
+
 // Returns true if the buffer is yuv
 static inline bool isYuvBuffer(const private_handle_t* hnd) {
     return (hnd && (hnd->bufferType == BUFFER_TYPE_VIDEO));
@@ -598,6 +618,9 @@
     bool mThermalBurstMode;
     //Layers out of ROI
     bool copybitDrop[MAX_NUM_APP_LAYERS];
+    // Flags related to windowboxing feature
+    bool mAIVVideoMode[HWC_NUM_DISPLAY_TYPES];
+    bool mWindowboxFeature;
 };
 
 namespace qhwc {