blob: 80a47f11180d6ce841b08bbcac010cab32128e07 [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;
Sravan Kumar D.V.Nb5ed0292013-03-15 08:51:16 +053043 virtual bool isModeOn() = 0;
Saurabh Shahacf10202013-02-26 10:15:15 -080044 //Factory method that returns a low-res or high-res version
45 static IVideoOverlay *getObject(const int& width, const int& dpy);
Sravan Kumar D.V.Nb5ed0292013-03-15 08:51:16 +053046
Saurabh Shahacf10202013-02-26 10:15:15 -080047protected:
48 const int mDpy; // display to update
49 bool mModeOn; // if prepare happened
50 overlay::Rotator *mRot;
Naseer Ahmedf48aef62012-07-20 09:05:53 -070051};
52
Saurabh Shahacf10202013-02-26 10:15:15 -080053class VideoOverlayLowRes : public IVideoOverlay {
54public:
55 explicit VideoOverlayLowRes(const int& dpy);
56 virtual ~VideoOverlayLowRes() {};
57 bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list);
58 bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list);
59 void reset();
Sravan Kumar D.V.Nb5ed0292013-03-15 08:51:16 +053060 bool isModeOn();
Saurabh Shahacf10202013-02-26 10:15:15 -080061private:
62 //Configures overlay for video prim and ext
63 bool configure(hwc_context_t *ctx, hwc_layer_1_t *yuvlayer);
64 //Marks layer flags if this feature is used
65 void markFlags(hwc_layer_1_t *yuvLayer);
66 //Flags if this feature is on.
67 bool mModeOn;
68 ovutils::eDest mDest;
69};
70
71class VideoOverlayHighRes : public IVideoOverlay {
72public:
73 explicit VideoOverlayHighRes(const int& dpy);
74 virtual ~VideoOverlayHighRes() {};
75 bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list);
76 bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list);
77 void reset();
Sravan Kumar D.V.Nb5ed0292013-03-15 08:51:16 +053078 bool isModeOn();
Saurabh Shahacf10202013-02-26 10:15:15 -080079private:
80 //Configures overlay for video prim and ext
81 bool configure(hwc_context_t *ctx, hwc_layer_1_t *yuvlayer);
82 //Marks layer flags if this feature is used
83 void markFlags(hwc_layer_1_t *yuvLayer);
84 //Flags if this feature is on.
85 bool mModeOn;
86 ovutils::eDest mDestL;
87 ovutils::eDest mDestR;
88};
89
90//=================Inlines======================
91inline void VideoOverlayLowRes::reset() {
92 mModeOn = false;
93 mDest = ovutils::OV_INVALID;
94 mRot = NULL;
Naseer Ahmed4c588a22012-07-31 19:12:17 -070095}
Saurabh Shahacf10202013-02-26 10:15:15 -080096
97inline void VideoOverlayHighRes::reset() {
98 mModeOn = false;
99 mDestL = ovutils::OV_INVALID;
100 mDestR = ovutils::OV_INVALID;
101 mRot = NULL;
102}
103
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700104}; //namespace qhwc
105
106#endif //HWC_VIDEO_H