Debian Codegraph @

experimental/rust_bmp/decoder/SkBmpRustDecoder.cpp

raw
1 /*
2 * Copyright 2025 Google LLC.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "experimental/rust_bmp/decoder/SkBmpRustDecoder.h"
9
10 #include <utility>
11
12 #include "experimental/rust_bmp/ffi/FFI.rs.h"
13 #include "experimental/rust_bmp/decoder/impl/SkBmpRustCodec.h"
14 #include "include/core/SkData.h"
15 #include "include/core/SkStream.h"
16 #include "src/core/SkStreamPriv.h"
17
18 namespace SkBmpRustDecoder {
19
20 bool IsBmp(const void* buff, size_t bytesRead) {
21 const rust::Slice<const uint8_t> data_slice{
22 static_cast<const uint8_t*>(buff),
23 bytesRead
24 };
25
26 return rust_bmp::is_bmp_data(data_slice);
27 }
28
29 std::unique_ptr<SkCodec> Decode(std::unique_ptr<SkStream> stream,
30 SkCodec::Result* result,
31 SkCodecs::DecodeContext) {
32 return SkBmpRustCodec::MakeFromStream(std::move(stream), result);
33 }
34
35 std::unique_ptr<SkCodec> Decode(sk_sp<const SkData> data,
36 SkCodec::Result* result,
37 SkCodecs::DecodeContext) {
38 return Decode(SkMemoryStream::Make(std::move(data)), result);
39 }
40
41 } // namespace SkBmpRustDecoder