Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 3 | * Copyright (C) 2012-2013, The Linux Foundation. All rights reserved. |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 4 | * |
| 5 | * Not a Contribution, Apache license notifications and license are retained |
| 6 | * 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 | */ |
| 20 | #ifndef HWC_COPYBIT_H |
| 21 | #define HWC_COPYBIT_H |
| 22 | #include "hwc_utils.h" |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 23 | |
Xiaoming Zhou | b49438c | 2013-07-02 19:17:59 -0400 | [diff] [blame^] | 24 | #define NUM_RENDER_BUFFERS 3 |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 25 | |
| 26 | namespace qhwc { |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 27 | |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 28 | class CopyBit { |
| 29 | public: |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 30 | CopyBit(); |
| 31 | ~CopyBit(); |
| 32 | // API to get copybit engine(non static) |
| 33 | struct copybit_device_t *getCopyBitDevice(); |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 34 | //Sets up members and prepares copybit if conditions are met |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 35 | bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list, |
| 36 | int dpy); |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 37 | //Draws layer if the layer is set for copybit in prepare |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 38 | bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list, |
| 39 | int dpy, int* fd); |
| 40 | // resets the values |
| 41 | void reset(); |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 42 | |
| 43 | private_handle_t * getCurrentRenderBuffer(); |
| 44 | |
| 45 | void setReleaseFd(int fd); |
| 46 | |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 47 | private: |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 48 | // holds the copybit device |
| 49 | struct copybit_device_t *mEngine; |
| 50 | // Helper functions for copybit composition |
| 51 | int drawLayerUsingCopybit(hwc_context_t *dev, hwc_layer_1_t *layer, |
| 52 | private_handle_t *renderBuffer, int dpy); |
| 53 | bool canUseCopybitForYUV (hwc_context_t *ctx); |
| 54 | bool canUseCopybitForRGB (hwc_context_t *ctx, |
| 55 | hwc_display_contents_1_t *list, int dpy); |
| 56 | bool validateParams (hwc_context_t *ctx, |
| 57 | const hwc_display_contents_1_t *list); |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 58 | //Flags if this feature is on. |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 59 | bool mIsModeOn; |
| 60 | // flag that indicates whether CopyBit composition is enabled for this cycle |
| 61 | bool mCopyBitDraw; |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 62 | |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 63 | unsigned int getRGBRenderingArea |
| 64 | (const hwc_display_contents_1_t *list); |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 65 | |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 66 | void getLayerResolution(const hwc_layer_1_t* layer, |
Naseer Ahmed | 45a9960 | 2012-07-31 19:15:24 -0700 | [diff] [blame] | 67 | unsigned int &width, unsigned int& height); |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 68 | |
| 69 | int allocRenderBuffers(int w, int h, int f); |
| 70 | |
| 71 | void freeRenderBuffers(); |
| 72 | |
Naseer Ahmed | 183939d | 2013-03-14 20:44:17 -0400 | [diff] [blame] | 73 | int clear (private_handle_t* hnd, hwc_rect_t& rect); |
| 74 | |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 75 | private_handle_t* mRenderBuffer[NUM_RENDER_BUFFERS]; |
| 76 | |
| 77 | // Index of the current intermediate render buffer |
| 78 | int mCurRenderBufferIndex; |
| 79 | |
| 80 | //These are the the release FDs of the T-2 and T-1 round |
| 81 | //We wait on the T-2 fence |
| 82 | int mRelFd[2]; |
Prabhanjan Kandula | 73030ba | 2013-03-15 22:33:39 +0530 | [diff] [blame] | 83 | |
| 84 | //Dynamic composition threshold for deciding copybit usage. |
| 85 | double mDynThreshold; |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 86 | }; |
| 87 | |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 88 | }; //namespace qhwc |
| 89 | |
| 90 | #endif //HWC_COPYBIT_H |