2 * Copyright 2016 Xamarin Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
12 #include "sk_types_priv.h"
14 sk_data_t* sk_data_new_from_file(const char* path) {
15 return ToData(SkData::MakeFromFileName(path).release());
18 sk_data_t* sk_data_new_from_stream(sk_stream_t* stream, size_t length) {
19 return ToData(SkData::MakeFromStream(AsStream(stream), length).release());
22 const uint8_t* sk_data_get_bytes(const sk_data_t* cdata) {
23 return AsData(cdata)->bytes();
26 sk_data_t* sk_data_new_empty() {
27 return ToData(SkData::MakeEmpty().release());
30 sk_data_t* sk_data_new_with_copy(const void* src, size_t length) {
31 return ToData(SkData::MakeWithCopy(src, length).release());
34 sk_data_t* sk_data_new_from_malloc(const void* memory, size_t length) {
35 return ToData(SkData::MakeFromMalloc(memory, length).release());
38 sk_data_t* sk_data_new_subset(const sk_data_t* csrc, size_t offset, size_t length) {
39 return ToData(SkData::MakeSubset(AsData(csrc), offset, length).release());
42 void sk_data_ref(const sk_data_t* cdata) {
43 SkSafeRef(AsData(cdata));
46 void sk_data_unref(const sk_data_t* cdata) {
47 SkSafeUnref(AsData(cdata));
50 size_t sk_data_get_size(const sk_data_t* cdata) {
51 return AsData(cdata)->size();
54 const void* sk_data_get_data(const sk_data_t* cdata) {
55 return AsData(cdata)->data();