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