blob: f2cfd2db579b30abeea9356e1e5684e9d515e25c [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
Mathias Agopian1f7bec62010-06-25 18:02:21 -070032#include "GLExtensions.h"
33
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080034#include "DisplayHardware/DisplayHardwareBase.h"
35
36struct overlay_control_device_t;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080037
38namespace android {
39
Mathias Agopian076b1cc2009-04-10 14:24:30 -070040class FramebufferNativeWindow;
Mathias Agopiana350ff92010-08-10 17:14:02 -070041class HWComposer;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080042
43class DisplayHardware : public DisplayHardwareBase
44{
45public:
46 enum {
Mathias Agopian1f7bec62010-06-25 18:02:21 -070047 COPY_BITS_EXTENSION = 0x00000008,
48 BUFFER_PRESERVED = 0x00010000,
49 PARTIAL_UPDATES = 0x00020000, // video driver feature
50 SLOW_CONFIG = 0x00040000, // software
51 SWAP_RECTANGLE = 0x00080000,
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080052 };
53
54 DisplayHardware(
55 const sp<SurfaceFlinger>& flinger,
56 uint32_t displayIndex);
57
58 ~DisplayHardware();
59
60 void releaseScreen() const;
61 void acquireScreen() const;
62
63 // Flip the front and back buffers if the back buffer is "dirty". Might
64 // be instantaneous, might involve copying the frame buffer around.
65 void flip(const Region& dirty) const;
66
67 float getDpiX() const;
68 float getDpiY() const;
69 float getRefreshRate() const;
70 float getDensity() const;
71 int getWidth() const;
72 int getHeight() const;
73 PixelFormat getFormat() const;
74 uint32_t getFlags() const;
75 void makeCurrent() const;
Mathias Agopianca99fb82010-04-14 16:43:44 -070076 uint32_t getMaxTextureSize() const;
77 uint32_t getMaxViewportDims() const;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080078
79 uint32_t getPageFlipCount() const;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080080 EGLDisplay getEGLDisplay() const { return mDisplay; }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080081 overlay_control_device_t* getOverlayEngine() const { return mOverlayEngine; }
Mathias Agopiana350ff92010-08-10 17:14:02 -070082
83 // Hardware Composer
84 HWComposer& getHwComposer() const;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080085
Mathias Agopian74faca22009-09-17 16:18:16 -070086 status_t compositionComplete() const;
87
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080088 Rect bounds() const {
89 return Rect(mWidth, mHeight);
90 }
91
92private:
93 void init(uint32_t displayIndex) __attribute__((noinline));
94 void fini() __attribute__((noinline));
95
96 EGLDisplay mDisplay;
97 EGLSurface mSurface;
98 EGLContext mContext;
99 EGLConfig mConfig;
100 float mDpiX;
101 float mDpiY;
102 float mRefreshRate;
103 float mDensity;
104 int mWidth;
105 int mHeight;
106 PixelFormat mFormat;
107 uint32_t mFlags;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700108 mutable uint32_t mPageFlipCount;
Mathias Agopianca99fb82010-04-14 16:43:44 -0700109 GLint mMaxViewportDims;
110 GLint mMaxTextureSize;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700111
Mathias Agopiana350ff92010-08-10 17:14:02 -0700112 HWComposer* mHwc;
113
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700114 sp<FramebufferNativeWindow> mNativeWindow;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800115 overlay_control_device_t* mOverlayEngine;
116};
117
118}; // namespace android
119
120#endif // ANDROID_DISPLAY_HARDWARE_H