blob: e9c7df2c32b15b7ebfd534100179196467c0e21f [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
Rodrigo Obregon71484f22010-11-03 15:16:18 -050032#define NUM_FRAME_BUFFERS 2
Mathias Agopian076b1cc2009-04-10 14:24:30 -070033
34extern "C" EGLNativeWindowType android_createDisplaySurface(void);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080035
36// ---------------------------------------------------------------------------
37namespace android {
38// ---------------------------------------------------------------------------
39
40class Surface;
Mathias Agopian7189c002009-05-05 18:11:11 -070041class NativeBuffer;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080042
Mathias Agopian076b1cc2009-04-10 14:24:30 -070043// ---------------------------------------------------------------------------
44
45class FramebufferNativeWindow
46 : public EGLNativeBase<
47 android_native_window_t,
48 FramebufferNativeWindow,
49 LightRefBase<FramebufferNativeWindow> >
50{
51public:
52 FramebufferNativeWindow();
53
54 framebuffer_device_t const * getDevice() const { return fbDev; }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080055
Mathias Agopian1e16b132009-05-07 17:40:23 -070056 bool isUpdateOnDemand() const { return mUpdateOnDemand; }
57 status_t setUpdateRectangle(const Rect& updateRect);
Mathias Agopian74faca22009-09-17 16:18:16 -070058 status_t compositionComplete();
Mathias Agopian1e16b132009-05-07 17:40:23 -070059
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080060private:
Mathias Agopian076b1cc2009-04-10 14:24:30 -070061 friend class LightRefBase<FramebufferNativeWindow>;
62 ~FramebufferNativeWindow(); // this class cannot be overloaded
Mathias Agopian076b1cc2009-04-10 14:24:30 -070063 static int setSwapInterval(android_native_window_t* window, int interval);
Mathias Agopian076b1cc2009-04-10 14:24:30 -070064 static int dequeueBuffer(android_native_window_t* window, android_native_buffer_t** buffer);
65 static int lockBuffer(android_native_window_t* window, android_native_buffer_t* buffer);
66 static int queueBuffer(android_native_window_t* window, android_native_buffer_t* buffer);
Mathias Agopiancb6b9042009-07-30 18:14:56 -070067 static int query(android_native_window_t* window, int what, int* value);
Mathias Agopian52212712009-08-11 22:34:02 -070068 static int perform(android_native_window_t* window, int operation, ...);
Mathias Agopian076b1cc2009-04-10 14:24:30 -070069
Mathias Agopian076b1cc2009-04-10 14:24:30 -070070 framebuffer_device_t* fbDev;
71 alloc_device_t* grDev;
72
Rodrigo Obregon71484f22010-11-03 15:16:18 -050073 sp<NativeBuffer> buffers[NUM_FRAME_BUFFERS];
Mathias Agopian076b1cc2009-04-10 14:24:30 -070074 sp<NativeBuffer> front;
75
Mathias Agopian076b1cc2009-04-10 14:24:30 -070076 mutable Mutex mutex;
77 Condition mCondition;
78 int32_t mNumBuffers;
79 int32_t mNumFreeBuffers;
80 int32_t mBufferHead;
Mathias Agopian1e16b132009-05-07 17:40:23 -070081 bool mUpdateOnDemand;
Mathias Agopian69029eb2009-06-23 21:11:43 -070082};
83
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080084// ---------------------------------------------------------------------------
85}; // namespace android
86// ---------------------------------------------------------------------------
87
Mathias Agopian0926f502009-05-04 14:17:04 -070088#endif // ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080089