blob: d64fea78b4eec185ad3281504c47d3aa0d47fd4c [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;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -070033class HWComposer;
Mathias Agopian3e876012012-06-07 17:52:54 -070034
35// ---------------------------------------------------------------------------
36
Jamie Gennis1a4d8832012-08-02 20:11:05 -070037class FramebufferSurface : public ConsumerBase {
Mathias Agopian3e876012012-06-07 17:52:54 -070038public:
Mathias Agopianf5a33922012-09-19 18:16:22 -070039 FramebufferSurface(HWComposer& hwc, int disp);
Mathias Agopian3e876012012-06-07 17:52:54 -070040
Jamie Gennis1a4d8832012-08-02 20:11:05 -070041 bool isUpdateOnDemand() const { return false; }
Mathias Agopian3e876012012-06-07 17:52:54 -070042 status_t setUpdateRectangle(const Rect& updateRect);
43 status_t compositionComplete();
44
Jamie Gennis1a4d8832012-08-02 20:11:05 -070045 virtual void dump(String8& result);
Mathias Agopian3e876012012-06-07 17:52:54 -070046
Mathias Agopianda27af92012-09-13 18:17:13 -070047 // setReleaseFenceFd stores a fence file descriptor that will signal when the
48 // current buffer is no longer being read. This fence will be returned to
49 // the producer when the current buffer is released by updateTexImage().
50 // Multiple fences can be set for a given buffer; they will be merged into
51 // a single union fence. The SurfaceTexture will close the file descriptor
52 // when finished with it.
53 status_t setReleaseFenceFd(int fenceFd);
Mathias Agopiana4912602012-07-12 14:25:33 -070054
Mathias Agopian3e876012012-06-07 17:52:54 -070055private:
Andy McFaddenb0d1dd32012-09-10 14:08:09 -070056 virtual ~FramebufferSurface() { }; // this class cannot be overloaded
Jamie Gennis1a4d8832012-08-02 20:11:05 -070057
58 virtual void onFrameAvailable();
59 virtual void freeBufferLocked(int slotIndex);
Mathias Agopian3e876012012-06-07 17:52:54 -070060
Mathias Agopianda27af92012-09-13 18:17:13 -070061 // nextBuffer waits for and then latches the next buffer from the
62 // BufferQueue and releases the previously latched buffer to the
63 // BufferQueue. The new buffer is returned in the 'buffer' argument.
64 status_t nextBuffer(sp<GraphicBuffer>& outBuffer, sp<Fence>& outFence);
65
Mathias Agopianf5a33922012-09-19 18:16:22 -070066 // mDisplayType must match one of the HWC display types
67 int mDisplayType;
68
Jamie Gennis1a4d8832012-08-02 20:11:05 -070069 // mCurrentBufferIndex is the slot index of the current buffer or
70 // INVALID_BUFFER_SLOT to indicate that either there is no current buffer
71 // or the buffer is not associated with a slot.
72 int mCurrentBufferSlot;
Mathias Agopian3e876012012-06-07 17:52:54 -070073
Jamie Gennis1a4d8832012-08-02 20:11:05 -070074 // mCurrentBuffer is the current buffer or NULL to indicate that there is
75 // no current buffer.
76 sp<GraphicBuffer> mCurrentBuffer;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -070077
78 // Hardware composer, owned by SurfaceFlinger.
79 HWComposer& mHwc;
Mathias Agopian3e876012012-06-07 17:52:54 -070080};
81
82// ---------------------------------------------------------------------------
83}; // namespace android
84// ---------------------------------------------------------------------------
85
86#endif // ANDROID_SF_FRAMEBUFFER_SURFACE_H
87