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