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 <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 <HwcLayer.h> 26 27namespace android { 28namespace intel { 29 30 31class HwcLayerList { 32public: 33 HwcLayerList(hwc_display_contents_1_t *list, int disp); 34 virtual ~HwcLayerList(); 35 36public: 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 48private: 49 bool checkSupported(int planeType, HwcLayer *hwcLayer); 50 bool checkCursorSupported(HwcLayer *hwcLayer); 51 bool allocatePlanes(); 52 bool assignCursorPlanes(); 53 bool assignCursorPlanes(int index, int planeNumber); 54 bool assignOverlayPlanes(); 55 bool assignOverlayPlanes(int index, int planeNumber); 56 bool assignSpritePlanes(); 57 bool assignSpritePlanes(int index, int planeNumber); 58 bool assignPrimaryPlane(); 59 bool assignPrimaryPlaneHelper(HwcLayer *hwcLayer, int zorder = -1); 60 bool attachPlanes(); 61 bool useAsFrameBufferTarget(HwcLayer *target); 62 bool hasIntersection(HwcLayer *la, HwcLayer *lb); 63 void addStaticLayerSize(HwcLayer *hwcLayer); 64 bool checkStaticLayerSize(); 65 ZOrderLayer* addZOrderLayer(int type, HwcLayer *hwcLayer, int zorder = -1); 66 void removeZOrderLayer(ZOrderLayer *layer); 67 void setupSmartComposition(); 68 bool setupSmartComposition2(); 69 void dump(); 70 71private: 72 class HwcLayerVector : public SortedVector<HwcLayer*> { 73 public: 74 HwcLayerVector() {} 75 virtual int do_compare(const void* lhs, const void* rhs) const { 76 const HwcLayer* l = *(HwcLayer**)lhs; 77 const HwcLayer* r = *(HwcLayer**)rhs; 78 // sorted from index 0 to n 79 return l->getIndex() - r->getIndex(); 80 } 81 }; 82 83 class PriorityVector : public SortedVector<HwcLayer*> { 84 public: 85 PriorityVector() {} 86 virtual int do_compare(const void* lhs, const void* rhs) const { 87 const HwcLayer* l = *(HwcLayer**)lhs; 88 const HwcLayer* r = *(HwcLayer**)rhs; 89 return r->getPriority() - l->getPriority(); 90 } 91 }; 92 93 hwc_display_contents_1_t *mList; 94 int mLayerCount; 95 96 HwcLayerVector mLayers; 97 HwcLayerVector mFBLayers; 98 Vector<int> mStaticLayersIndex; 99 PriorityVector mSpriteCandidates; 100 PriorityVector mOverlayCandidates; 101 PriorityVector mCursorCandidates; 102 ZOrderConfig mZOrderConfig; 103 HwcLayer *mFrameBufferTarget; 104 int mDisplayIndex; 105 int mLayerSize; 106}; 107 108} // namespace intel 109} // namespace android 110 111 112#endif /* HWC_LAYER_LIST_H */ 113