blob: 897a6edd8bbf09c39d96fd0cd7500889d4c22c82 [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_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
Mathias Agopian076b1cc2009-04-10 14:24:30 -070025#include <GLES/gl.h>
26#include <GLES/glext.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080027#include <EGL/egl.h>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070028#include <EGL/eglext.h>
29
30#include <pixelflinger/pixelflinger.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080031
32#include "DisplayHardware/DisplayHardwareBase.h"
33
34struct overlay_control_device_t;
Mathias Agopian076b1cc2009-04-10 14:24:30 -070035struct framebuffer_device_t;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080036struct copybit_image_t;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080037
38namespace android {
39
Mathias Agopian076b1cc2009-04-10 14:24:30 -070040class FramebufferNativeWindow;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080041
42class DisplayHardware : public DisplayHardwareBase
43{
44public:
45 enum {
46 DIRECT_TEXTURE = 0x00000002,
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080047 COPY_BITS_EXTENSION = 0x00000008,
48 NPOT_EXTENSION = 0x00000100,
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080049 BUFFER_PRESERVED = 0x00010000,
Mathias Agopian95a666b2009-09-24 14:57:26 -070050 PARTIAL_UPDATES = 0x00020000, // video driver feature
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080051 SLOW_CONFIG = 0x00040000, // software
Mathias Agopiandf3ca302009-05-04 19:29:25 -070052 SWAP_RECTANGLE = 0x00080000,
Mathias Agopiana4b740e2009-10-05 18:20:39 -070053 CACHED_BUFFERS = 0x00100000
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080054 };
55
56 DisplayHardware(
57 const sp<SurfaceFlinger>& flinger,
58 uint32_t displayIndex);
59
60 ~DisplayHardware();
61
62 void releaseScreen() const;
63 void acquireScreen() const;
64
65 // Flip the front and back buffers if the back buffer is "dirty". Might
66 // be instantaneous, might involve copying the frame buffer around.
67 void flip(const Region& dirty) const;
68
69 float getDpiX() const;
70 float getDpiY() const;
71 float getRefreshRate() const;
72 float getDensity() const;
73 int getWidth() const;
74 int getHeight() const;
75 PixelFormat getFormat() const;
76 uint32_t getFlags() const;
77 void makeCurrent() const;
Mathias Agopianca99fb82010-04-14 16:43:44 -070078 uint32_t getMaxTextureSize() const;
79 uint32_t getMaxViewportDims() const;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080080
81 uint32_t getPageFlipCount() const;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080082 EGLDisplay getEGLDisplay() const { return mDisplay; }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080083 overlay_control_device_t* getOverlayEngine() const { return mOverlayEngine; }
84
Mathias Agopian74faca22009-09-17 16:18:16 -070085 status_t compositionComplete() const;
86
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080087 Rect bounds() const {
88 return Rect(mWidth, mHeight);
89 }
90
91private:
92 void init(uint32_t displayIndex) __attribute__((noinline));
93 void fini() __attribute__((noinline));
94
95 EGLDisplay mDisplay;
96 EGLSurface mSurface;
97 EGLContext mContext;
98 EGLConfig mConfig;
99 float mDpiX;
100 float mDpiY;
101 float mRefreshRate;
102 float mDensity;
103 int mWidth;
104 int mHeight;
105 PixelFormat mFormat;
106 uint32_t mFlags;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700107 mutable uint32_t mPageFlipCount;
Mathias Agopianca99fb82010-04-14 16:43:44 -0700108 GLint mMaxViewportDims;
109 GLint mMaxTextureSize;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700110
111 sp<FramebufferNativeWindow> mNativeWindow;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800112 overlay_control_device_t* mOverlayEngine;
113};
114
115}; // namespace android
116
117#endif // ANDROID_DISPLAY_HARDWARE_H