blob: 40a7c14e4b4b2ff662877ee3849d31dc26c8c969 [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
Naseer Ahmed5b6708a2012-08-02 13:46:08 -070029 static bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list);
Naseer Ahmedf48aef62012-07-20 09:05:53 -070030 //Draws layer if this feature is on
Naseer Ahmed5b6708a2012-08-02 13:46:08 -070031 static bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list);
Naseer Ahmedf48aef62012-07-20 09:05:53 -070032 //Receives data from hwc
Naseer Ahmed4c588a22012-07-31 19:12:17 -070033 static void setStats(int yuvCount, int yuvLayerIndex, bool isYuvLayerSkip,
34 int ccLayerIndex);
35 //resets values
36 static void reset();
Naseer Ahmedf48aef62012-07-20 09:05:53 -070037private:
38 //Choose an appropriate overlay state based on conditions
39 static void chooseState(hwc_context_t *ctx);
Naseer Ahmed4c588a22012-07-31 19:12:17 -070040 //Configures overlay for video prim and ext
Naseer Ahmed5b6708a2012-08-02 13:46:08 -070041 static bool configure(hwc_context_t *ctx, hwc_layer_1_t *yuvlayer,
42 hwc_layer_1_t *ccLayer);
Naseer Ahmedf48aef62012-07-20 09:05:53 -070043 //Marks layer flags if this feature is used
Naseer Ahmed5b6708a2012-08-02 13:46:08 -070044 static void markFlags(hwc_layer_1_t *layer);
Naseer Ahmedf48aef62012-07-20 09:05:53 -070045 //returns yuv count
46 static int getYuvCount();
47
48 //The chosen overlay state.
49 static ovutils::eOverlayState sState;
50 //Number of yuv layers in this drawing round
51 static int sYuvCount;
52 //Index of YUV layer, relevant only if count is 1
53 static int sYuvLayerIndex;
54 //Flags if a yuv layer is animating or below something that is animating
Naseer Ahmed4c588a22012-07-31 19:12:17 -070055 static bool sIsYuvLayerSkip;
56 //Holds the closed caption layer index, -1 by default
57 static int sCCLayerIndex;
Naseer Ahmedf48aef62012-07-20 09:05:53 -070058 //Flags if this feature is on.
59 static bool sIsModeOn;
60};
61
62inline void VideoOverlay::setStats(int yuvCount, int yuvLayerIndex,
Naseer Ahmed4c588a22012-07-31 19:12:17 -070063 bool isYuvLayerSkip, int ccLayerIndex) {
Naseer Ahmedf48aef62012-07-20 09:05:53 -070064 sYuvCount = yuvCount;
65 sYuvLayerIndex = yuvLayerIndex;
Naseer Ahmed4c588a22012-07-31 19:12:17 -070066 sIsYuvLayerSkip = isYuvLayerSkip;
67 sCCLayerIndex = ccLayerIndex;
Naseer Ahmedf48aef62012-07-20 09:05:53 -070068}
69
70inline int VideoOverlay::getYuvCount() { return sYuvCount; }
Naseer Ahmed4c588a22012-07-31 19:12:17 -070071inline void VideoOverlay::reset() {
72 sYuvCount = 0;
73 sYuvLayerIndex = -1;
74 sIsYuvLayerSkip = false;
75 sCCLayerIndex = -1;
76 sIsModeOn = false;
77 sState = ovutils::OV_CLOSED;
78}
Naseer Ahmedf48aef62012-07-20 09:05:53 -070079}; //namespace qhwc
80
81#endif //HWC_VIDEO_H