blob: 6b66d5f66b02845159ff0fa121e2d06f2ff69aee [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
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
Dan Stoza01049c82014-11-11 10:32:31 -080017#ifndef INCLUDED_FROM_FRAMEBUFFER_NATIVE_WINDOW_CPP
18#warning "FramebufferNativeWindow is deprecated"
19#endif
20
Mathias Agopian0926f502009-05-04 14:17:04 -070021#ifndef ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
22#define ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080023
24#include <stdint.h>
25#include <sys/types.h>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070026
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080027#include <EGL/egl.h>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070028
29#include <utils/threads.h>
Erik Gilling1d21a9c2010-12-01 16:38:01 -080030#include <utils/String8.h>
Mathias Agopian5f2165f2012-02-24 18:25:41 -080031
32#include <ui/ANativeObjectBase.h>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070033#include <ui/Rect.h>
34
Naseer Ahmed0bc64be2012-06-29 12:02:32 -070035#define MIN_NUM_FRAME_BUFFERS 2
36#define MAX_NUM_FRAME_BUFFERS 3
Mathias Agopian076b1cc2009-04-10 14:24:30 -070037
38extern "C" EGLNativeWindowType android_createDisplaySurface(void);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080039
40// ---------------------------------------------------------------------------
41namespace android {
42// ---------------------------------------------------------------------------
43
44class Surface;
Mathias Agopian7189c002009-05-05 18:11:11 -070045class NativeBuffer;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080046
Mathias Agopian076b1cc2009-04-10 14:24:30 -070047// ---------------------------------------------------------------------------
48
49class FramebufferNativeWindow
Mathias Agopian5f2165f2012-02-24 18:25:41 -080050 : public ANativeObjectBase<
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -070051 ANativeWindow,
Mathias Agopian076b1cc2009-04-10 14:24:30 -070052 FramebufferNativeWindow,
53 LightRefBase<FramebufferNativeWindow> >
54{
55public:
56 FramebufferNativeWindow();
57
58 framebuffer_device_t const * getDevice() const { return fbDev; }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080059
Mathias Agopian1e16b132009-05-07 17:40:23 -070060 bool isUpdateOnDemand() const { return mUpdateOnDemand; }
61 status_t setUpdateRectangle(const Rect& updateRect);
Mathias Agopian74faca22009-09-17 16:18:16 -070062 status_t compositionComplete();
Erik Gilling1d21a9c2010-12-01 16:38:01 -080063
64 void dump(String8& result);
65
Mathias Agopian35b48d12010-09-13 22:57:58 -070066 // for debugging only
67 int getCurrentBufferIndex() const;
68
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080069private:
Mathias Agopian076b1cc2009-04-10 14:24:30 -070070 friend class LightRefBase<FramebufferNativeWindow>;
71 ~FramebufferNativeWindow(); // this class cannot be overloaded
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -070072 static int setSwapInterval(ANativeWindow* window, int interval);
Jamie Gennisd8e812c2012-06-13 16:32:25 -070073 static int dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd);
74 static int queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd);
Iliyan Malchev41abd672011-04-14 16:54:38 -070075 static int query(const ANativeWindow* window, int what, int* value);
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -070076 static int perform(ANativeWindow* window, int operation, ...);
Jamie Gennisd8e812c2012-06-13 16:32:25 -070077
78 static int dequeueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer** buffer);
79 static int queueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer);
80 static int lockBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer);
81
Mathias Agopian076b1cc2009-04-10 14:24:30 -070082 framebuffer_device_t* fbDev;
83 alloc_device_t* grDev;
84
Naseer Ahmed0bc64be2012-06-29 12:02:32 -070085 sp<NativeBuffer> buffers[MAX_NUM_FRAME_BUFFERS];
Mathias Agopian076b1cc2009-04-10 14:24:30 -070086 sp<NativeBuffer> front;
87
Mathias Agopian076b1cc2009-04-10 14:24:30 -070088 mutable Mutex mutex;
89 Condition mCondition;
90 int32_t mNumBuffers;
91 int32_t mNumFreeBuffers;
92 int32_t mBufferHead;
Mathias Agopian35b48d12010-09-13 22:57:58 -070093 int32_t mCurrentBufferIndex;
Mathias Agopian1e16b132009-05-07 17:40:23 -070094 bool mUpdateOnDemand;
Mathias Agopian69029eb2009-06-23 21:11:43 -070095};
96
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080097// ---------------------------------------------------------------------------
98}; // namespace android
99// ---------------------------------------------------------------------------
100
Mathias Agopian0926f502009-05-04 14:17:04 -0700101#endif // ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800102