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 | |
| 28 | namespace qhwc { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 29 | namespace ovutils = overlay::utils; |
| 30 | |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 31 | //Framebuffer update Interface |
| 32 | class IFBUpdate { |
| 33 | public: |
| 34 | explicit IFBUpdate(const int& dpy) : mDpy(dpy) {} |
| 35 | virtual ~IFBUpdate() {}; |
| 36 | // Sets up members and prepares overlay if conditions are met |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 37 | virtual bool prepare(hwc_context_t *ctx, hwc_display_contents_1 *list) = 0; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 38 | // Draws layer |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 39 | virtual bool draw(hwc_context_t *ctx, private_handle_t *hnd) = 0; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 40 | //Reset values |
| 41 | virtual void reset(); |
| 42 | //Factory method that returns a low-res or high-res version |
| 43 | static IFBUpdate *getObject(const int& width, const int& dpy); |
| 44 | |
| 45 | protected: |
| 46 | const int mDpy; // display to update |
| 47 | bool mModeOn; // if prepare happened |
| 48 | }; |
| 49 | |
| 50 | //Low resolution (<= 2048) panel handler. |
| 51 | class FBUpdateLowRes : public IFBUpdate { |
| 52 | public: |
| 53 | explicit FBUpdateLowRes(const int& dpy); |
| 54 | virtual ~FBUpdateLowRes() {}; |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 55 | bool prepare(hwc_context_t *ctx, hwc_display_contents_1 *list); |
| 56 | |
| 57 | bool draw(hwc_context_t *ctx, private_handle_t *hnd); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 58 | void reset(); |
| 59 | private: |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 60 | bool configure(hwc_context_t *ctx, hwc_display_contents_1 *list); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 61 | ovutils::eDest mDest; //pipe to draw on |
| 62 | }; |
| 63 | |
| 64 | //High resolution (> 2048) panel handler. |
| 65 | class FBUpdateHighRes : public IFBUpdate { |
| 66 | public: |
| 67 | explicit FBUpdateHighRes(const int& dpy); |
| 68 | virtual ~FBUpdateHighRes() {}; |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 69 | bool prepare(hwc_context_t *ctx, hwc_display_contents_1 *list); |
| 70 | bool draw(hwc_context_t *ctx, private_handle_t *hnd); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 71 | void reset(); |
| 72 | private: |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 73 | bool configure(hwc_context_t *ctx, hwc_display_contents_1 *list); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 74 | ovutils::eDest mDestLeft; //left pipe to draw on |
| 75 | ovutils::eDest mDestRight; //right pipe to draw on |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | }; //namespace qhwc |
| 79 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 80 | #endif //HWC_FBUPDATE_H |