blob: da4cdfcc4856e2121ec855255da242793ba8445d [file] [log] [blame]
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
Saurabh Shah56f610d2012-08-07 15:27:06 -07003 * Copyright (C) 2012, The Linux Foundation. All rights reserved.
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -07004 *
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 Ahmed758bfc52012-11-28 17:02:08 -050020#ifndef HWC_FBUPDATE_H
21#define HWC_FBUPDATE_H
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -070022#include "hwc_utils.h"
Naseer Ahmed72cf9762012-07-21 12:17:13 -070023#include "overlay.h"
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -070024
25#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
26#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
27
Arun Kumar K.Rffef7482013-04-10 14:17:22 -070028namespace overlay {
29 class Rotator;
30}
31
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -070032namespace qhwc {
Naseer Ahmed758bfc52012-11-28 17:02:08 -050033namespace ovutils = overlay::utils;
34
Saurabh Shahcf053c62012-12-13 12:32:55 -080035//Framebuffer update Interface
36class IFBUpdate {
37public:
Saurabh Shah220a30c2013-10-29 16:12:12 -070038 explicit IFBUpdate(hwc_context_t *ctx, const int& dpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -080039 virtual ~IFBUpdate() {};
40 // Sets up members and prepares overlay if conditions are met
Jeykumar Sankaran85977e32013-02-25 17:06:08 -080041 virtual bool prepare(hwc_context_t *ctx, hwc_display_contents_1 *list,
Saurabh Shaha36be922013-12-16 18:18:39 -080042 int fbZorder) = 0;
43 virtual bool prepareAndValidate(hwc_context_t *ctx,
44 hwc_display_contents_1 *list, int fbZorder);
Saurabh Shahcf053c62012-12-13 12:32:55 -080045 // Draws layer
Naseer Ahmed64b81212013-02-14 10:29:47 -050046 virtual bool draw(hwc_context_t *ctx, private_handle_t *hnd) = 0;
Saurabh Shahcf053c62012-12-13 12:32:55 -080047 //Reset values
48 virtual void reset();
49 //Factory method that returns a low-res or high-res version
Saurabh Shah88e4d272013-09-03 13:31:29 -070050 static IFBUpdate *getObject(hwc_context_t *ctx, const int& dpy);
Jeykumar Sankaran85977e32013-02-25 17:06:08 -080051
Saurabh Shahcf053c62012-12-13 12:32:55 -080052protected:
53 const int mDpy; // display to update
54 bool mModeOn; // if prepare happened
Arun Kumar K.Rffef7482013-04-10 14:17:22 -070055 overlay::Rotator *mRot;
Saurabh Shah220a30c2013-10-29 16:12:12 -070056 int mAlignedFBWidth;
57 int mAlignedFBHeight;
Manoj Kumar AVM8a220812013-10-10 11:46:06 -070058 int mTileEnabled;
Saurabh Shahcf053c62012-12-13 12:32:55 -080059};
60
Saurabh Shah88e4d272013-09-03 13:31:29 -070061//Non-Split panel handler.
62class FBUpdateNonSplit : public IFBUpdate {
Saurabh Shahcf053c62012-12-13 12:32:55 -080063public:
Saurabh Shah220a30c2013-10-29 16:12:12 -070064 explicit FBUpdateNonSplit(hwc_context_t *ctx, const int& dpy);
Saurabh Shah88e4d272013-09-03 13:31:29 -070065 virtual ~FBUpdateNonSplit() {};
Jeykumar Sankaran85977e32013-02-25 17:06:08 -080066 bool prepare(hwc_context_t *ctx, hwc_display_contents_1 *list,
Saurabh Shah67a38c32013-06-10 16:23:15 -070067 int fbZorder);
Naseer Ahmed64b81212013-02-14 10:29:47 -050068 bool draw(hwc_context_t *ctx, private_handle_t *hnd);
Saurabh Shahcf053c62012-12-13 12:32:55 -080069 void reset();
70private:
Jeykumar Sankaran85977e32013-02-25 17:06:08 -080071 bool configure(hwc_context_t *ctx, hwc_display_contents_1 *list,
Saurabh Shah67a38c32013-06-10 16:23:15 -070072 int fbZorder);
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -070073 bool preRotateExtDisplay(hwc_context_t *ctx,
Prabhanjan Kanduladb202b72013-10-30 17:29:46 +053074 hwc_layer_1_t *layer,
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -070075 ovutils::Whf &info,
76 hwc_rect_t& sourceCrop,
77 ovutils::eMdpFlags& mdpFlags,
78 int& rotFlags);
Saurabh Shahcf053c62012-12-13 12:32:55 -080079 ovutils::eDest mDest; //pipe to draw on
80};
81
Saurabh Shah88e4d272013-09-03 13:31:29 -070082//Split panel handler.
83class FBUpdateSplit : public IFBUpdate {
Saurabh Shahcf053c62012-12-13 12:32:55 -080084public:
Saurabh Shah220a30c2013-10-29 16:12:12 -070085 explicit FBUpdateSplit(hwc_context_t *ctx, const int& dpy);
Saurabh Shah88e4d272013-09-03 13:31:29 -070086 virtual ~FBUpdateSplit() {};
Jeykumar Sankaran85977e32013-02-25 17:06:08 -080087 bool prepare(hwc_context_t *ctx, hwc_display_contents_1 *list,
Saurabh Shah67a38c32013-06-10 16:23:15 -070088 int fbZorder);
Naseer Ahmed64b81212013-02-14 10:29:47 -050089 bool draw(hwc_context_t *ctx, private_handle_t *hnd);
Saurabh Shahcf053c62012-12-13 12:32:55 -080090 void reset();
91private:
Jeykumar Sankaran85977e32013-02-25 17:06:08 -080092 bool configure(hwc_context_t *ctx, hwc_display_contents_1 *list,
Saurabh Shah67a38c32013-06-10 16:23:15 -070093 int fbZorder);
Saurabh Shahcf053c62012-12-13 12:32:55 -080094 ovutils::eDest mDestLeft; //left pipe to draw on
95 ovutils::eDest mDestRight; //right pipe to draw on
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -070096};
97
98}; //namespace qhwc
99
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500100#endif //HWC_FBUPDATE_H