Home | History | Annotate | Download | only in libhwcomposer
      1 /*
      2  * Copyright (C) 2010 The Android Open Source Project
      3  * Copyright (C)2012-2014, The Linux Foundation. All rights reserved.
      4  *
      5  * Not a Contribution, Apache license notifications and license are retained
      6  * for attribution purposes only.
      7  *
      8  * Licensed under the Apache License, Version 2.0 (the "License");
      9  * you may not use this file except in compliance with the License.
     10  * You may obtain a copy of the License at
     11  *
     12  *      http://www.apache.org/licenses/LICENSE-2.0
     13  *
     14  * Unless required by applicable law or agreed to in writing, software
     15  * distributed under the License is distributed on an "AS IS" BASIS,
     16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     17  * See the License for the specific language governing permissions and
     18  * limitations under the License.
     19  */
     20 
     21 #ifndef HWC_UTILS_H
     22 #define HWC_UTILS_H
     23 
     24 #define HWC_REMOVE_DEPRECATED_VERSIONS 1
     25 #include <fcntl.h>
     26 #include <math.h>
     27 #include <hardware/hwcomposer.h>
     28 #include <gr.h>
     29 #include <gralloc_priv.h>
     30 #include <utils/String8.h>
     31 #include "qdMetaData.h"
     32 #include <overlayUtils.h>
     33 #include <EGL/egl.h>
     34 
     35 
     36 #define ALIGN_TO(x, align)     (((x) + ((align)-1)) & ~((align)-1))
     37 #define LIKELY( exp )       (__builtin_expect( (exp) != 0, true  ))
     38 #define UNLIKELY( exp )     (__builtin_expect( (exp) != 0, false ))
     39 #define MAX_NUM_APP_LAYERS 32
     40 #define MIN_DISPLAY_XRES 200
     41 #define MIN_DISPLAY_YRES 200
     42 #define HWC_WFDDISPSYNC_LOG 0
     43 #define STR(f) #f;
     44 // Max number of PTOR layers handled
     45 #define MAX_PTOR_LAYERS 2
     46 
     47 //Fwrd decls
     48 struct hwc_context_t;
     49 
     50 namespace ovutils = overlay::utils;
     51 
     52 namespace overlay {
     53 class Overlay;
     54 class Rotator;
     55 class RotMgr;
     56 }
     57 
     58 namespace qhwc {
     59 //fwrd decl
     60 class QueuedBufferStore;
     61 class ExternalDisplay;
     62 class VirtualDisplay;
     63 class IFBUpdate;
     64 class IVideoOverlay;
     65 class MDPComp;
     66 class CopyBit;
     67 class HwcDebug;
     68 class AssertiveDisplay;
     69 class HWCVirtualBase;
     70 
     71 
     72 struct MDPInfo {
     73     int version;
     74     char panel;
     75     bool hasOverlay;
     76 };
     77 
     78 struct DisplayAttributes {
     79     uint32_t vsync_period; //nanos
     80     uint32_t xres;
     81     uint32_t yres;
     82     uint32_t stride;
     83     float xdpi;
     84     float ydpi;
     85     int fd;
     86     bool connected; //Applies only to pluggable disp.
     87     //Connected does not mean it ready to use.
     88     //It should be active also. (UNBLANKED)
     89     bool isActive;
     90     // In pause state, composition is bypassed
     91     // used for WFD displays only
     92     bool isPause;
     93     // To trigger padding round to clean up mdp
     94     // pipes
     95     bool isConfiguring;
     96     // External Display is in MDP Downscale mode indicator
     97     bool mDownScaleMode;
     98     // Ext dst Rect
     99     hwc_rect_t mDstRect;
    100     //Action safe attributes
    101     // Flag to indicate the presence of action safe dimensions for external
    102     bool mActionSafePresent;
    103     int mAsWidthRatio;
    104     int mAsHeightRatio;
    105 
    106     //If property fbsize set via adb shell debug.hwc.fbsize = XRESxYRES
    107     //following fields are used.
    108     bool customFBSize;
    109     uint32_t xres_new;
    110     uint32_t yres_new;
    111 
    112 };
    113 
    114 struct ListStats {
    115     int numAppLayers; //Total - 1, excluding FB layer.
    116     int skipCount;
    117     int fbLayerIndex; //Always last for now. = numAppLayers
    118     //Video specific
    119     int yuvCount;
    120     int yuvIndices[MAX_NUM_APP_LAYERS];
    121     int extOnlyLayerIndex;
    122     bool preMultipliedAlpha;
    123     int yuv4k2kIndices[MAX_NUM_APP_LAYERS];
    124     int yuv4k2kCount;
    125     // Notifies hwcomposer about the start and end of animation
    126     // This will be set to true during animation, otherwise false.
    127     bool isDisplayAnimating;
    128     bool secureUI; // Secure display layer
    129     bool isSecurePresent;
    130     hwc_rect_t lRoi;  //left ROI
    131     hwc_rect_t rRoi;  //right ROI. Unused in single DSI panels.
    132     //App Buffer Composition index
    133     int  renderBufIndexforABC;
    134 };
    135 
    136 //PTOR Comp info
    137 struct PtorInfo {
    138     int count;
    139     int layerIndex[MAX_PTOR_LAYERS];
    140     int mRenderBuffOffset[MAX_PTOR_LAYERS];
    141     hwc_rect_t displayFrame[MAX_PTOR_LAYERS];
    142     bool isActive() { return (count>0); }
    143     int getPTORArrayIndex(int index) {
    144         int idx = -1;
    145         for(int i = 0; i < count; i++) {
    146             if(index == layerIndex[i])
    147                 idx = i;
    148         }
    149         return idx;
    150     }
    151 };
    152 
    153 struct LayerProp {
    154     uint32_t mFlags; //qcom specific layer flags
    155     LayerProp():mFlags(0){};
    156 };
    157 
    158 struct VsyncState {
    159     bool enable;
    160     bool fakevsync;
    161     bool debug;
    162 };
    163 
    164 struct BwcPM {
    165     static void setBwc(const hwc_rect_t& crop,
    166             const hwc_rect_t& dst, const int& transform,
    167             ovutils::eMdpFlags& mdpFlags);
    168 };
    169 
    170 // LayerProp::flag values
    171 enum {
    172     HWC_MDPCOMP = 0x00000001,
    173     HWC_COPYBIT = 0x00000002,
    174 };
    175 
    176 // HAL specific features
    177 enum {
    178     HWC_COLOR_FILL = 0x00000008,
    179     HWC_FORMAT_RB_SWAP = 0x00000040,
    180 };
    181 
    182 /* External Display states */
    183 enum {
    184     EXTERNAL_OFFLINE = 0,
    185     EXTERNAL_ONLINE,
    186     EXTERNAL_PAUSE,
    187     EXTERNAL_RESUME,
    188     EXTERNAL_MAXSTATES
    189 };
    190 
    191 class LayerRotMap {
    192 public:
    193     LayerRotMap() { reset(); }
    194     enum { MAX_SESS = 3 };
    195     void add(hwc_layer_1_t* layer, overlay::Rotator *rot);
    196     //Resets the mapping of layer to rotator
    197     void reset();
    198     //Clears mappings and existing rotator fences
    199     //Intended to be used during errors
    200     void clear();
    201     uint32_t getCount() const;
    202     hwc_layer_1_t* getLayer(uint32_t index) const;
    203     overlay::Rotator* getRot(uint32_t index) const;
    204     void setReleaseFd(const int& fence);
    205 private:
    206     hwc_layer_1_t* mLayer[MAX_SESS];
    207     overlay::Rotator* mRot[MAX_SESS];
    208     uint32_t mCount;
    209 };
    210 
    211 inline uint32_t LayerRotMap::getCount() const {
    212     return mCount;
    213 }
    214 
    215 inline hwc_layer_1_t* LayerRotMap::getLayer(uint32_t index) const {
    216     if(index >= mCount) return NULL;
    217     return mLayer[index];
    218 }
    219 
    220 inline overlay::Rotator* LayerRotMap::getRot(uint32_t index) const {
    221     if(index >= mCount) return NULL;
    222     return mRot[index];
    223 }
    224 
    225 inline hwc_rect_t integerizeSourceCrop(const hwc_frect_t& cropF) {
    226     hwc_rect_t cropI = {0,0,0,0};
    227     cropI.left = int(ceilf(cropF.left));
    228     cropI.top = int(ceilf(cropF.top));
    229     cropI.right = int(floorf(cropF.right));
    230     cropI.bottom = int(floorf(cropF.bottom));
    231     return cropI;
    232 }
    233 
    234 inline bool isNonIntegralSourceCrop(const hwc_frect_t& cropF) {
    235     if(cropF.left - roundf(cropF.left)     ||
    236        cropF.top - roundf(cropF.top)       ||
    237        cropF.right - roundf(cropF.right)   ||
    238        cropF.bottom - roundf(cropF.bottom))
    239         return true;
    240     else
    241         return false;
    242 }
    243 
    244 // -----------------------------------------------------------------------------
    245 // Utility functions - implemented in hwc_utils.cpp
    246 void dumpLayer(hwc_layer_1_t const* l);
    247 void setListStats(hwc_context_t *ctx, hwc_display_contents_1_t *list,
    248         int dpy);
    249 void initContext(hwc_context_t *ctx);
    250 void closeContext(hwc_context_t *ctx);
    251 //Crops source buffer against destination and FB boundaries
    252 void calculate_crop_rects(hwc_rect_t& crop, hwc_rect_t& dst,
    253                          const hwc_rect_t& scissor, int orient);
    254 void getNonWormholeRegion(hwc_display_contents_1_t* list,
    255                               hwc_rect_t& nwr);
    256 bool isSecuring(hwc_context_t* ctx, hwc_layer_1_t const* layer);
    257 bool isSecureModePolicy(int mdpVersion);
    258 // Returns true, if the input layer format is supported by rotator
    259 bool isRotatorSupportedFormat(private_handle_t *hnd);
    260 //Returns true, if the layer is YUV or the layer has been rendered by CPU
    261 bool isRotationDoable(hwc_context_t *ctx, private_handle_t *hnd);
    262 bool isExternalActive(hwc_context_t* ctx);
    263 bool isAlphaScaled(hwc_layer_1_t const* layer);
    264 bool needsScaling(hwc_layer_1_t const* layer);
    265 bool isDownscaleRequired(hwc_layer_1_t const* layer);
    266 bool needsScalingWithSplit(hwc_context_t* ctx, hwc_layer_1_t const* layer,
    267                            const int& dpy);
    268 void sanitizeSourceCrop(hwc_rect_t& cropL, hwc_rect_t& cropR,
    269                         private_handle_t *hnd);
    270 bool isAlphaPresent(hwc_layer_1_t const* layer);
    271 int hwc_vsync_control(hwc_context_t* ctx, int dpy, int enable);
    272 int getBlending(int blending);
    273 bool isGLESOnlyComp(hwc_context_t *ctx, const int& dpy);
    274 void reset_layer_prop(hwc_context_t* ctx, int dpy, int numAppLayers);
    275 bool isAbcInUse(hwc_context_t *ctx);
    276 
    277 void dumpBuffer(private_handle_t *ohnd, char *bufferName);
    278 
    279 //Helper function to dump logs
    280 void dumpsys_log(android::String8& buf, const char* fmt, ...);
    281 
    282 int getExtOrientation(hwc_context_t* ctx);
    283 bool isValidRect(const hwc_rect_t& rect);
    284 hwc_rect_t deductRect(const hwc_rect_t& rect1, const hwc_rect_t& rect2);
    285 bool isSameRect(const hwc_rect& rect1, const hwc_rect& rect2);
    286 hwc_rect_t moveRect(const hwc_rect_t& rect, const int& x_off, const int& y_off);
    287 hwc_rect_t getIntersection(const hwc_rect_t& rect1, const hwc_rect_t& rect2);
    288 hwc_rect_t getUnion(const hwc_rect_t& rect1, const hwc_rect_t& rect2);
    289 void optimizeLayerRects(const hwc_display_contents_1_t *list);
    290 bool areLayersIntersecting(const hwc_layer_1_t* layer1,
    291         const hwc_layer_1_t* layer2);
    292 bool operator ==(const hwc_rect_t& lhs, const hwc_rect_t& rhs);
    293 
    294 // returns true if Action safe dimensions are set and target supports Actionsafe
    295 bool isActionSafePresent(hwc_context_t *ctx, int dpy);
    296 
    297 /* Calculates the destination position based on the action safe rectangle */
    298 void getActionSafePosition(hwc_context_t *ctx, int dpy, hwc_rect_t& dst);
    299 
    300 void getAspectRatioPosition(hwc_context_t* ctx, int dpy, int extOrientation,
    301                                 hwc_rect_t& inRect, hwc_rect_t& outRect);
    302 
    303 bool isPrimaryPortrait(hwc_context_t *ctx);
    304 
    305 bool isOrientationPortrait(hwc_context_t *ctx);
    306 
    307 void calcExtDisplayPosition(hwc_context_t *ctx,
    308                                private_handle_t *hnd,
    309                                int dpy,
    310                                hwc_rect_t& sourceCrop,
    311                                hwc_rect_t& displayFrame,
    312                                int& transform,
    313                                ovutils::eTransform& orient);
    314 
    315 // Returns the orientation that needs to be set on external for
    316 // BufferMirrirMode(Sidesync)
    317 int getMirrorModeOrientation(hwc_context_t *ctx);
    318 
    319 /* Get External State names */
    320 const char* getExternalDisplayState(uint32_t external_state);
    321 
    322 // Resets display ROI to full panel resoluion
    323 void resetROI(hwc_context_t *ctx, const int dpy);
    324 
    325 // Aligns updating ROI to panel restrictions
    326 hwc_rect_t getSanitizeROI(struct hwc_rect roi, hwc_rect boundary);
    327 
    328 // Handles wfd Pause and resume events
    329 void handle_pause(hwc_context_t *ctx, int dpy);
    330 void handle_resume(hwc_context_t *ctx, int dpy);
    331 
    332 //Close acquireFenceFds of all layers of incoming list
    333 void closeAcquireFds(hwc_display_contents_1_t* list);
    334 
    335 //Sync point impl.
    336 int hwc_sync(hwc_context_t *ctx, hwc_display_contents_1_t* list, int dpy,
    337         int fd);
    338 
    339 //Sets appropriate mdp flags for a layer.
    340 void setMdpFlags(hwc_context_t *ctx, hwc_layer_1_t *layer,
    341         ovutils::eMdpFlags &mdpFlags,
    342         int rotDownscale, int transform);
    343 
    344 int configRotator(overlay::Rotator *rot, ovutils::Whf& whf,
    345         hwc_rect_t& crop, const ovutils::eMdpFlags& mdpFlags,
    346         const ovutils::eTransform& orient, const int& downscale);
    347 
    348 int configMdp(overlay::Overlay *ov, const ovutils::PipeArgs& parg,
    349         const ovutils::eTransform& orient, const hwc_rect_t& crop,
    350         const hwc_rect_t& pos, const MetaData_t *metadata,
    351         const ovutils::eDest& dest);
    352 
    353 int configColorLayer(hwc_context_t *ctx, hwc_layer_1_t *layer, const int& dpy,
    354         ovutils::eMdpFlags& mdpFlags, ovutils::eZorder& z,
    355         ovutils::eIsFg& isFg, const ovutils::eDest& dest);
    356 
    357 void updateSource(ovutils::eTransform& orient, ovutils::Whf& whf,
    358         hwc_rect_t& crop, overlay::Rotator *rot);
    359 
    360 //Routine to configure low resolution panels (<= 2048 width)
    361 int configureNonSplit(hwc_context_t *ctx, hwc_layer_1_t *layer, const int& dpy,
    362         ovutils::eMdpFlags& mdpFlags, ovutils::eZorder& z,
    363         ovutils::eIsFg& isFg, const ovutils::eDest& dest,
    364         overlay::Rotator **rot);
    365 
    366 //Routine to configure high resolution panels (> 2048 width)
    367 int configureSplit(hwc_context_t *ctx, hwc_layer_1_t *layer, const int& dpy,
    368         ovutils::eMdpFlags& mdpFlags, ovutils::eZorder& z,
    369         ovutils::eIsFg& isFg, const ovutils::eDest& lDest,
    370         const ovutils::eDest& rDest, overlay::Rotator **rot);
    371 
    372 //Routine to split and configure high resolution YUV layer (> 2048 width)
    373 int configureSourceSplit(hwc_context_t *ctx, hwc_layer_1_t *layer,
    374         const int& dpy,
    375         ovutils::eMdpFlags& mdpFlags, ovutils::eZorder& z,
    376         ovutils::eIsFg& isFg, const ovutils::eDest& lDest,
    377         const ovutils::eDest& rDest, overlay::Rotator **rot);
    378 
    379 //On certain targets DMA pipes are used for rotation and they won't be available
    380 //for line operations. On a per-target basis we can restrict certain use cases
    381 //from using rotator, since we know before-hand that such scenarios can lead to
    382 //extreme unavailability of pipes. This can also be done via hybrid calculations
    383 //also involving many more variables like number of write-back interfaces etc,
    384 //but the variety of scenarios is too high to warrant that.
    385 bool canUseRotator(hwc_context_t *ctx, int dpy);
    386 
    387 int getLeftSplit(hwc_context_t *ctx, const int& dpy);
    388 
    389 bool isDisplaySplit(hwc_context_t* ctx, int dpy);
    390 
    391 // Set the GPU hint flag to high for MIXED/GPU composition only for
    392 // first frame after MDP to GPU/MIXED mode transition.
    393 // Set the GPU hint to default if the current composition type is GPU
    394 // due to idle fallback or MDP composition.
    395 void setGPUHint(hwc_context_t* ctx, hwc_display_contents_1_t* list);
    396 
    397 // Returns true if rect1 is peripheral to rect2, false otherwise.
    398 bool isPeripheral(const hwc_rect_t& rect1, const hwc_rect_t& rect2);
    399 
    400 // Inline utility functions
    401 static inline bool isSkipLayer(const hwc_layer_1_t* l) {
    402     return (UNLIKELY(l && (l->flags & HWC_SKIP_LAYER)));
    403 }
    404 
    405 // Returns true if the buffer is yuv
    406 static inline bool isYuvBuffer(const private_handle_t* hnd) {
    407     return (hnd && (hnd->bufferType == BUFFER_TYPE_VIDEO));
    408 }
    409 
    410 // Returns true if the buffer is yuv
    411 static inline bool is4kx2kYuvBuffer(const private_handle_t* hnd) {
    412     return (hnd && (hnd->bufferType == BUFFER_TYPE_VIDEO) &&
    413             (hnd->width > 2048));
    414 }
    415 
    416 // Returns true if the buffer is secure
    417 static inline bool isSecureBuffer(const private_handle_t* hnd) {
    418     return (hnd && (private_handle_t::PRIV_FLAGS_SECURE_BUFFER & hnd->flags));
    419 }
    420 
    421 static inline bool isTileRendered(const private_handle_t* hnd) {
    422     return (hnd && (private_handle_t::PRIV_FLAGS_TILE_RENDERED & hnd->flags));
    423 }
    424 
    425 static inline bool isCPURendered(const private_handle_t* hnd) {
    426     return (hnd && (private_handle_t::PRIV_FLAGS_CPU_RENDERED & hnd->flags));
    427 }
    428 
    429 //Return true if buffer is marked locked
    430 static inline bool isBufferLocked(const private_handle_t* hnd) {
    431     return (hnd && (private_handle_t::PRIV_FLAGS_HWC_LOCK & hnd->flags));
    432 }
    433 
    434 //Return true if buffer is for external display only
    435 static inline bool isExtOnly(const private_handle_t* hnd) {
    436     return (hnd && (hnd->flags & private_handle_t::PRIV_FLAGS_EXTERNAL_ONLY));
    437 }
    438 
    439 //Return true if the buffer is intended for Secure Display
    440 static inline bool isSecureDisplayBuffer(const private_handle_t* hnd) {
    441     return (hnd && (hnd->flags & private_handle_t::PRIV_FLAGS_SECURE_DISPLAY));
    442 }
    443 
    444 static inline int getWidth(const private_handle_t* hnd) {
    445     if(isYuvBuffer(hnd)) {
    446         MetaData_t *metadata = reinterpret_cast<MetaData_t*>(hnd->base_metadata);
    447         if(metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
    448             return metadata->bufferDim.sliceWidth;
    449         }
    450     }
    451     return hnd->width;
    452 }
    453 
    454 static inline int getHeight(const private_handle_t* hnd) {
    455     if(isYuvBuffer(hnd)) {
    456         MetaData_t *metadata = reinterpret_cast<MetaData_t*>(hnd->base_metadata);
    457         if(metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
    458             return metadata->bufferDim.sliceHeight;
    459         }
    460     }
    461     return hnd->height;
    462 }
    463 
    464 template<typename T> inline T max(T a, T b) { return (a > b) ? a : b; }
    465 template<typename T> inline T min(T a, T b) { return (a < b) ? a : b; }
    466 
    467 // Initialize uevent thread
    468 void init_uevent_thread(hwc_context_t* ctx);
    469 // Initialize vsync thread
    470 void init_vsync_thread(hwc_context_t* ctx);
    471 
    472 inline void getLayerResolution(const hwc_layer_1_t* layer,
    473                                int& width, int& height) {
    474     hwc_rect_t displayFrame  = layer->displayFrame;
    475     width = displayFrame.right - displayFrame.left;
    476     height = displayFrame.bottom - displayFrame.top;
    477 }
    478 
    479 static inline int openFb(int dpy) {
    480     int fd = -1;
    481     const char *devtmpl = "/dev/graphics/fb%u";
    482     char name[64] = {0};
    483     snprintf(name, 64, devtmpl, dpy);
    484     fd = open(name, O_RDWR);
    485     return fd;
    486 }
    487 
    488 template <class T>
    489 inline void swap(T& a, T& b) {
    490     T tmp = a;
    491     a = b;
    492     b = tmp;
    493 }
    494 
    495 }; //qhwc namespace
    496 
    497 enum eAnimationState{
    498     ANIMATION_STOPPED,
    499     ANIMATION_STARTED,
    500 };
    501 
    502 enum eCompositionState {
    503     COMPOSITION_STATE_MDP = 0,        // Set if composition type is MDP
    504     COMPOSITION_STATE_GPU,            // Set if composition type is GPU or MIXED
    505     COMPOSITION_STATE_IDLE_FALLBACK,  // Set if it is idlefallback
    506 };
    507 
    508 // Structure holds the information about the GPU hint.
    509 struct gpu_hint_info {
    510     // system level flag to enable gpu_perf_mode
    511     bool mGpuPerfModeEnable;
    512     // Stores the current GPU performance mode DEFAULT/HIGH
    513     bool mCurrGPUPerfMode;
    514     // Stores the compositon state GPU, MDP or IDLE_FALLBACK
    515     bool mCompositionState;
    516     // Stores the EGLContext of current process
    517     EGLContext mEGLContext;
    518     // Stores the EGLDisplay of current process
    519     EGLDisplay mEGLDisplay;
    520 };
    521 
    522 // -----------------------------------------------------------------------------
    523 // HWC context
    524 // This structure contains overall state
    525 struct hwc_context_t {
    526     hwc_composer_device_1_t device;
    527     const hwc_procs_t* proc;
    528 
    529     //CopyBit objects
    530     qhwc::CopyBit *mCopyBit[HWC_NUM_DISPLAY_TYPES];
    531 
    532     //Overlay object - NULL for non overlay devices
    533     overlay::Overlay *mOverlay;
    534     //Holds a few rot objects
    535     overlay::RotMgr *mRotMgr;
    536 
    537     //Primary and external FB updater
    538     qhwc::IFBUpdate *mFBUpdate[HWC_NUM_DISPLAY_TYPES];
    539     // External display related information
    540     qhwc::ExternalDisplay *mExtDisplay;
    541     qhwc::VirtualDisplay *mVirtualDisplay;
    542     qhwc::MDPInfo mMDP;
    543     qhwc::VsyncState vstate;
    544     qhwc::DisplayAttributes dpyAttr[HWC_NUM_DISPLAY_TYPES];
    545     qhwc::ListStats listStats[HWC_NUM_DISPLAY_TYPES];
    546     qhwc::LayerProp *layerProp[HWC_NUM_DISPLAY_TYPES];
    547     qhwc::MDPComp *mMDPComp[HWC_NUM_DISPLAY_TYPES];
    548     qhwc::HwcDebug *mHwcDebug[HWC_NUM_DISPLAY_TYPES];
    549     hwc_rect_t mViewFrame[HWC_NUM_DISPLAY_TYPES];
    550     qhwc::AssertiveDisplay *mAD;
    551     eAnimationState mAnimationState[HWC_NUM_DISPLAY_TYPES];
    552     qhwc::HWCVirtualBase *mHWCVirtual;
    553 
    554     // stores the #numHwLayers of the previous frame
    555     // for each display device
    556     int mPrevHwLayerCount[HWC_NUM_DISPLAY_TYPES];
    557 
    558     // stores the primary device orientation
    559     int deviceOrientation;
    560     //Securing in progress indicator
    561     bool mSecuring;
    562     //WFD on proprietary stack
    563     bool mVirtualonExtActive;
    564     //Display in secure mode indicator
    565     bool mSecureMode;
    566     //Lock to protect drawing data structures
    567     mutable Locker mDrawLock;
    568     //Drawing round when we use GPU
    569     bool isPaddingRound;
    570     // External Orientation
    571     int mExtOrientation;
    572     //Flags the transition of a video session
    573     bool mVideoTransFlag;
    574     //Used for SideSync feature
    575     //which overrides the mExtOrientation
    576     bool mBufferMirrorMode;
    577     // Used to synchronize between WFD and Display modules
    578     mutable Locker mWfdSyncLock;
    579 
    580     qhwc::LayerRotMap *mLayerRotMap[HWC_NUM_DISPLAY_TYPES];
    581     // Panel reset flag will be set if BTA check fails
    582     bool mPanelResetStatus;
    583     // number of active Displays
    584     int numActiveDisplays;
    585     // Downscale feature switch, set via system property
    586     // sys.hwc.mdp_downscale_enabled
    587     bool mMDPDownscaleEnabled;
    588     // Is WFD enabled through VDS solution ?
    589     // This can be set via system property
    590     // persist.hwc.enable_vds
    591     bool mVDSEnabled;
    592     struct gpu_hint_info mGPUHintInfo;
    593     //App Buffer Composition
    594     bool enableABC;
    595     // PTOR Info
    596     qhwc::PtorInfo mPtorInfo;
    597 };
    598 
    599 namespace qhwc {
    600 static inline bool isSkipPresent (hwc_context_t *ctx, int dpy) {
    601     return  ctx->listStats[dpy].skipCount;
    602 }
    603 
    604 static inline bool isYuvPresent (hwc_context_t *ctx, int dpy) {
    605     return  ctx->listStats[dpy].yuvCount;
    606 }
    607 
    608 static inline bool has90Transform(hwc_layer_1_t const* layer) {
    609     return ((layer->transform & HWC_TRANSFORM_ROT_90) &&
    610             !(layer->flags & HWC_COLOR_FILL));
    611 }
    612 
    613 inline bool isSecurePresent(hwc_context_t *ctx, int dpy) {
    614     return ctx->listStats[dpy].isSecurePresent;
    615 }
    616 
    617 static inline bool isSecondaryConfiguring(hwc_context_t* ctx) {
    618     return (ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].isConfiguring ||
    619             ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].isConfiguring);
    620 }
    621 
    622 static inline bool isSecondaryConnected(hwc_context_t* ctx) {
    623     return (ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].connected ||
    624             ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].connected);
    625 }
    626 
    627 };
    628 
    629 #endif //HWC_UTILS_H
    630