diff options
author | Mathias Agopian <mathias@google.com> | 2009-05-07 17:40:23 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2009-05-07 17:40:23 -0700 |
commit | 1e16b13857809eaa9bd17fb60ac0a471dc92844b (patch) | |
tree | 0af8e8f35ac417b91d454318a45a2130e56cee04 | |
parent | e6bf8b32b616450f80b64d226ea673f4a2e0bf8d (diff) | |
download | frameworks_native-1e16b13857809eaa9bd17fb60ac0a471dc92844b.zip frameworks_native-1e16b13857809eaa9bd17fb60ac0a471dc92844b.tar.gz frameworks_native-1e16b13857809eaa9bd17fb60ac0a471dc92844b.tar.bz2 |
add support for update-on-demand in SurfaceFlinger
-rw-r--r-- | include/ui/FramebufferNativeWindow.h | 4 | ||||
-rw-r--r-- | libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp | 12 | ||||
-rw-r--r-- | libs/ui/FramebufferNativeWindow.cpp | 12 |
3 files changed, 24 insertions, 4 deletions
diff --git a/include/ui/FramebufferNativeWindow.h b/include/ui/FramebufferNativeWindow.h index aad39a2..a780472 100644 --- a/include/ui/FramebufferNativeWindow.h +++ b/include/ui/FramebufferNativeWindow.h @@ -52,6 +52,9 @@ public: framebuffer_device_t const * getDevice() const { return fbDev; } + bool isUpdateOnDemand() const { return mUpdateOnDemand; } + status_t setUpdateRectangle(const Rect& updateRect); + private: friend class LightRefBase<FramebufferNativeWindow>; ~FramebufferNativeWindow(); // this class cannot be overloaded @@ -71,6 +74,7 @@ private: int32_t mNumBuffers; int32_t mNumFreeBuffers; int32_t mBufferHead; + bool mUpdateOnDemand; }; // --------------------------------------------------------------------------- diff --git a/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp b/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp index 31db31f..25e351c 100644 --- a/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp +++ b/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp @@ -183,9 +183,11 @@ void DisplayHardware::init(uint32_t dpy) LOGI("extensions: %s", egl_extensions); LOGI("Client API: %s", eglQueryString(display, EGL_CLIENT_APIS)?:"Not Supported"); - // TODO: get the real "update_on_demand" behavior (probably should be HAL module) - // FIXME: mFlags |= UPDATE_ON_DEMAND; + if (mNativeWindow->isUpdateOnDemand()) { + mFlags |= UPDATE_ON_DEMAND; + } + if (eglGetConfigAttrib(display, config, EGL_CONFIG_CAVEAT, &dummy) == EGL_TRUE) { if (dummy == EGL_SLOW_CONFIG) mFlags |= SLOW_CONFIG; @@ -210,7 +212,7 @@ void DisplayHardware::init(uint32_t dpy) mDpiX = mNativeWindow->xdpi; mDpiX = mNativeWindow->ydpi; - mRefreshRate = mNativeWindow->getDevice()->fps; + mRefreshRate = fbDev->fps; char property[PROPERTY_VALUE_MAX]; if (property_get("ro.sf.lcd_density", property, NULL) <= 0) { @@ -314,6 +316,10 @@ void DisplayHardware::flip(const Region& dirty) const b.left, b.top, b.width(), b.height()); } + if (mFlags & UPDATE_ON_DEMAND) { + mNativeWindow->setUpdateRectangle(dirty.bounds()); + } + mPageFlipCount++; eglSwapBuffers(dpy, surface); checkEGLErrors("eglSwapBuffers"); diff --git a/libs/ui/FramebufferNativeWindow.cpp b/libs/ui/FramebufferNativeWindow.cpp index 83b333f..8c8fd6b 100644 --- a/libs/ui/FramebufferNativeWindow.cpp +++ b/libs/ui/FramebufferNativeWindow.cpp @@ -76,7 +76,7 @@ private: */ FramebufferNativeWindow::FramebufferNativeWindow() - : BASE(), fbDev(0), grDev(0) + : BASE(), fbDev(0), grDev(0), mUpdateOnDemand(false) { hw_module_t const* module; if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) { @@ -86,6 +86,8 @@ FramebufferNativeWindow::FramebufferNativeWindow() int err; + mUpdateOnDemand = (fbDev->setUpdateRect != 0); + // initialize the buffer FIFO mNumBuffers = 2; mNumFreeBuffers = 2; @@ -131,6 +133,14 @@ FramebufferNativeWindow::~FramebufferNativeWindow() { framebuffer_close(fbDev); } +status_t FramebufferNativeWindow::setUpdateRectangle(const Rect& r) +{ + if (!mUpdateOnDemand) { + return INVALID_OPERATION; + } + return fbDev->setUpdateRect(fbDev, r.left, r.top, r.width(), r.height()); +} + int FramebufferNativeWindow::setSwapInterval( android_native_window_t* window, int interval) { |