Improve picture capture debug path

* Fixes hardware bitmap capture
* Fixes mutable bitmap capture (no flickering)
* Adds basic single-frame LRU cache to avoid
  repeated readbacks of GPU resources
* Does up-front readback of GPU resources
* Moves serialization off RenderThread again thanks
  to up-front readback avoiding needing GPU access
  off-thread
* Reduces RAM usage & improves performance by serializing
  directly to output stream instead of first copying to
  a byte[]

Bug: 174223722
Test: PictureCaptureDemo mirrors the content
Change-Id: If7ec208b61d5b917e82087cc312880fc5a38c943
diff --git a/libs/hwui/jni/Picture.h b/libs/hwui/jni/Picture.h
index 536f651..87ba397 100644
--- a/libs/hwui/jni/Picture.h
+++ b/libs/hwui/jni/Picture.h
@@ -38,6 +38,7 @@
 public:
     explicit Picture(const Picture* src = NULL);
     explicit Picture(sk_sp<SkPicture>&& src);
+    virtual ~Picture() = default;
 
     Canvas* beginRecording(int width, int height);
 
@@ -49,7 +50,7 @@
 
     static Picture* CreateFromStream(SkStream* stream);
 
-    void serialize(SkWStream* stream) const;
+    virtual void serialize(SkWStream* stream) const;
 
     void draw(Canvas* canvas);