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