Home | History | Annotate | Download | only in libhwcomposer
      1 /*
      2  * Copyright (C) 2010 The Android Open Source Project
      3  * Copyright (C) 2012, The Linux Foundation. All rights reserved.
      4  *
      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  */
     20 #ifndef HWC_FBUPDATE_H
     21 #define HWC_FBUPDATE_H
     22 #include "hwc_utils.h"
     23 #include "overlay.h"
     24 
     25 #define LIKELY( exp )       (__builtin_expect( (exp) != 0, true  ))
     26 #define UNLIKELY( exp )     (__builtin_expect( (exp) != 0, false ))
     27 
     28 namespace qhwc {
     29 namespace ovutils = overlay::utils;
     30 
     31 //Framebuffer update Interface
     32 class IFBUpdate {
     33 public:
     34     explicit IFBUpdate(const int& dpy) : mDpy(dpy) {}
     35     virtual ~IFBUpdate() {};
     36     // Sets up members and prepares overlay if conditions are met
     37     virtual bool prepare(hwc_context_t *ctx, hwc_display_contents_1 *list,
     38                                                        int fbZorder) = 0;
     39     // Draws layer
     40     virtual bool draw(hwc_context_t *ctx, private_handle_t *hnd) = 0;
     41     //Reset values
     42     virtual void reset();
     43     //Factory method that returns a low-res or high-res version
     44     static IFBUpdate *getObject(const int& width, const int& dpy);
     45 
     46 protected:
     47     const int mDpy; // display to update
     48     bool mModeOn; // if prepare happened
     49 };
     50 
     51 //Low resolution (<= 2048) panel handler.
     52 class FBUpdateLowRes : public IFBUpdate {
     53 public:
     54     explicit FBUpdateLowRes(const int& dpy);
     55     virtual ~FBUpdateLowRes() {};
     56     bool prepare(hwc_context_t *ctx, hwc_display_contents_1 *list,
     57                                                           int fbZorder);
     58     bool draw(hwc_context_t *ctx, private_handle_t *hnd);
     59     void reset();
     60 private:
     61     bool configure(hwc_context_t *ctx, hwc_display_contents_1 *list,
     62                                                                int fbZorder);
     63     ovutils::eDest mDest; //pipe to draw on
     64 };
     65 
     66 //High resolution (> 2048) panel handler.
     67 class FBUpdateHighRes : public IFBUpdate {
     68 public:
     69     explicit FBUpdateHighRes(const int& dpy);
     70     virtual ~FBUpdateHighRes() {};
     71     bool prepare(hwc_context_t *ctx, hwc_display_contents_1 *list,
     72                                                              int fbZorder);
     73     bool draw(hwc_context_t *ctx, private_handle_t *hnd);
     74     void reset();
     75 private:
     76     bool configure(hwc_context_t *ctx, hwc_display_contents_1 *list,
     77                                                             int fbZorder);
     78     ovutils::eDest mDestLeft; //left pipe to draw on
     79     ovutils::eDest mDestRight; //right pipe to draw on
     80 };
     81 
     82 }; //namespace qhwc
     83 
     84 #endif //HWC_FBUPDATE_H
     85