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.h b/services/surfaceflinger/DisplayDevice.h
index 4afca58..9bcb6fd 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -39,7 +39,7 @@
 class LayerBase;
 class SurfaceFlinger;
 
-class DisplayDevice
+class DisplayDevice : public virtual RefBase
 {
 public:
     // region in layer-stack space
@@ -59,19 +59,13 @@
         SWAP_RECTANGLE  = 0x00080000,
     };
 
-    DisplayDevice();
-
     DisplayDevice(
             const sp<SurfaceFlinger>& flinger,
             int dpy,
             const sp<ANativeWindow>& surface,
             EGLConfig config);
 
-    ~DisplayDevice();
-
-    // must be called when this object is no longer needed. this will
-    // render the associated EGLSurface invalid.
-    void terminate();
+    virtual ~DisplayDevice();
 
     // whether this is a valid object. An invalid DisplayDevice is returned
     // when an non existing id is requested
@@ -107,7 +101,7 @@
     }
     inline Rect bounds() const { return getBounds(); }
 
-    static void makeCurrent(const DisplayDevice& hw, EGLContext ctx);
+    static void makeCurrent(const sp<const DisplayDevice>& hw, EGLContext ctx);
 
     /* ------------------------------------------------------------------------
      * blank / unplank management