diff options
author | Jesse Hall <jessehall@google.com> | 2012-04-05 15:53:28 -0700 |
---|---|---|
committer | Jesse Hall <jessehall@google.com> | 2012-04-09 21:36:17 -0700 |
commit | 258385978c517a47626161b1e644c48bcee28de1 (patch) | |
tree | 23832c73a74da659b78104838c3cc1d43bbdc291 /opengl/libs/EGL/egl_object.h | |
parent | b29e5e8c2682ae145e8c56d9afb061f8da7f854c (diff) | |
download | frameworks_native-258385978c517a47626161b1e644c48bcee28de1.zip frameworks_native-258385978c517a47626161b1e644c48bcee28de1.tar.gz frameworks_native-258385978c517a47626161b1e644c48bcee28de1.tar.bz2 |
Hibernate the EGL implementation when idle
If the EGL implementation supports the EGL_IMG_hibernate_process
extension, use it to hibernate (and hopefully release memory or other
resources) when the process isn't actively using EGL or OpenGL ES. The
idleness heuristic used in this change is:
(a) Wake up when entering any EGL API call, and remain awake for the
duration of the call.
(b) Do not hibernate when any window surface exists; this means the
application is very likely in the foreground.
(c) Do not hibernate while any context is made current to a thread.
The app may be using a client API without the EGL layer knowing,
so it is not safe to hibernate.
(d) Only check these conditions and attempt to hibernate after a
window surface is destroyed or a thread's context is detached. By
not attempting to hibernate at the end of every EGL call, we avoid
some transient wakeups/hibernate cycles when the app is mostly idle,
or is starting to become active but hasn't created its window
surface yet.
On a Galaxy Nexus, hibernating frees 1567 VM pages from the process.
Both hibernating and waking can take anywhere from 30ms to over 100ms
-- measurements have been very inconsistent.
Change-Id: Ib555f5d9d069aefccca06e8173a89625b5f32d7e
Diffstat (limited to 'opengl/libs/EGL/egl_object.h')
-rw-r--r-- | opengl/libs/EGL/egl_object.h | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/opengl/libs/EGL/egl_object.h b/opengl/libs/EGL/egl_object.h index d1162db..2a08424 100644 --- a/opengl/libs/EGL/egl_object.h +++ b/opengl/libs/EGL/egl_object.h @@ -127,23 +127,14 @@ void egl_object_t::LocalRef<N,T>::terminate() { class egl_surface_t : public egl_object_t { protected: - ~egl_surface_t() { - ANativeWindow* const window = win.get(); - if (window != NULL) { - native_window_set_buffers_format(window, 0); - if (native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL)) { - ALOGW("EGLNativeWindowType %p disconnect failed", window); - } - } - } + ~egl_surface_t(); public: typedef egl_object_t::LocalRef<egl_surface_t, EGLSurface> Ref; egl_surface_t(egl_display_t* dpy, EGLConfig config, EGLNativeWindowType win, EGLSurface surface, - egl_connection_t const* cnx) : - egl_object_t(dpy), surface(surface), config(config), win(win), cnx(cnx) - {} + egl_connection_t const* cnx); + EGLSurface surface; EGLConfig config; sp<ANativeWindow> win; |