forked from revery-ui/esy-skia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sk_data.cpp
62 lines (47 loc) · 1.66 KB
/
sk_data.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Copyright 2014 Google Inc.
* Copyright 2015 Xamarin Inc.
* Copyright 2017 Microsoft Corporation. All rights reserved.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkData.h"
#include "sk_data.h"
#include "sk_types_priv.h"
sk_data_t* sk_data_new_from_file(const char* path) {
return ToData(SkData::MakeFromFileName(path).release());
}
sk_data_t* sk_data_new_from_stream(sk_stream_t* stream, size_t length) {
return ToData(SkData::MakeFromStream(AsStream(stream), length).release());
}
const uint8_t* sk_data_get_bytes(const sk_data_t* cdata) {
return AsData(cdata)->bytes();
}
sk_data_t* sk_data_new_empty() {
return ToData(SkData::MakeEmpty().release());
}
sk_data_t* sk_data_new_with_copy(const void* src, size_t length) {
return ToData(SkData::MakeWithCopy(src, length).release());
}
sk_data_t* sk_data_new_subset(const sk_data_t* csrc, size_t offset, size_t length) {
return ToData(SkData::MakeSubset(AsData(csrc), offset, length).release());
}
sk_data_t* sk_data_new_with_proc(const void* ptr, size_t length, sk_data_release_proc proc, void* ctx) {
return ToData(SkData::MakeWithProc(ptr, length, proc, ctx).release());
}
sk_data_t* sk_data_new_uninitialized(size_t size) {
return ToData(SkData::MakeUninitialized(size).release());
}
void sk_data_ref(const sk_data_t* cdata) {
SkSafeRef(AsData(cdata));
}
void sk_data_unref(const sk_data_t* cdata) {
SkSafeUnref(AsData(cdata));
}
size_t sk_data_get_size(const sk_data_t* cdata) {
return AsData(cdata)->size();
}
const void* sk_data_get_data(const sk_data_t* cdata) {
return AsData(cdata)->data();
}