blob: c6c6c22c726c5625ea91bd98d3551f99893650eb [file] [log] [blame]
Naseer Ahmedf48aef62012-07-20 09:05:53 -07001/*
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_VIDEO_H
18#define HWC_VIDEO_H
19#include "hwc_utils.h"
20
21#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
22#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
23
24namespace qhwc {
25//Feature for using overlay to display videos.
26class VideoOverlay {
27public:
28 //Sets up members and prepares overlay if conditions are met
29 static bool prepare(hwc_context_t *ctx, hwc_layer_list_t *list);
30 //Draws layer if this feature is on
31 static bool draw(hwc_context_t *ctx, hwc_layer_list_t *list);
32 //Receives data from hwc
33 static void setStats(int yuvCount, int yuvLayerIndex, bool isYuvLayerSkip);
34private:
35 //Choose an appropriate overlay state based on conditions
36 static void chooseState(hwc_context_t *ctx);
37 //Configures overlay
38 static bool configure(hwc_context_t *ctx, hwc_layer_t *layer);
39 //Marks layer flags if this feature is used
40 static void markFlags(hwc_layer_t *layer);
41 //returns yuv count
42 static int getYuvCount();
43
44 //The chosen overlay state.
45 static ovutils::eOverlayState sState;
46 //Number of yuv layers in this drawing round
47 static int sYuvCount;
48 //Index of YUV layer, relevant only if count is 1
49 static int sYuvLayerIndex;
50 //Flags if a yuv layer is animating or below something that is animating
51 static bool sIsLayerSkip;
52 //Flags if this feature is on.
53 static bool sIsModeOn;
54};
55
56inline void VideoOverlay::setStats(int yuvCount, int yuvLayerIndex,
57 bool isYuvLayerSkip) {
58 sYuvCount = yuvCount;
59 sYuvLayerIndex = yuvLayerIndex;
60 sIsLayerSkip = isYuvLayerSkip;
61}
62
63inline int VideoOverlay::getYuvCount() { return sYuvCount; }
64
65}; //namespace qhwc
66
67#endif //HWC_VIDEO_H