FramebufferSurface.h revision f5a33928349bebc8eebc9f466618997e98c24e68
12c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/*
22c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * Copyright (C) 2007 The Android Open Source Project
32c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *
42c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * Licensed under the Apache License, Version 2.0 (the "License");
52c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * you may not use this file except in compliance with the License.
62c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * You may obtain a copy of the License at
72c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *
82c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *      http://www.apache.org/licenses/LICENSE-2.0
92c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *
102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * Unless required by applicable law or agreed to in writing, software
112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * distributed under the License is distributed on an "AS IS" BASIS,
122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * See the License for the specific language governing permissions and
142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * limitations under the License.
152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent */
162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#ifndef ANDROID_SF_FRAMEBUFFER_SURFACE_H
182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#define ANDROID_SF_FRAMEBUFFER_SURFACE_H
192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
206d8b694d999e9be7d5dcc336535832a80fb6f61fEric Laurent#include <stdint.h>
216d8b694d999e9be7d5dcc336535832a80fb6f61fEric Laurent#include <sys/types.h>
226d8b694d999e9be7d5dcc336535832a80fb6f61fEric Laurent
232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include <gui/ConsumerBase.h>
24e0aed6ddcb4e3c301b80aa26706b6052dab42c41Eric Laurent
252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#define NUM_FRAME_BUFFERS  2
262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// ---------------------------------------------------------------------------
282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentnamespace android {
292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// ---------------------------------------------------------------------------
30d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent
31d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurentclass Rect;
32d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurentclass String8;
33d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurentclass HWComposer;
34e0aed6ddcb4e3c301b80aa26706b6052dab42c41Eric Laurent
35d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent// ---------------------------------------------------------------------------
36d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent
37d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurentclass FramebufferSurface : public ConsumerBase {
38d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurentpublic:
39d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent    FramebufferSurface(HWComposer& hwc, int disp);
40163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent
412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    bool isUpdateOnDemand() const { return false; }
4223e1de74359f4bb1763aef0adfebe073122b032cEric Laurent    status_t setUpdateRectangle(const Rect& updateRect);
43163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent    status_t compositionComplete();
44163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent
452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    virtual void dump(String8& result);
4623e1de74359f4bb1763aef0adfebe073122b032cEric Laurent
472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    // setReleaseFenceFd stores a fence file descriptor that will signal when the
482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    // current buffer is no longer being read. This fence will be returned to
492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    // the producer when the current buffer is released by updateTexImage().
502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    // Multiple fences can be set for a given buffer; they will be merged into
512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    // a single union fence. The SurfaceTexture will close the file descriptor
52163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent    // when finished with it.
532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    status_t setReleaseFenceFd(int fenceFd);
542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentprivate:
562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    virtual ~FramebufferSurface() { }; // this class cannot be overloaded
572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    virtual void onFrameAvailable();
592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    virtual void freeBufferLocked(int slotIndex);
602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    // nextBuffer waits for and then latches the next buffer from the
622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    // BufferQueue and releases the previously latched buffer to the
632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    // BufferQueue.  The new buffer is returned in the 'buffer' argument.
642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    status_t nextBuffer(sp<GraphicBuffer>& outBuffer, sp<Fence>& outFence);
652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent    // mDisplayType must match one of the HWC display types
67163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent    int mDisplayType;
68163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent
69c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent    // mCurrentBufferIndex is the slot index of the current buffer or
70163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent    // INVALID_BUFFER_SLOT to indicate that either there is no current buffer
71163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent    // or the buffer is not associated with a slot.
72163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent    int mCurrentBufferSlot;
73163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent
74163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent    // mCurrentBuffer is the current buffer or NULL to indicate that there is
75163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent    // no current buffer.
76333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi    sp<GraphicBuffer> mCurrentBuffer;
77333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi
78163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent    // Hardware composer, owned by SurfaceFlinger.
79163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent    HWComposer& mHwc;
80d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent};
812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent
822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// ---------------------------------------------------------------------------
83163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent}; // namespace android
842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// ---------------------------------------------------------------------------
85163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent
862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#endif // ANDROID_SF_FRAMEBUFFER_SURFACE_H
87163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent
882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent