2013-08-06 22:31:22 +00:00
|
|
|
/*
|
2011-05-13 23:21:08 +00:00
|
|
|
** Copyright 2007, The Android Open Source Project
|
|
|
|
**
|
2013-08-06 22:31:22 +00:00
|
|
|
** 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
|
2011-05-13 23:21:08 +00:00
|
|
|
**
|
2013-08-06 22:31:22 +00:00
|
|
|
** http://www.apache.org/licenses/LICENSE-2.0
|
2011-05-13 23:21:08 +00:00
|
|
|
**
|
2013-08-06 22:31:22 +00:00
|
|
|
** 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
|
2011-05-13 23:21:08 +00:00
|
|
|
** limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2012-04-04 23:53:42 +00:00
|
|
|
#define __STDC_LIMIT_MACROS 1
|
|
|
|
|
2011-11-14 07:52:47 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2013-04-05 06:17:56 +00:00
|
|
|
#include "../egl_impl.h"
|
|
|
|
|
2011-11-04 00:42:43 +00:00
|
|
|
#include "egl_cache.h"
|
2011-05-13 23:21:08 +00:00
|
|
|
#include "egl_display.h"
|
|
|
|
#include "egl_object.h"
|
|
|
|
#include "egl_tls.h"
|
|
|
|
#include "Loader.h"
|
2012-03-25 07:49:46 +00:00
|
|
|
#include <cutils/properties.h>
|
2011-05-13 23:21:08 +00:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
namespace android {
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2011-11-14 07:52:47 +00:00
|
|
|
static char const * const sVendorString = "Android";
|
|
|
|
static char const * const sVersionString = "1.4 Android META-EGL";
|
2012-05-21 21:01:37 +00:00
|
|
|
static char const * const sClientApiString = "OpenGL_ES";
|
2011-11-14 07:52:47 +00:00
|
|
|
|
2013-08-06 22:31:22 +00:00
|
|
|
extern char const * const gBuiltinExtensionString;
|
2013-03-27 21:30:19 +00:00
|
|
|
extern char const * const gExtensionString;
|
2011-11-14 07:52:47 +00:00
|
|
|
|
2011-05-13 23:21:08 +00:00
|
|
|
extern void initEglTraceLevel();
|
2012-03-09 22:51:28 +00:00
|
|
|
extern void initEglDebugLevel();
|
2011-05-13 23:21:08 +00:00
|
|
|
extern void setGLHooksThreadSpecific(gl_hooks_t const *value);
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2013-08-08 20:40:22 +00:00
|
|
|
static bool findExtension(const char* exts, const char* name, size_t nameLen) {
|
|
|
|
if (exts) {
|
|
|
|
const char* match = strstr(exts, name);
|
|
|
|
if (match && (match[nameLen] == '\0' || match[nameLen] == ' ')) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-13 23:21:08 +00:00
|
|
|
egl_display_t egl_display_t::sDisplay[NUM_DISPLAYS];
|
|
|
|
|
|
|
|
egl_display_t::egl_display_t() :
|
2012-04-17 19:02:26 +00:00
|
|
|
magic('_dpy'), finishOnSwap(false), traceGpuCompletion(false), refs(0) {
|
2011-05-13 23:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
egl_display_t::~egl_display_t() {
|
|
|
|
magic = 0;
|
2011-11-06 22:14:33 +00:00
|
|
|
egl_cache_t::get()->terminate();
|
2011-05-13 23:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
egl_display_t* egl_display_t::get(EGLDisplay dpy) {
|
|
|
|
uintptr_t index = uintptr_t(dpy)-1U;
|
|
|
|
return (index >= NUM_DISPLAYS) ? NULL : &sDisplay[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
void egl_display_t::addObject(egl_object_t* object) {
|
|
|
|
Mutex::Autolock _l(lock);
|
|
|
|
objects.add(object);
|
|
|
|
}
|
|
|
|
|
2011-05-17 01:58:55 +00:00
|
|
|
void egl_display_t::removeObject(egl_object_t* object) {
|
2011-05-13 23:21:08 +00:00
|
|
|
Mutex::Autolock _l(lock);
|
2011-05-17 01:58:55 +00:00
|
|
|
objects.remove(object);
|
2011-05-13 23:21:08 +00:00
|
|
|
}
|
|
|
|
|
2011-11-14 04:50:07 +00:00
|
|
|
bool egl_display_t::getObject(egl_object_t* object) const {
|
2011-05-13 23:21:08 +00:00
|
|
|
Mutex::Autolock _l(lock);
|
2011-05-17 01:58:55 +00:00
|
|
|
if (objects.indexOf(object) >= 0) {
|
2011-11-14 04:50:07 +00:00
|
|
|
if (object->getDisplay() == this) {
|
|
|
|
object->incRef();
|
|
|
|
return true;
|
|
|
|
}
|
2011-05-13 23:21:08 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
EGLDisplay egl_display_t::getFromNativeDisplay(EGLNativeDisplayType disp) {
|
|
|
|
if (uintptr_t(disp) >= NUM_DISPLAYS)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return sDisplay[uintptr_t(disp)].getDisplay(disp);
|
|
|
|
}
|
|
|
|
|
|
|
|
EGLDisplay egl_display_t::getDisplay(EGLNativeDisplayType display) {
|
|
|
|
|
|
|
|
Mutex::Autolock _l(lock);
|
|
|
|
|
|
|
|
// get our driver loader
|
|
|
|
Loader& loader(Loader::getInstance());
|
|
|
|
|
2012-02-14 01:09:30 +00:00
|
|
|
egl_connection_t* const cnx = &gEGLImpl;
|
|
|
|
if (cnx->dso && disp.dpy == EGL_NO_DISPLAY) {
|
|
|
|
EGLDisplay dpy = cnx->egl.eglGetDisplay(display);
|
|
|
|
disp.dpy = dpy;
|
|
|
|
if (dpy == EGL_NO_DISPLAY) {
|
|
|
|
loader.close(cnx->dso);
|
|
|
|
cnx->dso = NULL;
|
2011-05-13 23:21:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return EGLDisplay(uintptr_t(display) + 1U);
|
|
|
|
}
|
|
|
|
|
|
|
|
EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) {
|
|
|
|
|
|
|
|
Mutex::Autolock _l(lock);
|
|
|
|
|
|
|
|
if (refs > 0) {
|
|
|
|
if (major != NULL)
|
|
|
|
*major = VERSION_MAJOR;
|
|
|
|
if (minor != NULL)
|
|
|
|
*minor = VERSION_MINOR;
|
|
|
|
refs++;
|
|
|
|
return EGL_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if EGL_TRACE
|
|
|
|
|
|
|
|
// Called both at early_init time and at this time. (Early_init is pre-zygote, so
|
|
|
|
// the information from that call may be stale.)
|
|
|
|
initEglTraceLevel();
|
2012-03-09 22:51:28 +00:00
|
|
|
initEglDebugLevel();
|
2011-05-13 23:21:08 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
setGLHooksThreadSpecific(&gHooksNoContext);
|
|
|
|
|
|
|
|
// initialize each EGL and
|
|
|
|
// build our own extension string first, based on the extension we know
|
|
|
|
// and the extension supported by our client implementation
|
2012-02-14 01:09:30 +00:00
|
|
|
|
|
|
|
egl_connection_t* const cnx = &gEGLImpl;
|
|
|
|
cnx->major = -1;
|
|
|
|
cnx->minor = -1;
|
|
|
|
if (cnx->dso) {
|
|
|
|
EGLDisplay idpy = disp.dpy;
|
2011-05-13 23:21:08 +00:00
|
|
|
if (cnx->egl.eglInitialize(idpy, &cnx->major, &cnx->minor)) {
|
2012-02-14 01:09:30 +00:00
|
|
|
//ALOGD("initialized dpy=%p, ver=%d.%d, cnx=%p",
|
|
|
|
// idpy, cnx->major, cnx->minor, cnx);
|
2011-05-13 23:21:08 +00:00
|
|
|
|
|
|
|
// display is now initialized
|
2012-02-14 01:09:30 +00:00
|
|
|
disp.state = egl_display_t::INITIALIZED;
|
2011-05-13 23:21:08 +00:00
|
|
|
|
|
|
|
// get the query-strings for this display for each implementation
|
2012-02-14 01:09:30 +00:00
|
|
|
disp.queryString.vendor = cnx->egl.eglQueryString(idpy,
|
2011-05-13 23:21:08 +00:00
|
|
|
EGL_VENDOR);
|
2012-02-14 01:09:30 +00:00
|
|
|
disp.queryString.version = cnx->egl.eglQueryString(idpy,
|
2011-05-13 23:21:08 +00:00
|
|
|
EGL_VERSION);
|
2012-02-14 01:09:30 +00:00
|
|
|
disp.queryString.extensions = cnx->egl.eglQueryString(idpy,
|
2011-05-13 23:21:08 +00:00
|
|
|
EGL_EXTENSIONS);
|
2012-02-14 01:09:30 +00:00
|
|
|
disp.queryString.clientApi = cnx->egl.eglQueryString(idpy,
|
2011-05-13 23:21:08 +00:00
|
|
|
EGL_CLIENT_APIS);
|
|
|
|
|
|
|
|
} else {
|
2012-02-14 01:09:30 +00:00
|
|
|
ALOGW("eglInitialize(%p) failed (%s)", idpy,
|
2011-05-13 23:21:08 +00:00
|
|
|
egl_tls_t::egl_strerror(cnx->egl.eglGetError()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-14 07:52:47 +00:00
|
|
|
// the query strings are per-display
|
|
|
|
mVendorString.setTo(sVendorString);
|
|
|
|
mVersionString.setTo(sVersionString);
|
|
|
|
mClientApiString.setTo(sClientApiString);
|
|
|
|
|
2013-08-06 22:31:22 +00:00
|
|
|
mExtensionString.setTo(gBuiltinExtensionString);
|
2013-03-27 21:30:19 +00:00
|
|
|
char const* start = gExtensionString;
|
2011-11-14 07:52:47 +00:00
|
|
|
char const* end;
|
|
|
|
do {
|
|
|
|
// find the space separating this extension for the next one
|
|
|
|
end = strchr(start, ' ');
|
|
|
|
if (end) {
|
|
|
|
// length of the extension string
|
|
|
|
const size_t len = end - start;
|
2011-11-17 00:49:25 +00:00
|
|
|
if (len) {
|
|
|
|
// NOTE: we could avoid the copy if we had strnstr.
|
|
|
|
const String8 ext(start, len);
|
2013-08-08 20:40:22 +00:00
|
|
|
if (findExtension(disp.queryString.extensions, ext.string(),
|
|
|
|
len)) {
|
|
|
|
mExtensionString.append(start, len+1);
|
2011-11-14 07:52:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// process the next extension string, and skip the space.
|
|
|
|
start = end + 1;
|
|
|
|
}
|
|
|
|
} while (end);
|
|
|
|
|
2011-11-04 00:42:43 +00:00
|
|
|
egl_cache_t::get()->initialize(this);
|
|
|
|
|
2012-03-25 07:49:46 +00:00
|
|
|
char value[PROPERTY_VALUE_MAX];
|
|
|
|
property_get("debug.egl.finish", value, "0");
|
|
|
|
if (atoi(value)) {
|
|
|
|
finishOnSwap = true;
|
|
|
|
}
|
|
|
|
|
2012-04-06 03:34:54 +00:00
|
|
|
property_get("debug.egl.traceGpuCompletion", value, "0");
|
|
|
|
if (atoi(value)) {
|
|
|
|
traceGpuCompletion = true;
|
|
|
|
}
|
|
|
|
|
2012-02-14 04:06:08 +00:00
|
|
|
refs++;
|
|
|
|
if (major != NULL)
|
|
|
|
*major = VERSION_MAJOR;
|
|
|
|
if (minor != NULL)
|
|
|
|
*minor = VERSION_MINOR;
|
2012-04-17 19:02:26 +00:00
|
|
|
|
|
|
|
mHibernation.setDisplayValid(true);
|
|
|
|
|
2012-02-14 04:06:08 +00:00
|
|
|
return EGL_TRUE;
|
2011-05-13 23:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EGLBoolean egl_display_t::terminate() {
|
|
|
|
|
|
|
|
Mutex::Autolock _l(lock);
|
|
|
|
|
|
|
|
if (refs == 0) {
|
2012-06-13 22:21:21 +00:00
|
|
|
/*
|
|
|
|
* From the EGL spec (3.2):
|
|
|
|
* "Termination of a display that has already been terminated,
|
|
|
|
* (...), is allowed, but the only effect of such a call is
|
|
|
|
* to return EGL_TRUE (...)
|
|
|
|
*/
|
|
|
|
return EGL_TRUE;
|
2011-05-13 23:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// this is specific to Android, display termination is ref-counted.
|
|
|
|
if (refs > 1) {
|
|
|
|
refs--;
|
|
|
|
return EGL_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EGLBoolean res = EGL_FALSE;
|
2012-02-14 01:09:30 +00:00
|
|
|
egl_connection_t* const cnx = &gEGLImpl;
|
|
|
|
if (cnx->dso && disp.state == egl_display_t::INITIALIZED) {
|
|
|
|
if (cnx->egl.eglTerminate(disp.dpy) == EGL_FALSE) {
|
|
|
|
ALOGW("eglTerminate(%p) failed (%s)", disp.dpy,
|
|
|
|
egl_tls_t::egl_strerror(cnx->egl.eglGetError()));
|
|
|
|
}
|
|
|
|
// REVISIT: it's unclear what to do if eglTerminate() fails
|
|
|
|
disp.state = egl_display_t::TERMINATED;
|
|
|
|
res = EGL_TRUE;
|
2011-05-13 23:21:08 +00:00
|
|
|
}
|
|
|
|
|
2012-04-17 19:02:26 +00:00
|
|
|
mHibernation.setDisplayValid(false);
|
|
|
|
|
2012-09-16 21:02:20 +00:00
|
|
|
// Reset the extension string since it will be regenerated if we get
|
|
|
|
// reinitialized.
|
|
|
|
mExtensionString.setTo("");
|
|
|
|
|
2011-05-17 01:58:55 +00:00
|
|
|
// Mark all objects remaining in the list as terminated, unless
|
|
|
|
// there are no reference to them, it which case, we're free to
|
|
|
|
// delete them.
|
|
|
|
size_t count = objects.size();
|
2012-01-05 23:22:43 +00:00
|
|
|
ALOGW_IF(count, "eglTerminate() called w/ %d objects remaining", count);
|
2011-05-17 01:58:55 +00:00
|
|
|
for (size_t i=0 ; i<count ; i++) {
|
|
|
|
egl_object_t* o = objects.itemAt(i);
|
|
|
|
o->destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
// this marks all object handles are "terminated"
|
|
|
|
objects.clear();
|
2011-05-13 23:21:08 +00:00
|
|
|
|
|
|
|
refs--;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2012-01-31 02:20:52 +00:00
|
|
|
void egl_display_t::loseCurrent(egl_context_t * cur_c)
|
|
|
|
{
|
|
|
|
if (cur_c) {
|
2012-02-03 23:24:51 +00:00
|
|
|
egl_display_t* display = cur_c->getDisplay();
|
|
|
|
if (display) {
|
|
|
|
display->loseCurrentImpl(cur_c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-01-31 02:20:52 +00:00
|
|
|
|
2012-02-03 23:24:51 +00:00
|
|
|
void egl_display_t::loseCurrentImpl(egl_context_t * cur_c)
|
|
|
|
{
|
|
|
|
// by construction, these are either 0 or valid (possibly terminated)
|
|
|
|
// it should be impossible for these to be invalid
|
|
|
|
ContextRef _cur_c(cur_c);
|
|
|
|
SurfaceRef _cur_r(cur_c ? get_surface(cur_c->read) : NULL);
|
|
|
|
SurfaceRef _cur_d(cur_c ? get_surface(cur_c->draw) : NULL);
|
|
|
|
|
|
|
|
{ // scope for the lock
|
|
|
|
Mutex::Autolock _l(lock);
|
2012-01-31 02:20:52 +00:00
|
|
|
cur_c->onLooseCurrent();
|
|
|
|
|
|
|
|
}
|
2012-02-03 23:24:51 +00:00
|
|
|
|
|
|
|
// This cannot be called with the lock held because it might end-up
|
|
|
|
// calling back into EGL (in particular when a surface is destroyed
|
|
|
|
// it calls ANativeWindow::disconnect
|
|
|
|
_cur_c.release();
|
|
|
|
_cur_r.release();
|
|
|
|
_cur_d.release();
|
2012-01-31 02:20:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EGLBoolean egl_display_t::makeCurrent(egl_context_t* c, egl_context_t* cur_c,
|
|
|
|
EGLSurface draw, EGLSurface read, EGLContext ctx,
|
|
|
|
EGLSurface impl_draw, EGLSurface impl_read, EGLContext impl_ctx)
|
|
|
|
{
|
|
|
|
EGLBoolean result;
|
2012-02-03 23:24:51 +00:00
|
|
|
|
|
|
|
// by construction, these are either 0 or valid (possibly terminated)
|
|
|
|
// it should be impossible for these to be invalid
|
|
|
|
ContextRef _cur_c(cur_c);
|
|
|
|
SurfaceRef _cur_r(cur_c ? get_surface(cur_c->read) : NULL);
|
|
|
|
SurfaceRef _cur_d(cur_c ? get_surface(cur_c->draw) : NULL);
|
|
|
|
|
|
|
|
{ // scope for the lock
|
|
|
|
Mutex::Autolock _l(lock);
|
2012-01-31 02:20:52 +00:00
|
|
|
if (c) {
|
2012-02-03 23:24:51 +00:00
|
|
|
result = c->cnx->egl.eglMakeCurrent(
|
2012-02-14 01:09:30 +00:00
|
|
|
disp.dpy, impl_draw, impl_read, impl_ctx);
|
2012-02-03 23:24:51 +00:00
|
|
|
if (result == EGL_TRUE) {
|
|
|
|
c->onMakeCurrent(draw, read);
|
2012-04-05 22:53:28 +00:00
|
|
|
if (!cur_c) {
|
2012-04-17 19:02:26 +00:00
|
|
|
mHibernation.incWakeCount(HibernationMachine::STRONG);
|
2012-04-05 22:53:28 +00:00
|
|
|
}
|
2012-02-03 23:24:51 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
result = cur_c->cnx->egl.eglMakeCurrent(
|
2012-02-14 01:09:30 +00:00
|
|
|
disp.dpy, impl_draw, impl_read, impl_ctx);
|
2012-02-03 23:24:51 +00:00
|
|
|
if (result == EGL_TRUE) {
|
|
|
|
cur_c->onLooseCurrent();
|
2012-04-17 19:02:26 +00:00
|
|
|
mHibernation.decWakeCount(HibernationMachine::STRONG);
|
2012-02-03 23:24:51 +00:00
|
|
|
}
|
2012-01-31 02:20:52 +00:00
|
|
|
}
|
|
|
|
}
|
2012-02-03 23:24:51 +00:00
|
|
|
|
|
|
|
if (result == EGL_TRUE) {
|
|
|
|
// This cannot be called with the lock held because it might end-up
|
|
|
|
// calling back into EGL (in particular when a surface is destroyed
|
|
|
|
// it calls ANativeWindow::disconnect
|
|
|
|
_cur_c.release();
|
|
|
|
_cur_r.release();
|
|
|
|
_cur_d.release();
|
|
|
|
}
|
|
|
|
|
2012-01-31 02:20:52 +00:00
|
|
|
return result;
|
|
|
|
}
|
2011-05-13 23:21:08 +00:00
|
|
|
|
2013-08-08 20:40:22 +00:00
|
|
|
bool egl_display_t::haveExtension(const char* name, size_t nameLen) const {
|
|
|
|
if (!nameLen) {
|
|
|
|
nameLen = strlen(name);
|
|
|
|
}
|
|
|
|
return findExtension(mExtensionString.string(), name, nameLen);
|
|
|
|
}
|
|
|
|
|
2012-04-17 19:02:26 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool egl_display_t::HibernationMachine::incWakeCount(WakeRefStrength strength) {
|
|
|
|
Mutex::Autolock _l(mLock);
|
2012-04-04 23:53:42 +00:00
|
|
|
ALOGE_IF(mWakeCount < 0 || mWakeCount == INT32_MAX,
|
|
|
|
"Invalid WakeCount (%d) on enter\n", mWakeCount);
|
2012-04-17 19:02:26 +00:00
|
|
|
|
2012-04-04 23:53:42 +00:00
|
|
|
mWakeCount++;
|
2012-04-17 19:02:26 +00:00
|
|
|
if (strength == STRONG)
|
|
|
|
mAttemptHibernation = false;
|
|
|
|
|
2012-04-05 22:53:28 +00:00
|
|
|
if (CC_UNLIKELY(mHibernating)) {
|
|
|
|
ALOGV("Awakening\n");
|
|
|
|
egl_connection_t* const cnx = &gEGLImpl;
|
2012-04-17 19:02:26 +00:00
|
|
|
|
|
|
|
// These conditions should be guaranteed before entering hibernation;
|
|
|
|
// we don't want to get into a state where we can't wake up.
|
|
|
|
ALOGD_IF(!mDpyValid || !cnx->egl.eglAwakenProcessIMG,
|
|
|
|
"Invalid hibernation state, unable to awaken\n");
|
|
|
|
|
2012-04-05 22:53:28 +00:00
|
|
|
if (!cnx->egl.eglAwakenProcessIMG()) {
|
|
|
|
ALOGE("Failed to awaken EGL implementation\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mHibernating = false;
|
|
|
|
}
|
2012-04-04 23:53:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-04-17 19:02:26 +00:00
|
|
|
void egl_display_t::HibernationMachine::decWakeCount(WakeRefStrength strength) {
|
|
|
|
Mutex::Autolock _l(mLock);
|
2012-04-04 23:53:42 +00:00
|
|
|
ALOGE_IF(mWakeCount <= 0, "Invalid WakeCount (%d) on leave\n", mWakeCount);
|
2012-04-17 19:02:26 +00:00
|
|
|
|
|
|
|
mWakeCount--;
|
|
|
|
if (strength == STRONG)
|
|
|
|
mAttemptHibernation = true;
|
|
|
|
|
|
|
|
if (mWakeCount == 0 && CC_UNLIKELY(mAttemptHibernation)) {
|
2012-04-05 22:53:28 +00:00
|
|
|
egl_connection_t* const cnx = &gEGLImpl;
|
|
|
|
mAttemptHibernation = false;
|
2012-05-04 21:52:40 +00:00
|
|
|
if (mAllowHibernation && mDpyValid &&
|
2012-04-17 19:02:26 +00:00
|
|
|
cnx->egl.eglHibernateProcessIMG &&
|
|
|
|
cnx->egl.eglAwakenProcessIMG) {
|
2012-04-05 22:53:28 +00:00
|
|
|
ALOGV("Hibernating\n");
|
|
|
|
if (!cnx->egl.eglHibernateProcessIMG()) {
|
|
|
|
ALOGE("Failed to hibernate EGL implementation\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mHibernating = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-17 19:02:26 +00:00
|
|
|
void egl_display_t::HibernationMachine::setDisplayValid(bool valid) {
|
|
|
|
Mutex::Autolock _l(mLock);
|
|
|
|
mDpyValid = valid;
|
2012-04-04 23:53:42 +00:00
|
|
|
}
|
|
|
|
|
2011-05-13 23:21:08 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
}; // namespace android
|
|
|
|
// ----------------------------------------------------------------------------
|