DisplayDevice.h revision edbf3b6af777b721cd2a1ef461947e51e88241e1
1182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski/* 2182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski * Copyright (C) 2007 The Android Open Source Project 3182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski * 4182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski * Licensed under the Apache License, Version 2.0 (the "License"); 5182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski * you may not use this file except in compliance with the License. 6182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski * You may obtain a copy of the License at 7182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski * 8182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski * http://www.apache.org/licenses/LICENSE-2.0 9182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski * 10182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski * Unless required by applicable law or agreed to in writing, software 11182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski * distributed under the License is distributed on an "AS IS" BASIS, 12182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski * See the License for the specific language governing permissions and 14182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski * limitations under the License. 15182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski */ 16182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski 17182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski#ifndef ANDROID_DISPLAY_HARDWARE_H 18182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski#define ANDROID_DISPLAY_HARDWARE_H 19182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski 20182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski#include <stdlib.h> 21182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski 22182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski#include <ui/PixelFormat.h> 23182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski#include <ui/Region.h> 24182f73fc4da13a6417e5086ec9ecce80eb8423caAdam Lesinski 25#include <EGL/egl.h> 26 27#include "DisplayHardware/DisplayHardwareBase.h" 28 29struct overlay_control_device_t; 30struct copybit_device_t; 31struct copybit_image_t; 32struct copybit_t; 33 34namespace android { 35 36class EGLDisplaySurface; 37 38class DisplayHardware : public DisplayHardwareBase 39{ 40public: 41 enum { 42 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; 68 float getDensity() const; 69 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; } 79 copybit_device_t* getBlitEngine() const { return mBlitEngine; } 80 overlay_control_device_t* getOverlayEngine() const { return mOverlayEngine; } 81 82 void copyFrontToImage(const copybit_image_t& front) const; 83 void copyBackToImage(const copybit_image_t& front) const; 84 85 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; 100 float mDensity; 101 int mWidth; 102 int mHeight; 103 PixelFormat mFormat; 104 uint32_t mFlags; 105 mutable Region mDirty; 106 sp<EGLDisplaySurface> mDisplaySurface; 107 copybit_device_t* mBlitEngine; 108 overlay_control_device_t* mOverlayEngine; 109}; 110 111}; // namespace android 112 113#endif // ANDROID_DISPLAY_HARDWARE_H 114