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 | |
| 24 | #define LIKELY( exp ) (__builtin_expect( (exp) != 0, true )) |
| 25 | #define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false )) |
| 26 | |
| 27 | namespace qhwc { |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 28 | |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 29 | class CopyBit { |
| 30 | public: |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame^] | 31 | CopyBit(); |
| 32 | ~CopyBit(); |
| 33 | // API to get copybit engine(non static) |
| 34 | struct copybit_device_t *getCopyBitDevice(); |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 35 | //Sets up members and prepares copybit if conditions are met |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame^] | 36 | bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list, |
| 37 | int dpy); |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 38 | //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^] | 39 | bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list, |
| 40 | int dpy, int* fd); |
| 41 | // resets the values |
| 42 | void reset(); |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 43 | private: |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame^] | 44 | // holds the copybit device |
| 45 | struct copybit_device_t *mEngine; |
| 46 | // Helper functions for copybit composition |
| 47 | int drawLayerUsingCopybit(hwc_context_t *dev, hwc_layer_1_t *layer, |
| 48 | private_handle_t *renderBuffer, int dpy); |
| 49 | bool canUseCopybitForYUV (hwc_context_t *ctx); |
| 50 | bool canUseCopybitForRGB (hwc_context_t *ctx, |
| 51 | hwc_display_contents_1_t *list, int dpy); |
| 52 | bool validateParams (hwc_context_t *ctx, |
| 53 | const hwc_display_contents_1_t *list); |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 54 | //Flags if this feature is on. |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame^] | 55 | bool mIsModeOn; |
| 56 | // flag that indicates whether CopyBit composition is enabled for this cycle |
| 57 | bool mCopyBitDraw; |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 58 | |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame^] | 59 | unsigned int getRGBRenderingArea |
| 60 | (const hwc_display_contents_1_t *list); |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 61 | |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame^] | 62 | void getLayerResolution(const hwc_layer_1_t* layer, |
Naseer Ahmed | 45a9960 | 2012-07-31 19:15:24 -0700 | [diff] [blame] | 63 | unsigned int &width, unsigned int& height); |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 64 | }; |
| 65 | |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 66 | }; //namespace qhwc |
| 67 | |
| 68 | #endif //HWC_COPYBIT_H |