Skip to content

Commit

Permalink
Expose more SkPicture and SkDrawable APIs (#127)
Browse files Browse the repository at this point in the history
* Add more SkPicture APIs to the C API

* Drawable things
  • Loading branch information
mattleibow authored Jun 3, 2024
1 parent dd03dd1 commit 2bb9dd9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
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();
}

0 comments on commit 2bb9dd9

Please sign in to comment.