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>
This commit is contained in:
Mike Klein 2019-05-15 11:17:34 -05:00 committed by Skia Commit-Bot
parent bc233135e4
commit 9b2633e294
3 changed files with 19 additions and 4 deletions

View File

@ -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 @@ int main(int argc, char** argv) {
#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)

View File

@ -325,7 +325,7 @@ bool SkPngCodec::createColorTable(const SkImageInfo& dstInfo) {
// 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);
}

View File

@ -19,11 +19,17 @@ class SkStream;
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; }