blob: 4acde9d8b043c95f96448285cf0128f52ff9309c [file] [log] [blame]
Naseer Ahmedf48aef62012-07-20 09:05:53 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
Duy Truong73d36df2013-02-09 20:33:23 -08003 * Copyright (C) 2012, The Linux Foundation. All rights reserved.
Naseer Ahmedf48aef62012-07-20 09:05:53 -07004 *
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
Naseer Ahmed758bfc52012-11-28 17:02:08 -050019
Naseer Ahmedf48aef62012-07-20 09:05:53 -070020#include "hwc_utils.h"
Naseer Ahmed758bfc52012-11-28 17:02:08 -050021#include "overlayUtils.h"
Naseer Ahmedf48aef62012-07-20 09:05:53 -070022
23#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
24#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
25
Saurabh Shahacf10202013-02-26 10:15:15 -080026namespace overlay {
27 class Rotator;
28}
29
Naseer Ahmedf48aef62012-07-20 09:05:53 -070030namespace qhwc {
Naseer Ahmed758bfc52012-11-28 17:02:08 -050031namespace ovutils = overlay::utils;
32
Saurabh Shahacf10202013-02-26 10:15:15 -080033class IVideoOverlay {
Naseer Ahmedf48aef62012-07-20 09:05:53 -070034public:
Saurabh Shahacf10202013-02-26 10:15:15 -080035 explicit IVideoOverlay(const int& dpy) : mDpy(dpy), mModeOn(false),
36 mRot(NULL) {}
37 virtual ~IVideoOverlay() {};
38 virtual bool prepare(hwc_context_t *ctx,
39 hwc_display_contents_1_t *list) = 0;
40 virtual bool draw(hwc_context_t *ctx,
41 hwc_display_contents_1_t *list) = 0;
42 virtual void reset() = 0;
43 //Factory method that returns a low-res or high-res version
44 static IVideoOverlay *getObject(const int& width, const int& dpy);
45protected:
46 const int mDpy; // display to update
47 bool mModeOn; // if prepare happened
48 overlay::Rotator *mRot;
Naseer Ahmedf48aef62012-07-20 09:05:53 -070049};
50
Saurabh Shahacf10202013-02-26 10:15:15 -080051class VideoOverlayLowRes : public IVideoOverlay {
52public:
53 explicit VideoOverlayLowRes(const int& dpy);
54 virtual ~VideoOverlayLowRes() {};
55 bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list);
56 bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list);
57 void reset();
58private:
59 //Configures overlay for video prim and ext
60 bool configure(hwc_context_t *ctx, hwc_layer_1_t *yuvlayer);
61 //Marks layer flags if this feature is used
62 void markFlags(hwc_layer_1_t *yuvLayer);
63 //Flags if this feature is on.
64 bool mModeOn;
65 ovutils::eDest mDest;
66};
67
68class VideoOverlayHighRes : public IVideoOverlay {
69public:
70 explicit VideoOverlayHighRes(const int& dpy);
71 virtual ~VideoOverlayHighRes() {};
72 bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list);
73 bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list);
74 void reset();
75private:
76 //Configures overlay for video prim and ext
77 bool configure(hwc_context_t *ctx, hwc_layer_1_t *yuvlayer);
78 //Marks layer flags if this feature is used
79 void markFlags(hwc_layer_1_t *yuvLayer);
80 //Flags if this feature is on.
81 bool mModeOn;
82 ovutils::eDest mDestL;
83 ovutils::eDest mDestR;
84};
85
86//=================Inlines======================
87inline void VideoOverlayLowRes::reset() {
88 mModeOn = false;
89 mDest = ovutils::OV_INVALID;
90 mRot = NULL;
Naseer Ahmed4c588a22012-07-31 19:12:17 -070091}
Saurabh Shahacf10202013-02-26 10:15:15 -080092
93inline void VideoOverlayHighRes::reset() {
94 mModeOn = false;
95 mDestL = ovutils::OV_INVALID;
96 mDestR = ovutils::OV_INVALID;
97 mRot = NULL;
98}
99
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700100}; //namespace qhwc
101
102#endif //HWC_VIDEO_H