1/* 2 * Copyright (C) 2010 The Android Open Source Project 3 * Copyright (C) 2012, Code Aurora Forum. All rights reserved. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17#ifndef HWC_EXTONLY_H 18#define HWC_EXTONLY_H 19 20#include <overlay.h> 21#include "hwc_utils.h" 22 23#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true )) 24#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false )) 25 26namespace qhwc { 27//Feature for using overlay to display external-only layers on HDTV 28class ExtOnly { 29public: 30 //Sets up members and prepares overlay if conditions are met 31 static bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list); 32 //Draws layer if this feature is on 33 static bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list); 34 //Receives data from hwc 35 static void setStats(int extCount, int extIndex, bool isExtBlock); 36 //resets values 37 static void reset(); 38private: 39 //Choose an appropriate overlay state based on conditions 40 static void chooseState(hwc_context_t *ctx); 41 //Configures overlay 42 static bool configure(hwc_context_t *ctx, hwc_layer_1_t *layer); 43 //Marks layer flags if this feature is used 44 static void markFlags(hwc_layer_1_t *layer); 45 //returns ext-only count 46 static int getExtCount(); 47 48 //The chosen overlay state. 49 static ovutils::eOverlayState sState; 50 //Number of ext-only layers in this drawing round. Used for stats/debugging. 51 //This does not reflect the closed caption layer count even though its 52 //ext-only. 53 static int sExtCount; 54 //Index of ext-only layer. If there are 2 such layers with 1 marked as BLOCK 55 //then this will hold the index of BLOCK layer. 56 static int sExtIndex; 57 //Flags if ext-only layer is BLOCK, which means only this layer (sExtIndex) 58 //is displayed even if other ext-only layers are present to block their 59 //content. This is used for stats / debugging only. 60 static bool sIsExtBlock; 61 //Flags if this feature is on. 62 static bool sIsModeOn; 63}; 64 65inline void ExtOnly::setStats(int extCount, int extIndex, bool isExtBlock) { 66 sExtCount = extCount; 67 sExtIndex = extIndex; 68 sIsExtBlock = isExtBlock; 69} 70 71inline int ExtOnly::getExtCount() { return sExtCount; } 72inline void ExtOnly::reset() { 73 sExtCount = 0; 74 sExtIndex = -1; 75 sIsExtBlock = false; 76 sIsModeOn = false; 77 sState = ovutils::OV_CLOSED; 78} 79 80}; //namespace qhwc 81 82#endif //HWC_EXTONLY_H 83