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 | |
Jamie Gennis | 1a4d883 | 2012-08-02 20:11:05 -0700 | [diff] [blame] | 23 | #include <gui/ConsumerBase.h> |
Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 24 | |
| 25 | #define NUM_FRAME_BUFFERS 2 |
| 26 | |
| 27 | // --------------------------------------------------------------------------- |
| 28 | namespace android { |
| 29 | // --------------------------------------------------------------------------- |
| 30 | |
| 31 | class Rect; |
| 32 | class String8; |
| 33 | |
| 34 | // --------------------------------------------------------------------------- |
| 35 | |
Jamie Gennis | 1a4d883 | 2012-08-02 20:11:05 -0700 | [diff] [blame] | 36 | class FramebufferSurface : public ConsumerBase { |
Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 37 | public: |
Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 38 | |
Mathias Agopian | a491260 | 2012-07-12 14:25:33 -0700 | [diff] [blame] | 39 | static sp<FramebufferSurface> create(); |
Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 40 | |
Jamie Gennis | 1a4d883 | 2012-08-02 20:11:05 -0700 | [diff] [blame] | 41 | bool isUpdateOnDemand() const { return false; } |
Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 42 | status_t setUpdateRectangle(const Rect& updateRect); |
| 43 | status_t compositionComplete(); |
| 44 | |
Jamie Gennis | 1a4d883 | 2012-08-02 20:11:05 -0700 | [diff] [blame] | 45 | virtual void dump(String8& result); |
Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 46 | |
Jamie Gennis | 1a4d883 | 2012-08-02 20:11:05 -0700 | [diff] [blame] | 47 | // nextBuffer waits for and then latches the next buffer from the |
| 48 | // BufferQueue and releases the previously latched buffer to the |
| 49 | // BufferQueue. The new buffer is returned in the 'buffer' argument. |
| 50 | status_t nextBuffer(sp<GraphicBuffer>* buffer); |
Mathias Agopian | a491260 | 2012-07-12 14:25:33 -0700 | [diff] [blame] | 51 | |
Mathias Agopian | 8b736f1 | 2012-08-13 17:54:26 -0700 | [diff] [blame] | 52 | // FIXME: currently there are information we can only get from the |
| 53 | // FB HAL, and FB HAL can only be instantiated once on some devices. |
| 54 | // Eventually this functionality will have to move in HWC or somewhere else. |
| 55 | const framebuffer_device_t* getFbHal() const { |
| 56 | return fbDev; |
| 57 | } |
| 58 | |
Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 59 | private: |
Mathias Agopian | a491260 | 2012-07-12 14:25:33 -0700 | [diff] [blame] | 60 | FramebufferSurface(); |
Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 61 | virtual ~FramebufferSurface(); // this class cannot be overloaded |
Jamie Gennis | 1a4d883 | 2012-08-02 20:11:05 -0700 | [diff] [blame] | 62 | |
| 63 | virtual void onFrameAvailable(); |
| 64 | virtual void freeBufferLocked(int slotIndex); |
Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 65 | |
| 66 | framebuffer_device_t* fbDev; |
| 67 | |
Jamie Gennis | 1a4d883 | 2012-08-02 20:11:05 -0700 | [diff] [blame] | 68 | // mCurrentBufferIndex is the slot index of the current buffer or |
| 69 | // INVALID_BUFFER_SLOT to indicate that either there is no current buffer |
| 70 | // or the buffer is not associated with a slot. |
| 71 | int mCurrentBufferSlot; |
Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 72 | |
Jamie Gennis | 1a4d883 | 2012-08-02 20:11:05 -0700 | [diff] [blame] | 73 | // mCurrentBuffer is the current buffer or NULL to indicate that there is |
| 74 | // no current buffer. |
| 75 | sp<GraphicBuffer> mCurrentBuffer; |
Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | // --------------------------------------------------------------------------- |
| 79 | }; // namespace android |
| 80 | // --------------------------------------------------------------------------- |
| 81 | |
| 82 | #endif // ANDROID_SF_FRAMEBUFFER_SURFACE_H |
| 83 | |