FramebufferSurface.h revision a49126087b4494f4ef50873f3a3f6727265f6621
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_SF_FRAMEBUFFER_SURFACE_H 18#define ANDROID_SF_FRAMEBUFFER_SURFACE_H 19 20#include <stdint.h> 21#include <sys/types.h> 22 23#include <EGL/egl.h> 24 25#include <gui/SurfaceTextureClient.h> 26 27#define NUM_FRAME_BUFFERS 2 28 29// --------------------------------------------------------------------------- 30namespace android { 31// --------------------------------------------------------------------------- 32 33class Rect; 34class String8; 35 36// --------------------------------------------------------------------------- 37 38class FramebufferSurface : public SurfaceTextureClient { 39public: 40 41 static sp<FramebufferSurface> create(); 42 43 // TODO: this should be coming from HWC 44 float getRefreshRate() const; 45 46 bool isUpdateOnDemand() const { return mUpdateOnDemand; } 47 status_t setUpdateRectangle(const Rect& updateRect); 48 status_t compositionComplete(); 49 50 void dump(String8& result); 51 52protected: 53 virtual void onFirstRef(); 54 55private: 56 FramebufferSurface(); 57 virtual ~FramebufferSurface(); // this class cannot be overloaded 58 virtual int query(int what, int* value) const; 59 60 framebuffer_device_t* fbDev; 61 62 sp<BufferQueue> mBufferQueue; 63 int mCurrentBufferIndex; 64 sp<GraphicBuffer> mBuffers[NUM_FRAME_BUFFERS]; 65 66 mutable Mutex mLock; 67 bool mUpdateOnDemand; 68}; 69 70// --------------------------------------------------------------------------- 71}; // namespace android 72// --------------------------------------------------------------------------- 73 74#endif // ANDROID_SF_FRAMEBUFFER_SURFACE_H 75 76