Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
Duy Truong | 73d36df | 2013-02-09 20:33:23 -0800 | [diff] [blame] | 3 | * Copyright (C) 2012, The Linux Foundation. All rights reserved. |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 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 |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 19 | |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 20 | #include "hwc_utils.h" |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 21 | #include "overlayUtils.h" |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 22 | |
| 23 | #define LIKELY( exp ) (__builtin_expect( (exp) != 0, true )) |
| 24 | #define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false )) |
| 25 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 26 | namespace overlay { |
| 27 | class Rotator; |
| 28 | } |
| 29 | |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 30 | namespace qhwc { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 31 | namespace ovutils = overlay::utils; |
| 32 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 33 | class IVideoOverlay { |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 34 | public: |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 35 | 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.N | b5ed029 | 2013-03-15 08:51:16 +0530 | [diff] [blame] | 43 | virtual bool isModeOn() = 0; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 44 | //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.N | b5ed029 | 2013-03-15 08:51:16 +0530 | [diff] [blame] | 46 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 47 | protected: |
| 48 | const int mDpy; // display to update |
| 49 | bool mModeOn; // if prepare happened |
| 50 | overlay::Rotator *mRot; |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 51 | }; |
| 52 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 53 | class VideoOverlayLowRes : public IVideoOverlay { |
| 54 | public: |
| 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.N | b5ed029 | 2013-03-15 08:51:16 +0530 | [diff] [blame] | 60 | bool isModeOn(); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 61 | private: |
| 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 | |
| 71 | class VideoOverlayHighRes : public IVideoOverlay { |
| 72 | public: |
| 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.N | b5ed029 | 2013-03-15 08:51:16 +0530 | [diff] [blame] | 78 | bool isModeOn(); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 79 | private: |
| 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====================== |
| 91 | inline void VideoOverlayLowRes::reset() { |
| 92 | mModeOn = false; |
| 93 | mDest = ovutils::OV_INVALID; |
| 94 | mRot = NULL; |
Naseer Ahmed | 4c588a2 | 2012-07-31 19:12:17 -0700 | [diff] [blame] | 95 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 96 | |
| 97 | inline void VideoOverlayHighRes::reset() { |
| 98 | mModeOn = false; |
| 99 | mDestL = ovutils::OV_INVALID; |
| 100 | mDestR = ovutils::OV_INVALID; |
| 101 | mRot = NULL; |
| 102 | } |
| 103 | |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 104 | }; //namespace qhwc |
| 105 | |
| 106 | #endif //HWC_VIDEO_H |