blob: 299e2363f94b9c6ad2d7bb328b84c5a4bab2227e [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
29struct copybit_image_t;
30struct copybit_t;
31
32namespace android {
33
34class EGLDisplaySurface;
35
36class DisplayHardware : public DisplayHardwareBase
37{
38public:
39 enum {
40 COPY_BACK_EXTENSION = 0x00000001,
41 DIRECT_TEXTURE = 0x00000002,
42 SWAP_RECTANGLE_EXTENSION= 0x00000004,
43 COPY_BITS_EXTENSION = 0x00000008,
44 NPOT_EXTENSION = 0x00000100,
45 DRAW_TEXTURE_EXTENSION = 0x00000200,
46 BUFFER_PRESERVED = 0x00010000,
47 UPDATE_ON_DEMAND = 0x00020000, // video driver feature
48 SLOW_CONFIG = 0x00040000, // software
49 };
50
51 DisplayHardware(
52 const sp<SurfaceFlinger>& flinger,
53 uint32_t displayIndex);
54
55 ~DisplayHardware();
56
57 void releaseScreen() const;
58 void acquireScreen() const;
59
60 // Flip the front and back buffers if the back buffer is "dirty". Might
61 // be instantaneous, might involve copying the frame buffer around.
62 void flip(const Region& dirty) const;
63
64 float getDpiX() const;
65 float getDpiY() const;
66 float getRefreshRate() const;
67 int getWidth() const;
68 int getHeight() const;
69 PixelFormat getFormat() const;
70 uint32_t getFlags() const;
71 void makeCurrent() const;
72
73 uint32_t getPageFlipCount() const;
74 void getDisplaySurface(copybit_image_t* img) const;
75 void getDisplaySurface(GGLSurface* fb) const;
76 EGLDisplay getEGLDisplay() const { return mDisplay; }
77 copybit_t* getBlitEngine() const { return mBlitEngine; }
78
79 Rect bounds() const {
80 return Rect(mWidth, mHeight);
81 }
82
83private:
84 void init(uint32_t displayIndex) __attribute__((noinline));
85 void fini() __attribute__((noinline));
86
87 EGLDisplay mDisplay;
88 EGLSurface mSurface;
89 EGLContext mContext;
90 EGLConfig mConfig;
91 float mDpiX;
92 float mDpiY;
93 float mRefreshRate;
94 int mWidth;
95 int mHeight;
96 PixelFormat mFormat;
97 uint32_t mFlags;
98 mutable Region mDirty;
99 sp<EGLDisplaySurface> mDisplaySurface;
100 copybit_t* mBlitEngine;
101};
102
103}; // namespace android
104
105#endif // ANDROID_DISPLAY_HARDWARE_H