The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 25 | #include <GLES/gl.h> |
| 26 | #include <GLES/glext.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | #include <EGL/egl.h> |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 28 | #include <EGL/eglext.h> |
| 29 | |
| 30 | #include <pixelflinger/pixelflinger.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 32 | #include "GLExtensions.h" |
| 33 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | #include "DisplayHardware/DisplayHardwareBase.h" |
| 35 | |
| 36 | struct overlay_control_device_t; |
Mathias Agopian | 000ca8f | 2010-08-17 20:19:23 -0700 | [diff] [blame] | 37 | struct framebuffer_device_t; |
| 38 | struct copybit_image_t; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | |
| 40 | namespace android { |
| 41 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 42 | class FramebufferNativeWindow; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | |
| 44 | class DisplayHardware : public DisplayHardwareBase |
| 45 | { |
| 46 | public: |
| 47 | enum { |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 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, |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
| 68 | float getDpiX() const; |
| 69 | float getDpiY() const; |
| 70 | float getRefreshRate() const; |
| 71 | float getDensity() const; |
| 72 | int getWidth() const; |
| 73 | int getHeight() const; |
| 74 | PixelFormat getFormat() const; |
| 75 | uint32_t getFlags() const; |
| 76 | void makeCurrent() const; |
Mathias Agopian | ca99fb8 | 2010-04-14 16:43:44 -0700 | [diff] [blame] | 77 | uint32_t getMaxTextureSize() const; |
| 78 | uint32_t getMaxViewportDims() const; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 79 | |
| 80 | uint32_t getPageFlipCount() const; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 81 | EGLDisplay getEGLDisplay() const { return mDisplay; } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 82 | overlay_control_device_t* getOverlayEngine() const { return mOverlayEngine; } |
| 83 | |
Mathias Agopian | 74faca2 | 2009-09-17 16:18:16 -0700 | [diff] [blame] | 84 | status_t compositionComplete() const; |
| 85 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | Rect bounds() const { |
| 87 | return Rect(mWidth, mHeight); |
| 88 | } |
| 89 | |
Mathias Agopian | 35b48d1 | 2010-09-13 22:57:58 -0700 | [diff] [blame] | 90 | // only for debugging |
| 91 | int getCurrentBufferIndex() const; |
| 92 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 93 | private: |
| 94 | void init(uint32_t displayIndex) __attribute__((noinline)); |
| 95 | void fini() __attribute__((noinline)); |
| 96 | |
| 97 | EGLDisplay mDisplay; |
| 98 | EGLSurface mSurface; |
| 99 | EGLContext mContext; |
| 100 | EGLConfig mConfig; |
| 101 | float mDpiX; |
| 102 | float mDpiY; |
| 103 | float mRefreshRate; |
| 104 | float mDensity; |
| 105 | int mWidth; |
| 106 | int mHeight; |
| 107 | PixelFormat mFormat; |
| 108 | uint32_t mFlags; |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 109 | mutable uint32_t mPageFlipCount; |
Mathias Agopian | ca99fb8 | 2010-04-14 16:43:44 -0700 | [diff] [blame] | 110 | GLint mMaxViewportDims; |
| 111 | GLint mMaxTextureSize; |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 112 | |
| 113 | sp<FramebufferNativeWindow> mNativeWindow; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 114 | overlay_control_device_t* mOverlayEngine; |
| 115 | }; |
| 116 | |
| 117 | }; // namespace android |
| 118 | |
| 119 | #endif // ANDROID_DISPLAY_HARDWARE_H |