| /* | |
| * Copyright 2025 Google LLC | |
| * | |
| * Use of this source code is governed by a BSD-style license that can be | |
| * found in the LICENSE file. | |
| */ | |
| #include "include/codec/SkBmpRustDecoder.h" | |
| #include <utility> | |
| #include "include/core/SkData.h" | |
| #include "include/core/SkStream.h" | |
| #include "rust/bmp/FFI.rs.h" | |
| #include "src/codec/SkBmpRustCodec.h" | |
| namespace SkBmpRustDecoder { | |
| bool IsBmp(const void* buff, size_t bytesRead) { | |
| const rust::Slice<const uint8_t> data_slice{ | |
| static_cast<const uint8_t*>(buff), | |
| bytesRead | |
| }; | |
| return rust_bmp::is_bmp_data(data_slice); | |
| } | |
| std::unique_ptr<SkCodec> Decode(std::unique_ptr<SkStream> stream, | |
| SkCodec::Result* result, | |
| SkCodecs::DecodeContext) { | |
| return SkBmpRustCodec::MakeFromStream(std::move(stream), result); | |
| } | |
| std::unique_ptr<SkCodec> Decode(sk_sp<const SkData> data, | |
| SkCodec::Result* result, | |
| SkCodecs::DecodeContext) { | |
| return SkBmpRustCodec::MakeFromData(std::move(data), result); | |
| } | |
| } // namespace SkBmpRustDecoder |