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 DISPLAY_ANALYZER_H 17 #define DISPLAY_ANALYZER_H 18 19 #include <utils/threads.h> 20 #include <utils/Vector.h> 21 22 23 namespace android { 24 namespace intel { 25 26 27 class DisplayAnalyzer { 28 public: 29 DisplayAnalyzer(); 30 virtual ~DisplayAnalyzer(); 31 32 public: 33 bool initialize(); 34 void deinitialize(); 35 void analyzeContents(size_t numDisplays, hwc_display_contents_1_t** displays); 36 void postHotplugEvent(bool connected); 37 38 private: 39 enum DisplayEventType { 40 HOTPLUG_EVENT, 41 }; 42 43 struct Event { 44 int type; 45 46 union { 47 bool bValue; 48 int nValue; 49 }; 50 }; 51 inline void postEvent(Event& e); 52 inline bool getEvent(Event& e); 53 void handlePendingEvents(); 54 void handleHotplugEvent(bool connected); 55 inline void setCompositionType(hwc_display_contents_1_t *content, int type); 56 inline void setCompositionType(int device, int type, bool reset); 57 58 59 private: 60 bool mInitialized; 61 int mCachedNumDisplays; 62 hwc_display_contents_1_t** mCachedDisplays; 63 Vector<Event> mPendingEvents; 64 Mutex mEventMutex; 65 }; 66 67 } // namespace intel 68 } // namespace android 69 70 71 72 #endif /* DISPLAY_ANALYZER_H */ 73