Add SkCodec, including PNG implementation.

DM:
Add a flag to use SkCodec instead of SkImageDecoder.

SkCodec:
Base class for codecs, allowing creation from an SkStream or an SkData.
An SkCodec, on creation, knows properties of the data like its width and height. Further calls can be used to generate the image.
TODO: Add scanline iterator

SkPngCodec:
New decoder for png. Wraps libpng. The code has been repurposed from SkImageDecoder_libpng.
TODO: Handle other destination colortypes
TODO: Substitute the transpose color
TODO: Allow silencing warnings
TODO: Use RGB instead of filler?
TODO: sRGB

SkSwizzler:
Simplified version of SkScaledSampler. Unlike the sampler, this object does no sampling.
TODO: Implement other swizzles.

Requires a gclient sync to pull down libpng.

BUG=skia:3257

Committed: https://skia.googlesource.com/skia/+/ca358852b4fed656d11107b2aaf28318a4518b49
(and then reverted)

Review URL: https://codereview.chromium.org/930283002
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
new file mode 100644
index 0000000..ec36bc7
--- /dev/null
+++ b/src/codec/SkCodec.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkCodec.h"
+#include "SkData.h"
+#include "SkCodec_libpng.h"
+#include "SkStream.h"
+
+SkCodec* SkCodec::NewFromStream(SkStream* stream) {
+    if (!stream) {
+        return NULL;
+    }
+    SkAutoTDelete<SkStream> streamDeleter(stream);
+    const bool isPng = SkPngCodec::IsPng(stream);
+    // TODO: Avoid rewinding.
+    if (!stream->rewind()) {
+        return NULL;
+    }
+    if (isPng) {
+        streamDeleter.detach();
+        return SkPngCodec::NewFromStream(stream);
+    }
+    // TODO: Check other image types.
+    return NULL;
+}
+
+SkCodec* SkCodec::NewFromData(SkData* data) {
+    if (!data) {
+        return NULL;
+    }
+    return NewFromStream(SkNEW_ARGS(SkMemoryStream, (data)));
+}
+
+SkCodec::SkCodec(const SkImageInfo& info, SkStream* stream)
+    : fInfo(info)
+    , fStream(stream)
+    , fNeedsRewind(false)
+{}
+
+bool SkCodec::rewindIfNeeded() {
+    // Store the value of fNeedsRewind so we can update it. Next read will
+    // require a rewind.
+    const bool neededRewind = fNeedsRewind;
+    fNeedsRewind = true;
+    return !neededRewind || fStream->rewind();
+}