1 /* 2 // Copyright(c)2014 IntelCorporation 3 // 4 // LicensedundertheApacheLicense,Version2.0(the"License"); 5 // youmaynotusethisfileexceptincompliancewiththeLicense. 6 // YoumayobtainacopyoftheLicenseat 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unlessrequiredbyapplicablelaworagreedtoinwriting,software 11 // distributedundertheLicenseisdistributedonan"ASIS"BASIS, 12 // WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied. 13 // SeetheLicenseforthespecificlanguagegoverningpermissionsand 14 // limitationsundertheLicense. 15 */ 16 #ifndef HWC_LAYER_LIST_H 17 #define HWC_LAYER_LIST_H 18 19 #include <common/utils/Dump.h> 20 #include <hardware/hwcomposer.h> 21 #include <utils/SortedVector.h> 22 #include <DataBuffer.h> 23 #include <DisplayPlane.h> 24 #include <DisplayPlaneManager.h> 25 #include <common/base/HwcLayer.h> 26 27 namespace android { 28 namespace intel { 29 30 31 class HwcLayerList { 32 public: 33 HwcLayerList(hwc_display_contents_1_t *list, int disp); 34 virtual ~HwcLayerList(); 35 36 public: 37 virtual bool initialize(); 38 virtual void deinitialize(); 39 40 virtual bool update(hwc_display_contents_1_t *list); 41 virtual DisplayPlane* getPlane(uint32_t index) const; 42 43 void postFlip(); 44 45 void updateFBT(hwc_display_contents_1_t *list); 46 47 // dump interface 48 virtual void dump(Dump& d); 49 50 51 private: 52 bool checkSupported(int planeType, HwcLayer *hwcLayer); 53 bool checkRgbOverlaySupported(HwcLayer *hwcLayer); 54 bool checkCursorSupported(HwcLayer *hwcLayer); 55 bool allocatePlanes(); 56 bool assignCursorPlanes(); 57 bool assignCursorPlanes(int index, int planeNumber); 58 bool assignOverlayPlanes(); 59 bool assignOverlayPlanes(int index, int planeNumber); 60 bool assignSpritePlanes(); 61 bool assignSpritePlanes(int index, int planeNumber); 62 bool assignPrimaryPlane(); 63 bool assignPrimaryPlaneHelper(HwcLayer *hwcLayer, int zorder = -1); 64 bool attachPlanes(); 65 bool useAsFrameBufferTarget(HwcLayer *target); 66 bool hasIntersection(HwcLayer *la, HwcLayer *lb); 67 ZOrderLayer* addZOrderLayer(int type, HwcLayer *hwcLayer, int zorder = -1); 68 void removeZOrderLayer(ZOrderLayer *layer); 69 void setupSmartComposition(); 70 void dump(); 71 72 private: 73 class HwcLayerVector : public SortedVector<HwcLayer*> { 74 public: 75 HwcLayerVector() {} 76 virtual int do_compare(const void* lhs, const void* rhs) const { 77 const HwcLayer* l = *(HwcLayer**)lhs; 78 const HwcLayer* r = *(HwcLayer**)rhs; 79 // sorted from index 0 to n 80 return l->getIndex() - r->getIndex(); 81 } 82 }; 83 84 class PriorityVector : public SortedVector<HwcLayer*> { 85 public: 86 PriorityVector() {} 87 virtual int do_compare(const void* lhs, const void* rhs) const { 88 const HwcLayer* l = *(HwcLayer**)lhs; 89 const HwcLayer* r = *(HwcLayer**)rhs; 90 return r->getPriority() - l->getPriority(); 91 } 92 }; 93 94 hwc_display_contents_1_t *mList; 95 int mLayerCount; 96 97 HwcLayerVector mLayers; 98 HwcLayerVector mFBLayers; 99 PriorityVector mSpriteCandidates; 100 PriorityVector mOverlayCandidates; 101 PriorityVector mCursorCandidates; 102 ZOrderConfig mZOrderConfig; 103 HwcLayer *mFrameBufferTarget; 104 int mDisplayIndex; 105 }; 106 107 } // namespace intel 108 } // namespace android 109 110 111 #endif /* HWC_LAYER_LIST_H */ 112