turn DisplayDevice into a reference-counted object

it's safer this way because this object owns an
EGLSurface which cannot be easily reference-counted.

it also gives us the ability to sub-class it, which
we might want to do soon.

Change-Id: I07358bb052dc5a13b4f2196b2c2b6e6e94c4bb4f
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index 822b2b5..175f808 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -97,14 +97,6 @@
  *
  */
 
-DisplayDevice::DisplayDevice()
-    : mId(0),
-      mDisplay(EGL_NO_DISPLAY),
-      mSurface(EGL_NO_SURFACE),
-      mContext(EGL_NO_CONTEXT)
-{
-}
-
 DisplayDevice::DisplayDevice(
         const sp<SurfaceFlinger>& flinger,
         int display,
@@ -130,12 +122,6 @@
 }
 
 DisplayDevice::~DisplayDevice() {
-    // DO NOT call terminate() from here, because we create
-    // temporaries of this class (on the stack typically), and we don't
-    // want to destroy the EGLSurface in that case
-}
-
-void DisplayDevice::terminate() {
     if (mSurface != EGL_NO_SURFACE) {
         eglDestroySurface(mDisplay, mSurface);
         mSurface = EGL_NO_SURFACE;
@@ -297,11 +283,11 @@
     }
 }
 
-void DisplayDevice::makeCurrent(const DisplayDevice& hw, EGLContext ctx) {
+void DisplayDevice::makeCurrent(const sp<const DisplayDevice>& hw, EGLContext ctx) {
     EGLSurface sur = eglGetCurrentSurface(EGL_DRAW);
-    if (sur != hw.mSurface) {
+    if (sur != hw->mSurface) {
         EGLDisplay dpy = eglGetCurrentDisplay();
-        eglMakeCurrent(dpy, hw.mSurface, hw.mSurface, ctx);
+        eglMakeCurrent(dpy, hw->mSurface, hw->mSurface, ctx);
     }
 }