Implement IO_OUTPUT + SurfaceTexture

Change-Id: Id96fecd6d768196523330c5eda77c4ee86b9bd3c
diff --git a/driver/rsdGL.cpp b/driver/rsdGL.cpp
index e308adb..a935e6f 100644
--- a/driver/rsdGL.cpp
+++ b/driver/rsdGL.cpp
@@ -424,13 +424,11 @@
 }
 
 
-bool rsdGLSetSurface(const Context *rsc, uint32_t w, uint32_t h, RsNativeWindow sur) {
+bool rsdGLSetInternalSurface(const Context *rsc, RsNativeWindow sur) {
     RsdHal *dc = (RsdHal *)rsc->mHal.drv;
 
     EGLBoolean ret;
-    // WAR: Some drivers fail to handle 0 size surfaces correcntly.
-    // Use the pbuffer to avoid this pitfall.
-    if ((dc->gl.egl.surface != NULL) || (w == 0) || (h == 0)) {
+    if (dc->gl.egl.surface != NULL) {
         rsc->setWatchdogGL("eglMakeCurrent", __LINE__, __FILE__);
         ret = eglMakeCurrent(dc->gl.egl.display, dc->gl.egl.surfaceDefault,
                              dc->gl.egl.surfaceDefault, dc->gl.egl.context);
@@ -441,23 +439,19 @@
         checkEglError("eglDestroySurface", ret);
 
         dc->gl.egl.surface = NULL;
-        dc->gl.width = 1;
-        dc->gl.height = 1;
     }
 
-    if (dc->gl.wndSurface != NULL) {
-        dc->gl.wndSurface->decStrong(NULL);
+    if (dc->gl.currentWndSurface != NULL) {
+        dc->gl.currentWndSurface->decStrong(NULL);
     }
 
-    dc->gl.wndSurface = (ANativeWindow *)sur;
-    if (dc->gl.wndSurface != NULL) {
-        dc->gl.wndSurface->incStrong(NULL);
-        dc->gl.width = w;
-        dc->gl.height = h;
+    dc->gl.currentWndSurface = (ANativeWindow *)sur;
+    if (dc->gl.currentWndSurface != NULL) {
+        dc->gl.currentWndSurface->incStrong(NULL);
 
         rsc->setWatchdogGL("eglCreateWindowSurface", __LINE__, __FILE__);
         dc->gl.egl.surface = eglCreateWindowSurface(dc->gl.egl.display, dc->gl.egl.config,
-                                                    dc->gl.wndSurface, NULL);
+                                                    dc->gl.currentWndSurface, NULL);
         checkEglError("eglCreateWindowSurface");
         if (dc->gl.egl.surface == EGL_NO_SURFACE) {
             ALOGE("eglCreateWindowSurface returned EGL_NO_SURFACE");
@@ -472,6 +466,25 @@
     return true;
 }
 
+bool rsdGLSetSurface(const Context *rsc, uint32_t w, uint32_t h, RsNativeWindow sur) {
+    RsdHal *dc = (RsdHal *)rsc->mHal.drv;
+
+    if (dc->gl.wndSurface != NULL) {
+        dc->gl.wndSurface->decStrong(NULL);
+        dc->gl.wndSurface = NULL;
+    }
+    if(w && h) {
+        // WAR: Some drivers fail to handle 0 size surfaces correctly. Use the
+        // pbuffer to avoid this pitfall.
+        dc->gl.wndSurface = (ANativeWindow *)sur;
+        if (dc->gl.wndSurface != NULL) {
+            dc->gl.wndSurface->incStrong(NULL);
+        }
+    }
+
+    return rsdGLSetInternalSurface(rsc, sur);
+}
+
 void rsdGLSwap(const android::renderscript::Context *rsc) {
     RsdHal *dc = (RsdHal *)rsc->mHal.drv;
     RSD_CALL_GL(eglSwapBuffers, dc->gl.egl.display, dc->gl.egl.surface);