summaryrefslogtreecommitdiff
path: root/packages/SystemUI/src/com/android/systemui/glwallpaper/EglHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/glwallpaper/EglHelper.java')
-rw-r--r--packages/SystemUI/src/com/android/systemui/glwallpaper/EglHelper.java28
1 files changed, 25 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/glwallpaper/EglHelper.java b/packages/SystemUI/src/com/android/systemui/glwallpaper/EglHelper.java
index d74112608491..aac721e3cb56 100644
--- a/packages/SystemUI/src/com/android/systemui/glwallpaper/EglHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/glwallpaper/EglHelper.java
@@ -146,7 +146,13 @@ public class EglHelper {
* @return true if EglSurface is ready.
*/
public boolean createEglSurface(SurfaceHolder surfaceHolder) {
- mEglSurface = eglCreateWindowSurface(mEglDisplay, mEglConfig, surfaceHolder, null, 0);
+ if (hasEglDisplay()) {
+ mEglSurface = eglCreateWindowSurface(mEglDisplay, mEglConfig, surfaceHolder, null, 0);
+ } else {
+ Log.w(TAG, "mEglDisplay is null");
+ return false;
+ }
+
if (mEglSurface == null || mEglSurface == EGL_NO_SURFACE) {
Log.w(TAG, "createWindowSurface failed: " + GLUtils.getEGLErrorString(eglGetError()));
return false;
@@ -186,7 +192,13 @@ public class EglHelper {
public boolean createEglContext() {
int[] attrib_list = new int[] {EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_LOW_IMG, EGL_NONE};
- mEglContext = eglCreateContext(mEglDisplay, mEglConfig, EGL_NO_CONTEXT, attrib_list, 0);
+ if (hasEglDisplay()) {
+ mEglContext = eglCreateContext(mEglDisplay, mEglConfig, EGL_NO_CONTEXT, attrib_list, 0);
+ } else {
+ Log.w(TAG, "mEglDisplay is null");
+ return false;
+ }
+
if (mEglContext == EGL_NO_CONTEXT) {
Log.w(TAG, "eglCreateContext failed: " + GLUtils.getEGLErrorString(eglGetError()));
return false;
@@ -213,6 +225,14 @@ public class EglHelper {
}
/**
+ * Check if we have EglDisplay.
+ * @return true if EglDisplay is ready.
+ */
+ public boolean hasEglDisplay() {
+ return mEglDisplay != null;
+ }
+
+ /**
* Swap buffer to display.
* @return true if swap successfully.
*/
@@ -235,7 +255,9 @@ public class EglHelper {
if (hasEglContext()) {
destroyEglContext();
}
- eglTerminate(mEglDisplay);
+ if (hasEglDisplay()) {
+ eglTerminate(mEglDisplay);
+ }
mEglReady = false;
}