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; |
| 43 | //Factory method that returns a low-res or high-res version |
| 44 | static IVideoOverlay *getObject(const int& width, const int& dpy); |
| 45 | protected: |
| 46 | const int mDpy; // display to update |
| 47 | bool mModeOn; // if prepare happened |
| 48 | overlay::Rotator *mRot; |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 49 | }; |
| 50 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame^] | 51 | class VideoOverlayLowRes : public IVideoOverlay { |
| 52 | public: |
| 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(); |
| 58 | private: |
| 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 | |
| 68 | class VideoOverlayHighRes : public IVideoOverlay { |
| 69 | public: |
| 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(); |
| 75 | private: |
| 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====================== |
| 87 | inline void VideoOverlayLowRes::reset() { |
| 88 | mModeOn = false; |
| 89 | mDest = ovutils::OV_INVALID; |
| 90 | mRot = NULL; |
Naseer Ahmed | 4c588a2 | 2012-07-31 19:12:17 -0700 | [diff] [blame] | 91 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame^] | 92 | |
| 93 | inline void VideoOverlayHighRes::reset() { |
| 94 | mModeOn = false; |
| 95 | mDestL = ovutils::OV_INVALID; |
| 96 | mDestR = ovutils::OV_INVALID; |
| 97 | mRot = NULL; |
| 98 | } |
| 99 | |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 100 | }; //namespace qhwc |
| 101 | |
| 102 | #endif //HWC_VIDEO_H |