michael@0: /* michael@0: * Copyright (C) 2007 The Android Open Source Project michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: #ifndef ANDROID_SF_FRAMEBUFFER_SURFACE_H michael@0: #define ANDROID_SF_FRAMEBUFFER_SURFACE_H michael@0: michael@0: #include michael@0: #include michael@0: michael@0: #include michael@0: michael@0: // --------------------------------------------------------------------------- michael@0: namespace android { michael@0: // --------------------------------------------------------------------------- michael@0: michael@0: class Rect; michael@0: class String8; michael@0: class HWComposer; michael@0: michael@0: // --------------------------------------------------------------------------- michael@0: michael@0: class FramebufferSurface : public ConsumerBase { michael@0: public: michael@0: FramebufferSurface(int disp, uint32_t width, uint32_t height, uint32_t format, sp& bq); michael@0: michael@0: bool isUpdateOnDemand() const { return false; } michael@0: status_t setUpdateRectangle(const Rect& updateRect); michael@0: status_t compositionComplete(); michael@0: michael@0: virtual void dump(String8& result); michael@0: virtual void dump(String8& result, const char* prefix); michael@0: michael@0: // setReleaseFenceFd stores a fence file descriptor that will signal when the michael@0: // current buffer is no longer being read. This fence will be returned to michael@0: // the producer when the current buffer is released by updateTexImage(). michael@0: // Multiple fences can be set for a given buffer; they will be merged into michael@0: // a single union fence. The SurfaceTexture will close the file descriptor michael@0: // when finished with it. michael@0: status_t setReleaseFenceFd(int fenceFd); michael@0: michael@0: virtual int GetPrevFBAcquireFd(); michael@0: michael@0: buffer_handle_t lastHandle; michael@0: private: michael@0: virtual ~FramebufferSurface() { }; // this class cannot be overloaded michael@0: michael@0: virtual void onFrameAvailable(); michael@0: virtual void freeBufferLocked(int slotIndex); michael@0: michael@0: // nextBuffer waits for and then latches the next buffer from the michael@0: // BufferQueue and releases the previously latched buffer to the michael@0: // BufferQueue. The new buffer is returned in the 'buffer' argument. michael@0: status_t nextBuffer(sp& outBuffer, sp& outFence); michael@0: michael@0: // mDisplayType must match one of the HWC display types michael@0: int mDisplayType; michael@0: michael@0: // mCurrentBufferIndex is the slot index of the current buffer or michael@0: // INVALID_BUFFER_SLOT to indicate that either there is no current buffer michael@0: // or the buffer is not associated with a slot. michael@0: int mCurrentBufferSlot; michael@0: michael@0: // mCurrentBuffer is the current buffer or NULL to indicate that there is michael@0: // no current buffer. michael@0: sp mCurrentBuffer; michael@0: michael@0: android::sp mPrevFBAcquireFence; michael@0: }; michael@0: michael@0: // --------------------------------------------------------------------------- michael@0: }; // namespace android michael@0: // --------------------------------------------------------------------------- michael@0: michael@0: #endif // ANDROID_SF_FRAMEBUFFER_SURFACE_H michael@0: