FramebufferSurface.h revision 7adb0f8a9fdb961692ffd2f0c65cacb155143f64
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 <gui/ConsumerBase.h>
24
25// ---------------------------------------------------------------------------
26namespace android {
27// ---------------------------------------------------------------------------
28
29class Rect;
30class String8;
31class HWComposer;
32
33// ---------------------------------------------------------------------------
34
35class FramebufferSurface : public ConsumerBase {
36public:
37    FramebufferSurface(HWComposer& hwc, int disp);
38
39    status_t compositionComplete();
40
41    // TODO(jessehall): This overrides the non-virtual ConsumerBase version.
42    // Will rework slightly in a following change.
43    void dump(String8& result);
44
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
49    // a single union fence. The GLConsumer will close the file descriptor
50    // when finished with it.
51    status_t setReleaseFenceFd(int fenceFd);
52
53private:
54    virtual ~FramebufferSurface() { }; // this class cannot be overloaded
55
56    virtual void onFrameAvailable();
57    virtual void freeBufferLocked(int slotIndex);
58
59    virtual void dumpLocked(String8& result, const char* prefix,
60            char* buffer, size_t SIZE) const;
61
62    // nextBuffer waits for and then latches the next buffer from the
63    // BufferQueue and releases the previously latched buffer to the
64    // BufferQueue.  The new buffer is returned in the 'buffer' argument.
65    status_t nextBuffer(sp<GraphicBuffer>& outBuffer, sp<Fence>& outFence);
66
67    // mDisplayType must match one of the HWC display types
68    int mDisplayType;
69
70    // mCurrentBufferIndex is the slot index of the current buffer or
71    // INVALID_BUFFER_SLOT to indicate that either there is no current buffer
72    // or the buffer is not associated with a slot.
73    int mCurrentBufferSlot;
74
75    // mCurrentBuffer is the current buffer or NULL to indicate that there is
76    // no current buffer.
77    sp<GraphicBuffer> mCurrentBuffer;
78
79    // Hardware composer, owned by SurfaceFlinger.
80    HWComposer& mHwc;
81};
82
83// ---------------------------------------------------------------------------
84}; // namespace android
85// ---------------------------------------------------------------------------
86
87#endif // ANDROID_SF_FRAMEBUFFER_SURFACE_H
88
89