blob: a8b58539d192d0b893cd33726848189db77b8853 [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
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
27#include <pixelflinger/pixelflinger.h>
28#include <linux/fb.h>
29
30#include <EGL/egl.h>
31
32struct copybit_device_t;
33struct copybit_image_t;
34
35// ---------------------------------------------------------------------------
36namespace android {
37// ---------------------------------------------------------------------------
38
39class Region;
40class Rect;
41
42class EGLDisplaySurface : public EGLNativeSurface<EGLDisplaySurface>
43{
44public:
45 EGLDisplaySurface();
46 ~EGLDisplaySurface();
47
48 int32_t getPageFlipCount() const;
49 void copyFrontToBack(const Region& copyback);
50 void copyFrontToImage(const copybit_image_t& dst);
51 void copyBackToImage(const copybit_image_t& dst);
52
53 void setSwapRectangle(int l, int t, int w, int h);
54
55private:
56 static void hook_incRef(NativeWindowType window);
57 static void hook_decRef(NativeWindowType window);
58 static uint32_t hook_swapBuffers(NativeWindowType window);
59
60 uint32_t swapBuffers();
61
62 status_t mapFrameBuffer();
63
64 enum {
65 PAGE_FLIP = 0x00000001
66 };
67 GGLSurface mFb[2];
68 int mIndex;
69 uint32_t mFlags;
70 size_t mSize;
71 fb_var_screeninfo mInfo;
72 fb_fix_screeninfo mFinfo;
73 int32_t mPageFlipCount;
74 nsecs_t mTime;
75 int32_t mSwapCount;
76 nsecs_t mSleep;
77 uint32_t mFeatureFlags;
78 copybit_device_t* mBlitEngine;
79};
80
81// ---------------------------------------------------------------------------
82}; // namespace android
83// ---------------------------------------------------------------------------
84
85#endif // ANDROID_EGL_DISPLAY_SURFACE_H
86