| Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [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 |  | 
 | 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 | // --------------------------------------------------------------------------- | 
 | 30 | namespace android { | 
 | 31 | // --------------------------------------------------------------------------- | 
 | 32 |  | 
 | 33 | class Rect; | 
 | 34 | class String8; | 
 | 35 |  | 
 | 36 | // --------------------------------------------------------------------------- | 
 | 37 |  | 
 | 38 | class FramebufferSurface : public SurfaceTextureClient { | 
 | 39 | public: | 
| Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 40 |  | 
| Mathias Agopian | a491260 | 2012-07-12 14:25:33 -0700 | [diff] [blame] | 41 |     static sp<FramebufferSurface> create(); | 
| Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 42 |  | 
| Mathias Agopian | a491260 | 2012-07-12 14:25:33 -0700 | [diff] [blame] | 43 |     // TODO: this should be coming from HWC | 
 | 44 |     float getRefreshRate() const; | 
| Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 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 |  | 
| Mathias Agopian | a491260 | 2012-07-12 14:25:33 -0700 | [diff] [blame] | 52 | protected: | 
 | 53 |     virtual void onFirstRef(); | 
 | 54 |  | 
| Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 55 | private: | 
| Mathias Agopian | a491260 | 2012-07-12 14:25:33 -0700 | [diff] [blame] | 56 |     FramebufferSurface(); | 
| Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 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 |  |