fix RefBase so it retains binary-compatibility with gingerbread

Bug: 4595257
Change-Id: I0d5e10f497e3f39868bff58f6ded510c38b44b12
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 0137120..2bab6a8 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -69,13 +69,15 @@
     glGenTextures(1, &mTextureName);
 }
 
-void Layer::destroy() const {
-    mFlinger->destroyLayer(this);
+void Layer::destroy(RefBase const* base) {
+    mFlinger->destroyLayer(static_cast<LayerBase const*>(base));
 }
 
 void Layer::onFirstRef()
 {
     LayerBaseClient::onFirstRef();
+    setDestroyer(this);
+
     struct FrameQueuedListener : public SurfaceTexture::FrameAvailableListener {
         FrameQueuedListener(Layer* layer) : mLayer(layer) { }
     private:
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 72e290c..e3fc13d 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -45,7 +45,7 @@
 
 // ---------------------------------------------------------------------------
 
-class Layer : public LayerBaseClient
+class Layer : public LayerBaseClient, private RefBase::Destroyer
 {
 public:
             Layer(SurfaceFlinger* flinger, DisplayID display,
@@ -79,7 +79,7 @@
     inline const sp<FreezeLock>&  getFreezeLock() const { return mFreezeLock; }
 
 protected:
-    virtual void destroy() const;
+    virtual void destroy(RefBase const* base);
     virtual void onFirstRef();
     virtual void dump(String8& result, char* scratch, size_t size) const;