Home | History | Annotate | Download | only in DisplayHardware
      1 /*
      2  * Copyright (C) 2007 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef ANDROID_DISPLAY_HARDWARE_H
     18 #define ANDROID_DISPLAY_HARDWARE_H
     19 
     20 #include <stdlib.h>
     21 
     22 #include <ui/PixelFormat.h>
     23 #include <ui/Region.h>
     24 
     25 #include <GLES/gl.h>
     26 #include <GLES/glext.h>
     27 #include <EGL/egl.h>
     28 #include <EGL/eglext.h>
     29 
     30 #include <pixelflinger/pixelflinger.h>
     31 
     32 #include "GLExtensions.h"
     33 
     34 #include "DisplayHardware/DisplayHardwareBase.h"
     35 
     36 struct overlay_control_device_t;
     37 struct framebuffer_device_t;
     38 struct copybit_image_t;
     39 
     40 namespace android {
     41 
     42 class FramebufferNativeWindow;
     43 
     44 class DisplayHardware : public DisplayHardwareBase
     45 {
     46 public:
     47     enum {
     48         COPY_BITS_EXTENSION         = 0x00000008,
     49         BUFFER_PRESERVED            = 0x00010000,
     50         PARTIAL_UPDATES             = 0x00020000,   // video driver feature
     51         SLOW_CONFIG                 = 0x00040000,   // software
     52         SWAP_RECTANGLE              = 0x00080000,
     53     };
     54 
     55     DisplayHardware(
     56             const sp<SurfaceFlinger>& flinger,
     57             uint32_t displayIndex);
     58 
     59     ~DisplayHardware();
     60 
     61     void releaseScreen() const;
     62     void acquireScreen() const;
     63 
     64     // Flip the front and back buffers if the back buffer is "dirty".  Might
     65     // be instantaneous, might involve copying the frame buffer around.
     66     void flip(const Region& dirty) const;
     67     status_t postBypassBuffer(const native_handle_t* handle) const;
     68 
     69     float       getDpiX() const;
     70     float       getDpiY() const;
     71     float       getRefreshRate() const;
     72     float       getDensity() const;
     73     int         getWidth() const;
     74     int         getHeight() const;
     75     PixelFormat getFormat() const;
     76     uint32_t    getFlags() const;
     77     void        makeCurrent() const;
     78     uint32_t    getMaxTextureSize() const;
     79     uint32_t    getMaxViewportDims() const;
     80 
     81     uint32_t getPageFlipCount() const;
     82     EGLDisplay getEGLDisplay() const { return mDisplay; }
     83     overlay_control_device_t* getOverlayEngine() const { return mOverlayEngine; }
     84 
     85     status_t compositionComplete() const;
     86 
     87     Rect bounds() const {
     88         return Rect(mWidth, mHeight);
     89     }
     90 
     91     // only for debugging
     92     int getCurrentBufferIndex() const;
     93 
     94 private:
     95     void init(uint32_t displayIndex) __attribute__((noinline));
     96     void fini() __attribute__((noinline));
     97 
     98     EGLDisplay      mDisplay;
     99     EGLSurface      mSurface;
    100     EGLContext      mContext;
    101     EGLConfig       mConfig;
    102     float           mDpiX;
    103     float           mDpiY;
    104     float           mRefreshRate;
    105     float           mDensity;
    106     int             mWidth;
    107     int             mHeight;
    108     PixelFormat     mFormat;
    109     uint32_t        mFlags;
    110     mutable uint32_t mPageFlipCount;
    111     GLint           mMaxViewportDims;
    112     GLint           mMaxTextureSize;
    113 
    114     sp<FramebufferNativeWindow> mNativeWindow;
    115     overlay_control_device_t* mOverlayEngine;
    116 };
    117 
    118 }; // namespace android
    119 
    120 #endif // ANDROID_DISPLAY_HARDWARE_H
    121