rework screenshot API and implementation

- SurfaceFlinger now supports to take a screenshot
  directly into an IGraphicBufferProducer

- reimplement the IMemoryHeap screenshot on top
  of the above

- reimplement LayerScreenshot such that its
  BufferQueue is directly used as the destination
  of the screenshot. LayerScreenshot is now a thin
  wrapper around Layer

Bug: 6940974

Change-Id: I69a2096b44b91acbb99eba16f83a9c78d94e0d10
diff --git a/services/surfaceflinger/LayerScreenshot.h b/services/surfaceflinger/LayerScreenshot.h
index 38cbd88..a2ae03f 100644
--- a/services/surfaceflinger/LayerScreenshot.h
+++ b/services/surfaceflinger/LayerScreenshot.h
@@ -20,39 +20,18 @@
 #include <stdint.h>
 #include <sys/types.h>
 
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-
-#include "LayerBase.h"
+#include "Layer.h"
 
 // ---------------------------------------------------------------------------
 
 namespace android {
 
-class LayerScreenshot : public LayerBaseClient
+class LayerScreenshot : public Layer
 {
-    GLuint mTextureName;
-    GLfloat mTexCoords[8];
-    sp<SurfaceFlinger> mFlinger;
-    bool mIsSecure;
 public:    
-            LayerScreenshot(SurfaceFlinger* flinger, const sp<Client>& client);
-        virtual ~LayerScreenshot();
-
-        status_t capture();
-
-    virtual void initStates(uint32_t w, uint32_t h, uint32_t flags);
-    virtual uint32_t doTransaction(uint32_t flags);
-    virtual void onDraw(const sp<const DisplayDevice>& hw, const Region& clip) const;
-    virtual bool isOpaque() const         { return false; }
-    virtual bool isSecure() const         { return mIsSecure; }
-    virtual bool isProtectedByApp() const { return false; }
-    virtual bool isProtectedByDRM() const { return false; }
-    virtual const char* getTypeId() const { return "LayerScreenshot"; }
-
-private:
-    status_t captureLocked(int32_t layerStack);
-    void initTexture(GLfloat u, GLfloat v);
+    LayerScreenshot(SurfaceFlinger* flinger, const sp<Client>& client);
+protected:
+    virtual void onFirstRef();
 };
 
 // ---------------------------------------------------------------------------