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" |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame^] | 35 | #include "DisplayHardware/VSyncBarrier.h" |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | namespace android { |
| 38 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 39 | class FramebufferNativeWindow; |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 40 | class HWComposer; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | |
| 42 | class DisplayHardware : public DisplayHardwareBase |
| 43 | { |
| 44 | public: |
| 45 | enum { |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 46 | COPY_BITS_EXTENSION = 0x00000008, |
| 47 | BUFFER_PRESERVED = 0x00010000, |
| 48 | PARTIAL_UPDATES = 0x00020000, // video driver feature |
| 49 | SLOW_CONFIG = 0x00040000, // software |
| 50 | SWAP_RECTANGLE = 0x00080000, |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | DisplayHardware( |
| 54 | const sp<SurfaceFlinger>& flinger, |
| 55 | uint32_t displayIndex); |
| 56 | |
| 57 | ~DisplayHardware(); |
| 58 | |
| 59 | void releaseScreen() const; |
| 60 | void acquireScreen() const; |
| 61 | |
| 62 | // Flip the front and back buffers if the back buffer is "dirty". Might |
| 63 | // be instantaneous, might involve copying the frame buffer around. |
| 64 | void flip(const Region& dirty) const; |
| 65 | |
| 66 | float getDpiX() const; |
| 67 | float getDpiY() const; |
| 68 | float getRefreshRate() const; |
| 69 | float getDensity() const; |
| 70 | int getWidth() const; |
| 71 | int getHeight() const; |
| 72 | PixelFormat getFormat() const; |
| 73 | uint32_t getFlags() const; |
| 74 | void makeCurrent() const; |
Mathias Agopian | ca99fb8 | 2010-04-14 16:43:44 -0700 | [diff] [blame] | 75 | uint32_t getMaxTextureSize() const; |
| 76 | uint32_t getMaxViewportDims() const; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 77 | |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame^] | 78 | // waits for the next vsync and returns the timestamp of when it happened |
| 79 | nsecs_t waitForVSync() const; |
| 80 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 81 | uint32_t getPageFlipCount() const; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 82 | EGLDisplay getEGLDisplay() const { return mDisplay; } |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 83 | |
Erik Gilling | 1d21a9c | 2010-12-01 16:38:01 -0800 | [diff] [blame] | 84 | void dump(String8& res) const; |
| 85 | |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 86 | // Hardware Composer |
| 87 | HWComposer& getHwComposer() const; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 88 | |
Mathias Agopian | 74faca2 | 2009-09-17 16:18:16 -0700 | [diff] [blame] | 89 | status_t compositionComplete() const; |
| 90 | |
Mathias Agopian | 9c6e297 | 2011-09-20 17:21:56 -0700 | [diff] [blame] | 91 | Rect getBounds() const { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 92 | return Rect(mWidth, mHeight); |
| 93 | } |
Mathias Agopian | 9c6e297 | 2011-09-20 17:21:56 -0700 | [diff] [blame] | 94 | inline Rect bounds() const { return getBounds(); } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 95 | |
Mathias Agopian | 35b48d1 | 2010-09-13 22:57:58 -0700 | [diff] [blame] | 96 | // only for debugging |
| 97 | int getCurrentBufferIndex() const; |
| 98 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 99 | private: |
| 100 | void init(uint32_t displayIndex) __attribute__((noinline)); |
| 101 | void fini() __attribute__((noinline)); |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame^] | 102 | int32_t getDelayToNextVSyncUs(nsecs_t* timestamp) const; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 103 | |
Mathias Agopian | c7d14e2 | 2011-08-01 16:32:21 -0700 | [diff] [blame] | 104 | sp<SurfaceFlinger> mFlinger; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 105 | EGLDisplay mDisplay; |
| 106 | EGLSurface mSurface; |
| 107 | EGLContext mContext; |
| 108 | EGLConfig mConfig; |
| 109 | float mDpiX; |
| 110 | float mDpiY; |
| 111 | float mRefreshRate; |
| 112 | float mDensity; |
| 113 | int mWidth; |
| 114 | int mHeight; |
| 115 | PixelFormat mFormat; |
| 116 | uint32_t mFlags; |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 117 | mutable uint32_t mPageFlipCount; |
Mathias Agopian | 3d64e73 | 2011-04-18 15:59:24 -0700 | [diff] [blame] | 118 | GLint mMaxViewportDims[2]; |
Mathias Agopian | ca99fb8 | 2010-04-14 16:43:44 -0700 | [diff] [blame] | 119 | GLint mMaxTextureSize; |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame^] | 120 | VSyncBarrier mVSync; |
| 121 | |
| 122 | mutable Mutex mFakeVSyncMutex; |
| 123 | mutable nsecs_t mNextFakeVSync; |
| 124 | nsecs_t mRefreshPeriod; |
| 125 | |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 126 | HWComposer* mHwc; |
| 127 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 128 | sp<FramebufferNativeWindow> mNativeWindow; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 129 | }; |
| 130 | |
| 131 | }; // namespace android |
| 132 | |
| 133 | #endif // ANDROID_DISPLAY_HARDWARE_H |