am 888c822c
: remove a dependency of DisplayDevice on the refresh rate
* commit '888c822c4cb6976aab9256c58bae9e17e3e55c5c': remove a dependency of DisplayDevice on the refresh rate
This commit is contained in:
commit
8766b0cc8f
@ -117,12 +117,10 @@ DisplayDevice::DisplayDevice(
|
|||||||
mSurface(EGL_NO_SURFACE),
|
mSurface(EGL_NO_SURFACE),
|
||||||
mContext(EGL_NO_CONTEXT),
|
mContext(EGL_NO_CONTEXT),
|
||||||
mDpiX(), mDpiY(),
|
mDpiX(), mDpiY(),
|
||||||
mRefreshRate(),
|
|
||||||
mDensity(),
|
mDensity(),
|
||||||
mDisplayWidth(), mDisplayHeight(), mFormat(),
|
mDisplayWidth(), mDisplayHeight(), mFormat(),
|
||||||
mFlags(),
|
mFlags(),
|
||||||
mPageFlipCount(),
|
mPageFlipCount(),
|
||||||
mRefreshPeriod(),
|
|
||||||
mSecureLayerVisible(false),
|
mSecureLayerVisible(false),
|
||||||
mScreenAcquired(false),
|
mScreenAcquired(false),
|
||||||
mOrientation(),
|
mOrientation(),
|
||||||
@ -160,10 +158,6 @@ float DisplayDevice::getDensity() const {
|
|||||||
return mDensity;
|
return mDensity;
|
||||||
}
|
}
|
||||||
|
|
||||||
float DisplayDevice::getRefreshRate() const {
|
|
||||||
return mRefreshRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
int DisplayDevice::getWidth() const {
|
int DisplayDevice::getWidth() const {
|
||||||
return mDisplayWidth;
|
return mDisplayWidth;
|
||||||
}
|
}
|
||||||
@ -180,19 +174,6 @@ EGLSurface DisplayDevice::getEGLSurface() const {
|
|||||||
return mSurface;
|
return mSurface;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t DisplayDevice::getInfo(DisplayInfo* info) const {
|
|
||||||
info->w = getWidth();
|
|
||||||
info->h = getHeight();
|
|
||||||
info->xdpi = getDpiX();
|
|
||||||
info->ydpi = getDpiY();
|
|
||||||
info->fps = getRefreshRate();
|
|
||||||
info->density = getDensity();
|
|
||||||
info->orientation = getOrientation();
|
|
||||||
// TODO: this needs to go away (currently needed only by webkit)
|
|
||||||
getPixelFormatInfo(getFormat(), &info->pixelFormatInfo);
|
|
||||||
return NO_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DisplayDevice::init(EGLConfig config)
|
void DisplayDevice::init(EGLConfig config)
|
||||||
{
|
{
|
||||||
ANativeWindow* const window = mNativeWindow.get();
|
ANativeWindow* const window = mNativeWindow.get();
|
||||||
@ -207,13 +188,6 @@ void DisplayDevice::init(EGLConfig config)
|
|||||||
window->query(window, NATIVE_WINDOW_FORMAT, &format);
|
window->query(window, NATIVE_WINDOW_FORMAT, &format);
|
||||||
mDpiX = window->xdpi;
|
mDpiX = window->xdpi;
|
||||||
mDpiY = window->ydpi;
|
mDpiY = window->ydpi;
|
||||||
if (mFramebufferSurface != NULL) {
|
|
||||||
mRefreshRate = mFramebufferSurface->getRefreshRate();
|
|
||||||
} else {
|
|
||||||
mRefreshRate = 60;
|
|
||||||
}
|
|
||||||
mRefreshPeriod = nsecs_t(1e9 / mRefreshRate);
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: Not sure if display density should handled by SF any longer
|
// TODO: Not sure if display density should handled by SF any longer
|
||||||
class Density {
|
class Density {
|
||||||
@ -279,10 +253,6 @@ uint32_t DisplayDevice::getPageFlipCount() const {
|
|||||||
return mPageFlipCount;
|
return mPageFlipCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsecs_t DisplayDevice::getRefreshPeriod() const {
|
|
||||||
return mRefreshPeriod;
|
|
||||||
}
|
|
||||||
|
|
||||||
status_t DisplayDevice::compositionComplete() const {
|
status_t DisplayDevice::compositionComplete() const {
|
||||||
if (mFramebufferSurface == NULL) {
|
if (mFramebufferSurface == NULL) {
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
|
@ -82,14 +82,11 @@ public:
|
|||||||
|
|
||||||
float getDpiX() const;
|
float getDpiX() const;
|
||||||
float getDpiY() const;
|
float getDpiY() const;
|
||||||
float getRefreshRate() const;
|
|
||||||
float getDensity() const;
|
float getDensity() const;
|
||||||
int getWidth() const;
|
int getWidth() const;
|
||||||
int getHeight() const;
|
int getHeight() const;
|
||||||
PixelFormat getFormat() const;
|
PixelFormat getFormat() const;
|
||||||
uint32_t getFlags() const;
|
uint32_t getFlags() const;
|
||||||
nsecs_t getRefreshPeriod() const;
|
|
||||||
status_t getInfo(DisplayInfo* info) const;
|
|
||||||
|
|
||||||
EGLSurface getEGLSurface() const;
|
EGLSurface getEGLSurface() const;
|
||||||
|
|
||||||
@ -149,14 +146,12 @@ private:
|
|||||||
EGLContext mContext;
|
EGLContext mContext;
|
||||||
float mDpiX;
|
float mDpiX;
|
||||||
float mDpiY;
|
float mDpiY;
|
||||||
float mRefreshRate;
|
|
||||||
float mDensity;
|
float mDensity;
|
||||||
int mDisplayWidth;
|
int mDisplayWidth;
|
||||||
int mDisplayHeight;
|
int mDisplayHeight;
|
||||||
PixelFormat mFormat;
|
PixelFormat mFormat;
|
||||||
uint32_t mFlags;
|
uint32_t mFlags;
|
||||||
mutable uint32_t mPageFlipCount;
|
mutable uint32_t mPageFlipCount;
|
||||||
nsecs_t mRefreshPeriod;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Can only accessed from the main thread, these members
|
* Can only accessed from the main thread, these members
|
||||||
|
@ -101,14 +101,12 @@ struct HWComposer::cb_context {
|
|||||||
|
|
||||||
HWComposer::HWComposer(
|
HWComposer::HWComposer(
|
||||||
const sp<SurfaceFlinger>& flinger,
|
const sp<SurfaceFlinger>& flinger,
|
||||||
EventHandler& handler,
|
EventHandler& handler)
|
||||||
nsecs_t refreshPeriod)
|
|
||||||
: mFlinger(flinger),
|
: mFlinger(flinger),
|
||||||
mModule(0), mHwc(0), mList(0), mCapacity(0),
|
mModule(0), mHwc(0), mList(0), mCapacity(0),
|
||||||
mNumOVLayers(0), mNumFBLayers(0),
|
mNumOVLayers(0), mNumFBLayers(0),
|
||||||
mCBContext(new cb_context),
|
mCBContext(new cb_context),
|
||||||
mEventHandler(handler),
|
mEventHandler(handler), mRefreshPeriod(0),
|
||||||
mRefreshPeriod(refreshPeriod),
|
|
||||||
mVSyncCount(0), mDebugForceFakeVSync(false)
|
mVSyncCount(0), mDebugForceFakeVSync(false)
|
||||||
{
|
{
|
||||||
char value[PROPERTY_VALUE_MAX];
|
char value[PROPERTY_VALUE_MAX];
|
||||||
@ -137,6 +135,11 @@ HWComposer::HWComposer(
|
|||||||
// always turn vsync off when we start
|
// always turn vsync off when we start
|
||||||
mHwc->methods->eventControl(mHwc, HWC_EVENT_VSYNC, 0);
|
mHwc->methods->eventControl(mHwc, HWC_EVENT_VSYNC, 0);
|
||||||
needVSyncThread = false;
|
needVSyncThread = false;
|
||||||
|
|
||||||
|
int period;
|
||||||
|
if (mHwc->query(mHwc, HWC_VSYNC_PERIOD, &period) == NO_ERROR) {
|
||||||
|
mRefreshPeriod = nsecs_t(period);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (mHwc->registerProcs) {
|
if (mHwc->registerProcs) {
|
||||||
mCBContext->hwc = this;
|
mCBContext->hwc = this;
|
||||||
@ -148,6 +151,26 @@ HWComposer::HWComposer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mRefreshPeriod == 0) {
|
||||||
|
// for compatibility, we attempt to get the refresh rate from
|
||||||
|
// the FB HAL if we couldn't get it from the HWC HAL.
|
||||||
|
hw_module_t const* module;
|
||||||
|
if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) {
|
||||||
|
framebuffer_device_t* fbDev;
|
||||||
|
int err = framebuffer_open(module, &fbDev);
|
||||||
|
if (!err && fbDev) {
|
||||||
|
mRefreshPeriod = nsecs_t(1e9 / fbDev->fps);
|
||||||
|
framebuffer_close(fbDev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ALOGW("getting VSYNC period from fb HAL: %lld", mRefreshPeriod);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mRefreshPeriod == 0) {
|
||||||
|
mRefreshPeriod = nsecs_t(1e9 / 60.0);
|
||||||
|
ALOGW("getting VSYNC period thin air: %lld", mRefreshPeriod);
|
||||||
|
}
|
||||||
|
|
||||||
if (needVSyncThread) {
|
if (needVSyncThread) {
|
||||||
// we don't have VSYNC support, we need to fake it
|
// we don't have VSYNC support, we need to fake it
|
||||||
mVSyncThread = new VSyncThread(*this);
|
mVSyncThread = new VSyncThread(*this);
|
||||||
@ -189,6 +212,10 @@ void HWComposer::vsync(int dpy, int64_t timestamp) {
|
|||||||
mLastHwVSync = timestamp;
|
mLastHwVSync = timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsecs_t HWComposer::getRefreshPeriod() const {
|
||||||
|
return mRefreshPeriod;
|
||||||
|
}
|
||||||
|
|
||||||
nsecs_t HWComposer::getRefreshTimestamp() const {
|
nsecs_t HWComposer::getRefreshTimestamp() const {
|
||||||
// this returns the last refresh timestamp.
|
// this returns the last refresh timestamp.
|
||||||
// if the last one is not available, we estimate it based on
|
// if the last one is not available, we estimate it based on
|
||||||
|
@ -55,8 +55,7 @@ public:
|
|||||||
virtual ~EventHandler() {}
|
virtual ~EventHandler() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
HWComposer(const sp<SurfaceFlinger>& flinger,
|
HWComposer(const sp<SurfaceFlinger>& flinger, EventHandler& handler);
|
||||||
EventHandler& handler, nsecs_t refreshPeriod);
|
|
||||||
~HWComposer();
|
~HWComposer();
|
||||||
|
|
||||||
status_t initCheck() const;
|
status_t initCheck() const;
|
||||||
@ -189,6 +188,7 @@ public:
|
|||||||
|
|
||||||
void eventControl(int event, int enabled);
|
void eventControl(int event, int enabled);
|
||||||
|
|
||||||
|
nsecs_t getRefreshPeriod() const;
|
||||||
nsecs_t getRefreshTimestamp() const;
|
nsecs_t getRefreshTimestamp() const;
|
||||||
|
|
||||||
// this class is only used to fake the VSync event on systems that don't
|
// this class is only used to fake the VSync event on systems that don't
|
||||||
|
@ -729,7 +729,7 @@ void Layer::dumpStats(String8& result, char* buffer, size_t SIZE) const
|
|||||||
LayerBaseClient::dumpStats(result, buffer, SIZE);
|
LayerBaseClient::dumpStats(result, buffer, SIZE);
|
||||||
const size_t o = mFrameLatencyOffset;
|
const size_t o = mFrameLatencyOffset;
|
||||||
const DisplayDevice& hw(mFlinger->getDefaultDisplayDevice());
|
const DisplayDevice& hw(mFlinger->getDefaultDisplayDevice());
|
||||||
const nsecs_t period = hw.getRefreshPeriod();
|
const nsecs_t period = mFlinger->getHwComposer().getRefreshPeriod();
|
||||||
result.appendFormat("%lld\n", period);
|
result.appendFormat("%lld\n", period);
|
||||||
for (size_t i=0 ; i<128 ; i++) {
|
for (size_t i=0 ; i<128 ; i++) {
|
||||||
const size_t index = (o+i) % 128;
|
const size_t index = (o+i) % 128;
|
||||||
|
@ -378,9 +378,7 @@ status_t SurfaceFlinger::readyToRun()
|
|||||||
mEventQueue.setEventThread(mEventThread);
|
mEventQueue.setEventThread(mEventThread);
|
||||||
|
|
||||||
// initialize the H/W composer
|
// initialize the H/W composer
|
||||||
mHwc = new HWComposer(this,
|
mHwc = new HWComposer(this, *static_cast<HWComposer::EventHandler *>(this));
|
||||||
*static_cast<HWComposer::EventHandler *>(this),
|
|
||||||
hw.getRefreshPeriod());
|
|
||||||
|
|
||||||
// initialize our drawing state
|
// initialize our drawing state
|
||||||
mDrawingState = mCurrentState;
|
mDrawingState = mCurrentState;
|
||||||
@ -453,11 +451,21 @@ bool SurfaceFlinger::authenticateSurfaceTexture(
|
|||||||
}
|
}
|
||||||
|
|
||||||
status_t SurfaceFlinger::getDisplayInfo(DisplayID dpy, DisplayInfo* info) {
|
status_t SurfaceFlinger::getDisplayInfo(DisplayID dpy, DisplayInfo* info) {
|
||||||
|
// TODO: this is here only for compatibility -- show go away eventually.
|
||||||
if (uint32_t(dpy) >= 2) {
|
if (uint32_t(dpy) >= 2) {
|
||||||
return BAD_INDEX;
|
return BAD_INDEX;
|
||||||
}
|
}
|
||||||
const DisplayDevice& hw(getDefaultDisplayDevice());
|
const DisplayDevice& hw(getDefaultDisplayDevice());
|
||||||
return hw.getInfo(info);
|
info->w = hw.getWidth();
|
||||||
|
info->h = hw.getHeight();
|
||||||
|
info->xdpi = hw.getDpiX();
|
||||||
|
info->ydpi = hw.getDpiY();
|
||||||
|
info->fps = float(1e9 / getHwComposer().getRefreshPeriod());
|
||||||
|
info->density = hw.getDensity();
|
||||||
|
info->orientation = hw.getOrientation();
|
||||||
|
// TODO: this needs to go away (currently needed only by webkit)
|
||||||
|
getPixelFormatInfo(hw.getFormat(), &info->pixelFormatInfo);
|
||||||
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -1818,6 +1826,7 @@ void SurfaceFlinger::dumpAllLocked(
|
|||||||
snprintf(buffer, SIZE, "SurfaceFlinger global state:\n");
|
snprintf(buffer, SIZE, "SurfaceFlinger global state:\n");
|
||||||
result.append(buffer);
|
result.append(buffer);
|
||||||
|
|
||||||
|
HWComposer& hwc(getHwComposer());
|
||||||
const DisplayDevice& hw(getDefaultDisplayDevice());
|
const DisplayDevice& hw(getDefaultDisplayDevice());
|
||||||
const GLExtensions& extensions(GLExtensions::getInstance());
|
const GLExtensions& extensions(GLExtensions::getInstance());
|
||||||
snprintf(buffer, SIZE, "GLES: %s, %s, %s\n",
|
snprintf(buffer, SIZE, "GLES: %s, %s, %s\n",
|
||||||
@ -1849,7 +1858,7 @@ void SurfaceFlinger::dumpAllLocked(
|
|||||||
mLastSwapBufferTime/1000.0,
|
mLastSwapBufferTime/1000.0,
|
||||||
mLastTransactionTime/1000.0,
|
mLastTransactionTime/1000.0,
|
||||||
mTransactionFlags,
|
mTransactionFlags,
|
||||||
hw.getRefreshRate(),
|
1e9 / hwc.getRefreshPeriod(),
|
||||||
hw.getDpiX(),
|
hw.getDpiX(),
|
||||||
hw.getDpiY(),
|
hw.getDpiY(),
|
||||||
hw.getDensity());
|
hw.getDensity());
|
||||||
@ -1871,7 +1880,6 @@ void SurfaceFlinger::dumpAllLocked(
|
|||||||
/*
|
/*
|
||||||
* Dump HWComposer state
|
* Dump HWComposer state
|
||||||
*/
|
*/
|
||||||
HWComposer& hwc(getHwComposer());
|
|
||||||
snprintf(buffer, SIZE, "h/w composer state:\n");
|
snprintf(buffer, SIZE, "h/w composer state:\n");
|
||||||
result.append(buffer);
|
result.append(buffer);
|
||||||
snprintf(buffer, SIZE, " h/w composer %s and %s\n",
|
snprintf(buffer, SIZE, " h/w composer %s and %s\n",
|
||||||
|
@ -336,7 +336,7 @@ private:
|
|||||||
|
|
||||||
HWComposer& getHwComposer() const { return *mHwc; }
|
HWComposer& getHwComposer() const { return *mHwc; }
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------
|
||||||
* Compositing
|
* Compositing
|
||||||
*/
|
*/
|
||||||
void invalidateHwcGeometry();
|
void invalidateHwcGeometry();
|
||||||
|
Loading…
Reference in New Issue
Block a user