skia 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +12 -0
  3. data/LICENSE +21 -0
  4. data/README.md +205 -0
  5. data/Rakefile +8 -0
  6. data/examples/advanced_features.rb +50 -0
  7. data/examples/avatar_generator.rb +74 -0
  8. data/examples/bar_chart.rb +89 -0
  9. data/examples/basic_drawing.rb +43 -0
  10. data/examples/gradient.rb +32 -0
  11. data/examples/pdf_output.rb +48 -0
  12. data/examples/pdf_stream.rb +23 -0
  13. data/examples/picture_recording.rb +62 -0
  14. data/examples/progress_gauge.rb +103 -0
  15. data/examples/runtime_effect.rb +26 -0
  16. data/examples/social_card.rb +121 -0
  17. data/examples/text_drawing.rb +40 -0
  18. data/lib/skia/base.rb +40 -0
  19. data/lib/skia/bitmap.rb +140 -0
  20. data/lib/skia/canvas.rb +239 -0
  21. data/lib/skia/color.rb +82 -0
  22. data/lib/skia/color_filter.rb +23 -0
  23. data/lib/skia/color_space.rb +44 -0
  24. data/lib/skia/data.rb +47 -0
  25. data/lib/skia/document.rb +222 -0
  26. data/lib/skia/font.rb +118 -0
  27. data/lib/skia/image.rb +216 -0
  28. data/lib/skia/image_filter.rb +29 -0
  29. data/lib/skia/image_info.rb +59 -0
  30. data/lib/skia/mask_filter.rb +26 -0
  31. data/lib/skia/matrix.rb +163 -0
  32. data/lib/skia/native/callbacks.rb +6 -0
  33. data/lib/skia/native/functions.rb +384 -0
  34. data/lib/skia/native/types.rb +400 -0
  35. data/lib/skia/native.rb +67 -0
  36. data/lib/skia/paint.rb +144 -0
  37. data/lib/skia/path.rb +166 -0
  38. data/lib/skia/path_effect.rb +30 -0
  39. data/lib/skia/picture.rb +120 -0
  40. data/lib/skia/pixmap.rb +109 -0
  41. data/lib/skia/point.rb +94 -0
  42. data/lib/skia/rect.rb +179 -0
  43. data/lib/skia/rrect.rb +139 -0
  44. data/lib/skia/runtime_effect.rb +88 -0
  45. data/lib/skia/shader.rb +145 -0
  46. data/lib/skia/surface.rb +272 -0
  47. data/lib/skia/text_blob.rb +47 -0
  48. data/lib/skia/typeface.rb +175 -0
  49. data/lib/skia/version.rb +5 -0
  50. data/lib/skia.rb +42 -0
  51. data/skia-ruby.gemspec +30 -0
  52. metadata +107 -0
