blob: 550a4d12702c9e6a79930490180b6d0a57645cce [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
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -080025#include <EGL/egl.h>
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070026
27#include "DisplayHardware/DisplayHardwareBase.h"
28
The Android Open Source Project27629322009-01-09 17:51:23 -080029struct overlay_control_device_t;
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080030struct 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 {
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070042 DIRECT_TEXTURE = 0x00000002,
43 SWAP_RECTANGLE_EXTENSION= 0x00000004,
44 COPY_BITS_EXTENSION = 0x00000008,
45 NPOT_EXTENSION = 0x00000100,
46 DRAW_TEXTURE_EXTENSION = 0x00000200,
47 BUFFER_PRESERVED = 0x00010000,
48 UPDATE_ON_DEMAND = 0x00020000, // video driver feature
49 SLOW_CONFIG = 0x00040000, // software
50 };
51
52 DisplayHardware(
53 const sp<SurfaceFlinger>& flinger,
54 uint32_t displayIndex);
55
56 ~DisplayHardware();
57
58 void releaseScreen() const;
59 void acquireScreen() const;
60
61 // Flip the front and back buffers if the back buffer is "dirty". Might
62 // be instantaneous, might involve copying the frame buffer around.
63 void flip(const Region& dirty) const;
64
65 float getDpiX() const;
66 float getDpiY() const;
67 float getRefreshRate() const;
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080068 float getDensity() const;
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070069 int getWidth() const;
70 int getHeight() const;
71 PixelFormat getFormat() const;
72 uint32_t getFlags() const;
73 void makeCurrent() const;
74
75 uint32_t getPageFlipCount() const;
76 void getDisplaySurface(copybit_image_t* img) const;
77 void getDisplaySurface(GGLSurface* fb) const;
78 EGLDisplay getEGLDisplay() const { return mDisplay; }
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080079 copybit_device_t* getBlitEngine() const { return mBlitEngine; }
The Android Open Source Project27629322009-01-09 17:51:23 -080080 overlay_control_device_t* getOverlayEngine() const { return mOverlayEngine; }
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070081
The Android Open Source Projecta6938ba2009-02-10 15:44:00 -080082 void copyFrontToImage(const copybit_image_t& front) const;
83 void copyBackToImage(const copybit_image_t& front) const;
84
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070085 Rect bounds() const {
86 return Rect(mWidth, mHeight);
87 }
88
89private:
90 void init(uint32_t displayIndex) __attribute__((noinline));
91 void fini() __attribute__((noinline));
92
93 EGLDisplay mDisplay;
94 EGLSurface mSurface;
95 EGLContext mContext;
96 EGLConfig mConfig;
97 float mDpiX;
98 float mDpiY;
99 float mRefreshRate;
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800100 float mDensity;
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700101 int mWidth;
102 int mHeight;
103 PixelFormat mFormat;
104 uint32_t mFlags;
105 mutable Region mDirty;
106 sp<EGLDisplaySurface> mDisplaySurface;
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800107 copybit_device_t* mBlitEngine;
The Android Open Source Project27629322009-01-09 17:51:23 -0800108 overlay_control_device_t* mOverlayEngine;
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700109};
110
111}; // namespace android
112
113#endif // ANDROID_DISPLAY_HARDWARE_H