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 | |
Mathias Agopian | 0926f50 | 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 | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | |
Andy McFadden | 2e33649 | 2014-03-05 15:40:26 -0800 | [diff] [blame] | 20 | #warning "FramebufferNativeWindow is deprecated" |
| 21 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | #include <stdint.h> |
| 23 | #include <sys/types.h> |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 24 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | #include <EGL/egl.h> |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 26 | |
| 27 | #include <utils/threads.h> |
Erik Gilling | 1d21a9c | 2010-12-01 16:38:01 -0800 | [diff] [blame] | 28 | #include <utils/String8.h> |
Mathias Agopian | 5f2165f | 2012-02-24 18:25:41 -0800 | [diff] [blame] | 29 | |
| 30 | #include <ui/ANativeObjectBase.h> |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 31 | #include <ui/Rect.h> |
| 32 | |
Naseer Ahmed | 0bc64be | 2012-06-29 12:02:32 -0700 | [diff] [blame] | 33 | #define MIN_NUM_FRAME_BUFFERS 2 |
| 34 | #define MAX_NUM_FRAME_BUFFERS 3 |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 35 | |
| 36 | extern "C" EGLNativeWindowType android_createDisplaySurface(void); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | |
| 38 | // --------------------------------------------------------------------------- |
| 39 | namespace android { |
| 40 | // --------------------------------------------------------------------------- |
| 41 | |
| 42 | class Surface; |
Mathias Agopian | 7189c00 | 2009-05-05 18:11:11 -0700 | [diff] [blame] | 43 | class NativeBuffer; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 45 | // --------------------------------------------------------------------------- |
| 46 | |
| 47 | class FramebufferNativeWindow |
Mathias Agopian | 5f2165f | 2012-02-24 18:25:41 -0800 | [diff] [blame] | 48 | : public ANativeObjectBase< |
Dianne Hackborn | 4b5e91e | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 49 | ANativeWindow, |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 50 | FramebufferNativeWindow, |
| 51 | LightRefBase<FramebufferNativeWindow> > |
| 52 | { |
| 53 | public: |
| 54 | FramebufferNativeWindow(); |
| 55 | |
| 56 | framebuffer_device_t const * getDevice() const { return fbDev; } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | |
Mathias Agopian | 1e16b13 | 2009-05-07 17:40:23 -0700 | [diff] [blame] | 58 | bool isUpdateOnDemand() const { return mUpdateOnDemand; } |
| 59 | status_t setUpdateRectangle(const Rect& updateRect); |
Mathias Agopian | 74faca2 | 2009-09-17 16:18:16 -0700 | [diff] [blame] | 60 | status_t compositionComplete(); |
Erik Gilling | 1d21a9c | 2010-12-01 16:38:01 -0800 | [diff] [blame] | 61 | |
| 62 | void dump(String8& result); |
| 63 | |
Mathias Agopian | 35b48d1 | 2010-09-13 22:57:58 -0700 | [diff] [blame] | 64 | // for debugging only |
| 65 | int getCurrentBufferIndex() const; |
| 66 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 67 | private: |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 68 | friend class LightRefBase<FramebufferNativeWindow>; |
| 69 | ~FramebufferNativeWindow(); // this class cannot be overloaded |
Dianne Hackborn | 4b5e91e | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 70 | static int setSwapInterval(ANativeWindow* window, int interval); |
Jamie Gennis | d8e812c | 2012-06-13 16:32:25 -0700 | [diff] [blame] | 71 | static int dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd); |
| 72 | static int queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd); |
Iliyan Malchev | 41abd67 | 2011-04-14 16:54:38 -0700 | [diff] [blame] | 73 | static int query(const ANativeWindow* window, int what, int* value); |
Dianne Hackborn | 4b5e91e | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 74 | static int perform(ANativeWindow* window, int operation, ...); |
Jamie Gennis | d8e812c | 2012-06-13 16:32:25 -0700 | [diff] [blame] | 75 | |
| 76 | static int dequeueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer** buffer); |
| 77 | static int queueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer); |
| 78 | static int lockBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer); |
| 79 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 80 | framebuffer_device_t* fbDev; |
| 81 | alloc_device_t* grDev; |
| 82 | |
Naseer Ahmed | 0bc64be | 2012-06-29 12:02:32 -0700 | [diff] [blame] | 83 | sp<NativeBuffer> buffers[MAX_NUM_FRAME_BUFFERS]; |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 84 | sp<NativeBuffer> front; |
| 85 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 86 | mutable Mutex mutex; |
| 87 | Condition mCondition; |
| 88 | int32_t mNumBuffers; |
| 89 | int32_t mNumFreeBuffers; |
| 90 | int32_t mBufferHead; |
Mathias Agopian | 35b48d1 | 2010-09-13 22:57:58 -0700 | [diff] [blame] | 91 | int32_t mCurrentBufferIndex; |
Mathias Agopian | 1e16b13 | 2009-05-07 17:40:23 -0700 | [diff] [blame] | 92 | bool mUpdateOnDemand; |
Mathias Agopian | 69029eb | 2009-06-23 21:11:43 -0700 | [diff] [blame] | 93 | }; |
| 94 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 95 | // --------------------------------------------------------------------------- |
| 96 | }; // namespace android |
| 97 | // --------------------------------------------------------------------------- |
| 98 | |
Mathias Agopian | 0926f50 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 99 | #endif // ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 100 | |