-
-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathsk.rs
More file actions
3819 lines (3324 loc) · 89.8 KB
/
sk.rs
File metadata and controls
3819 lines (3324 loc) · 89.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
use std::convert::TryFrom;
use std::f32::consts::PI;
use std::ffi::{c_void, CStr, CString, NulError};
use std::fmt::{self, Display};
use std::ops::{Deref, DerefMut};
use std::os::raw::c_char;
use std::ptr;
use std::slice;
use std::str::FromStr;
use crate::error::SkError;
use crate::font::{FontStretch, FontStyle};
use crate::image::ImageData;
#[allow(non_camel_case_types)]
pub mod ffi {
use std::ffi::c_void;
use std::os::raw::c_char;
use super::SkiaString;
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_surface {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_w_memory_stream {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_svg_surface {
pub stream: *mut skiac_w_memory_stream,
pub surface: *mut skiac_surface,
pub canvas: *mut skiac_canvas,
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_canvas {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_paint {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_path {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_matrix {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_shader {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_path_effect {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_mask_filter {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_image_filter {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_data {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_image {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_bitmap {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct skiac_bitmap_info {
pub bitmap: *mut skiac_bitmap,
pub width: i32,
pub height: i32,
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_sk_string {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_rect {
pub left: f32,
pub top: f32,
pub right: f32,
pub bottom: f32,
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_transform {
pub a: f32,
pub b: f32,
pub c: f32,
pub d: f32,
pub e: f32,
pub f: f32,
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_point {
pub x: f32,
pub y: f32,
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_surface_data {
pub ptr: *mut u8,
pub size: usize,
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_sk_data {
pub ptr: *mut u8,
pub size: usize,
pub data: *mut skiac_data,
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_typeface {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_resource_provider {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_typeface_font_provider {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Copy, Clone, Default, Debug)]
pub struct skiac_line_metrics {
pub ascent: f32,
pub descent: f32,
pub left: f32,
pub right: f32,
pub width: f32,
pub font_ascent: f32,
pub font_descent: f32,
pub alphabetic_baseline: f32,
pub em_height_ascent: f32,
pub em_height_descent: f32,
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_font_mgr {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct skiac_font_collection {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct skiac_mapped_point {
pub x: f32,
pub y: f32,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct skiac_picture_recorder {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct skiac_picture {
_unused: [u8; 0],
}
pub type SkiacFontCollectionGetFamily =
Option<unsafe extern "C" fn(width: i32, weight: i32, slant: i32, raw_cb: *mut c_void)>;
pub type SkiacResourceProviderLoadImage =
Option<unsafe extern "C" fn(resource_path: *const c_char, on_load_image: *mut c_void)>;
#[allow(clippy::duplicated_attributes)]
// https://github.com/rust-lang/rust/issues/96192
#[link(
name = "svg",
kind = "static",
modifiers = "+bundle,+whole-archive",
cfg(not(target_os = "windows"))
)]
#[link(name = "svg", kind = "static", cfg(target_os = "windows"))]
#[link(
name = "skparagraph",
kind = "static",
modifiers = "+bundle,+whole-archive",
cfg(not(target_os = "windows"))
)]
#[link(name = "skparagraph", kind = "static", cfg(target_os = "windows"))]
#[link(
name = "skunicode_core",
kind = "static",
modifiers = "+bundle,+whole-archive",
cfg(not(target_os = "windows"))
)]
#[link(name = "skunicode_core", kind = "static", cfg(target_os = "windows"))]
#[link(
name = "skunicode_icu",
kind = "static",
modifiers = "+bundle,+whole-archive",
cfg(not(target_os = "windows"))
)]
#[link(name = "skunicode_icu", kind = "static", cfg(target_os = "windows"))]
#[link(
name = "skia",
kind = "static",
modifiers = "+bundle,+whole-archive",
cfg(not(target_os = "windows"))
)]
#[link(name = "skia", kind = "static", cfg(target_os = "windows"))]
#[link(
name = "skiac",
kind = "static",
modifiers = "+bundle,+whole-archive",
cfg(not(target_os = "windows"))
)]
#[link(name = "skiac", kind = "static", cfg(target_os = "windows"))]
extern "C" {
pub fn skiac_clear_all_cache();
pub fn skiac_surface_create_rgba_premultiplied(
width: i32,
height: i32,
cs: u8,
) -> *mut skiac_surface;
pub fn skiac_surface_create_svg(
c_surface: *mut skiac_svg_surface,
width: i32,
height: i32,
alphaType: i32,
flag: u32,
cs: u8,
);
pub fn skiac_surface_create_rgba(width: i32, height: i32, cs: u8) -> *mut skiac_surface;
pub fn skiac_surface_destroy(surface: *mut skiac_surface);
pub fn skiac_surface_copy_rgba(
surface: *mut skiac_surface,
x: u32,
y: u32,
width: u32,
height: u32,
cs: u8,
) -> *mut skiac_surface;
pub fn skiac_surface_save(c_surface: *mut skiac_surface, path: *const c_char) -> bool;
pub fn skiac_surface_get_canvas(surface: *mut skiac_surface) -> *mut skiac_canvas;
pub fn skiac_surface_get_width(surface: *mut skiac_surface) -> i32;
pub fn skiac_surface_get_height(surface: *mut skiac_surface) -> i32;
pub fn skiac_surface_read_pixels(surface: *mut skiac_surface, data: *mut skiac_surface_data);
pub fn skiac_surface_read_pixels_rect(
surface: *mut skiac_surface,
data: *mut u8,
x: i32,
y: i32,
w: i32,
h: i32,
color_space: u8,
) -> bool;
pub fn skiac_surface_png_data(surface: *mut skiac_surface, data: *mut skiac_sk_data);
pub fn skiac_surface_encode_data(
surface: *mut skiac_surface,
data: *mut skiac_sk_data,
format: i32,
quality: i32,
);
pub fn skiac_surface_get_alpha_type(surface: *mut skiac_surface) -> i32;
pub fn skiac_surface_draw_svg(
surface: *mut skiac_surface,
paint: *mut skiac_paint,
width: f32,
height: f32,
flag: u32,
sk_data: *mut skiac_sk_data,
);
pub fn skiac_surface_get_bitmap(surface: *mut skiac_surface, info: *mut skiac_bitmap_info);
// SkCanvas
pub fn skiac_canvas_clear(canvas: *mut skiac_canvas, color: u32);
pub fn skiac_canvas_set_transform(canvas: *mut skiac_canvas, ts: *mut skiac_matrix);
pub fn skiac_canvas_concat(canvas: *mut skiac_canvas, ts: *mut skiac_matrix);
pub fn skiac_canvas_scale(canvas: *mut skiac_canvas, sx: f32, sy: f32);
pub fn skiac_canvas_translate(canvas: *mut skiac_canvas, dx: f32, dy: f32);
pub fn skiac_canvas_rotate(canvas: *mut skiac_canvas, degrees: f32);
pub fn skiac_canvas_get_total_transform(canvas: *mut skiac_canvas) -> skiac_transform;
pub fn skiac_canvas_get_total_transform_matrix(canvas: *mut skiac_canvas) -> *mut skiac_matrix;
pub fn skiac_canvas_draw_color(canvas: *mut skiac_canvas, r: f32, g: f32, b: f32, a: f32);
pub fn skiac_canvas_draw_image(
canvas: *mut skiac_canvas,
bitmap: *mut skiac_bitmap,
sx: f32,
sy: f32,
s_width: f32,
s_height: f32,
dx: f32,
dy: f32,
d_width: f32,
d_height: f32,
enable_smoothing: bool,
filter_quality: i32,
paint: *mut skiac_paint,
);
pub fn skiac_canvas_draw_path(
canvas: *mut skiac_canvas,
path: *mut skiac_path,
paint: *mut skiac_paint,
);
pub fn skiac_canvas_draw_rect(
canvas: *mut skiac_canvas,
x: f32,
y: f32,
w: f32,
h: f32,
paint: *mut skiac_paint,
);
pub fn skiac_canvas_draw_surface(
canvas: *mut skiac_canvas,
surface: *mut skiac_surface,
left: f32,
top: f32,
alpha: u8,
blend_mode: i32,
filter_quality: i32,
);
pub fn skiac_canvas_draw_surface_rect(
canvas: *mut skiac_canvas,
surface: *mut skiac_surface,
sx: f32,
sy: f32,
sw: f32,
sh: f32,
dx: f32,
dy: f32,
dw: f32,
dh: f32,
filter_quality: i32,
);
pub fn skiac_canvas_get_line_metrics_or_draw_text(
text: *const c_char,
text_len: usize,
max_width: f32,
x: f32,
y: f32,
canvas_width: f32,
font_collection: *mut skiac_font_collection,
font_size: f32,
weight: i32,
width: i32,
slant: i32,
font_family: *const c_char,
baseline: i32,
align: i32,
direction: i32,
letter_spacing: f32,
word_spacing: f32,
paint: *mut skiac_paint,
canvas: *mut skiac_canvas,
line_metrics: *mut skiac_line_metrics,
);
pub fn skiac_canvas_reset_transform(canvas: *mut skiac_canvas);
pub fn skiac_canvas_clip_rect(canvas: *mut skiac_canvas, x: f32, y: f32, w: f32, h: f32);
pub fn skiac_canvas_clip_path(canvas: *mut skiac_canvas, path: *mut skiac_path);
pub fn skiac_canvas_save(canvas: *mut skiac_canvas);
pub fn skiac_canvas_restore(canvas: *mut skiac_canvas);
pub fn skiac_canvas_reset(canvas: *mut skiac_canvas);
pub fn skiac_canvas_write_pixels(
canvas: *mut skiac_canvas,
width: i32,
height: i32,
pixels: *const u8,
row_bytes: usize,
x: i32,
y: i32,
);
pub fn skiac_canvas_write_pixels_dirty(
canvas: *mut skiac_canvas,
width: i32,
height: i32,
pixels: *const u8,
row_bytes: usize,
length: usize,
x: f32,
y: f32,
dirty_x: f32,
dirty_y: f32,
dirty_width: f32,
dirty_height: f32,
color_space: u8,
);
pub fn skiac_canvas_draw_picture(
canvas: *mut skiac_canvas,
picture: *mut skiac_picture,
matrix: *mut skiac_matrix,
paint: *mut skiac_paint,
);
pub fn skiac_paint_create() -> *mut skiac_paint;
pub fn skiac_paint_clone(source: *mut skiac_paint) -> *mut skiac_paint;
pub fn skiac_paint_destroy(paint: *mut skiac_paint);
pub fn skiac_paint_set_style(paint: *mut skiac_paint, style: i32);
pub fn skiac_paint_set_color(paint: *mut skiac_paint, r: u8, g: u8, b: u8, a: u8);
pub fn skiac_paint_set_alpha(paint: *mut skiac_paint, a: u8);
pub fn skiac_paint_get_alpha(paint: *mut skiac_paint) -> u8;
pub fn skiac_paint_set_anti_alias(paint: *mut skiac_paint, aa: bool);
pub fn skiac_paint_set_blend_mode(paint: *mut skiac_paint, blend_mode: i32);
pub fn skiac_paint_get_blend_mode(paint: *mut skiac_paint) -> i32;
pub fn skiac_paint_set_shader(paint: *mut skiac_paint, shader: *mut skiac_shader);
pub fn skiac_paint_set_stroke_width(paint: *mut skiac_paint, width: f32);
pub fn skiac_paint_get_stroke_width(paint: *mut skiac_paint) -> f32;
pub fn skiac_paint_set_stroke_cap(paint: *mut skiac_paint, cap: i32);
pub fn skiac_paint_get_stroke_cap(paint: *mut skiac_paint) -> i32;
pub fn skiac_paint_set_stroke_join(paint: *mut skiac_paint, join: u8);
pub fn skiac_paint_get_stroke_join(paint: *mut skiac_paint) -> u8;
pub fn skiac_paint_set_stroke_miter(paint: *mut skiac_paint, miter: f32);
pub fn skiac_paint_get_stroke_miter(paint: *mut skiac_paint) -> f32;
pub fn skiac_paint_set_path_effect(
paint: *mut skiac_paint,
path_effect: *mut skiac_path_effect,
);
pub fn skiac_paint_set_mask_filter(
paint: *mut skiac_paint,
mask_filter: *mut skiac_mask_filter,
);
pub fn skiac_paint_set_image_filter(
paint: *mut skiac_paint,
image_filter: *mut skiac_image_filter,
);
pub fn skiac_path_create() -> *mut skiac_path;
pub fn skiac_path_from_svg(svg_path: *mut std::os::raw::c_char) -> *mut skiac_path;
pub fn skiac_path_clone(path: *mut skiac_path) -> *mut skiac_path;
pub fn skiac_path_swap(path: *mut skiac_path, other: *mut skiac_path);
pub fn skiac_add_path(
c_path: *mut skiac_path,
other_path: *mut skiac_path,
c_matrix: *mut skiac_matrix,
);
pub fn skiac_path_op(c_path_one: *mut skiac_path, c_path_two: *mut skiac_path, op: i32)
-> bool;
pub fn skiac_path_to_svg_string(c_path: *mut skiac_path, skia_string: *mut SkiaString);
pub fn skiac_path_simplify(c_path: *mut skiac_path) -> bool;
pub fn skiac_path_stroke(
c_path: *mut skiac_path,
cap: i32,
join: u8,
width: f32,
miter_limit: f32,
) -> bool;
pub fn skiac_path_get_bounds(path: *mut skiac_path, c_rect: *mut skiac_rect);
pub fn skiac_path_compute_tight_bounds(path: *mut skiac_path, c_rect: *mut skiac_rect);
pub fn skiac_path_trim(
path: *mut skiac_path,
start_t: f32,
stop_t: f32,
is_complement: bool,
) -> bool;
pub fn skiac_path_dash(path: *mut skiac_path, on: f32, off: f32, phase: f32) -> bool;
pub fn skiac_path_equals(path: *mut skiac_path, other: *mut skiac_path) -> bool;
pub fn skiac_path_destroy(path: *mut skiac_path);
pub fn skiac_path_set_fill_type(path: *mut skiac_path, kind: i32);
pub fn skiac_path_get_fill_type(path: *mut skiac_path) -> i32;
pub fn skiac_path_as_winding(path: *mut skiac_path) -> bool;
pub fn skiac_path_arc_to(
path: *mut skiac_path,
left: f32,
top: f32,
right: f32,
bottom: f32,
start_angle: f32,
sweep_angle: f32,
force_move_to: bool,
);
pub fn skiac_path_arc_to_tangent(
path: *mut skiac_path,
x1: f32,
y1: f32,
x2: f32,
y2: f32,
radius: f32,
);
pub fn skiac_path_move_to(path: *mut skiac_path, x: f32, y: f32);
pub fn skiac_path_line_to(path: *mut skiac_path, x: f32, y: f32);
pub fn skiac_path_cubic_to(
path: *mut skiac_path,
x1: f32,
y1: f32,
x2: f32,
y2: f32,
x3: f32,
y3: f32,
);
pub fn skiac_path_quad_to(path: *mut skiac_path, cpx: f32, cpy: f32, x: f32, y: f32);
pub fn skiac_path_close(path: *mut skiac_path);
pub fn skiac_path_add_rect(path: *mut skiac_path, l: f32, t: f32, r: f32, b: f32);
pub fn skiac_path_add_circle(path: *mut skiac_path, x: f32, y: f32, r: f32);
pub fn skiac_path_transform(
path: *mut skiac_path,
matrix: *mut skiac_matrix,
) -> *mut skiac_path;
pub fn skiac_path_transform_self(path: *mut skiac_path, matrix: *mut skiac_matrix);
pub fn skiac_path_is_empty(path: *mut skiac_path) -> bool;
pub fn skiac_path_hit_test(path: *mut skiac_path, x: f32, y: f32, kind: i32) -> bool;
pub fn skiac_path_stroke_hit_test(path: *mut skiac_path, x: f32, y: f32, stroke_w: f32)
-> bool;
pub fn skiac_path_round_rect(
path: *mut skiac_path,
x: f32,
y: f32,
width: f32,
height: f32,
radii: *const f32,
clockwise: bool,
);
pub fn skiac_path_effect_make_dash_path(
intervals: *const f32,
count: i32,
phase: f32,
) -> *mut skiac_path_effect;
pub fn skiac_path_effect_destroy(path_effect: *mut skiac_path_effect);
pub fn skiac_shader_make_linear_gradient(
points: *const skiac_point,
colors: *const super::Color,
positions: *const f32,
count: i32,
tile_mode: i32,
flags: u32,
ts: skiac_transform,
) -> *mut skiac_shader;
pub fn skiac_shader_make_radial_gradient(
start_point: skiac_point,
start_radius: f32,
end_point: skiac_point,
end_radius: f32,
colors: *const super::Color,
positions: *const f32,
count: i32,
tile_mode: i32,
flags: u32,
ts: skiac_transform,
) -> *mut skiac_shader;
pub fn skiac_shader_make_conic_gradient(
cx: f32,
cy: f32,
radius: f32,
colors: *const super::Color,
positions: *const f32,
count: i32,
tile_mode: i32,
flags: u32,
ts: skiac_transform,
) -> *mut skiac_shader;
pub fn skiac_shader_make_from_surface_image(
surface: *mut skiac_surface,
ts: skiac_transform,
filter_quality: i32,
) -> *mut skiac_shader;
pub fn skiac_shader_destroy(shader: *mut skiac_shader);
pub fn skiac_matrix_create() -> *mut skiac_matrix;
pub fn skiac_matrix_new(a: f32, b: f32, c: f32, d: f32, e: f32, f: f32) -> *mut skiac_matrix;
pub fn skiac_matrix_from_ts(ts: *mut skiac_transform) -> *mut skiac_matrix;
pub fn skiac_matrix_concat(
ts: *mut skiac_matrix,
other: *mut skiac_matrix,
) -> *mut skiac_matrix;
pub fn skiac_matrix_multiply(
ts: *mut skiac_matrix,
other: *mut skiac_matrix,
) -> *mut skiac_matrix;
pub fn skiac_matrix_create_rotated(rotation: f32, x: f32, y: f32) -> *mut skiac_matrix;
pub fn skiac_matrix_create_translated(x: f32, y: f32) -> *mut skiac_matrix;
pub fn skiac_matrix_clone(matrix: *mut skiac_matrix) -> *mut skiac_matrix;
pub fn skiac_matrix_map_points_1(
c_matrix: *mut skiac_matrix,
x: f32,
y: f32,
mapped_point: *mut skiac_mapped_point,
);
pub fn skiac_matrix_pre_concat_transform(matrix: *mut skiac_matrix, ts: skiac_transform);
pub fn skiac_matrix_pre_translate(matrix: *mut skiac_matrix, dx: f32, dy: f32);
pub fn skiac_matrix_pre_concat(matrix: *mut skiac_matrix, other: *mut skiac_matrix);
pub fn skiac_matrix_pre_scale(matrix: *mut skiac_matrix, sx: f32, sy: f32);
pub fn skiac_matrix_pre_rotate(matrix: *mut skiac_matrix, degrees: f32);
pub fn skiac_matrix_pre_rotate_x_y(matrix: *mut skiac_matrix, degrees: f32, x: f32, y: f32);
pub fn skiac_matrix_invert(matrix: *mut skiac_matrix, inverse: *mut skiac_matrix) -> bool;
pub fn skiac_matrix_to_transform(matrix: *mut skiac_matrix) -> skiac_transform;
pub fn skiac_matrix_destroy(matrix: *mut skiac_matrix);
pub fn skiac_mask_filter_make_blur(radius: f32) -> *mut skiac_mask_filter;
pub fn skiac_mask_filter_destroy(mask_filter: *mut skiac_mask_filter);
pub fn skiac_image_filter_make_drop_shadow_only(
dx: f32,
dy: f32,
sigma_x: f32,
sigma_y: f32,
color: u32,
chained_filter: *mut skiac_image_filter,
) -> *mut skiac_image_filter;
pub fn skiac_image_filter_make_drop_shadow(
dx: f32,
dy: f32,
sigma_x: f32,
sigma_y: f32,
color: u32,
chained_filter: *mut skiac_image_filter,
) -> *mut skiac_image_filter;
pub fn skiac_image_filter_make_blur(
sigma_x: f32,
sigma_y: f32,
chained_filter: *mut skiac_image_filter,
) -> *mut skiac_image_filter;
pub fn skiac_image_filter_color_filter(
m00: f32,
m01: f32,
m02: f32,
m10: f32,
m11: f32,
m12: f32,
m20: f32,
m21: f32,
m22: f32,
opacity: f32,
chained_filter: *mut skiac_image_filter,
) -> *mut skiac_image_filter;
pub fn skiac_image_filter_from_argb(
table_a: *const u8,
table_r: *const u8,
table_g: *const u8,
table_b: *const u8,
c_image_filter: *mut skiac_image_filter,
) -> *mut skiac_image_filter;
pub fn skiac_image_filter_ref(image_filter: *mut skiac_image_filter);
pub fn skiac_image_filter_destroy(image_filter: *mut skiac_image_filter);
pub fn skiac_sk_data_destroy(c_data: *mut skiac_data);
pub fn skiac_bitmap_make_from_buffer(ptr: *mut u8, size: usize, info: *mut skiac_bitmap_info);
pub fn skiac_bitmap_make_from_svg(
data: *const u8,
size: usize,
width: f32,
height: f32,
info: *mut skiac_bitmap_info,
font_collection: *mut skiac_font_collection,
cs: u8,
) -> bool;
pub fn skiac_bitmap_make_from_image_data(
ptr: *mut u8,
width: usize,
height: usize,
row_bytes: usize,
size: usize,
color_type: i32,
alpha_type: i32,
) -> *mut skiac_bitmap;
pub fn skiac_bitmap_get_width(c_bitmap: *mut skiac_bitmap) -> usize;
pub fn skiac_bitmap_get_height(c_bitmap: *mut skiac_bitmap) -> usize;
pub fn skiac_bitmap_get_shader(
c_bitmap: *mut skiac_bitmap,
repeat_x: i32,
repeat_y: i32,
b: f32,
c: f32,
ts: skiac_transform,
) -> *mut skiac_shader;
pub fn skiac_bitmap_destroy(c_bitmap: *mut skiac_bitmap);
// SkString
pub fn skiac_delete_sk_string(c_sk_string: *mut skiac_sk_string);
// FontCollection
pub fn skiac_font_collection_create() -> *mut skiac_font_collection;
pub fn skiac_font_collection_get_default_fonts_count(
c_font_collection: *mut skiac_font_collection,
) -> u32;
pub fn skiac_font_collection_get_family(
c_font_collection: *mut skiac_font_collection,
i: u32,
skia_string: *mut SkiaString,
on_get_style_rust: *mut c_void,
on_get_style: SkiacFontCollectionGetFamily,
);
pub fn skiac_font_collection_register(
c_font_collection: *mut skiac_font_collection,
font: *const u8,
length: usize,
maybe_name_alias: *const c_char,
) -> usize;
pub fn skiac_font_collection_register_from_path(
c_font_collection: *mut skiac_font_collection,
font_path: *const c_char,
maybe_name_alias: *const c_char,
) -> usize;
pub fn skiac_font_collection_set_alias(
c_font_collection: *mut skiac_font_collection,
family: *const c_char,
alias: *const c_char,
);
pub fn skiac_font_collection_destroy(c_font_collection: *mut skiac_font_collection);
// ResourceProvider
pub fn skiac_resource_provider_create(
on_load_image_rust: *mut c_void,
on_load_image: SkiacResourceProviderLoadImage,
) -> *mut skiac_resource_provider;
// SkDynamicMemoryStream
pub fn skiac_sk_w_stream_get(
c_w_memory_stream: *mut skiac_w_memory_stream,
sk_data: *mut skiac_sk_data,
w: i32,
h: i32,
);
pub fn skiac_sk_w_stream_destroy(c_w_memory_stream: *mut skiac_w_memory_stream);
// SkSVG
pub fn skiac_svg_text_to_path(
data: *const u8,
length: usize,
font_collection: *mut skiac_font_collection,
output_data: *mut skiac_sk_data,
);
// SkPictureRecorder
pub fn skiac_picture_recorder_create() -> *mut skiac_picture_recorder;
pub fn skiac_picture_recorder_begin_recording(
picture_recorder: *mut skiac_picture_recorder,
x: f32,
y: f32,
w: f32,
h: f32,
);
pub fn skiac_picture_recorder_get_recording_canvas(
picture_recorder: *mut skiac_picture_recorder,
) -> *mut skiac_canvas;
pub fn skiac_picture_recorder_finish_recording_as_picture(
picture_recorder: *mut skiac_picture_recorder,
) -> *mut skiac_picture;
}
}
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
#[repr(i32)]
pub enum ColorType {
Unknown,
/// uninitialized
Alpha8,
/// pixel with alpha in 8-bit byte
RGB565,
/// pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
ARGB4444,
/// pixel with 4 bits for alpha, red, green, blue; in 16-bit word
RGBA8888,
/// pixel with 8 bits for red, green, blue, alpha; in 32-bit word
RGB888x,
/// pixel with 8 bits each for red, green, blue; in 32-bit word
BGRA8888,
/// pixel with 8 bits for blue, green, red, alpha; in 32-bit word
RGBA1010102,
/// 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
BGRA1010102,
/// 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
RGB101010x,
/// pixel with 10 bits each for red, green, blue; in 32-bit word
BGR101010x,
/// pixel with 10 bits each for blue, green, red; in 32-bit word
Gray8,
/// pixel with grayscale level in 8-bit byte
RGBAF16Norm,
/// pixel with half floats in [0,1] for red, green, blue, alpha;
// in 64-bit word
RGBAF16,
/// pixel with half floats for red, green, blue, alpha;
// in 64-bit word
RGBAF32,
/// pixel using C float for red, green, blue, alpha; in 128-bit word
/// The following 6 colortypes are just for reading from - not for rendering to
/// pixel with a uint8_t for red and green
R8G8Unorm,
// pixel with a half float for alpha
A16Float,
/// pixel with a half float for red and green
R16G16Float,
// pixel with a little endian uint16_t for alpha
A16Unorm,
// pixel with a little endian uint16_t for red and green
R16G16Unorm,
/// pixel with a little endian uint16_t for red, green, blue and alpha
R16G16B16A16Unorm,
}
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
#[repr(u8)]
pub enum ColorSpace {
Srgb,
DisplayP3,
}
impl Default for ColorSpace {