blob: dbfc2368832ddcc92944c612d0cf06d2bba35d72 [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
Saurabh Shah3e858eb2012-09-17 16:53:21 -070029 static bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list,
30 int dpy);
Naseer Ahmedf48aef62012-07-20 09:05:53 -070031 //Draws layer if this feature is on
Saurabh Shah3e858eb2012-09-17 16:53:21 -070032 static bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list,
33 int dpy);
Naseer Ahmed4c588a22012-07-31 19:12:17 -070034 //resets values
35 static void reset();
Naseer Ahmedf48aef62012-07-20 09:05:53 -070036private:
37 //Choose an appropriate overlay state based on conditions
Saurabh Shah3e858eb2012-09-17 16:53:21 -070038 static void chooseState(hwc_context_t *ctx, int dpy,
39 hwc_layer_1_t *yuvLayer);
Naseer Ahmed4c588a22012-07-31 19:12:17 -070040 //Configures overlay for video prim and ext
Saurabh Shah3e858eb2012-09-17 16:53:21 -070041 static bool configure(hwc_context_t *ctx, int dpy,
42 hwc_layer_1_t *yuvlayer);
Naseer Ahmedf48aef62012-07-20 09:05:53 -070043 //Marks layer flags if this feature is used
Saurabh Shah3e858eb2012-09-17 16:53:21 -070044 static void markFlags(hwc_layer_1_t *yuvLayer);
Naseer Ahmedf48aef62012-07-20 09:05:53 -070045 //The chosen overlay state.
Saurabh Shahc4d034f2012-09-27 15:55:15 -070046 static ovutils::eOverlayState sState[HWC_NUM_DISPLAY_TYPES];
Naseer Ahmedf48aef62012-07-20 09:05:53 -070047 //Flags if this feature is on.
Saurabh Shahc4d034f2012-09-27 15:55:15 -070048 static bool sIsModeOn[HWC_NUM_DISPLAY_TYPES];
Naseer Ahmedf48aef62012-07-20 09:05:53 -070049};
50
Naseer Ahmed4c588a22012-07-31 19:12:17 -070051inline void VideoOverlay::reset() {
Saurabh Shahc4d034f2012-09-27 15:55:15 -070052 for(uint32_t i = 0; i < HWC_NUM_DISPLAY_TYPES; i++) {
53 sIsModeOn[i] = false;
54 sState[i] = ovutils::OV_CLOSED;
55 }
Naseer Ahmed4c588a22012-07-31 19:12:17 -070056}
Naseer Ahmedf48aef62012-07-20 09:05:53 -070057}; //namespace qhwc
58
59#endif //HWC_VIDEO_H