blob: 10863f3dadcbea3d1d734ee80d57a5c10aa7bb0d [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
Xiaoming Zhoub49438c2013-07-02 19:17:59 -040024#define NUM_RENDER_BUFFERS 3
Naseer Ahmed31da0b12012-07-31 18:55:33 -070025
26namespace qhwc {
Naseer Ahmed72cf9762012-07-21 12:17:13 -070027
Naseer Ahmed31da0b12012-07-31 18:55:33 -070028class CopyBit {
29public:
Arun Kumar K.R361da4f2012-11-28 10:42:59 -080030 CopyBit();
31 ~CopyBit();
32 // API to get copybit engine(non static)
33 struct copybit_device_t *getCopyBitDevice();
Naseer Ahmed31da0b12012-07-31 18:55:33 -070034 //Sets up members and prepares copybit if conditions are met
Arun Kumar K.R361da4f2012-11-28 10:42:59 -080035 bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list,
36 int dpy);
Naseer Ahmed31da0b12012-07-31 18:55:33 -070037 //Draws layer if the layer is set for copybit in prepare
Arun Kumar K.R361da4f2012-11-28 10:42:59 -080038 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 Ahmed64b81212013-02-14 10:29:47 -050042
43 private_handle_t * getCurrentRenderBuffer();
44
45 void setReleaseFd(int fd);
46
Naseer Ahmed31da0b12012-07-31 18:55:33 -070047private:
Arun Kumar K.R361da4f2012-11-28 10:42:59 -080048 // 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,
Shivaraj Shettye86506a2013-08-06 12:56:30 +053052 private_handle_t *renderBuffer, int dpy, bool isFG);
Sushil Chauhan943797c2013-10-21 17:35:55 -070053 int fillColorUsingCopybit(hwc_layer_1_t *layer,
54 private_handle_t *renderBuffer);
Arun Kumar K.R361da4f2012-11-28 10:42:59 -080055 bool canUseCopybitForYUV (hwc_context_t *ctx);
56 bool canUseCopybitForRGB (hwc_context_t *ctx,
57 hwc_display_contents_1_t *list, int dpy);
58 bool validateParams (hwc_context_t *ctx,
59 const hwc_display_contents_1_t *list);
Naseer Ahmed31da0b12012-07-31 18:55:33 -070060 //Flags if this feature is on.
Arun Kumar K.R361da4f2012-11-28 10:42:59 -080061 bool mIsModeOn;
62 // flag that indicates whether CopyBit composition is enabled for this cycle
63 bool mCopyBitDraw;
Naseer Ahmed31da0b12012-07-31 18:55:33 -070064
Arun Kumar K.R361da4f2012-11-28 10:42:59 -080065 unsigned int getRGBRenderingArea
66 (const hwc_display_contents_1_t *list);
Naseer Ahmed31da0b12012-07-31 18:55:33 -070067
Arun Kumar K.R361da4f2012-11-28 10:42:59 -080068 void getLayerResolution(const hwc_layer_1_t* layer,
Naseer Ahmed45a99602012-07-31 19:15:24 -070069 unsigned int &width, unsigned int& height);
Naseer Ahmed64b81212013-02-14 10:29:47 -050070
71 int allocRenderBuffers(int w, int h, int f);
72
73 void freeRenderBuffers();
74
Naseer Ahmed183939d2013-03-14 20:44:17 -040075 int clear (private_handle_t* hnd, hwc_rect_t& rect);
76
Naseer Ahmed64b81212013-02-14 10:29:47 -050077 private_handle_t* mRenderBuffer[NUM_RENDER_BUFFERS];
78
79 // Index of the current intermediate render buffer
80 int mCurRenderBufferIndex;
81
82 //These are the the release FDs of the T-2 and T-1 round
83 //We wait on the T-2 fence
84 int mRelFd[2];
Prabhanjan Kandula73030ba2013-03-15 22:33:39 +053085
86 //Dynamic composition threshold for deciding copybit usage.
87 double mDynThreshold;
Naseer Ahmed31da0b12012-07-31 18:55:33 -070088};
89
Naseer Ahmed31da0b12012-07-31 18:55:33 -070090}; //namespace qhwc
91
92#endif //HWC_COPYBIT_H