blob: 0db245af44dd5738d5c7dd6f48e77826799b57a3 [file] [log] [blame]
The Android Open Source Project9066cfe2009-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 Agopiandff8e582009-05-04 14:17:04 -070017#ifndef ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
18#define ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080019
20#include <stdint.h>
21#include <sys/types.h>
Mathias Agopian1473f462009-04-10 14:24:30 -070022
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080023#include <EGL/egl.h>
Mathias Agopian1473f462009-04-10 14:24:30 -070024#include <EGL/android_natives.h>
25
26#include <utils/threads.h>
27#include <ui/Rect.h>
28
29#include <pixelflinger/pixelflinger.h>
30
31
32extern "C" EGLNativeWindowType android_createDisplaySurface(void);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080033
34// ---------------------------------------------------------------------------
35namespace android {
36// ---------------------------------------------------------------------------
37
38class Surface;
39
Mathias Agopian1473f462009-04-10 14:24:30 -070040
41class NativeBuffer
42 : public EGLNativeBase<
43 android_native_buffer_t,
44 NativeBuffer,
45 LightRefBase<NativeBuffer> >
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080046{
47public:
Mathias Agopian1473f462009-04-10 14:24:30 -070048 NativeBuffer(int w, int h, int f, int u) : BASE() {
49 android_native_buffer_t::width = w;
50 android_native_buffer_t::height = h;
51 android_native_buffer_t::format = f;
52 android_native_buffer_t::usage = u;
Mathias Agopian1473f462009-04-10 14:24:30 -070053 }
Mathias Agopian1473f462009-04-10 14:24:30 -070054private:
55 friend class LightRefBase<NativeBuffer>;
56 ~NativeBuffer() { }; // this class cannot be overloaded
Mathias Agopian1473f462009-04-10 14:24:30 -070057};
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080058
Mathias Agopian1473f462009-04-10 14:24:30 -070059// ---------------------------------------------------------------------------
60
61class FramebufferNativeWindow
62 : public EGLNativeBase<
63 android_native_window_t,
64 FramebufferNativeWindow,
65 LightRefBase<FramebufferNativeWindow> >
66{
67public:
68 FramebufferNativeWindow();
69
70 framebuffer_device_t const * getDevice() const { return fbDev; }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080071
72private:
Mathias Agopian1473f462009-04-10 14:24:30 -070073 friend class LightRefBase<FramebufferNativeWindow>;
74 ~FramebufferNativeWindow(); // this class cannot be overloaded
Mathias Agopian1473f462009-04-10 14:24:30 -070075 static int setSwapInterval(android_native_window_t* window, int interval);
Mathias Agopian1473f462009-04-10 14:24:30 -070076 static int dequeueBuffer(android_native_window_t* window, android_native_buffer_t** buffer);
77 static int lockBuffer(android_native_window_t* window, android_native_buffer_t* buffer);
78 static int queueBuffer(android_native_window_t* window, android_native_buffer_t* buffer);
79
Mathias Agopian1473f462009-04-10 14:24:30 -070080 framebuffer_device_t* fbDev;
81 alloc_device_t* grDev;
82
83 sp<NativeBuffer> buffers[2];
84 sp<NativeBuffer> front;
85
Mathias Agopian1473f462009-04-10 14:24:30 -070086 mutable Mutex mutex;
87 Condition mCondition;
88 int32_t mNumBuffers;
89 int32_t mNumFreeBuffers;
90 int32_t mBufferHead;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080091};
92
93// ---------------------------------------------------------------------------
94}; // namespace android
95// ---------------------------------------------------------------------------
96
Mathias Agopiandff8e582009-05-04 14:17:04 -070097#endif // ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080098