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 "DisplayHardware/DisplayHardwareBase.h" 33 34 struct overlay_control_device_t; 35 struct framebuffer_device_t; 36 struct copybit_image_t; 37 38 namespace android { 39 40 class FramebufferNativeWindow; 41 42 class DisplayHardware : public DisplayHardwareBase 43 { 44 public: 45 enum { 46 DIRECT_TEXTURE = 0x00000002, 47 COPY_BITS_EXTENSION = 0x00000008, 48 NPOT_EXTENSION = 0x00000100, 49 DRAW_TEXTURE_EXTENSION = 0x00000200, 50 BUFFER_PRESERVED = 0x00010000, 51 PARTIAL_UPDATES = 0x00020000, // video driver feature 52 SLOW_CONFIG = 0x00040000, // software 53 SWAP_RECTANGLE = 0x00080000, 54 CACHED_BUFFERS = 0x00100000 55 }; 56 57 DisplayHardware( 58 const sp<SurfaceFlinger>& flinger, 59 uint32_t displayIndex); 60 61 ~DisplayHardware(); 62 63 void releaseScreen() const; 64 void acquireScreen() const; 65 66 // Flip the front and back buffers if the back buffer is "dirty". Might 67 // be instantaneous, might involve copying the frame buffer around. 68 void flip(const Region& dirty) const; 69 70 float getDpiX() const; 71 float getDpiY() const; 72 float getRefreshRate() const; 73 float getDensity() const; 74 int getWidth() const; 75 int getHeight() const; 76 PixelFormat getFormat() const; 77 uint32_t getFlags() const; 78 void makeCurrent() const; 79 uint32_t getMaxTextureSize() const; 80 uint32_t getMaxViewportDims() const; 81 82 uint32_t getPageFlipCount() const; 83 EGLDisplay getEGLDisplay() const { return mDisplay; } 84 overlay_control_device_t* getOverlayEngine() const { return mOverlayEngine; } 85 86 status_t compositionComplete() const; 87 88 Rect bounds() const { 89 return Rect(mWidth, mHeight); 90 } 91 92 private: 93 void init(uint32_t displayIndex) __attribute__((noinline)); 94 void fini() __attribute__((noinline)); 95 96 EGLDisplay mDisplay; 97 EGLSurface mSurface; 98 EGLContext mContext; 99 EGLConfig mConfig; 100 float mDpiX; 101 float mDpiY; 102 float mRefreshRate; 103 float mDensity; 104 int mWidth; 105 int mHeight; 106 PixelFormat mFormat; 107 uint32_t mFlags; 108 mutable uint32_t mPageFlipCount; 109 GLint mMaxViewportDims; 110 GLint mMaxTextureSize; 111 112 sp<FramebufferNativeWindow> mNativeWindow; 113 overlay_control_device_t* mOverlayEngine; 114 }; 115 116 }; // namespace android 117 118 #endif // ANDROID_DISPLAY_HARDWARE_H 119