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 INCLUDED_FROM_FRAMEBUFFER_NATIVE_WINDOW_CPP 18 #warning "FramebufferNativeWindow is deprecated" 19 #endif 20 21 #ifndef ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H 22 #define ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H 23 24 #include <stdint.h> 25 #include <sys/types.h> 26 27 #include <EGL/egl.h> 28 29 #include <utils/threads.h> 30 #include <utils/String8.h> 31 32 #include <ui/ANativeObjectBase.h> 33 #include <ui/Rect.h> 34 35 #define MIN_NUM_FRAME_BUFFERS 2 36 #define MAX_NUM_FRAME_BUFFERS 3 37 38 extern "C" EGLNativeWindowType android_createDisplaySurface(void); 39 40 // --------------------------------------------------------------------------- 41 namespace android { 42 // --------------------------------------------------------------------------- 43 44 class Surface; 45 class NativeBuffer; 46 47 // --------------------------------------------------------------------------- 48 49 class FramebufferNativeWindow 50 : public ANativeObjectBase< 51 ANativeWindow, 52 FramebufferNativeWindow, 53 LightRefBase<FramebufferNativeWindow> > 54 { 55 public: 56 FramebufferNativeWindow(); 57 getDevice()58 framebuffer_device_t const * getDevice() const { return fbDev; } 59 isUpdateOnDemand()60 bool isUpdateOnDemand() const { return mUpdateOnDemand; } 61 status_t setUpdateRectangle(const Rect& updateRect); 62 status_t compositionComplete(); 63 64 void dump(String8& result); 65 66 // for debugging only 67 int getCurrentBufferIndex() const; 68 69 private: 70 friend class LightRefBase<FramebufferNativeWindow>; 71 ~FramebufferNativeWindow(); // this class cannot be overloaded 72 static int setSwapInterval(ANativeWindow* window, int interval); 73 static int dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd); 74 static int queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd); 75 static int query(const ANativeWindow* window, int what, int* value); 76 static int perform(ANativeWindow* window, int operation, ...); 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 82 framebuffer_device_t* fbDev; 83 alloc_device_t* grDev; 84 85 sp<NativeBuffer> buffers[MAX_NUM_FRAME_BUFFERS]; 86 sp<NativeBuffer> front; 87 88 mutable Mutex mutex; 89 Condition mCondition; 90 int32_t mNumBuffers; 91 int32_t mNumFreeBuffers; 92 int32_t mBufferHead; 93 int32_t mCurrentBufferIndex; 94 bool mUpdateOnDemand; 95 }; 96 97 // --------------------------------------------------------------------------- 98 }; // namespace android 99 // --------------------------------------------------------------------------- 100 101 #endif // ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H 102 103