blob: ddd24d73e5fab1b84140f2efa8ac1303212359dd [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
28namespace qhwc {
Naseer Ahmed758bfc52012-11-28 17:02:08 -050029namespace ovutils = overlay::utils;
30
Saurabh Shahcf053c62012-12-13 12:32:55 -080031//Framebuffer update Interface
32class IFBUpdate {
33public:
34 explicit IFBUpdate(const int& dpy) : mDpy(dpy) {}
35 virtual ~IFBUpdate() {};
36 // Sets up members and prepares overlay if conditions are met
Naseer Ahmed64b81212013-02-14 10:29:47 -050037 virtual bool prepare(hwc_context_t *ctx, hwc_display_contents_1 *list) = 0;
Saurabh Shahcf053c62012-12-13 12:32:55 -080038 // Draws layer
Naseer Ahmed64b81212013-02-14 10:29:47 -050039 virtual bool draw(hwc_context_t *ctx, private_handle_t *hnd) = 0;
Saurabh Shahcf053c62012-12-13 12:32:55 -080040 //Reset values
41 virtual void reset();
42 //Factory method that returns a low-res or high-res version
43 static IFBUpdate *getObject(const int& width, const int& dpy);
Sravan Kumar D.V.Nc6a82502013-03-22 06:20:04 +053044 //To know if configuring FbUpdate is needed.
45 static bool needFbUpdate(hwc_context_t *ctx,
46 const hwc_display_contents_1_t *list,
47 int dpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -080048protected:
49 const int mDpy; // display to update
50 bool mModeOn; // if prepare happened
51};
52
53//Low resolution (<= 2048) panel handler.
54class FBUpdateLowRes : public IFBUpdate {
55public:
56 explicit FBUpdateLowRes(const int& dpy);
57 virtual ~FBUpdateLowRes() {};
Naseer Ahmed64b81212013-02-14 10:29:47 -050058 bool prepare(hwc_context_t *ctx, hwc_display_contents_1 *list);
59
60 bool draw(hwc_context_t *ctx, private_handle_t *hnd);
Saurabh Shahcf053c62012-12-13 12:32:55 -080061 void reset();
62private:
Naseer Ahmed64b81212013-02-14 10:29:47 -050063 bool configure(hwc_context_t *ctx, hwc_display_contents_1 *list);
Saurabh Shahcf053c62012-12-13 12:32:55 -080064 ovutils::eDest mDest; //pipe to draw on
65};
66
67//High resolution (> 2048) panel handler.
68class FBUpdateHighRes : public IFBUpdate {
69public:
70 explicit FBUpdateHighRes(const int& dpy);
71 virtual ~FBUpdateHighRes() {};
Naseer Ahmed64b81212013-02-14 10:29:47 -050072 bool prepare(hwc_context_t *ctx, hwc_display_contents_1 *list);
73 bool draw(hwc_context_t *ctx, private_handle_t *hnd);
Saurabh Shahcf053c62012-12-13 12:32:55 -080074 void reset();
75private:
Naseer Ahmed64b81212013-02-14 10:29:47 -050076 bool configure(hwc_context_t *ctx, hwc_display_contents_1 *list);
Saurabh Shahcf053c62012-12-13 12:32:55 -080077 ovutils::eDest mDestLeft; //left pipe to draw on
78 ovutils::eDest mDestRight; //right pipe to draw on
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -070079};
80
81}; //namespace qhwc
82
Naseer Ahmed758bfc52012-11-28 17:02:08 -050083#endif //HWC_FBUPDATE_H