The Android Open Source Project | 9066cfe | 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 | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 25 | #include <GLES/gl.h> |
| 26 | #include <GLES/glext.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | #include <EGL/egl.h> |
Mathias Agopian | 1473f46 | 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 | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | |
Mathias Agopian | 781953d | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 32 | #include "GLExtensions.h" |
| 33 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | #include "DisplayHardware/DisplayHardwareBase.h" |
| 35 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | namespace android { |
| 37 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 38 | class FramebufferNativeWindow; |
Mathias Agopian | e0d5f5b | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 39 | class HWComposer; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | |
| 41 | class DisplayHardware : public DisplayHardwareBase |
| 42 | { |
| 43 | public: |
| 44 | enum { |
Mathias Agopian | 781953d | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 45 | COPY_BITS_EXTENSION = 0x00000008, |
| 46 | BUFFER_PRESERVED = 0x00010000, |
| 47 | PARTIAL_UPDATES = 0x00020000, // video driver feature |
| 48 | SLOW_CONFIG = 0x00040000, // software |
| 49 | SWAP_RECTANGLE = 0x00080000, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | DisplayHardware( |
| 53 | const sp<SurfaceFlinger>& flinger, |
| 54 | uint32_t displayIndex); |
| 55 | |
| 56 | ~DisplayHardware(); |
| 57 | |
| 58 | void releaseScreen() const; |
| 59 | void acquireScreen() const; |
| 60 | |
| 61 | // Flip the front and back buffers if the back buffer is "dirty". Might |
| 62 | // be instantaneous, might involve copying the frame buffer around. |
| 63 | void flip(const Region& dirty) const; |
| 64 | |
| 65 | float getDpiX() const; |
| 66 | float getDpiY() const; |
| 67 | float getRefreshRate() const; |
| 68 | float getDensity() const; |
| 69 | int getWidth() const; |
| 70 | int getHeight() const; |
| 71 | PixelFormat getFormat() const; |
| 72 | uint32_t getFlags() const; |
| 73 | void makeCurrent() const; |
Mathias Agopian | 967dce3 | 2010-04-14 16:43:44 -0700 | [diff] [blame] | 74 | uint32_t getMaxTextureSize() const; |
| 75 | uint32_t getMaxViewportDims() const; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 76 | |
| 77 | uint32_t getPageFlipCount() const; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 78 | EGLDisplay getEGLDisplay() const { return mDisplay; } |
Mathias Agopian | e0d5f5b | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 79 | |
Erik Gilling | 94720d7 | 2010-12-01 16:38:01 -0800 | [diff] [blame] | 80 | void dump(String8& res) const; |
| 81 | |
Mathias Agopian | e0d5f5b | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 82 | // Hardware Composer |
| 83 | HWComposer& getHwComposer() const; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 84 | |
Mathias Agopian | b1a1874 | 2009-09-17 16:18:16 -0700 | [diff] [blame] | 85 | status_t compositionComplete() const; |
| 86 | |
Mathias Agopian | 88cde07 | 2011-09-20 17:21:56 -0700 | [diff] [blame] | 87 | Rect getBounds() const { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 88 | return Rect(mWidth, mHeight); |
| 89 | } |
Mathias Agopian | 88cde07 | 2011-09-20 17:21:56 -0700 | [diff] [blame] | 90 | inline Rect bounds() const { return getBounds(); } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 91 | |
Mathias Agopian | 04262e9 | 2010-09-13 22:57:58 -0700 | [diff] [blame] | 92 | // only for debugging |
| 93 | int getCurrentBufferIndex() const; |
| 94 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 95 | private: |
| 96 | void init(uint32_t displayIndex) __attribute__((noinline)); |
| 97 | void fini() __attribute__((noinline)); |
| 98 | |
Mathias Agopian | a0bd0d8 | 2011-08-01 16:32:21 -0700 | [diff] [blame] | 99 | sp<SurfaceFlinger> mFlinger; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 100 | EGLDisplay mDisplay; |
| 101 | EGLSurface mSurface; |
| 102 | EGLContext mContext; |
| 103 | EGLConfig mConfig; |
| 104 | float mDpiX; |
| 105 | float mDpiY; |
| 106 | float mRefreshRate; |
| 107 | float mDensity; |
| 108 | int mWidth; |
| 109 | int mHeight; |
| 110 | PixelFormat mFormat; |
| 111 | uint32_t mFlags; |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 112 | mutable uint32_t mPageFlipCount; |
Mathias Agopian | c94dce5 | 2011-04-18 15:59:24 -0700 | [diff] [blame] | 113 | GLint mMaxViewportDims[2]; |
Mathias Agopian | 967dce3 | 2010-04-14 16:43:44 -0700 | [diff] [blame] | 114 | GLint mMaxTextureSize; |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 115 | |
Mathias Agopian | e0d5f5b | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 116 | HWComposer* mHwc; |
| 117 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 118 | sp<FramebufferNativeWindow> mNativeWindow; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | }; // namespace android |
| 122 | |
| 123 | #endif // ANDROID_DISPLAY_HARDWARE_H |