blob: 639e7206107ca195d277d9fbabca13e76509450b [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
Mathias Agopian3e876012012-06-07 17:52:54 -070025// ---------------------------------------------------------------------------
26namespace android {
27// ---------------------------------------------------------------------------
28
29class Rect;
30class String8;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -070031class HWComposer;
Mathias Agopian3e876012012-06-07 17:52:54 -070032
33// ---------------------------------------------------------------------------
34
Jamie Gennis1a4d8832012-08-02 20:11:05 -070035class FramebufferSurface : public ConsumerBase {
Mathias Agopian3e876012012-06-07 17:52:54 -070036public:
Mathias Agopianf5a33922012-09-19 18:16:22 -070037 FramebufferSurface(HWComposer& hwc, int disp);
Mathias Agopian3e876012012-06-07 17:52:54 -070038
Mathias Agopian3e876012012-06-07 17:52:54 -070039 status_t compositionComplete();
40
Jesse Hall7adb0f82013-03-06 16:13:49 -080041 // TODO(jessehall): This overrides the non-virtual ConsumerBase version.
42 // Will rework slightly in a following change.
43 void dump(String8& result);
Mathias Agopian3e876012012-06-07 17:52:54 -070044
Mathias Agopianda27af92012-09-13 18:17:13 -070045 // 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
Andy McFadden2adaf042012-12-18 09:49:45 -080049 // a single union fence. The GLConsumer will close the file descriptor
Mathias Agopianda27af92012-09-13 18:17:13 -070050 // when finished with it.
51 status_t setReleaseFenceFd(int fenceFd);
Mathias Agopiana4912602012-07-12 14:25:33 -070052
Mathias Agopian3e876012012-06-07 17:52:54 -070053private:
Andy McFaddenb0d1dd32012-09-10 14:08:09 -070054 virtual ~FramebufferSurface() { }; // this class cannot be overloaded
Jamie Gennis1a4d8832012-08-02 20:11:05 -070055
56 virtual void onFrameAvailable();
57 virtual void freeBufferLocked(int slotIndex);
Mathias Agopian3e876012012-06-07 17:52:54 -070058
Jesse Hall7adb0f82013-03-06 16:13:49 -080059 virtual void dumpLocked(String8& result, const char* prefix,
60 char* buffer, size_t SIZE) const;
61
Mathias Agopianda27af92012-09-13 18:17:13 -070062 // 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
Mathias Agopianf5a33922012-09-19 18:16:22 -070067 // mDisplayType must match one of the HWC display types
68 int mDisplayType;
69
Jamie Gennis1a4d8832012-08-02 20:11:05 -070070 // 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;
Mathias Agopian3e876012012-06-07 17:52:54 -070074
Jamie Gennis1a4d8832012-08-02 20:11:05 -070075 // mCurrentBuffer is the current buffer or NULL to indicate that there is
76 // no current buffer.
77 sp<GraphicBuffer> mCurrentBuffer;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -070078
79 // Hardware composer, owned by SurfaceFlinger.
80 HWComposer& mHwc;
Mathias Agopian3e876012012-06-07 17:52:54 -070081};
82
83// ---------------------------------------------------------------------------
84}; // namespace android
85// ---------------------------------------------------------------------------
86
87#endif // ANDROID_SF_FRAMEBUFFER_SURFACE_H
88