diff options
author | Jesse Hall <jessehall@google.com> | 2012-05-08 12:00:20 -0700 |
---|---|---|
committer | Jesse Hall <jessehall@google.com> | 2012-06-05 12:20:56 -0700 |
commit | 23a322d55622b2045eaeb94ebcf5b26e8ef51369 (patch) | |
tree | 90bc265ccf9005b009fcb252a8a8766d2c05cd28 | |
parent | d812e574932a0ed386165532868a6854e8c1b331 (diff) | |
download | external_qemu-23a322d55622b2045eaeb94ebcf5b26e8ef51369.zip external_qemu-23a322d55622b2045eaeb94ebcf5b26e8ef51369.tar.gz external_qemu-23a322d55622b2045eaeb94ebcf5b26e8ef51369.tar.bz2 |
Track started and initialized states separately
Several OpenGL ES renderer functions are called blindly by the
emulator and are supposed to do nothing if the renderer isn't running.
They were checking whether the libraries were loaded instead of
whether the renderer was started. This causes problems when the
renderer is started and then stopped (for stats collection) since the
libraries aren't unloaded.
Change-Id: Ia6c0d2e5b618ff982b55caf35c38bda9aad30ee1
-rw-r--r-- | android/opengles.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/android/opengles.c b/android/opengles.c index f56252c..7405750 100644 --- a/android/opengles.c +++ b/android/opengles.c @@ -60,6 +60,7 @@ extern int android_init_opengles_pipes(void); #endif static ADynamicLibrary* rendererLib; +static int rendererStarted; /* Define the function pointers */ #define DYNLINK_FUNC(name) \ @@ -147,10 +148,16 @@ android_startOpenglesRenderer(int width, int height) return -1; } + if (rendererStarted) { + return 0; + } + if (!initOpenGLRenderer(width, height, ANDROID_OPENGLES_BASE_PORT)) { D("Can't start OpenGLES renderer?"); return -1; } + + rendererStarted = 1; return 0; } @@ -199,6 +206,15 @@ android_getOpenglesHardwareStrings(char* vendor, size_t vendorBufSize, { const char *vendorSrc, *rendererSrc, *versionSrc; + assert(vendorBufSize > 0 && rendererBufSize > 0 && versionBufSize > 0); + assert(vendor != NULL && renderer != NULL && version != NULL); + + if (!rendererStarted) { + D("Can't get OpenGL ES hardware strings when renderer not started"); + vendor[0] = renderer[0] = version = '\0'; + return; + } + getHardwareStrings(&vendorSrc, &rendererSrc, &versionSrc); if (!vendorSrc) vendorSrc = ""; if (!rendererSrc) rendererSrc = ""; @@ -221,15 +237,16 @@ android_getOpenglesHardwareStrings(char* vendor, size_t vendorBufSize, void android_stopOpenglesRenderer(void) { - if (rendererLib) { + if (rendererStarted) { stopOpenGLRenderer(); + rendererStarted = 0; } } int android_showOpenglesWindow(void* window, int x, int y, int width, int height, float rotation) { - if (rendererLib) { + if (rendererStarted) { int success = createOpenGLSubwindow((FBNativeWindowType)window, x, y, width, height, rotation); return success ? 0 : -1; } else { @@ -240,7 +257,7 @@ android_showOpenglesWindow(void* window, int x, int y, int width, int height, fl int android_hideOpenglesWindow(void) { - if (rendererLib) { + if (rendererStarted) { int success = destroyOpenGLSubwindow(); return success ? 0 : -1; } else { @@ -251,7 +268,7 @@ android_hideOpenglesWindow(void) void android_redrawOpenglesWindow(void) { - if (rendererLib) { + if (rendererStarted) { repaintOpenGLDisplay(); } } |