FramebufferSurface.h revision b0d1dd36f104c0b581674adc7f830cbf44b7db06
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#define NUM_FRAME_BUFFERS  2
26
27// ---------------------------------------------------------------------------
28namespace android {
29// ---------------------------------------------------------------------------
30
31class Rect;
32class String8;
33class HWComposer;
34
35// ---------------------------------------------------------------------------
36
37class FramebufferSurface : public ConsumerBase {
38public:
39    FramebufferSurface(HWComposer& hwc);
40
41    bool isUpdateOnDemand() const { return false; }
42    status_t setUpdateRectangle(const Rect& updateRect);
43    status_t compositionComplete();
44
45    virtual void dump(String8& result);
46
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);
51
52private:
53    virtual ~FramebufferSurface() { }; // this class cannot be overloaded
54
55    virtual void onFrameAvailable();
56    virtual void freeBufferLocked(int slotIndex);
57
58    // mCurrentBufferIndex is the slot index of the current buffer or
59    // INVALID_BUFFER_SLOT to indicate that either there is no current buffer
60    // or the buffer is not associated with a slot.
61    int mCurrentBufferSlot;
62
63    // mCurrentBuffer is the current buffer or NULL to indicate that there is
64    // no current buffer.
65    sp<GraphicBuffer> mCurrentBuffer;
66
67    // Hardware composer, owned by SurfaceFlinger.
68    HWComposer& mHwc;
69};
70
71// ---------------------------------------------------------------------------
72}; // namespace android
73// ---------------------------------------------------------------------------
74
75#endif // ANDROID_SF_FRAMEBUFFER_SURFACE_H
76
77