From 009e372b71021c6bbe5a05ec96843b2c2d554507 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Fri, 24 Feb 2017 11:02:19 +0200 Subject: [PATCH] Added C API for SkData::MakeWithProc --- include/c/sk_data.h | 2 ++ include/c/sk_types.h | 2 ++ src/c/sk_data.cpp | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/include/c/sk_data.h b/include/c/sk_data.h index 59a7971..95a66ed 100644 --- a/include/c/sk_data.h +++ b/include/c/sk_data.h @@ -79,6 +79,8 @@ SK_C_API sk_data_t* sk_data_new_from_stream(sk_stream_t* stream, size_t length); */ SK_C_API const uint8_t* sk_data_get_bytes(const sk_data_t*); +SK_C_API sk_data_t* sk_data_new_with_proc(const void* ptr, size_t length, sk_data_release_proc proc, void* ctx); + SK_C_PLUS_PLUS_END_GUARD #endif diff --git a/include/c/sk_types.h b/include/c/sk_types.h index a8a8cae..44feeee 100644 --- a/include/c/sk_types.h +++ b/include/c/sk_types.h @@ -726,6 +726,8 @@ typedef enum { typedef void (*sk_bitmap_release_proc)(void* addr, void* context); +typedef void (*sk_data_release_proc)(const void* ptr, void* context); + typedef void (*sk_image_raster_release_proc)(const void* addr, void* context); typedef void (*sk_image_texture_release_proc)(void* context); diff --git a/src/c/sk_data.cpp b/src/c/sk_data.cpp index e6acc69..497a7b1 100644 --- a/src/c/sk_data.cpp +++ b/src/c/sk_data.cpp @@ -39,6 +39,10 @@ sk_data_t* sk_data_new_subset(const sk_data_t* csrc, size_t offset, size_t lengt 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()); +} + void sk_data_ref(const sk_data_t* cdata) { SkSafeRef(AsData(cdata)); } -- 2.7.4