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 | |
Mathias Agopian | dff8e58 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 17 | #ifndef ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H |
| 18 | #define ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 22 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | #include <EGL/egl.h> |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 24 | |
| 25 | #include <utils/threads.h> |
| 26 | #include <ui/Rect.h> |
| 27 | |
| 28 | #include <pixelflinger/pixelflinger.h> |
| 29 | |
Mathias Agopian | ac2523b | 2009-05-05 18:11:11 -0700 | [diff] [blame] | 30 | #include <ui/egl/android_natives.h> |
| 31 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 32 | |
| 33 | extern "C" EGLNativeWindowType android_createDisplaySurface(void); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | |
| 35 | // --------------------------------------------------------------------------- |
| 36 | namespace android { |
| 37 | // --------------------------------------------------------------------------- |
| 38 | |
| 39 | class Surface; |
Mathias Agopian | ac2523b | 2009-05-05 18:11:11 -0700 | [diff] [blame] | 40 | class NativeBuffer; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 42 | // --------------------------------------------------------------------------- |
| 43 | |
| 44 | class FramebufferNativeWindow |
| 45 | : public EGLNativeBase< |
| 46 | android_native_window_t, |
| 47 | FramebufferNativeWindow, |
| 48 | LightRefBase<FramebufferNativeWindow> > |
| 49 | { |
| 50 | public: |
| 51 | FramebufferNativeWindow(); |
| 52 | |
| 53 | framebuffer_device_t const * getDevice() const { return fbDev; } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | |
Mathias Agopian | 97b8056 | 2009-05-07 17:40:23 -0700 | [diff] [blame] | 55 | bool isUpdateOnDemand() const { return mUpdateOnDemand; } |
| 56 | status_t setUpdateRectangle(const Rect& updateRect); |
Mathias Agopian | b1a1874 | 2009-09-17 16:18:16 -0700 | [diff] [blame] | 57 | status_t compositionComplete(); |
Mathias Agopian | 97b8056 | 2009-05-07 17:40:23 -0700 | [diff] [blame] | 58 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | private: |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 60 | friend class LightRefBase<FramebufferNativeWindow>; |
| 61 | ~FramebufferNativeWindow(); // this class cannot be overloaded |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 62 | static int setSwapInterval(android_native_window_t* window, int interval); |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 63 | static int dequeueBuffer(android_native_window_t* window, android_native_buffer_t** buffer); |
| 64 | static int lockBuffer(android_native_window_t* window, android_native_buffer_t* buffer); |
| 65 | static int queueBuffer(android_native_window_t* window, android_native_buffer_t* buffer); |
Mathias Agopian | 5b5c914 | 2009-07-30 18:14:56 -0700 | [diff] [blame] | 66 | static int query(android_native_window_t* window, int what, int* value); |
Mathias Agopian | 5cec474 | 2009-08-11 22:34:02 -0700 | [diff] [blame] | 67 | static int perform(android_native_window_t* window, int operation, ...); |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 68 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 69 | framebuffer_device_t* fbDev; |
| 70 | alloc_device_t* grDev; |
| 71 | |
| 72 | sp<NativeBuffer> buffers[2]; |
| 73 | sp<NativeBuffer> front; |
| 74 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 75 | mutable Mutex mutex; |
| 76 | Condition mCondition; |
| 77 | int32_t mNumBuffers; |
| 78 | int32_t mNumFreeBuffers; |
| 79 | int32_t mBufferHead; |
Mathias Agopian | 97b8056 | 2009-05-07 17:40:23 -0700 | [diff] [blame] | 80 | bool mUpdateOnDemand; |
Mathias Agopian | cbc4c9f | 2009-06-23 21:11:43 -0700 | [diff] [blame] | 81 | }; |
| 82 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 83 | // --------------------------------------------------------------------------- |
| 84 | }; // namespace android |
| 85 | // --------------------------------------------------------------------------- |
| 86 | |
Mathias Agopian | dff8e58 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 87 | #endif // ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 88 | |