DisplayAnalyzer.h revision b58f29390918c0df3bd6d0731bf98daf57511b9f
1/* 2 * Copyright © 2012 Intel Corporation 3 * All rights reserved. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the next 13 * paragraph) shall be included in all copies or substantial portions of the 14 * Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 * IN THE SOFTWARE. 23 * 24 * Authors: 25 * Jackie Li <yaodong.li@intel.com> 26 * 27 */ 28#ifndef DISPLAY_ANALYZER_H 29#define DISPLAY_ANALYZER_H 30 31#include <utils/threads.h> 32#include <utils/Vector.h> 33 34 35namespace android { 36namespace intel { 37 38 39class DisplayAnalyzer { 40public: 41 DisplayAnalyzer(); 42 virtual ~DisplayAnalyzer(); 43 44public: 45 bool initialize(); 46 void deinitialize(); 47 void analyzeContents(size_t numDisplays, hwc_display_contents_1_t** displays); 48 bool checkVideoExtendedMode(); 49 bool isVideoExtendedModeEnabled(); 50 bool isVideoLayer(hwc_layer_1_t &layer); 51 bool isVideoFullScreen(int device, hwc_layer_1_t &layer); 52 bool isVideoPlaying(); 53 bool isOverlayAllowed(); 54 void postHotplugEvent(bool connected); 55 void postVideoEvent(int instances, int instanceID, bool preparing, bool playing); 56 void postBlankEvent(bool blank); 57 58private: 59 enum DisplayEventType { 60 HOTPLUG_EVENT, 61 BLANK_EVENT, 62 VIDEO_EVENT, 63 }; 64 65 struct Event { 66 int type; 67 68 struct VideoEvent { 69 int instances; 70 int instanceID; 71 bool preparing; 72 bool playing; 73 }; 74 75 union { 76 bool connected; 77 bool blank; 78 VideoEvent videoEvent; 79 }; 80 }; 81 inline void postEvent(Event& e); 82 void handlePendingEvents(); 83 void handleHotplugEvent(bool connected); 84 void handleBlankEvent(bool blank); 85 void handleVideoEvent(int instances, int instanceID, bool preparing, bool playing); 86 87 void blankSecondaryDevice(); 88 void detectVideoExtendedMode(); 89 void detectTrickMode(hwc_display_contents_1_t *list); 90 void handleModeSwitch(); 91 92private: 93 bool mInitialized; 94 bool mEnableVideoExtendedMode; 95 bool mVideoExtendedMode; 96 bool mForceCloneMode; 97 bool mBlankDevice; 98 bool mVideoPlaying; 99 bool mVideoPreparing; 100 bool mVideoStateChanged; 101 bool mOverlayAllowed; 102 int mVideoInstances; 103 int mVideoInstanceId; 104 int mCachedNumDisplays; 105 hwc_display_contents_1_t** mCachedDisplays; 106 Vector<Event> mPendingEvents; 107 Mutex mEventMutex; 108 Condition mEventHandledCondition; 109}; 110 111} // namespace intel 112} // namespace android 113 114 115 116#endif /* DISPLAY_ANALYZER_H */ 117