blob: 5cd8101d30ec952bfb5d12243a956be1482dc41d [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
Mathias Agopian0926f502009-05-04 14:17:04 -070017#ifndef ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
18#define ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080019
Andy McFadden2e336492014-03-05 15:40:26 -080020#warning "FramebufferNativeWindow is deprecated"
21
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080022#include <stdint.h>
23#include <sys/types.h>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070024
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080025#include <EGL/egl.h>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070026
27#include <utils/threads.h>
Erik Gilling1d21a9c2010-12-01 16:38:01 -080028#include <utils/String8.h>
Mathias Agopian5f2165f2012-02-24 18:25:41 -080029
30#include <ui/ANativeObjectBase.h>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070031#include <ui/Rect.h>
32
Naseer Ahmed0bc64be2012-06-29 12:02:32 -070033#define MIN_NUM_FRAME_BUFFERS 2
34#define MAX_NUM_FRAME_BUFFERS 3
Mathias Agopian076b1cc2009-04-10 14:24:30 -070035
36extern "C" EGLNativeWindowType android_createDisplaySurface(void);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080037
38// ---------------------------------------------------------------------------
39namespace android {
40// ---------------------------------------------------------------------------
41
42class Surface;
Mathias Agopian7189c002009-05-05 18:11:11 -070043class NativeBuffer;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080044
Mathias Agopian076b1cc2009-04-10 14:24:30 -070045// ---------------------------------------------------------------------------
46
47class FramebufferNativeWindow
Mathias Agopian5f2165f2012-02-24 18:25:41 -080048 : public ANativeObjectBase<
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -070049 ANativeWindow,
Mathias Agopian076b1cc2009-04-10 14:24:30 -070050 FramebufferNativeWindow,
51 LightRefBase<FramebufferNativeWindow> >
52{
53public:
54 FramebufferNativeWindow();
55
56 framebuffer_device_t const * getDevice() const { return fbDev; }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080057
Mathias Agopian1e16b132009-05-07 17:40:23 -070058 bool isUpdateOnDemand() const { return mUpdateOnDemand; }
59 status_t setUpdateRectangle(const Rect& updateRect);
Mathias Agopian74faca22009-09-17 16:18:16 -070060 status_t compositionComplete();
Erik Gilling1d21a9c2010-12-01 16:38:01 -080061
62 void dump(String8& result);
63
Mathias Agopian35b48d12010-09-13 22:57:58 -070064 // for debugging only
65 int getCurrentBufferIndex() const;
66
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080067private:
Mathias Agopian076b1cc2009-04-10 14:24:30 -070068 friend class LightRefBase<FramebufferNativeWindow>;
69 ~FramebufferNativeWindow(); // this class cannot be overloaded
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -070070 static int setSwapInterval(ANativeWindow* window, int interval);
Jamie Gennisd8e812c2012-06-13 16:32:25 -070071 static int dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd);
72 static int queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd);
Iliyan Malchev41abd672011-04-14 16:54:38 -070073 static int query(const ANativeWindow* window, int what, int* value);
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -070074 static int perform(ANativeWindow* window, int operation, ...);
Jamie Gennisd8e812c2012-06-13 16:32:25 -070075
76 static int dequeueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer** buffer);
77 static int queueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer);
78 static int lockBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer);
79
Mathias Agopian076b1cc2009-04-10 14:24:30 -070080 framebuffer_device_t* fbDev;
81 alloc_device_t* grDev;
82
Naseer Ahmed0bc64be2012-06-29 12:02:32 -070083 sp<NativeBuffer> buffers[MAX_NUM_FRAME_BUFFERS];
Mathias Agopian076b1cc2009-04-10 14:24:30 -070084 sp<NativeBuffer> front;
85
Mathias Agopian076b1cc2009-04-10 14:24:30 -070086 mutable Mutex mutex;
87 Condition mCondition;
88 int32_t mNumBuffers;
89 int32_t mNumFreeBuffers;
90 int32_t mBufferHead;
Mathias Agopian35b48d12010-09-13 22:57:58 -070091 int32_t mCurrentBufferIndex;
Mathias Agopian1e16b132009-05-07 17:40:23 -070092 bool mUpdateOnDemand;
Mathias Agopian69029eb2009-06-23 21:11:43 -070093};
94
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080095// ---------------------------------------------------------------------------
96}; // namespace android
97// ---------------------------------------------------------------------------
98
Mathias Agopian0926f502009-05-04 14:17:04 -070099#endif // ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800100