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.cpp | |
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.cpp')
-rw-r--r-- | opengl/libs/EGL/egl_object.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/opengl/libs/EGL/egl_object.cpp b/opengl/libs/EGL/egl_object.cpp index b42b268..aaa5e72 100644 --- a/opengl/libs/EGL/egl_object.cpp +++ b/opengl/libs/EGL/egl_object.cpp @@ -63,6 +63,29 @@ bool egl_object_t::get(egl_display_t const* display, egl_object_t* object) { // ---------------------------------------------------------------------------- +egl_surface_t::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) +{ + if (win) { + getDisplay()->onWindowSurfaceCreated(); + } +} + +egl_surface_t::~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); + } + getDisplay()->onWindowSurfaceDestroyed(); + } +} + +// ---------------------------------------------------------------------------- + egl_context_t::egl_context_t(EGLDisplay dpy, EGLContext context, EGLConfig config, egl_connection_t const* cnx, int version) : egl_object_t(get_display_nowake(dpy)), dpy(dpy), context(context), |