1 /* 2 // Copyright (c) 2014 Intel Corporation 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 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 // dump interface 46 virtual void dump(Dump& d); 47 48 49 private: 50 bool checkSupported(int planeType, HwcLayer *hwcLayer); 51 bool checkRgbOverlaySupported(HwcLayer *hwcLayer); 52 bool checkCursorSupported(HwcLayer *hwcLayer); 53 bool allocatePlanes(); 54 bool assignCursorPlanes(); 55 bool assignCursorPlanes(int index, int planeNumber); 56 bool assignOverlayPlanes(); 57 bool assignOverlayPlanes(int index, int planeNumber); 58 bool assignSpritePlanes(); 59 bool assignSpritePlanes(int index, int planeNumber); 60 bool assignPrimaryPlane(); 61 bool assignPrimaryPlaneHelper(HwcLayer *hwcLayer, int zorder = -1); 62 bool attachPlanes(); 63 bool useAsFrameBufferTarget(HwcLayer *target); 64 bool hasIntersection(HwcLayer *la, HwcLayer *lb); 65 ZOrderLayer* addZOrderLayer(int type, HwcLayer *hwcLayer, int zorder = -1); 66 void removeZOrderLayer(ZOrderLayer *layer); 67 void setupSmartComposition(); 68 void dump(); 69 70 private: 71 class HwcLayerVector : public SortedVector<HwcLayer*> { 72 public: HwcLayerVector()73 HwcLayerVector() {} do_compare(const void * lhs,const void * rhs)74 virtual int do_compare(const void* lhs, const void* rhs) const { 75 const HwcLayer* l = *(HwcLayer**)lhs; 76 const HwcLayer* r = *(HwcLayer**)rhs; 77 // sorted from index 0 to n 78 return l->getIndex() - r->getIndex(); 79 } 80 }; 81 82 class PriorityVector : public SortedVector<HwcLayer*> { 83 public: PriorityVector()84 PriorityVector() {} do_compare(const void * lhs,const void * rhs)85 virtual int do_compare(const void* lhs, const void* rhs) const { 86 const HwcLayer* l = *(HwcLayer**)lhs; 87 const HwcLayer* r = *(HwcLayer**)rhs; 88 return r->getPriority() - l->getPriority(); 89 } 90 }; 91 92 hwc_display_contents_1_t *mList; 93 int mLayerCount; 94 95 HwcLayerVector mLayers; 96 HwcLayerVector mFBLayers; 97 PriorityVector mSpriteCandidates; 98 PriorityVector mOverlayCandidates; 99 PriorityVector mCursorCandidates; 100 ZOrderConfig mZOrderConfig; 101 HwcLayer *mFrameBufferTarget; 102 int mDisplayIndex; 103 }; 104 105 } // namespace intel 106 } // namespace android 107 108 109 #endif /* HWC_LAYER_LIST_H */ 110