blob: 95feaa05dcb68b083f71494e02af3ed521de8bcb [file] [log] [blame]
Mathias Agopian3e876012012-06-07 17:52:54 -07001/*
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 Gennis1a4d8832012-08-02 20:11:05 -070023#include <gui/ConsumerBase.h>
Mathias Agopian3e876012012-06-07 17:52:54 -070024
25#define NUM_FRAME_BUFFERS 2
26
27// ---------------------------------------------------------------------------
28namespace android {
29// ---------------------------------------------------------------------------
30
31class Rect;
32class String8;
33
34// ---------------------------------------------------------------------------
35
Jamie Gennis1a4d8832012-08-02 20:11:05 -070036class FramebufferSurface : public ConsumerBase {
Mathias Agopian3e876012012-06-07 17:52:54 -070037public:
Mathias Agopian3e876012012-06-07 17:52:54 -070038
Mathias Agopiana4912602012-07-12 14:25:33 -070039 static sp<FramebufferSurface> create();
Mathias Agopian3e876012012-06-07 17:52:54 -070040
Mathias Agopiana4912602012-07-12 14:25:33 -070041 // TODO: this should be coming from HWC
42 float getRefreshRate() const;
Mathias Agopian3e876012012-06-07 17:52:54 -070043
Jamie Gennis1a4d8832012-08-02 20:11:05 -070044 bool isUpdateOnDemand() const { return false; }
Mathias Agopian3e876012012-06-07 17:52:54 -070045 status_t setUpdateRectangle(const Rect& updateRect);
46 status_t compositionComplete();
47
Jamie Gennis1a4d8832012-08-02 20:11:05 -070048 virtual void dump(String8& result);
Mathias Agopian3e876012012-06-07 17:52:54 -070049
Jamie Gennis1a4d8832012-08-02 20:11:05 -070050 // nextBuffer waits for and then latches the next buffer from the
51 // BufferQueue and releases the previously latched buffer to the
52 // BufferQueue. The new buffer is returned in the 'buffer' argument.
53 status_t nextBuffer(sp<GraphicBuffer>* buffer);
Mathias Agopiana4912602012-07-12 14:25:33 -070054
Mathias Agopian3e876012012-06-07 17:52:54 -070055private:
Mathias Agopiana4912602012-07-12 14:25:33 -070056 FramebufferSurface();
Mathias Agopian3e876012012-06-07 17:52:54 -070057 virtual ~FramebufferSurface(); // this class cannot be overloaded
Jamie Gennis1a4d8832012-08-02 20:11:05 -070058
59 virtual void onFrameAvailable();
60 virtual void freeBufferLocked(int slotIndex);
Mathias Agopian3e876012012-06-07 17:52:54 -070061
62 framebuffer_device_t* fbDev;
63
Jamie Gennis1a4d8832012-08-02 20:11:05 -070064 // mCurrentBufferIndex is the slot index of the current buffer or
65 // INVALID_BUFFER_SLOT to indicate that either there is no current buffer
66 // or the buffer is not associated with a slot.
67 int mCurrentBufferSlot;
Mathias Agopian3e876012012-06-07 17:52:54 -070068
Jamie Gennis1a4d8832012-08-02 20:11:05 -070069 // mCurrentBuffer is the current buffer or NULL to indicate that there is
70 // no current buffer.
71 sp<GraphicBuffer> mCurrentBuffer;
Mathias Agopian3e876012012-06-07 17:52:54 -070072};
73
74// ---------------------------------------------------------------------------
75}; // namespace android
76// ---------------------------------------------------------------------------
77
78#endif // ANDROID_SF_FRAMEBUFFER_SURFACE_H
79