/* * Copyright 2024 Google LLC. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "experimental/rust_png/decoder/SkPngRustDecoder.h" #include #include "experimental/rust_png/decoder/impl/SkPngRustCodec.h" #include "include/core/SkStream.h" namespace SkPngRustDecoder { bool IsPng(const void* buff, size_t bytesRead) { static constexpr unsigned char pngSignature[] = { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A}; if (bytesRead < sizeof(pngSignature)) { return false; } return memcmp(buff, pngSignature, sizeof(pngSignature)) == 0; } std::unique_ptr Decode(std::unique_ptr stream, SkCodec::Result* result, SkCodecs::DecodeContext) { return SkPngRustCodec::MakeFromStream(std::move(stream), result); } } // namespace SkPngRustDecoder