blob: 015d85a5c8f2e500d2b3f70e1e57e28f65741d96 [file] [log] [blame]
Naseer Ahmed31da0b12012-07-31 18:55:33 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
Arun Kumar K.R361da4f2012-11-28 10:42:59 -08003 * Copyright (C) 2012-2013, The Linux Foundation. All rights reserved.
Naseer Ahmed31da0b12012-07-31 18:55:33 -07004 *
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 Ahmed31da0b12012-07-31 18:55:33 -070023
24#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
25#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
26
27namespace qhwc {
Naseer Ahmed72cf9762012-07-21 12:17:13 -070028
Naseer Ahmed31da0b12012-07-31 18:55:33 -070029class CopyBit {
30public:
Arun Kumar K.R361da4f2012-11-28 10:42:59 -080031 CopyBit();
32 ~CopyBit();
33 // API to get copybit engine(non static)
34 struct copybit_device_t *getCopyBitDevice();
Naseer Ahmed31da0b12012-07-31 18:55:33 -070035 //Sets up members and prepares copybit if conditions are met
Arun Kumar K.R361da4f2012-11-28 10:42:59 -080036 bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list,
37 int dpy);
Naseer Ahmed31da0b12012-07-31 18:55:33 -070038 //Draws layer if the layer is set for copybit in prepare
Arun Kumar K.R361da4f2012-11-28 10:42:59 -080039 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 Ahmed31da0b12012-07-31 18:55:33 -070043private:
Arun Kumar K.R361da4f2012-11-28 10:42:59 -080044 // 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 Ahmed31da0b12012-07-31 18:55:33 -070054 //Flags if this feature is on.
Arun Kumar K.R361da4f2012-11-28 10:42:59 -080055 bool mIsModeOn;
56 // flag that indicates whether CopyBit composition is enabled for this cycle
57 bool mCopyBitDraw;
Naseer Ahmed31da0b12012-07-31 18:55:33 -070058
Arun Kumar K.R361da4f2012-11-28 10:42:59 -080059 unsigned int getRGBRenderingArea
60 (const hwc_display_contents_1_t *list);
Naseer Ahmed31da0b12012-07-31 18:55:33 -070061
Arun Kumar K.R361da4f2012-11-28 10:42:59 -080062 void getLayerResolution(const hwc_layer_1_t* layer,
Naseer Ahmed45a99602012-07-31 19:15:24 -070063 unsigned int &width, unsigned int& height);
Naseer Ahmed31da0b12012-07-31 18:55:33 -070064};
65
Naseer Ahmed31da0b12012-07-31 18:55:33 -070066}; //namespace qhwc
67
68#endif //HWC_COPYBIT_H