blob: b61b7f50965baca1eac9b5c03cbeea28fef99326 [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
Jamie Gennis1a4d8832012-08-02 20:11:05 -070039 bool isUpdateOnDemand() const { return false; }
Mathias Agopian3e876012012-06-07 17:52:54 -070040 status_t setUpdateRectangle(const Rect& updateRect);
41 status_t compositionComplete();
42
Jamie Gennis1a4d8832012-08-02 20:11:05 -070043 virtual 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
Mathias Agopianda27af92012-09-13 18:17:13 -070059 // nextBuffer waits for and then latches the next buffer from the
60 // BufferQueue and releases the previously latched buffer to the
61 // BufferQueue. The new buffer is returned in the 'buffer' argument.
62 status_t nextBuffer(sp<GraphicBuffer>& outBuffer, sp<Fence>& outFence);
63
Mathias Agopianf5a33922012-09-19 18:16:22 -070064 // mDisplayType must match one of the HWC display types
65 int mDisplayType;
66
Jamie Gennis1a4d8832012-08-02 20:11:05 -070067 // mCurrentBufferIndex is the slot index of the current buffer or
68 // INVALID_BUFFER_SLOT to indicate that either there is no current buffer
69 // or the buffer is not associated with a slot.
70 int mCurrentBufferSlot;
Mathias Agopian3e876012012-06-07 17:52:54 -070071
Jamie Gennis1a4d8832012-08-02 20:11:05 -070072 // mCurrentBuffer is the current buffer or NULL to indicate that there is
73 // no current buffer.
74 sp<GraphicBuffer> mCurrentBuffer;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -070075
76 // Hardware composer, owned by SurfaceFlinger.
77 HWComposer& mHwc;
Mathias Agopian3e876012012-06-07 17:52:54 -070078};
79
80// ---------------------------------------------------------------------------
81}; // namespace android
82// ---------------------------------------------------------------------------
83
84#endif // ANDROID_SF_FRAMEBUFFER_SURFACE_H
85