Merge "make sure we have a context when creating the 1st surface" into klp-dev
diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp
index 86637dc..f759e6b 100644
--- a/opengl/libs/EGL/egl.cpp
+++ b/opengl/libs/EGL/egl.cpp
@@ -331,6 +331,11 @@
 
 void gl_unimplemented() {
     ALOGE("called unimplemented OpenGL ES API");
+    char value[PROPERTY_VALUE_MAX];
+    property_get("debug.egl.callstack", value, "0");
+    if (atoi(value)) {
+        CallStack stack(LOG_TAG);
+    }
 }
 
 void gl_noop() {
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index bc10853..4a84e5a 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -487,6 +487,10 @@
         }
     }
 
+    // make the GLContext current so that we can create textures when creating Layers
+    // (which may happens before we render something)
+    getDefaultDisplayDevice()->makeCurrent(mEGLDisplay, mEGLContext);
+
     // start the EventThread
     mEventThread = new EventThread(this);
     mEventQueue.setEventThread(mEventThread);