@@ -0,0 +1,384 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skia
4
+ module Native
5
+ # Surface
6
+ attach_function :sk_surface_new_null, %i[int32 int32], :sk_surface_t
7
+ attach_function :sk_surface_new_raster, [SKImageInfo.ptr, :size_t, :pointer], :sk_surface_t
8
+ attach_function :sk_surface_new_raster_direct,
9
+ [SKImageInfo.ptr, :pointer, :size_t, :pointer, :pointer, :pointer], :sk_surface_t
10
+ optional_attach_function :sk_surface_new_render_target,
11
+ [:gr_recording_context_t, :bool, SKImageInfo.ptr, :int, :gr_surface_origin_t,
12
+ :sk_surfaceprops_t, :bool], :sk_surface_t
13
+ optional_attach_function :sk_surface_new_backend_render_target,
14
+ [:gr_recording_context_t, :gr_backendrendertarget_t, :gr_surface_origin_t,
15
+ :sk_colortype_t, :sk_colorspace_t, :sk_surfaceprops_t], :sk_surface_t
16
+ optional_attach_function :sk_surface_new_backend_texture,
17
+ [:gr_recording_context_t, :gr_backendtexture_t, :gr_surface_origin_t, :int,
18
+ :sk_colortype_t, :sk_colorspace_t, :sk_surfaceprops_t], :sk_surface_t
19
+ attach_function :sk_surface_unref, [:sk_surface_t], :void
20
+ attach_function :sk_surface_get_canvas, [:sk_surface_t], :sk_canvas_t
21
+ attach_function :sk_surface_new_image_snapshot, [:sk_surface_t], :sk_image_t
22
+ attach_function :sk_surface_new_image_snapshot_with_crop, [:sk_surface_t, SKIRect.ptr], :sk_image_t
23
+ attach_function :sk_surface_peek_pixels, %i[sk_surface_t sk_pixmap_t], :bool
24
+ attach_function :sk_surface_read_pixels,
25
+ [:sk_surface_t, SKImageInfo.ptr, :pointer, :size_t, :int, :int], :bool
26
+ attach_function :sk_surfaceprops_new, %i[uint32 sk_pixel_geometry_t], :sk_surfaceprops_t
27
+ attach_function :sk_surfaceprops_delete, [:sk_surfaceprops_t], :void
28
+
29
+ # Canvas - State
30
+ attach_function :sk_canvas_save, [:sk_canvas_t], :int
31
+ attach_function :sk_canvas_save_layer, [:sk_canvas_t, SKRect.ptr, :sk_paint_t], :int
32
+ attach_function :sk_canvas_restore, [:sk_canvas_t], :void
33
+ attach_function :sk_canvas_restore_to_count, %i[sk_canvas_t int], :void
34
+ attach_function :sk_canvas_get_save_count, [:sk_canvas_t], :int
35
+
36
+ # Canvas - Transform
37
+ attach_function :sk_canvas_translate, %i[sk_canvas_t float float], :void
38
+ attach_function :sk_canvas_scale, %i[sk_canvas_t float float], :void
39
+ attach_function :sk_canvas_rotate_degrees, %i[sk_canvas_t float], :void
40
+ attach_function :sk_canvas_rotate_radians, %i[sk_canvas_t float], :void
41
+ attach_function :sk_canvas_skew, %i[sk_canvas_t float float], :void
42
+ attach_function :sk_canvas_concat, [:sk_canvas_t, SKMatrix44.ptr], :void
43
+ attach_function :sk_canvas_set_matrix, [:sk_canvas_t, SKMatrix44.ptr], :void
44
+ attach_function :sk_canvas_get_matrix, [:sk_canvas_t, SKMatrix44.ptr], :void
45
+ attach_function :sk_canvas_reset_matrix, [:sk_canvas_t], :void
46
+
47
+ # Canvas - Clip
48
+ attach_function :sk_canvas_clip_rect_with_operation,
49
+ [:sk_canvas_t, SKRect.ptr, :sk_clipop_t, :bool], :void
50
+ attach_function :sk_canvas_clip_path_with_operation,
51
+ %i[sk_canvas_t sk_path_t sk_clipop_t bool], :void
52
+ attach_function :sk_canvas_clip_rrect_with_operation,
53
+ %i[sk_canvas_t sk_rrect_t sk_clipop_t bool], :void
54
+ attach_function :sk_canvas_clip_region, %i[sk_canvas_t pointer sk_clipop_t], :void
55
+
56
+ # Canvas - Draw
57
+ attach_function :sk_canvas_draw_paint, %i[sk_canvas_t sk_paint_t], :void
58
+ attach_function :sk_canvas_draw_arc, [:sk_canvas_t, SKRect.ptr, :float, :float, :bool, :sk_paint_t], :void
59
+ attach_function :sk_canvas_draw_rect, [:sk_canvas_t, SKRect.ptr, :sk_paint_t], :void
60
+ attach_function :sk_canvas_draw_rrect, %i[sk_canvas_t sk_rrect_t sk_paint_t], :void
61
+ attach_function :sk_canvas_draw_round_rect,
62
+ [:sk_canvas_t, SKRect.ptr, :float, :float, :sk_paint_t], :void
63
+ attach_function :sk_canvas_draw_circle, %i[sk_canvas_t float float float sk_paint_t], :void
64
+ attach_function :sk_canvas_draw_oval, [:sk_canvas_t, SKRect.ptr, :sk_paint_t], :void
65
+ attach_function :sk_canvas_draw_path, %i[sk_canvas_t sk_path_t sk_paint_t], :void
66
+ attach_function :sk_canvas_draw_picture, [:sk_canvas_t, :sk_picture_t, SKMatrix.ptr, :sk_paint_t], :void
67
+ attach_function :sk_canvas_draw_image, %i[sk_canvas_t sk_image_t float float sk_paint_t], :void
68
+ attach_function :sk_canvas_draw_image_rect,
69
+ [:sk_canvas_t, :sk_image_t, SKRect.ptr, SKRect.ptr, :sk_paint_t], :void
70
+ attach_function :sk_canvas_draw_line, %i[sk_canvas_t float float float float sk_paint_t], :void
71
+ attach_function :sk_canvas_draw_point, %i[sk_canvas_t float float sk_paint_t], :void
72
+ attach_function :sk_canvas_draw_points, [:sk_canvas_t, :sk_point_mode_t, :size_t, :pointer, :sk_paint_t], :void
73
+ attach_function :sk_canvas_draw_simple_text,
74
+ %i[sk_canvas_t pointer size_t sk_text_encoding_t float float sk_font_t sk_paint_t], :void
75
+ attach_function :sk_canvas_draw_text_blob, %i[sk_canvas_t sk_textblob_t float float sk_paint_t], :void
76
+ attach_function :sk_canvas_clear, %i[sk_canvas_t sk_color_t], :void
77
+ attach_function :sk_canvas_draw_color, %i[sk_canvas_t sk_color_t sk_blend_mode_t], :void
78
+
79
+ # Paint
80
+ attach_function :sk_paint_new, [], :sk_paint_t
81
+ attach_function :sk_paint_clone, [:sk_paint_t], :sk_paint_t
82
+ attach_function :sk_paint_delete, [:sk_paint_t], :void
83
+ attach_function :sk_paint_reset, [:sk_paint_t], :void
84
+ attach_function :sk_paint_is_antialias, [:sk_paint_t], :bool
85
+ attach_function :sk_paint_set_antialias, %i[sk_paint_t bool], :void
86
+ attach_function :sk_paint_get_color, [:sk_paint_t], :sk_color_t
87
+ attach_function :sk_paint_set_color, %i[sk_paint_t sk_color_t], :void
88
+ attach_function :sk_paint_get_style, [:sk_paint_t], :sk_paint_style_t
89
+ attach_function :sk_paint_set_style, %i[sk_paint_t sk_paint_style_t], :void
90
+ attach_function :sk_paint_get_stroke_width, [:sk_paint_t], :float
91
+ attach_function :sk_paint_set_stroke_width, %i[sk_paint_t float], :void
92
+ attach_function :sk_paint_get_stroke_miter, [:sk_paint_t], :float
93
+ attach_function :sk_paint_set_stroke_miter, %i[sk_paint_t float], :void
94
+ attach_function :sk_paint_get_stroke_cap, [:sk_paint_t], :sk_stroke_cap_t
95
+ attach_function :sk_paint_set_stroke_cap, %i[sk_paint_t sk_stroke_cap_t], :void
96
+ attach_function :sk_paint_get_stroke_join, [:sk_paint_t], :sk_stroke_join_t
97
+ attach_function :sk_paint_set_stroke_join, %i[sk_paint_t sk_stroke_join_t], :void
98
+ attach_function :sk_paint_get_blendmode, [:sk_paint_t], :sk_blend_mode_t
99
+ attach_function :sk_paint_set_blendmode, %i[sk_paint_t sk_blend_mode_t], :void
100
+ attach_function :sk_paint_get_shader, [:sk_paint_t], :sk_shader_t
101
+ attach_function :sk_paint_set_shader, %i[sk_paint_t sk_shader_t], :void
102
+ attach_function :sk_paint_get_maskfilter, [:sk_paint_t], :sk_mask_filter_t
103
+ attach_function :sk_paint_set_maskfilter, %i[sk_paint_t sk_mask_filter_t], :void
104
+ attach_function :sk_paint_get_colorfilter, [:sk_paint_t], :sk_color_filter_t
105
+ attach_function :sk_paint_set_colorfilter, %i[sk_paint_t sk_color_filter_t], :void
106
+ attach_function :sk_paint_get_imagefilter, [:sk_paint_t], :sk_image_filter_t
107
+ attach_function :sk_paint_set_imagefilter, %i[sk_paint_t sk_image_filter_t], :void
108
+ attach_function :sk_paint_get_path_effect, [:sk_paint_t], :sk_path_effect_t
109
+ attach_function :sk_paint_set_path_effect, %i[sk_paint_t sk_path_effect_t], :void
110
+
111
+ # Path
112
+ attach_function :sk_path_new, [], :sk_path_t
113
+ attach_function :sk_path_clone, [:sk_path_t], :sk_path_t
114
+ attach_function :sk_path_delete, [:sk_path_t], :void
115
+ attach_function :sk_path_reset, [:sk_path_t], :void
116
+ attach_function :sk_path_move_to, %i[sk_path_t float float], :void
117
+ attach_function :sk_path_line_to, %i[sk_path_t float float], :void
118
+ attach_function :sk_path_quad_to, %i[sk_path_t float float float float], :void
119
+ attach_function :sk_path_conic_to, %i[sk_path_t float float float float float], :void
120
+ attach_function :sk_path_cubic_to, %i[sk_path_t float float float float float float], :void
121
+ attach_function :sk_path_arc_to, %i[sk_path_t float float float float float], :void
122
+ attach_function :sk_path_arc_to_with_oval, [:sk_path_t, SKRect.ptr, :float, :float, :bool], :void
123
+ attach_function :sk_path_close, [:sk_path_t], :void
124
+ attach_function :sk_path_add_rect, [:sk_path_t, SKRect.ptr, :sk_path_direction_t], :void
125
+ attach_function :sk_path_add_rrect, %i[sk_path_t sk_rrect_t sk_path_direction_t], :void
126
+ attach_function :sk_path_add_oval, [:sk_path_t, SKRect.ptr, :sk_path_direction_t], :void
127
+ attach_function :sk_path_add_circle, %i[sk_path_t float float float sk_path_direction_t], :void
128
+ attach_function :sk_path_add_arc, [:sk_path_t, SKRect.ptr, :float, :float], :void
129
+ attach_function :sk_path_add_path, %i[sk_path_t sk_path_t int int], :void
130
+ attach_function :sk_path_add_path_offset, %i[sk_path_t sk_path_t float float int], :void
131
+ attach_function :sk_path_add_path_reverse, %i[sk_path_t sk_path_t], :void
132
+ attach_function :sk_path_add_path_matrix, [:sk_path_t, :sk_path_t, SKMatrix.ptr, :int], :void
133
+ attach_function :sk_path_get_filltype, [:sk_path_t], :sk_path_filltype_t
134
+ attach_function :sk_path_set_filltype, %i[sk_path_t sk_path_filltype_t], :void
135
+ attach_function :sk_path_get_bounds, [:sk_path_t, SKRect.ptr], :void
136
+ attach_function :sk_path_contains, %i[sk_path_t float float], :bool
137
+ attach_function :sk_path_transform, [:sk_path_t, SKMatrix.ptr], :void
138
+ attach_function :sk_path_count_points, [:sk_path_t], :int
139
+ attach_function :sk_path_count_verbs, [:sk_path_t], :int
140
+
141
+ # PathMeasure
142
+ attach_function :sk_pathmeasure_new_with_path, [:sk_path_t, :bool, :float], :sk_pathmeasure_t
143
+ attach_function :sk_pathmeasure_get_length, [:sk_pathmeasure_t], :float
144
+ attach_function :sk_pathmeasure_destroy, [:sk_pathmeasure_t], :void
145
+
146
+ # Image
147
+ attach_function :sk_image_ref, [:sk_image_t], :void
148
+ attach_function :sk_image_unref, [:sk_image_t], :void
149
+ attach_function :sk_image_get_width, [:sk_image_t], :int32
150
+ attach_function :sk_image_get_height, [:sk_image_t], :int32
151
+ attach_function :sk_image_get_unique_id, [:sk_image_t], :uint32
152
+ attach_function :sk_image_get_color_type, [:sk_image_t], :sk_colortype_t
153
+ attach_function :sk_image_get_alpha_type, [:sk_image_t], :sk_alphatype_t
154
+ attach_function :sk_image_get_colorspace, [:sk_image_t], :sk_colorspace_t
155
+ attach_function :sk_image_new_from_encoded, [:sk_data_t], :sk_image_t
156
+ attach_function :sk_image_new_from_bitmap, [:sk_bitmap_t], :sk_image_t
157
+ attach_function :sk_image_new_raster, [SKImageInfo.ptr, :pointer, :size_t, :pointer, :pointer], :sk_image_t
158
+ attach_function :sk_image_ref_encoded, [:sk_image_t], :sk_data_t
159
+ attach_function :sk_image_make_shader,
160
+ [:sk_image_t, :sk_shader_tilemode_t, :sk_shader_tilemode_t, SKSamplingOptions.ptr, SKMatrix.ptr], :sk_shader_t
161
+ attach_function :sk_image_make_subset_raster, [:sk_image_t, SKIRect.ptr], :sk_image_t
162
+ attach_function :sk_image_read_pixels,
163
+ [:sk_image_t, SKImageInfo.ptr, :pointer, :size_t, :int, :int, :sk_image_caching_hint_t], :bool
164
+
165
+ # Pixmap
166
+ attach_function :sk_pixmap_new, [], :sk_pixmap_t
167
+ attach_function :sk_pixmap_new_with_params, [SKImageInfo.ptr, :pointer, :size_t], :sk_pixmap_t
168
+ attach_function :sk_pixmap_destructor, [:sk_pixmap_t], :void
169
+ attach_function :sk_pixmap_reset, [:sk_pixmap_t], :void
170
+ attach_function :sk_pixmap_reset_with_params, [:sk_pixmap_t, SKImageInfo.ptr, :pointer, :size_t], :void
171
+ attach_function :sk_pixmap_get_info, [:sk_pixmap_t, SKImageInfo.ptr], :void
172
+ attach_function :sk_pixmap_get_row_bytes, [:sk_pixmap_t], :size_t
173
+ attach_function :sk_pixmap_get_colorspace, [:sk_pixmap_t], :sk_colorspace_t
174
+ attach_function :sk_pixmap_set_colorspace, [:sk_pixmap_t, :sk_colorspace_t], :void
175
+ attach_function :sk_pixmap_get_pixel_color, [:sk_pixmap_t, :int, :int], :sk_color_t
176
+ attach_function :sk_pixmap_get_writable_addr, [:sk_pixmap_t], :pointer
177
+ attach_function :sk_pixmap_get_writeable_addr_with_xy, [:sk_pixmap_t, :int, :int], :pointer
178
+ attach_function :sk_pixmap_read_pixels,
179
+ [:sk_pixmap_t, SKImageInfo.ptr, :pointer, :size_t, :int, :int], :bool
180
+ attach_function :sk_pixmap_extract_subset, [:sk_pixmap_t, :sk_pixmap_t, SKIRect.ptr], :bool
181
+ attach_function :sk_pixmap_compute_is_opaque, [:sk_pixmap_t], :bool
182
+
183
+ # Bitmap
184
+ attach_function :sk_bitmap_new, [], :sk_bitmap_t
185
+ attach_function :sk_bitmap_destructor, [:sk_bitmap_t], :void
186
+ attach_function :sk_bitmap_reset, [:sk_bitmap_t], :void
187
+ attach_function :sk_bitmap_is_null, [:sk_bitmap_t], :bool
188
+ attach_function :sk_bitmap_is_immutable, [:sk_bitmap_t], :bool
189
+ attach_function :sk_bitmap_set_immutable, [:sk_bitmap_t], :void
190
+ attach_function :sk_bitmap_get_info, [:sk_bitmap_t, SKImageInfo.ptr], :void
191
+ attach_function :sk_bitmap_get_row_bytes, [:sk_bitmap_t], :size_t
192
+ attach_function :sk_bitmap_get_byte_count, [:sk_bitmap_t], :size_t
193
+ attach_function :sk_bitmap_get_pixels, [:sk_bitmap_t, :pointer], :pointer
194
+ attach_function :sk_bitmap_set_pixels, [:sk_bitmap_t, :pointer], :void
195
+ attach_function :sk_bitmap_install_pixels, [:sk_bitmap_t, SKImageInfo.ptr, :pointer, :size_t, :pointer, :pointer], :bool
196
+ attach_function :sk_bitmap_try_alloc_pixels, [:sk_bitmap_t, SKImageInfo.ptr, :size_t], :bool
197
+ attach_function :sk_bitmap_try_alloc_pixels_with_flags, [:sk_bitmap_t, SKImageInfo.ptr, :uint32], :bool
198
+ attach_function :sk_bitmap_peek_pixels, [:sk_bitmap_t, :sk_pixmap_t], :bool
199
+ attach_function :sk_bitmap_get_pixel_color, [:sk_bitmap_t, :int, :int], :sk_color_t
200
+ attach_function :sk_bitmap_erase, [:sk_bitmap_t, :sk_color_t], :void
201
+ attach_function :sk_bitmap_erase_rect, [:sk_bitmap_t, :sk_color_t, SKIRect.ptr], :void
202
+ attach_function :sk_bitmap_extract_subset, [:sk_bitmap_t, :sk_bitmap_t, SKIRect.ptr], :bool
203
+ attach_function :sk_bitmap_make_shader,
204
+ [:sk_bitmap_t, :sk_shader_tilemode_t, :sk_shader_tilemode_t, SKSamplingOptions.ptr, SKMatrix.ptr], :sk_shader_t
205
+
206
+ # Image - Pixmap operations
207
+ attach_function :sk_image_peek_pixels, %i[sk_image_t sk_pixmap_t], :bool
208
+
209
+ # Encoders (take sk_pixmap_t, not sk_image_t)
210
+ attach_function :sk_pngencoder_encode, [:pointer, :sk_pixmap_t, SKPngEncoderOptions.ptr], :bool
211
+ attach_function :sk_jpegencoder_encode, [:pointer, :sk_pixmap_t, SKJpegEncoderOptions.ptr], :bool
212
+ attach_function :sk_webpencoder_encode, [:pointer, :sk_pixmap_t, SKWebpEncoderOptions.ptr], :bool
213
+
214
+ # Data
215
+ attach_function :sk_data_new_with_copy, %i[pointer size_t], :sk_data_t
216
+ attach_function :sk_data_new_from_file, [:string], :sk_data_t
217
+ attach_function :sk_data_ref, [:sk_data_t], :void
218
+ attach_function :sk_data_unref, [:sk_data_t], :void
219
+ attach_function :sk_data_get_size, [:sk_data_t], :size_t
220
+ attach_function :sk_data_get_data, [:sk_data_t], :pointer
221
+
222
+ # Stream
223
+ attach_function :sk_dynamicmemorywstream_new, [], :pointer
224
+ attach_function :sk_dynamicmemorywstream_destroy, [:pointer], :void
225
+ attach_function :sk_dynamicmemorywstream_detach_as_data, [:pointer], :sk_data_t
226
+
227
+ # ColorSpace
228
+ attach_function :sk_colorspace_ref, [:sk_colorspace_t], :void
229
+ attach_function :sk_colorspace_unref, [:sk_colorspace_t], :void
230
+ attach_function :sk_colorspace_new_srgb, [], :sk_colorspace_t
231
+ attach_function :sk_colorspace_new_srgb_linear, [], :sk_colorspace_t
232
+ attach_function :sk_colorspace_is_srgb, [:sk_colorspace_t], :bool
233
+ attach_function :sk_colorspace_gamma_is_linear, [:sk_colorspace_t], :bool
234
+ attach_function :sk_colorspace_equals, [:sk_colorspace_t, :sk_colorspace_t], :bool
235
+
236
+ # Typeface
237
+ attach_function :sk_typeface_create_from_name, %i[string pointer], :sk_typeface_t
238
+ attach_function :sk_typeface_create_from_file, %i[string int], :sk_typeface_t
239
+ attach_function :sk_typeface_create_default, [], :sk_typeface_t
240
+ attach_function :sk_typeface_unref, [:sk_typeface_t], :void
241
+
242
+ # FontStyle
243
+ attach_function :sk_fontstyle_new, %i[int int sk_font_style_slant_t], :pointer
244
+ attach_function :sk_fontstyle_delete, [:pointer], :void
245
+
246
+ # Font
247
+ attach_function :sk_font_new, [], :sk_font_t
248
+ attach_function :sk_font_new_with_values, %i[sk_typeface_t float float float], :sk_font_t
249
+ attach_function :sk_font_delete, [:sk_font_t], :void
250
+ attach_function :sk_font_set_typeface, %i[sk_font_t sk_typeface_t], :void
251
+ attach_function :sk_font_get_typeface, [:sk_font_t], :sk_typeface_t
252
+ attach_function :sk_font_set_size, %i[sk_font_t float], :void
253
+ attach_function :sk_font_get_size, [:sk_font_t], :float
254
+ attach_function :sk_font_get_metrics, [:sk_font_t, SKFontMetrics.ptr], :float
255
+ attach_function :sk_font_get_xpos, [:sk_font_t, :pointer, :int, :pointer, :float], :void
256
+ attach_function :sk_font_text_to_glyphs,
257
+ [:sk_font_t, :pointer, :size_t, :sk_text_encoding_t, :pointer, :int], :int
258
+ attach_function :sk_font_measure_text,
259
+ [:sk_font_t, :pointer, :size_t, :sk_text_encoding_t, SKRect.ptr, :sk_paint_t], :float
260
+
261
+ # Shader
262
+ attach_function :sk_shader_unref, [:sk_shader_t], :void
263
+ attach_function :sk_shader_new_linear_gradient,
264
+ [:pointer, :pointer, :pointer, :int, :sk_shader_tilemode_t, SKMatrix.ptr], :sk_shader_t
265
+ attach_function :sk_shader_new_radial_gradient,
266
+ [SKPoint.ptr, :float, :pointer, :pointer, :int, :sk_shader_tilemode_t, SKMatrix.ptr], :sk_shader_t
267
+ attach_function :sk_shader_new_sweep_gradient,
268
+ [SKPoint.ptr, :pointer, :pointer, :int, :sk_shader_tilemode_t, :float, :float, SKMatrix.ptr], :sk_shader_t
269
+ optional_attach_function :sk_shader_new_two_point_conical_gradient,
270
+ [SKPoint.ptr, :float, SKPoint.ptr, :float, :pointer, :pointer, :int,
271
+ :sk_shader_tilemode_t, SKMatrix.ptr], :sk_shader_t
272
+
273
+ # MaskFilter
274
+ attach_function :sk_maskfilter_new_blur, %i[sk_blur_style_t float], :sk_mask_filter_t
275
+ attach_function :sk_maskfilter_new_blur_with_flags, %i[sk_blur_style_t float bool], :sk_mask_filter_t
276
+ attach_function :sk_maskfilter_unref, [:sk_mask_filter_t], :void
277
+
278
+ # ColorFilter
279
+ attach_function :sk_colorfilter_new_mode, %i[sk_color_t sk_blend_mode_t], :sk_color_filter_t
280
+ attach_function :sk_colorfilter_unref, [:sk_color_filter_t], :void
281
+
282
+ # ImageFilter
283
+ attach_function :sk_imagefilter_new_blur,
284
+ [:float, :float, :sk_shader_tilemode_t, :sk_image_filter_t, SKRect.ptr], :sk_image_filter_t
285
+ attach_function :sk_imagefilter_unref, [:sk_image_filter_t], :void
286
+
287
+ # PathEffect
288
+ attach_function :sk_path_effect_create_dash, [:pointer, :int, :float], :sk_path_effect_t
289
+ attach_function :sk_path_effect_unref, [:sk_path_effect_t], :void
290
+
291
+ # Color
292
+ attach_function :sk_colortype_get_default_8888, [], :sk_colortype_t
293
+
294
+ # String
295
+ attach_function :sk_string_destructor, [:sk_string_t], :void
296
+ attach_function :sk_string_get_c_str, [:sk_string_t], :pointer
297
+ attach_function :sk_string_get_size, [:sk_string_t], :size_t
298
+ attach_function :sk_string_new_empty, [], :sk_string_t
299
+ attach_function :sk_string_new_with_copy, [:pointer, :size_t], :sk_string_t
300
+
301
+ # RRect
302
+ attach_function :sk_rrect_new, [], :sk_rrect_t
303
+ attach_function :sk_rrect_new_copy, [:sk_rrect_t], :sk_rrect_t
304
+ attach_function :sk_rrect_delete, [:sk_rrect_t], :void
305
+ attach_function :sk_rrect_set_empty, [:sk_rrect_t], :void
306
+ attach_function :sk_rrect_set_rect, [:sk_rrect_t, SKRect.ptr], :void
307
+ attach_function :sk_rrect_set_rect_xy, [:sk_rrect_t, SKRect.ptr, :float, :float], :void
308
+ attach_function :sk_rrect_set_rect_radii, [:sk_rrect_t, SKRect.ptr, :pointer], :void
309
+ attach_function :sk_rrect_get_rect, [:sk_rrect_t, SKRect.ptr], :void
310
+ attach_function :sk_rrect_get_radii, [:sk_rrect_t, :sk_rrect_corner_t, SKPoint.ptr], :void
311
+ attach_function :sk_rrect_get_type, [:sk_rrect_t], :sk_rrect_type_t
312
+ attach_function :sk_rrect_get_width, [:sk_rrect_t], :float
313
+ attach_function :sk_rrect_get_height, [:sk_rrect_t], :float
314
+ attach_function :sk_rrect_is_valid, [:sk_rrect_t], :bool
315
+ attach_function :sk_rrect_contains, [:sk_rrect_t, SKRect.ptr], :bool
316
+ attach_function :sk_rrect_inset, [:sk_rrect_t, :float, :float], :void
317
+ attach_function :sk_rrect_outset, [:sk_rrect_t, :float, :float], :void
318
+ attach_function :sk_rrect_offset, [:sk_rrect_t, :float, :float], :void
319
+
320
+ # Document (PDF)
321
+ attach_function :sk_document_unref, [:sk_document_t], :void
322
+ attach_function :sk_document_create_pdf_from_stream, [:pointer], :sk_document_t
323
+ optional_attach_function :sk_document_create_pdf_from_stream_with_metadata,
324
+ [:pointer, SKDocumentPdfMetadata.ptr], :sk_document_t
325
+ attach_function :sk_document_begin_page, [:sk_document_t, :float, :float, SKRect.ptr], :sk_canvas_t
326
+ attach_function :sk_document_end_page, [:sk_document_t], :void
327
+ attach_function :sk_document_close, [:sk_document_t], :void
328
+ attach_function :sk_document_abort, [:sk_document_t], :void
329
+
330
+ # FileWStream (for PDF output)
331
+ attach_function :sk_filewstream_new, [:string], :pointer
332
+ attach_function :sk_filewstream_destroy, [:pointer], :void
333
+
334
+ # Picture Recorder
335
+ attach_function :sk_picture_recorder_new, [], :sk_picture_recorder_t
336
+ attach_function :sk_picture_recorder_delete, [:sk_picture_recorder_t], :void
337
+ attach_function :sk_picture_recorder_begin_recording, [:sk_picture_recorder_t, SKRect.ptr], :sk_canvas_t
338
+ attach_function :sk_picture_recorder_end_recording, [:sk_picture_recorder_t], :sk_picture_t
339
+ attach_function :sk_picture_get_recording_canvas, [:sk_picture_recorder_t], :sk_canvas_t
340
+
341
+ # Picture
342
+ attach_function :sk_picture_ref, [:sk_picture_t], :void
343
+ attach_function :sk_picture_unref, [:sk_picture_t], :void
344
+ attach_function :sk_picture_get_unique_id, [:sk_picture_t], :uint32
345
+ attach_function :sk_picture_get_cull_rect, [:sk_picture_t, SKRect.ptr], :void
346
+ attach_function :sk_picture_playback, %i[sk_picture_t sk_canvas_t], :void
347
+ attach_function :sk_picture_serialize_to_data, [:sk_picture_t], :sk_data_t
348
+ attach_function :sk_picture_deserialize_from_data, [:sk_data_t], :sk_picture_t
349
+ attach_function :sk_picture_approximate_op_count, %i[sk_picture_t bool], :int
350
+ attach_function :sk_picture_approximate_bytes_used, [:sk_picture_t], :size_t
351
+
352
+ # TextBlob
353
+ attach_function :sk_textblob_builder_new, [], :sk_textblob_builder_t
354
+ attach_function :sk_textblob_builder_alloc_run_pos_h,
355
+ [:sk_textblob_builder_t, :sk_font_t, :int, :float, SKRect.ptr, SKRunBuffer.ptr], :void
356
+ attach_function :sk_textblob_builder_make, [:sk_textblob_builder_t], :sk_textblob_t
357
+ attach_function :sk_textblob_builder_delete, [:sk_textblob_builder_t], :void
358
+ attach_function :sk_textblob_get_bounds, [:sk_textblob_t, SKRect.ptr], :void
359
+ attach_function :sk_textblob_get_unique_id, [:sk_textblob_t], :uint32
360
+ attach_function :sk_textblob_ref, [:sk_textblob_t], :void
361
+ attach_function :sk_textblob_unref, [:sk_textblob_t], :void
362
+
363
+ # Typeface extras
364
+ attach_function :sk_typeface_get_family_name, [:sk_typeface_t], :sk_string_t
365
+ optional_attach_function :sk_typeface_get_post_script_name, [:sk_typeface_t], :sk_string_t
366
+ attach_function :sk_typeface_get_font_weight, [:sk_typeface_t], :int
367
+ attach_function :sk_typeface_get_font_width, [:sk_typeface_t], :int
368
+ attach_function :sk_typeface_get_font_slant, [:sk_typeface_t], :sk_font_style_slant_t
369
+ attach_function :sk_typeface_is_fixed_pitch, [:sk_typeface_t], :bool
370
+ attach_function :sk_typeface_get_units_per_em, [:sk_typeface_t], :int
371
+ attach_function :sk_typeface_count_glyphs, [:sk_typeface_t], :int
372
+ attach_function :sk_typeface_count_tables, [:sk_typeface_t], :int
373
+ attach_function :sk_typeface_get_table_tags, [:sk_typeface_t, :pointer], :int
374
+ attach_function :sk_typeface_get_table_size, [:sk_typeface_t, :uint32], :size_t
375
+ attach_function :sk_typeface_get_table_data, [:sk_typeface_t, :uint32, :size_t, :size_t, :pointer], :size_t
376
+ attach_function :sk_typeface_copy_table_data, [:sk_typeface_t, :uint32], :sk_data_t
377
+
378
+ # RuntimeEffect
379
+ optional_attach_function :sk_runtimeeffect_make_for_shader, [:sk_string_t, :sk_string_t], :sk_runtimeeffect_t
380
+ optional_attach_function :sk_runtimeeffect_make_shader,
381
+ [:sk_runtimeeffect_t, :sk_data_t, :pointer, :size_t, SKMatrix.ptr], :sk_shader_t
382
+ optional_attach_function :sk_runtimeeffect_unref, [:sk_runtimeeffect_t], :void
383
+ end
384
+ end