blob: 672bfbb7db55a2b2307a2121f077578971859cbf [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
23#include <EGL/egl.h>
24
25#include <gui/SurfaceTextureClient.h>
26
27#define NUM_FRAME_BUFFERS 2
28
29// ---------------------------------------------------------------------------
30namespace android {
31// ---------------------------------------------------------------------------
32
33class Rect;
34class String8;
35
36// ---------------------------------------------------------------------------
37
38class FramebufferSurface : public SurfaceTextureClient {
39public:
Mathias Agopian3e876012012-06-07 17:52:54 -070040
Mathias Agopiana4912602012-07-12 14:25:33 -070041 static sp<FramebufferSurface> create();
Mathias Agopian3e876012012-06-07 17:52:54 -070042
Mathias Agopiana4912602012-07-12 14:25:33 -070043 // TODO: this should be coming from HWC
44 float getRefreshRate() const;
Mathias Agopian3e876012012-06-07 17:52:54 -070045
46 bool isUpdateOnDemand() const { return mUpdateOnDemand; }
47 status_t setUpdateRectangle(const Rect& updateRect);
48 status_t compositionComplete();
49
50 void dump(String8& result);
51
Mathias Agopiana4912602012-07-12 14:25:33 -070052protected:
53 virtual void onFirstRef();
54
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
58 virtual int query(int what, int* value) const;
59
60 framebuffer_device_t* fbDev;
61
62 sp<BufferQueue> mBufferQueue;
63 int mCurrentBufferIndex;
64 sp<GraphicBuffer> mBuffers[NUM_FRAME_BUFFERS];
65
66 mutable Mutex mLock;
67 bool mUpdateOnDemand;
68};
69
70// ---------------------------------------------------------------------------
71}; // namespace android
72// ---------------------------------------------------------------------------
73
74#endif // ANDROID_SF_FRAMEBUFFER_SURFACE_H
75