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 | |
Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 25 | // --------------------------------------------------------------------------- |
| 26 | namespace android { |
| 27 | // --------------------------------------------------------------------------- |
| 28 | |
| 29 | class Rect; |
| 30 | class String8; |
Andy McFadden | b0d1dd3 | 2012-09-10 14:08:09 -0700 | [diff] [blame] | 31 | class HWComposer; |
Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 32 | |
| 33 | // --------------------------------------------------------------------------- |
| 34 | |
Jamie Gennis | 1a4d883 | 2012-08-02 20:11:05 -0700 | [diff] [blame] | 35 | class FramebufferSurface : public ConsumerBase { |
Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 36 | public: |
Mathias Agopian | f5a3392 | 2012-09-19 18:16:22 -0700 | [diff] [blame] | 37 | FramebufferSurface(HWComposer& hwc, int disp); |
Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 38 | |
Jamie Gennis | 1a4d883 | 2012-08-02 20:11:05 -0700 | [diff] [blame] | 39 | bool isUpdateOnDemand() const { return false; } |
Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 40 | status_t setUpdateRectangle(const Rect& updateRect); |
| 41 | status_t compositionComplete(); |
| 42 | |
Jamie Gennis | 1a4d883 | 2012-08-02 20:11:05 -0700 | [diff] [blame] | 43 | virtual void dump(String8& result); |
Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 44 | |
Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 45 | // setReleaseFenceFd stores a fence file descriptor that will signal when the |
| 46 | // current buffer is no longer being read. This fence will be returned to |
| 47 | // the producer when the current buffer is released by updateTexImage(). |
| 48 | // Multiple fences can be set for a given buffer; they will be merged into |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame^] | 49 | // a single union fence. The GLConsumer will close the file descriptor |
Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 50 | // when finished with it. |
| 51 | status_t setReleaseFenceFd(int fenceFd); |
Mathias Agopian | a491260 | 2012-07-12 14:25:33 -0700 | [diff] [blame] | 52 | |
Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 53 | private: |
Andy McFadden | b0d1dd3 | 2012-09-10 14:08:09 -0700 | [diff] [blame] | 54 | virtual ~FramebufferSurface() { }; // this class cannot be overloaded |
Jamie Gennis | 1a4d883 | 2012-08-02 20:11:05 -0700 | [diff] [blame] | 55 | |
| 56 | virtual void onFrameAvailable(); |
| 57 | virtual void freeBufferLocked(int slotIndex); |
Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 58 | |
Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 59 | // nextBuffer waits for and then latches the next buffer from the |
| 60 | // BufferQueue and releases the previously latched buffer to the |
| 61 | // BufferQueue. The new buffer is returned in the 'buffer' argument. |
| 62 | status_t nextBuffer(sp<GraphicBuffer>& outBuffer, sp<Fence>& outFence); |
| 63 | |
Mathias Agopian | f5a3392 | 2012-09-19 18:16:22 -0700 | [diff] [blame] | 64 | // mDisplayType must match one of the HWC display types |
| 65 | int mDisplayType; |
| 66 | |
Jamie Gennis | 1a4d883 | 2012-08-02 20:11:05 -0700 | [diff] [blame] | 67 | // mCurrentBufferIndex is the slot index of the current buffer or |
| 68 | // INVALID_BUFFER_SLOT to indicate that either there is no current buffer |
| 69 | // or the buffer is not associated with a slot. |
| 70 | int mCurrentBufferSlot; |
Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 71 | |
Jamie Gennis | 1a4d883 | 2012-08-02 20:11:05 -0700 | [diff] [blame] | 72 | // mCurrentBuffer is the current buffer or NULL to indicate that there is |
| 73 | // no current buffer. |
| 74 | sp<GraphicBuffer> mCurrentBuffer; |
Andy McFadden | b0d1dd3 | 2012-09-10 14:08:09 -0700 | [diff] [blame] | 75 | |
| 76 | // Hardware composer, owned by SurfaceFlinger. |
| 77 | HWComposer& mHwc; |
Mathias Agopian | 3e87601 | 2012-06-07 17:52:54 -0700 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | // --------------------------------------------------------------------------- |
| 81 | }; // namespace android |
| 82 | // --------------------------------------------------------------------------- |
| 83 | |
| 84 | #endif // ANDROID_SF_FRAMEBUFFER_SURFACE_H |
| 85 | |