EGL: Disconnect native window in eglDestroySurface

Bug 27455025

Change-Id: I7549a3acb724e749925a8249feb180088aec7f3c
diff --git a/opengl/libs/EGL/egl_object.h b/opengl/libs/EGL/egl_object.h
index 17a8304..673b7da 100644
--- a/opengl/libs/EGL/egl_object.h
+++ b/opengl/libs/EGL/egl_object.h
@@ -45,6 +45,7 @@
 
 protected:
     virtual ~egl_object_t();
+    virtual void terminate();
 
 public:
     egl_object_t(egl_display_t* display);
@@ -55,7 +56,6 @@
     inline egl_display_t* getDisplay() const { return display; }
 
 private:
-    void terminate();
     static bool get(egl_display_t const* display, egl_object_t* object);
 
 public:
@@ -127,6 +127,7 @@
 class egl_surface_t : public egl_object_t {
 protected:
     ~egl_surface_t();
+    void terminate() override;
 public:
     typedef egl_object_t::LocalRef<egl_surface_t, EGLSurface> Ref;
 
@@ -138,6 +139,9 @@
     EGLConfig config;
     sp<ANativeWindow> win;
     egl_connection_t const* cnx;
+private:
+    bool connected;
+    void disconnect();
 };
 
 class egl_context_t: public egl_object_t {