Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 3 | * Copyright (C) 2012, The Linux Foundation. All rights reserved. |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 4 | * |
| 5 | * Not a Contribution, Apache license notifications and license are |
| 6 | * retained for attribution purposes only. |
| 7 | * |
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | * you may not use this file except in compliance with the License. |
| 10 | * You may obtain a copy of the License at |
| 11 | * |
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | * |
| 14 | * Unless required by applicable law or agreed to in writing, software |
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | * See the License for the specific language governing permissions and |
| 18 | * limitations under the License. |
| 19 | */ |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 20 | #ifndef HWC_FBUPDATE_H |
| 21 | #define HWC_FBUPDATE_H |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 22 | #include "hwc_utils.h" |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 23 | #include "overlay.h" |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 24 | |
| 25 | #define LIKELY( exp ) (__builtin_expect( (exp) != 0, true )) |
| 26 | #define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false )) |
| 27 | |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 28 | namespace overlay { |
| 29 | class Rotator; |
| 30 | } |
| 31 | |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 32 | namespace qhwc { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 33 | namespace ovutils = overlay::utils; |
| 34 | |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 35 | //Framebuffer update Interface |
| 36 | class IFBUpdate { |
| 37 | public: |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 38 | explicit IFBUpdate(hwc_context_t *ctx, const int& dpy); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 39 | virtual ~IFBUpdate() {}; |
| 40 | // Sets up members and prepares overlay if conditions are met |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 41 | virtual bool prepare(hwc_context_t *ctx, hwc_display_contents_1 *list, |
Jeykumar Sankaran | c2d78d8 | 2014-02-14 14:55:29 -0800 | [diff] [blame] | 42 | hwc_rect_t fbUpdatingRect, int fbZorder) = 0; |
Saurabh Shah | a36be92 | 2013-12-16 18:18:39 -0800 | [diff] [blame] | 43 | virtual bool prepareAndValidate(hwc_context_t *ctx, |
| 44 | hwc_display_contents_1 *list, int fbZorder); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 45 | // Draws layer |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 46 | virtual bool draw(hwc_context_t *ctx, private_handle_t *hnd) = 0; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 47 | //Reset values |
| 48 | virtual void reset(); |
| 49 | //Factory method that returns a low-res or high-res version |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 50 | static IFBUpdate *getObject(hwc_context_t *ctx, const int& dpy); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 51 | |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 52 | protected: |
| 53 | const int mDpy; // display to update |
| 54 | bool mModeOn; // if prepare happened |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 55 | overlay::Rotator *mRot; |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 56 | int mAlignedFBWidth; |
| 57 | int mAlignedFBHeight; |
Manoj Kumar AVM | 8a22081 | 2013-10-10 11:46:06 -0700 | [diff] [blame] | 58 | int mTileEnabled; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 59 | }; |
| 60 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 61 | //Non-Split panel handler. |
| 62 | class FBUpdateNonSplit : public IFBUpdate { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 63 | public: |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 64 | explicit FBUpdateNonSplit(hwc_context_t *ctx, const int& dpy); |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 65 | virtual ~FBUpdateNonSplit() {}; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 66 | bool prepare(hwc_context_t *ctx, hwc_display_contents_1 *list, |
Jeykumar Sankaran | c2d78d8 | 2014-02-14 14:55:29 -0800 | [diff] [blame] | 67 | hwc_rect_t fbUpdatingRect, int fbZorder); |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 68 | bool draw(hwc_context_t *ctx, private_handle_t *hnd); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 69 | void reset(); |
| 70 | private: |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 71 | bool configure(hwc_context_t *ctx, hwc_display_contents_1 *list, |
Jeykumar Sankaran | c2d78d8 | 2014-02-14 14:55:29 -0800 | [diff] [blame] | 72 | hwc_rect_t fbUpdatingRect, int fbZorder); |
Ramkumar Radhakrishnan | 66f856c | 2013-08-21 16:09:47 -0700 | [diff] [blame] | 73 | bool preRotateExtDisplay(hwc_context_t *ctx, |
Prabhanjan Kandula | db202b7 | 2013-10-30 17:29:46 +0530 | [diff] [blame] | 74 | hwc_layer_1_t *layer, |
Ramkumar Radhakrishnan | 66f856c | 2013-08-21 16:09:47 -0700 | [diff] [blame] | 75 | ovutils::Whf &info, |
| 76 | hwc_rect_t& sourceCrop, |
| 77 | ovutils::eMdpFlags& mdpFlags, |
| 78 | int& rotFlags); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 79 | ovutils::eDest mDest; //pipe to draw on |
| 80 | }; |
| 81 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 82 | //Split panel handler. |
| 83 | class FBUpdateSplit : public IFBUpdate { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 84 | public: |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 85 | explicit FBUpdateSplit(hwc_context_t *ctx, const int& dpy); |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 86 | virtual ~FBUpdateSplit() {}; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 87 | bool prepare(hwc_context_t *ctx, hwc_display_contents_1 *list, |
Jeykumar Sankaran | c2d78d8 | 2014-02-14 14:55:29 -0800 | [diff] [blame] | 88 | hwc_rect_t fbUpdatingRect, int fbZorder); |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 89 | bool draw(hwc_context_t *ctx, private_handle_t *hnd); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 90 | void reset(); |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 91 | |
| 92 | protected: |
| 93 | virtual bool configure(hwc_context_t *ctx, hwc_display_contents_1 *list, |
Jeykumar Sankaran | c2d78d8 | 2014-02-14 14:55:29 -0800 | [diff] [blame] | 94 | hwc_rect_t fbUpdatingRect, int fbZorder); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 95 | ovutils::eDest mDestLeft; //left pipe to draw on |
| 96 | ovutils::eDest mDestRight; //right pipe to draw on |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 97 | }; |
| 98 | |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 99 | //Source Split Handler |
| 100 | class FBSrcSplit : public FBUpdateSplit { |
| 101 | public: |
| 102 | explicit FBSrcSplit(hwc_context_t *ctx, const int& dpy); |
| 103 | virtual ~FBSrcSplit() {}; |
| 104 | private: |
| 105 | bool configure(hwc_context_t *ctx, hwc_display_contents_1 *list, |
| 106 | hwc_rect_t fbUpdatingRect, int fbZorder); |
| 107 | }; |
| 108 | |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 109 | }; //namespace qhwc |
| 110 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 111 | #endif //HWC_FBUPDATE_H |