2009-03-04 03:31:44 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ANDROID_DISPLAY_HARDWARE_H
|
|
|
|
#define ANDROID_DISPLAY_HARDWARE_H
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <ui/PixelFormat.h>
|
|
|
|
#include <ui/Region.h>
|
|
|
|
|
2009-04-10 21:24:30 +00:00
|
|
|
#include <GLES/gl.h>
|
|
|
|
#include <GLES/glext.h>
|
2009-03-04 03:31:44 +00:00
|
|
|
#include <EGL/egl.h>
|
2009-04-10 21:24:30 +00:00
|
|
|
#include <EGL/eglext.h>
|
|
|
|
|
2012-07-25 05:46:10 +00:00
|
|
|
#include <utils/Mutex.h>
|
|
|
|
#include <utils/Timers.h>
|
|
|
|
|
2012-06-21 00:51:20 +00:00
|
|
|
#include "Transform.h"
|
2010-06-26 01:02:21 +00:00
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
#include "DisplayHardware/DisplayHardwareBase.h"
|
|
|
|
|
|
|
|
namespace android {
|
|
|
|
|
2012-07-26 01:56:13 +00:00
|
|
|
class DisplayInfo;
|
2012-06-08 00:52:54 +00:00
|
|
|
class FramebufferSurface;
|
2012-07-25 05:46:10 +00:00
|
|
|
class LayerBase;
|
|
|
|
class SurfaceFlinger;
|
2012-07-12 21:25:33 +00:00
|
|
|
class SurfaceTextureClient;
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2012-07-25 05:46:10 +00:00
|
|
|
class DisplayHardware : public DisplayHardwareBase
|
2009-03-04 03:31:44 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-04-04 05:09:52 +00:00
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
enum {
|
2010-06-26 01:02:21 +00:00
|
|
|
PARTIAL_UPDATES = 0x00020000, // video driver feature
|
|
|
|
SWAP_RECTANGLE = 0x00080000,
|
2009-03-04 03:31:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
DisplayHardware(
|
|
|
|
const sp<SurfaceFlinger>& flinger,
|
2012-07-12 21:25:33 +00:00
|
|
|
int dpy,
|
|
|
|
const sp<SurfaceTextureClient>& surface,
|
|
|
|
EGLConfig config);
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2012-04-04 05:09:52 +00:00
|
|
|
virtual ~DisplayHardware();
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
// Flip the front and back buffers if the back buffer is "dirty". Might
|
|
|
|
// be instantaneous, might involve copying the frame buffer around.
|
|
|
|
void flip(const Region& dirty) const;
|
|
|
|
|
2012-07-25 05:46:10 +00:00
|
|
|
void onVSyncReceived(nsecs_t timestamp);
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
float getDpiX() const;
|
|
|
|
float getDpiY() const;
|
|
|
|
float getRefreshRate() const;
|
|
|
|
float getDensity() const;
|
|
|
|
int getWidth() const;
|
|
|
|
int getHeight() const;
|
|
|
|
PixelFormat getFormat() const;
|
|
|
|
uint32_t getFlags() const;
|
2012-01-20 02:34:40 +00:00
|
|
|
nsecs_t getRefreshPeriod() const;
|
|
|
|
nsecs_t getRefreshTimestamp() const;
|
2012-07-26 01:56:13 +00:00
|
|
|
status_t getInfo(DisplayInfo* info) const;
|
2012-04-04 05:09:52 +00:00
|
|
|
|
2012-07-12 21:25:33 +00:00
|
|
|
EGLSurface getEGLSurface() const;
|
2012-07-11 20:48:17 +00:00
|
|
|
|
|
|
|
void setVisibleLayersSortedByZ(const Vector< sp<LayerBase> >& layers);
|
|
|
|
Vector< sp<LayerBase> > getVisibleLayersSortedByZ() const;
|
|
|
|
bool getSecureLayerVisible() const;
|
|
|
|
|
2012-06-21 00:51:20 +00:00
|
|
|
status_t setOrientation(int orientation);
|
|
|
|
int getOrientation() const { return mOrientation; }
|
|
|
|
const Transform& getTransform() const { return mGlobalTransform; }
|
2012-04-04 05:09:52 +00:00
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
uint32_t getPageFlipCount() const;
|
|
|
|
EGLDisplay getEGLDisplay() const { return mDisplay; }
|
2010-08-11 00:14:02 +00:00
|
|
|
|
2010-12-02 00:38:01 +00:00
|
|
|
void dump(String8& res) const;
|
|
|
|
|
2009-09-17 23:18:16 +00:00
|
|
|
status_t compositionComplete() const;
|
|
|
|
|
2011-09-21 00:21:56 +00:00
|
|
|
Rect getBounds() const {
|
2012-06-21 00:51:20 +00:00
|
|
|
return Rect(mDisplayWidth, mDisplayHeight);
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
2011-09-21 00:21:56 +00:00
|
|
|
inline Rect bounds() const { return getBounds(); }
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
private:
|
2012-07-12 21:25:33 +00:00
|
|
|
void init(EGLConfig config);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Constants, set during initialization
|
|
|
|
*/
|
2011-08-01 23:32:21 +00:00
|
|
|
sp<SurfaceFlinger> mFlinger;
|
2012-07-12 21:25:33 +00:00
|
|
|
int mDisplayId;
|
|
|
|
// ANativeWindow this display is rendering into
|
|
|
|
sp<SurfaceTextureClient> mNativeWindow;
|
|
|
|
// set if mNativeWindow is a FramebufferSurface
|
|
|
|
sp<FramebufferSurface> mFramebufferSurface;
|
|
|
|
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
EGLDisplay mDisplay;
|
|
|
|
EGLSurface mSurface;
|
|
|
|
EGLContext mContext;
|
|
|
|
float mDpiX;
|
|
|
|
float mDpiY;
|
|
|
|
float mRefreshRate;
|
|
|
|
float mDensity;
|
2012-06-21 00:51:20 +00:00
|
|
|
int mDisplayWidth;
|
|
|
|
int mDisplayHeight;
|
2009-03-04 03:31:44 +00:00
|
|
|
PixelFormat mFormat;
|
|
|
|
uint32_t mFlags;
|
2009-04-10 21:24:30 +00:00
|
|
|
mutable uint32_t mPageFlipCount;
|
2011-11-18 01:49:17 +00:00
|
|
|
|
|
|
|
nsecs_t mRefreshPeriod;
|
2012-04-26 23:11:59 +00:00
|
|
|
|
2012-07-12 21:25:33 +00:00
|
|
|
/*
|
|
|
|
* Can only accessed from the main thread, these members
|
|
|
|
* don't need synchronization.
|
|
|
|
*/
|
2012-07-11 20:48:17 +00:00
|
|
|
// list of visible layers on that display
|
|
|
|
Vector< sp<LayerBase> > mVisibleLayersSortedByZ;
|
|
|
|
// Whether we have a visible secure layer on this display
|
|
|
|
bool mSecureLayerVisible;
|
|
|
|
|
2010-08-11 00:14:02 +00:00
|
|
|
|
2012-06-21 00:51:20 +00:00
|
|
|
// this used to be in GraphicPlane
|
|
|
|
static status_t orientationToTransfrom(int orientation, int w, int h,
|
|
|
|
Transform* tr);
|
2012-07-25 04:08:59 +00:00
|
|
|
Transform mGlobalTransform;
|
|
|
|
int mOrientation;
|
2012-04-04 05:09:52 +00:00
|
|
|
|
2012-07-12 21:25:33 +00:00
|
|
|
/*
|
|
|
|
* protected by mLock
|
|
|
|
*/
|
2012-07-25 04:08:59 +00:00
|
|
|
mutable Mutex mLock;
|
2012-07-25 05:46:10 +00:00
|
|
|
mutable nsecs_t mLastHwVSync;
|
2009-03-04 03:31:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}; // namespace android
|
|
|
|
|
|
|
|
#endif // ANDROID_DISPLAY_HARDWARE_H
|