Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose more SkPicture and SkDrawable APIs #127

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/c/sk_drawable.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ SK_C_API void sk_drawable_get_bounds (sk_drawable_t*, sk_rect_t*);
SK_C_API void sk_drawable_draw (sk_drawable_t*, sk_canvas_t*, const sk_matrix_t*);
SK_C_API sk_picture_t* sk_drawable_new_picture_snapshot(sk_drawable_t*);
SK_C_API void sk_drawable_notify_drawing_changed (sk_drawable_t*);
SK_C_API size_t sk_drawable_approximate_bytes_used(sk_drawable_t*);

SK_C_PLUS_PLUS_END_GUARD

Expand Down
3 changes: 3 additions & 0 deletions include/c/sk_picture.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ SK_C_API void sk_picture_serialize_to_stream(const sk_picture_t* picture, sk_wst
SK_C_API sk_picture_t* sk_picture_deserialize_from_stream(sk_stream_t* stream);
SK_C_API sk_picture_t* sk_picture_deserialize_from_data(sk_data_t* data);
SK_C_API sk_picture_t* sk_picture_deserialize_from_memory(void* buffer, size_t length);
SK_C_API void sk_picture_playback(const sk_picture_t* picture, sk_canvas_t* canvas);
SK_C_API int sk_picture_approximate_op_count(const sk_picture_t* picture, bool nested);
SK_C_API size_t sk_picture_approximate_bytes_used(const sk_picture_t* picture);

SK_C_PLUS_PLUS_END_GUARD

Expand Down
4 changes: 4 additions & 0 deletions src/c/sk_drawable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ void sk_drawable_notify_drawing_changed(sk_drawable_t* d)
{
AsDrawable(d)->notifyDrawingChanged();
}

size_t sk_drawable_approximate_bytes_used(sk_drawable_t* d) {
return AsDrawable(d)->approximateBytesUsed();
}
12 changes: 12 additions & 0 deletions src/c/sk_picture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,15 @@ sk_picture_t* sk_picture_deserialize_from_data(sk_data_t* data) {
sk_picture_t* sk_picture_deserialize_from_memory(void* buffer, size_t length) {
return ToPicture(SkPicture::MakeFromData(buffer, length).release());
}

void sk_picture_playback(const sk_picture_t* picture, sk_canvas_t* canvas) {
AsPicture(picture)->playback(AsCanvas(canvas));
}

int sk_picture_approximate_op_count(const sk_picture_t* picture, bool nested) {
return AsPicture(picture)->approximateOpCount(nested);
}

size_t sk_picture_approximate_bytes_used(const sk_picture_t* picture) {
return AsPicture(picture)->approximateBytesUsed();
}
Loading