blob: a9cfd5a0404943111e91b171545bcd7dcf3a9180 [file] [log] [blame]
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001/*
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
17#ifndef ANDROID_EGL_DISPLAY_SURFACE_H
18#define ANDROID_EGL_DISPLAY_SURFACE_H
19
20#include <stdint.h>
21#include <sys/types.h>
22
23#include <utils/Timers.h>
24
25#include <ui/EGLNativeSurface.h>
26#include <ui/BlitHardware.h>
27
28#include <pixelflinger/pixelflinger.h>
29#include <linux/fb.h>
30
31// ---------------------------------------------------------------------------
32namespace android {
33// ---------------------------------------------------------------------------
34
35class Region;
36class Rect;
37
38class EGLDisplaySurface : public EGLNativeSurface<EGLDisplaySurface>
39{
40public:
41 EGLDisplaySurface();
42 ~EGLDisplaySurface();
43
44 int32_t getPageFlipCount() const;
45 void copyFrontToBack(const Region& copyback);
46
47private:
48 static void hook_incRef(NativeWindowType window);
49 static void hook_decRef(NativeWindowType window);
50 static uint32_t hook_swapBuffers(NativeWindowType window);
51 static void hook_setSwapRectangle(NativeWindowType window, int l, int t, int w, int h);
52 static uint32_t hook_nextBuffer(NativeWindowType window);
53
54 uint32_t swapBuffers();
55 uint32_t nextBuffer();
56 void setSwapRectangle(int l, int t, int w, int h);
57
58 status_t mapFrameBuffer();
59
60 enum {
61 PAGE_FLIP = 0x00000001
62 };
63 GGLSurface mFb[2];
64 int mIndex;
65 uint32_t mFlags;
66 size_t mSize;
67 fb_var_screeninfo mInfo;
68 fb_fix_screeninfo mFinfo;
69 int32_t mPageFlipCount;
70 nsecs_t mTime;
71 int32_t mSwapCount;
72 nsecs_t mSleep;
73 uint32_t mFeatureFlags;
74 copybit_t* mBlitEngine;
75};
76
77// ---------------------------------------------------------------------------
78}; // namespace android
79// ---------------------------------------------------------------------------
80
81#endif // ANDROID_EGL_DISPLAY_SURFACE_H
82