blob: aad39a2a6b8b6f9e346d8a9f798455aeb7171818 [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
20#include <stdint.h>
21#include <sys/types.h>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070022
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080023#include <EGL/egl.h>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070024
25#include <utils/threads.h>
26#include <ui/Rect.h>
27
28#include <pixelflinger/pixelflinger.h>
29
Mathias Agopian7189c002009-05-05 18:11:11 -070030#include <ui/egl/android_natives.h>
31
Mathias Agopian076b1cc2009-04-10 14:24:30 -070032
33extern "C" EGLNativeWindowType android_createDisplaySurface(void);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080034
35// ---------------------------------------------------------------------------
36namespace android {
37// ---------------------------------------------------------------------------
38
39class Surface;
Mathias Agopian7189c002009-05-05 18:11:11 -070040class NativeBuffer;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080041
Mathias Agopian076b1cc2009-04-10 14:24:30 -070042// ---------------------------------------------------------------------------
43
44class FramebufferNativeWindow
45 : public EGLNativeBase<
46 android_native_window_t,
47 FramebufferNativeWindow,
48 LightRefBase<FramebufferNativeWindow> >
49{
50public:
51 FramebufferNativeWindow();
52
53 framebuffer_device_t const * getDevice() const { return fbDev; }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080054
55private:
Mathias Agopian076b1cc2009-04-10 14:24:30 -070056 friend class LightRefBase<FramebufferNativeWindow>;
57 ~FramebufferNativeWindow(); // this class cannot be overloaded
Mathias Agopian076b1cc2009-04-10 14:24:30 -070058 static int setSwapInterval(android_native_window_t* window, int interval);
Mathias Agopian076b1cc2009-04-10 14:24:30 -070059 static int dequeueBuffer(android_native_window_t* window, android_native_buffer_t** buffer);
60 static int lockBuffer(android_native_window_t* window, android_native_buffer_t* buffer);
61 static int queueBuffer(android_native_window_t* window, android_native_buffer_t* buffer);
62
Mathias Agopian076b1cc2009-04-10 14:24:30 -070063 framebuffer_device_t* fbDev;
64 alloc_device_t* grDev;
65
66 sp<NativeBuffer> buffers[2];
67 sp<NativeBuffer> front;
68
Mathias Agopian076b1cc2009-04-10 14:24:30 -070069 mutable Mutex mutex;
70 Condition mCondition;
71 int32_t mNumBuffers;
72 int32_t mNumFreeBuffers;
73 int32_t mBufferHead;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080074};
75
76// ---------------------------------------------------------------------------
77}; // namespace android
78// ---------------------------------------------------------------------------
79
Mathias Agopian0926f502009-05-04 14:17:04 -070080#endif // ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080081