GIF: Avoid copying/storing data when possible

If the input SkStream has a length and position, do not copy and store
LZW blocks or ColorMaps. Instead, mark the position and size, and read
from the stream when necessary.

This will save memory in Chromium's use case, which has already
buffered all of its data.

In the case where we *do* need to copy, store it on the SkStreamBuffer.
This allows SkGifImageReader to have simpler code.

Add tests.

Change-Id: Ic65fa766328ae2e5974b2084bc2099e19aced731
Reviewed-on: https://skia-review.googlesource.com/6157
Reviewed-by: Matt Sarett <msarett@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp
index 05859a9..19494b2 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -5,6 +5,7 @@
  * found in the LICENSE file.
  */
 
+#include "FakeStreams.h"
 #include "Resources.h"
 #include "SkAndroidCodec.h"
 #include "SkBitmap.h"
@@ -891,35 +892,6 @@
     const size_t   fLimit;
 };
 
-// Stream that is not an asset stream (!hasPosition() or !hasLength())
-class NotAssetMemStream : public SkStream {
-public:
-    NotAssetMemStream(sk_sp<SkData> data) : fStream(std::move(data)) {}
-
-    bool hasPosition() const override {
-        return false;
-    }
-
-    bool hasLength() const override {
-        return false;
-    }
-
-    size_t peek(void* buf, size_t bytes) const override {
-        return fStream.peek(buf, bytes);
-    }
-    size_t read(void* buf, size_t bytes) override {
-        return fStream.read(buf, bytes);
-    }
-    bool rewind() override {
-        return fStream.rewind();
-    }
-    bool isAtEnd() const override {
-        return fStream.isAtEnd();
-    }
-private:
-    SkMemoryStream fStream;
-};
-
 // Disable RAW tests for Win32.
 #if defined(SK_CODEC_DECODES_RAW) && (!defined(_WIN32))
 // Test that the RawCodec works also for not asset stream. This will test the code path using