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

Add R-Tree overload of beginRecording #129

Merged
merged 3 commits into from
Jun 5, 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
10 changes: 10 additions & 0 deletions include/c/sk_picture.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@

SK_C_PLUS_PLUS_BEGIN_GUARD

// SkPictureRecorder

SK_C_API sk_picture_recorder_t* sk_picture_recorder_new(void);
SK_C_API void sk_picture_recorder_delete(sk_picture_recorder_t*);
SK_C_API sk_canvas_t* sk_picture_recorder_begin_recording(sk_picture_recorder_t*, const sk_rect_t*);
SK_C_API sk_canvas_t* sk_picture_recorder_begin_recording_with_bbh_factory(sk_picture_recorder_t*, const sk_rect_t*, sk_bbh_factory_t*);
SK_C_API sk_picture_t* sk_picture_recorder_end_recording(sk_picture_recorder_t*);
SK_C_API sk_drawable_t* sk_picture_recorder_end_recording_as_drawable(sk_picture_recorder_t*);
SK_C_API sk_canvas_t* sk_picture_get_recording_canvas(sk_picture_recorder_t* crec);

// SkPicture

SK_C_API void sk_picture_ref(sk_picture_t*);
SK_C_API void sk_picture_unref(sk_picture_t*);
SK_C_API uint32_t sk_picture_get_unique_id(sk_picture_t*);
Expand All @@ -35,6 +40,11 @@ SK_C_API void sk_picture_playback(const sk_picture_t* picture, sk_canvas_t* canv
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);

// SkRTreeFactory

SK_C_API sk_rtree_factory_t* sk_rtree_factory_new(void);
SK_C_API void sk_rtree_factory_delete(sk_rtree_factory_t*);

SK_C_PLUS_PLUS_END_GUARD

#endif
13 changes: 13 additions & 0 deletions include/c/sk_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,19 @@ typedef struct sk_picture_t sk_picture_t;
to create a sk_picture_t.
*/
typedef struct sk_picture_recorder_t sk_picture_recorder_t;
/**
A sk_bbh_factory_t generates an sk_bbox_hierarchy as a display optimization
for culling invisible calls recorded by a sk_picture_recorder. It may
be passed in to sk_picture_recorder_begin_recording_with_bbh_factory,
typically as an instance of the subclass sk_rtree_factory_t.
*/
typedef struct sk_bbh_factory_t sk_bbh_factory_t;
/**
A sk_rtree_factory_t generates a sk_rtree as a display optimization
for culling invisible calls recorded by a sk_picture_recorder_t. Inherits
from sk_bbh_factory_t.
*/
typedef struct sk_rtree_factory_t sk_rtree_factory_t;
/**
A sk_shader_t specifies the source color(s) for what is being drawn. If a
paint has no shader, then the paint's color is used. If the paint
Expand Down
18 changes: 18 additions & 0 deletions src/c/sk_picture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include "src/c/sk_types_priv.h"

// SkPictureRecorder

sk_picture_recorder_t* sk_picture_recorder_new(void) {
return ToPictureRecorder(new SkPictureRecorder);
}
Expand All @@ -28,6 +30,10 @@ sk_canvas_t* sk_picture_recorder_begin_recording(sk_picture_recorder_t* crec, co
return ToCanvas(AsPictureRecorder(crec)->beginRecording(*AsRect(cbounds)));
}

sk_canvas_t* sk_picture_recorder_begin_recording_with_bbh_factory(sk_picture_recorder_t* crec, const sk_rect_t* cbounds, sk_bbh_factory_t* factory) {
return ToCanvas(AsPictureRecorder(crec)->beginRecording(*AsRect(cbounds), AsBBHFactory(factory)));
}

sk_picture_t* sk_picture_recorder_end_recording(sk_picture_recorder_t* crec) {
return ToPicture(AsPictureRecorder(crec)->finishRecordingAsPicture().release());
}
Expand All @@ -40,6 +46,8 @@ sk_canvas_t* sk_picture_get_recording_canvas(sk_picture_recorder_t* crec) {
return ToCanvas(AsPictureRecorder(crec)->getRecordingCanvas());
}

// SkPicture

void sk_picture_ref(sk_picture_t* cpic) {
SkSafeRef(AsPicture(cpic));
}
Expand Down Expand Up @@ -95,3 +103,13 @@ int sk_picture_approximate_op_count(const sk_picture_t* picture, bool nested) {
size_t sk_picture_approximate_bytes_used(const sk_picture_t* picture) {
return AsPicture(picture)->approximateBytesUsed();
}

// SkRTreeFactory

sk_rtree_factory_t* sk_rtree_factory_new(void) {
return ToRTreeFactory(new SkRTreeFactory);
}

void sk_rtree_factory_delete(sk_rtree_factory_t* factory) {
delete AsRTreeFactory(factory);
}
2 changes: 2 additions & 0 deletions src/c/sk_types_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
#define DEF_MAP_WITH_NS(Ns, SkType, sk_type, Name) \
DEF_MAP_DECL(SkType, sk_type, Name, , Ns)

DEF_CLASS_MAP(SkBBHFactory, sk_bbh_factory_t, BBHFactory)
DEF_CLASS_MAP(SkBitmap, sk_bitmap_t, Bitmap)
DEF_CLASS_MAP(SkCanvas, sk_canvas_t, Canvas)
DEF_CLASS_MAP(SkCodec, sk_codec_t, Codec)
Expand Down Expand Up @@ -131,6 +132,7 @@ DEF_CLASS_MAP(SkPictureRecorder, sk_picture_recorder_t, PictureRecorder)
DEF_CLASS_MAP(SkPixmap, sk_pixmap_t, Pixmap)
DEF_CLASS_MAP(SkRegion, sk_region_t, Region)
DEF_CLASS_MAP(SkRRect, sk_rrect_t, RRect)
DEF_CLASS_MAP(SkRTreeFactory, sk_rtree_factory_t, RTreeFactory)
DEF_CLASS_MAP(SkRuntimeEffect, sk_runtimeeffect_t, RuntimeEffect)
DEF_CLASS_MAP(SkShader, sk_shader_t, Shader)
DEF_CLASS_MAP(SkStream, sk_stream_t, Stream)
Expand Down
Loading