manually register codecs in DM

We'll want to do this when we've got Google3 refactored
to slice out each of these four codecs into its own little target.

Small tweaks to make SkPngCodec match the pattern of the rest.

Should be harmless to have both the compile-time and runtime
registration, right?

Change-Id: Ic72394764ac267758dc1023e85f3d0c4b655d420
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/213872
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 90810a3..5f0cf4f 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -22,6 +22,10 @@
 #include "include/private/SkMutex.h"
 #include "include/private/SkSpinlock.h"
 #include "include/private/SkTHash.h"
+#include "src/codec/SkIcoCodec.h"
+#include "src/codec/SkJpegCodec.h"
+#include "src/codec/SkPngCodec.h"
+#include "src/codec/SkWebpCodec.h"
 #include "src/core/SkColorSpacePriv.h"
 #include "src/core/SkMD5.h"
 #include "src/core/SkOSFile.h"
@@ -1385,6 +1389,11 @@
 #endif
     CommandLineFlags::Parse(argc, argv);
 
+    SkCodec::Register( SkIcoCodec::IsIco ,  SkIcoCodec::MakeFromStream);
+    SkCodec::Register(SkJpegCodec::IsJpeg, SkJpegCodec::MakeFromStream);
+    SkCodec::Register( SkPngCodec::IsPng ,  SkPngCodec::MakeFromStream);
+    SkCodec::Register(SkWebpCodec::IsWebp, SkWebpCodec::MakeFromStream);
+
     initializeEventTracingForTools();
 
 #if !defined(SK_BUILD_FOR_GOOGLE3) && defined(SK_BUILD_FOR_IOS)
diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp
index 4eaa034..c17070c 100644
--- a/src/codec/SkPngCodec.cpp
+++ b/src/codec/SkPngCodec.cpp
@@ -325,7 +325,7 @@
 // Creation
 ///////////////////////////////////////////////////////////////////////////////
 
-bool SkPngCodec::IsPng(const char* buf, size_t bytesRead) {
+bool SkPngCodec::IsPng(const void* buf, size_t bytesRead) {
     return !png_sig_cmp((png_bytep) buf, (png_size_t)0, bytesRead);
 }
 
diff --git a/src/codec/SkPngCodec.h b/src/codec/SkPngCodec.h
index 4233316..7951a89 100644
--- a/src/codec/SkPngCodec.h
+++ b/src/codec/SkPngCodec.h
@@ -19,11 +19,17 @@
 
 class SkPngCodec : public SkCodec {
 public:
-    static bool IsPng(const char*, size_t);
+    static bool IsPng(const void*, size_t);
 
     // Assume IsPng was called and returned true.
-    static std::unique_ptr<SkCodec> MakeFromStream(std::unique_ptr<SkStream>, Result*,
-                                                   SkPngChunkReader* = nullptr);
+    static std::unique_ptr<SkCodec> MakeFromStream(std::unique_ptr<SkStream>,
+                                                   Result*,
+                                                   SkPngChunkReader*);
+
+    static std::unique_ptr<SkCodec> MakeFromStream(std::unique_ptr<SkStream> stream,
+                                                   Result* result) {
+        return MakeFromStream(std::move(stream), result, nullptr);
+    }
 
     // FIXME (scroggo): Temporarily needed by AutoCleanPng.
     void setIdatLength(size_t len) { fIdatLength = len; }