blob: de4a2ccdd50106bc64da128a387a0a43c3feb79a [file] [log] [blame]
The Android Open Source Project7c1b96a2008-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_DISPLAY_HARDWARE_H
18#define ANDROID_DISPLAY_HARDWARE_H
19
20#include <stdlib.h>
21
22#include <ui/PixelFormat.h>
23#include <ui/Region.h>
24
25#include <GLES/egl.h>
26
27#include "DisplayHardware/DisplayHardwareBase.h"
28
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080029struct overlay_device_t;
30struct copybit_device_t;
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070031struct copybit_image_t;
32struct copybit_t;
33
34namespace android {
35
36class EGLDisplaySurface;
37
38class DisplayHardware : public DisplayHardwareBase
39{
40public:
41 enum {
42 COPY_BACK_EXTENSION = 0x00000001,
43 DIRECT_TEXTURE = 0x00000002,
44 SWAP_RECTANGLE_EXTENSION= 0x00000004,
45 COPY_BITS_EXTENSION = 0x00000008,
46 NPOT_EXTENSION = 0x00000100,
47 DRAW_TEXTURE_EXTENSION = 0x00000200,
48 BUFFER_PRESERVED = 0x00010000,
49 UPDATE_ON_DEMAND = 0x00020000, // video driver feature
50 SLOW_CONFIG = 0x00040000, // software
51 };
52
53 DisplayHardware(
54 const sp<SurfaceFlinger>& flinger,
55 uint32_t displayIndex);
56
57 ~DisplayHardware();
58
59 void releaseScreen() const;
60 void acquireScreen() const;
61
62 // Flip the front and back buffers if the back buffer is "dirty". Might
63 // be instantaneous, might involve copying the frame buffer around.
64 void flip(const Region& dirty) const;
65
66 float getDpiX() const;
67 float getDpiY() const;
68 float getRefreshRate() const;
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080069 float getDensity() const;
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070070 int getWidth() const;
71 int getHeight() const;
72 PixelFormat getFormat() const;
73 uint32_t getFlags() const;
74 void makeCurrent() const;
75
76 uint32_t getPageFlipCount() const;
77 void getDisplaySurface(copybit_image_t* img) const;
78 void getDisplaySurface(GGLSurface* fb) const;
79 EGLDisplay getEGLDisplay() const { return mDisplay; }
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080080 copybit_device_t* getBlitEngine() const { return mBlitEngine; }
81 overlay_device_t* getOverlayEngine() const { return mOverlayEngine; }
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070082
83 Rect bounds() const {
84 return Rect(mWidth, mHeight);
85 }
86
87private:
88 void init(uint32_t displayIndex) __attribute__((noinline));
89 void fini() __attribute__((noinline));
90
91 EGLDisplay mDisplay;
92 EGLSurface mSurface;
93 EGLContext mContext;
94 EGLConfig mConfig;
95 float mDpiX;
96 float mDpiY;
97 float mRefreshRate;
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080098 float mDensity;
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070099 int mWidth;
100 int mHeight;
101 PixelFormat mFormat;
102 uint32_t mFlags;
103 mutable Region mDirty;
104 sp<EGLDisplaySurface> mDisplaySurface;
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800105 copybit_device_t* mBlitEngine;
106 overlay_device_t* mOverlayEngine;
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700107};
108
109}; // namespace android
110
111#endif // ANDROID_DISPLAY_HARDWARE_H