forked from rust-skia/rust-skia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbindings.cpp
3216 lines (2513 loc) · 99.5 KB
/
bindings.cpp
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
#include <cassert>
#include <tuple>
#include <vector>
#include <memory>
#include "bindings.h"
// codec/
#include "include/codec/SkEncodedOrigin.h"
#include "include/codec/SkCodec.h"
#include "include/codec/SkCodecAnimation.h"
#include "include/codec/SkEncodedImageFormat.h"
#include "include/codec/SkPixmapUtils.h"
#include "include/codec/SkBmpDecoder.h"
#include "include/codec/SkGifDecoder.h"
#include "include/codec/SkIcoDecoder.h"
#include "include/codec/SkJpegDecoder.h"
#include "include/codec/SkPngDecoder.h"
#include "include/codec/SkWbmpDecoder.h"
#if defined(SK_CODEC_DECODES_WEBP)
#include "include/codec/SkWebpDecoder.h"
#endif
// core/
#include "include/core/SkAnnotation.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkBlurTypes.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkColorFilter.h"
#include "include/core/SkColorTable.h"
#include "include/core/SkContourMeasure.h"
#include "include/core/SkCoverageMode.h"
#include "include/core/SkCubicMap.h"
#include "include/core/SkDataTable.h"
#include "include/core/SkDrawable.h"
#include "include/core/SkDocument.h"
#include "include/core/SkFlattenable.h"
#include "include/core/SkFont.h"
#include "include/core/SkFontArguments.h"
#include "include/core/SkFontMetrics.h"
#include "include/core/SkFontMgr.h"
#include "include/core/SkGraphics.h"
#include "include/core/SkImage.h"
#include "include/core/SkImageFilter.h"
#include "include/core/SkImageGenerator.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkM44.h"
#include "include/core/SkMaskFilter.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPath.h"
#include "include/core/SkPathBuilder.h"
#include "include/core/SkPathMeasure.h"
#include "include/core/SkPathTypes.h"
#include "include/core/SkPathUtils.h"
#include "include/core/SkPicture.h"
#include "include/core/SkPictureRecorder.h"
#include "include/core/SkPixelRef.h"
#include "include/core/SkPoint.h"
#include "include/core/SkPoint3.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkRegion.h"
#include "include/core/SkRRect.h"
#include "include/core/SkRSXform.h"
#include "include/core/SkStream.h"
#include "include/core/SkStrokeRec.h"
#include "include/core/SkSurface.h"
#include "include/core/SkSwizzle.h"
#include "include/core/SkTextBlob.h"
#include "include/core/SkTextureCompressionType.h"
#include "include/core/SkTiledImageUtils.h"
#include "include/core/SkTypeface.h"
#include "include/core/SkTypes.h"
#include "include/core/SkVertices.h"
// docs/
#include "include/docs/SkPDFDocument.h"
// effects/
#include "include/effects/Sk1DPathEffect.h"
#include "include/effects/Sk2DPathEffect.h"
#include "include/effects/SkBlenders.h"
#include "include/effects/SkColorMatrix.h"
#include "include/effects/SkColorMatrixFilter.h"
#include "include/effects/SkCornerPathEffect.h"
#include "include/effects/SkDashPathEffect.h"
#include "include/effects/SkDiscretePathEffect.h"
#include "include/effects/SkGradientShader.h"
#include "include/effects/SkHighContrastFilter.h"
#include "include/effects/SkImageFilters.h"
#include "include/effects/SkLumaColorFilter.h"
#include "include/effects/SkOverdrawColorFilter.h"
#include "include/effects/SkRuntimeEffect.h"
#include "include/effects/SkPerlinNoiseShader.h"
#include "include/effects/SkShaderMaskFilter.h"
#include "include/effects/SkTableMaskFilter.h"
#include "include/effects/SkTrimPathEffect.h"
// encode/
#include "include/encode/SkPngEncoder.h"
#include "include/encode/SkJpegEncoder.h"
// pathops/
#include "include/pathops/SkPathOps.h"
// svg/
#include "include/svg/SkSVGCanvas.h"
// utils/
#include "include/utils/SkCamera.h"
#include "include/utils/SkCustomTypeface.h"
#include "include/utils/SkNullCanvas.h"
#include "include/utils/SkOrderedFontMgr.h"
#include "include/utils/SkParsePath.h"
#include "include/utils/SkShadowUtils.h"
#include "include/utils/SkTextUtils.h"
extern "C" void C_Bindings_Types(Sink<bool>) {}
//
// codec/SkCodec.h
//
extern "C" SkCodec* C_SkCodec_MakeFromStream(SkStream* stream, const SkCodecs::Decoder* decoders, size_t decodersCount, SkCodec::Result* result, SkCodec::SelectionPolicy selectionPolicy) {
return SkCodec::MakeFromStream(std::unique_ptr<SkStream>(stream), SkSpan(decoders, decodersCount), result, nullptr, selectionPolicy).release();
}
extern "C" SkCodec* C_SkCodec_MakeFromData(SkData* data) {
return SkCodec::MakeFromData(sp(data)).release();
}
extern "C" SkCodec* C_SkCodec_MakeFromData2(SkData* data, const SkCodecs::Decoder* decoders, size_t decodersCount) {
return SkCodec::MakeFromData(sp(data), SkSpan(decoders, decodersCount)).release();
}
extern "C" void C_SkCodec_delete(SkCodec* self) {
delete self;
}
extern "C" void C_SkCodec_getInfo(const SkCodec* self, SkImageInfo* info) {
*info = self->getInfo();
}
extern "C" SkISize C_SkCodec_dimensions(const SkCodec* self) {
return self->dimensions();
}
extern "C" void C_SkCodec_bounds(const SkCodec* self, SkIRect* uninitialized) {
new (uninitialized) SkIRect(self->bounds());
}
extern "C" SkEncodedOrigin C_SkCodec_getOrigin(const SkCodec* self) {
return self->getOrigin();
}
extern "C" SkISize C_SkCodec_getScaledDimensions(const SkCodec* self, float desiredScale) {
return self->getScaledDimensions(desiredScale);
}
extern "C" bool C_SkCodec_getValidSubset(const SkCodec* self, SkIRect* desiredSubset) {
return self->getValidSubset(desiredSubset);
}
extern "C" SkEncodedImageFormat C_SkCodec_getEncodedFormat(const SkCodec* self) {
return self->getEncodedFormat();
}
extern "C" SkImage* C_SkCodec_getImage(
SkCodec *self, const SkImageInfo *info, const SkCodec::Options *opts, SkCodec::Result* result) {
auto r = self->getImage(*info, opts);
*result = std::get<1>(r);
return std::get<0>(r).release();
}
extern "C" SkCodec::Result C_SkCodec_incrementalDecode(SkCodec* self, int* rowsDecoded) {
return self->incrementalDecode(rowsDecoded);
}
extern "C" SkCodec::SkScanlineOrder C_SkCodec_getScanlineOrder(const SkCodec* self) {
return self->getScanlineOrder();
}
extern "C" int C_SkCodec_nextScanline(const SkCodec* self) {
return self->nextScanline();
}
extern "C" int C_SkCodec_getFrameCount(SkCodec* self) {
return self->getFrameCount();
}
extern "C" void C_SkFrameInfo_Construct(SkCodec::FrameInfo* uninitialized) {
new (uninitialized) SkCodec::FrameInfo();
}
extern "C" bool C_SkCodec_getFrameInfo(SkCodec* self, int index, SkCodec::FrameInfo* info) {
return self->getFrameInfo(index, info);
}
extern "C" int C_SkCodec_getRepetitionCount(SkCodec* self) {
return self->getRepetitionCount();
}
// SkCodecs
extern "C" void C_SkCodecs_Decoder_CopyConstruct(SkCodecs::Decoder* uninitialized, const SkCodecs::Decoder* decoder) {
new (uninitialized) SkCodecs::Decoder(*decoder);
}
extern "C" const char* C_SkCodecs_Decoder_getId(const SkCodecs::Decoder* decoder, size_t* len) {
*len = decoder->id.size();
return decoder->id.data();
}
extern "C" SkCodec* C_SkCodecs_Decoder_MakeFromStream(const SkCodecs::Decoder* decoder, SkStream* stream, SkCodec::Result* result, SkCodecs::DecodeContext context) {
return decoder->makeFromStream(std::unique_ptr<SkStream>(stream), result, context).release();
}
extern "C" void C_SkCodecs_Decoder_destruct(SkCodecs::Decoder* decoder) {
decoder->~Decoder();
}
extern "C" SkImage* C_SkCodecs_DeferredImage(SkCodec* codec, const SkAlphaType* alphaType) {
return SkCodecs::DeferredImage(std::unique_ptr<SkCodec>(codec), alphaType ? std::optional(*alphaType) : std::nullopt).release();
}
//
// codec/*Decoder.h
//
extern "C" void C_SkBmpDecoder_Decoder(SkCodecs::Decoder* uninitialized) {
new (uninitialized) SkCodecs::Decoder(SkBmpDecoder::Decoder());
}
extern "C" void C_SkGifDecoder_Decoder(SkCodecs::Decoder* uninitialized) {
new (uninitialized) SkCodecs::Decoder(SkGifDecoder::Decoder());
}
extern "C" void C_SkIcoDecoder_Decoder(SkCodecs::Decoder* uninitialized) {
new (uninitialized) SkCodecs::Decoder(SkIcoDecoder::Decoder());
}
extern "C" void C_SkJpegDecoder_Decoder(SkCodecs::Decoder* uninitialized) {
new (uninitialized) SkCodecs::Decoder(SkJpegDecoder::Decoder());
}
extern "C" void C_SkPngDecoder_Decoder(SkCodecs::Decoder* uninitialized) {
new (uninitialized) SkCodecs::Decoder(SkPngDecoder::Decoder());
}
extern "C" void C_SkWbmpDecoder_Decoder(SkCodecs::Decoder* uninitialized) {
new (uninitialized) SkCodecs::Decoder(SkWbmpDecoder::Decoder());
}
#if defined(SK_CODEC_DECODES_WEBP)
extern "C" void C_SkWebpDecoder_Decoder(SkCodecs::Decoder* uninitialized) {
new (uninitialized) SkCodecs::Decoder(SkWebpDecoder::Decoder());
}
#endif
//
// codec/SkEncodedOrigin.h
//
extern "C" void C_SkEncodedOriginToMatrix(SkEncodedOrigin origin, int w, int h, SkMatrix* matrix) {
*matrix = SkEncodedOriginToMatrix(origin, w, h);
}
//
// codec/SkPixmapUtils.h
//
extern "C" bool C_SkPixmapUtils_Orient(SkPixmap& dst, const SkPixmap& src, SkEncodedOrigin origin) {
return SkPixmapUtils::Orient(dst, src, origin);
}
extern "C" void C_SkPixmapUtils_SwapWidthHeight(SkImageInfo* uninitialized, const SkImageInfo& info) {
new (uninitialized) SkImageInfo(SkPixmapUtils::SwapWidthHeight(info));
}
//
// core/
//
extern "C" void C_Core_Types(
SkGraphics *, SkCoverageMode *, SkColorChannelFlag *, SkSurfaces::BackendSurfaceAccess) {};
//
// core/SkBlender.h
//
extern "C" SkBlender* C_SkBlender_Mode(SkBlendMode mode) {
return SkBlender::Mode(mode).release();
}
extern "C" SkBlender* C_SkBlender_Deserialize(const void* data, size_t length) {
return static_cast<SkBlender*>(SkFlattenable::Deserialize(SkFlattenable::kSkBlender_Type, data, length).release());
}
//
// core/SkColor.h
//
extern "C" uint32_t C_SkColor4f_toBytes_RGBA(const SkColor4f* color) {
return color->toBytes_RGBA();
}
extern "C" SkColor4f C_SkColor4f_FromBytes_RGBA(uint32_t bytes) {
return SkColor4f::FromBytes_RGBA(bytes);
}
//
// core/SkCubicMap.h
//
extern "C" SkPoint C_SkCubicMap_computeFromT(const SkCubicMap* self, float t) {
return self->computeFromT(t);
}
//
// core/SkSurface.h
//
extern "C" SkSurface* C_SkSurfaces_Null(int width, int height) {
return SkSurfaces::Null(width, height).release();
}
extern "C" SkSurface* C_SkSurfaces_Raster(const SkImageInfo* imageInfo, size_t rowBytes, const SkSurfaceProps* surfaceProps) {
return SkSurfaces::Raster(*imageInfo, rowBytes, surfaceProps).release();
}
extern "C" SkSurface* C_SkSurfaces_WrapPixels(const SkImageInfo* imageInfo, void* pixels, size_t rowBytes, const SkSurfaceProps* surfaceProps) {
return SkSurfaces::WrapPixels(*imageInfo, pixels, rowBytes, surfaceProps).release();
}
extern "C" int C_SkSurface_width(const SkSurface* self) {
return self->width();
}
extern "C" int C_SkSurface_height(const SkSurface* self) {
return self->height();
}
extern "C" void C_SkSurface_imageInfo(SkSurface* self, SkImageInfo* info) {
*info = self->imageInfo();
}
extern "C" SkImage* C_SkSurface_makeImageSnapshot(SkSurface* self, const SkIRect* bounds) {
if (bounds) {
return self->makeImageSnapshot(*bounds).release();
} else {
return self->makeImageSnapshot().release();
}
}
extern "C" SkSurface* C_SkSurface_makeSurface(
SkSurface* self,
const SkImageInfo* imageInfo) {
return self->makeSurface(*imageInfo).release();
}
extern "C" SkSurface *C_SkSurface_makeSurface2(
SkSurface *self,
int width, int height) {
return self->makeSurface(width, height).release();
}
extern "C" const SkSurfaceProps* C_SkSurface_props(const SkSurface* self) {
return &self->props();
}
//
// core/SkImage.h
//
extern "C" SkImage* C_SkImages_RasterFromBitmap(const SkBitmap* bitmap) {
return SkImages::RasterFromBitmap(*bitmap).release();
}
extern "C" SkImage *C_SkImages_RasterFromCompressedTextureData(SkData *data, int width, int height, SkTextureCompressionType
type) {
return SkImages::RasterFromCompressedTextureData(sp(data), width, height, type).release();
}
extern "C" SkImage* C_SkImages_DeferredFromEncodedData(SkData* encoded, const SkAlphaType* alphaType) {
return SkImages::DeferredFromEncodedData(sp(encoded), opt(alphaType)).release();
}
extern "C" SkImage* C_SkImages_DeferredFromGenerator(SkImageGenerator* imageGenerator) {
return SkImages::DeferredFromGenerator(std::unique_ptr<SkImageGenerator>(imageGenerator)).release();
}
extern "C" SkImage* C_SkImages_DeferredFromPicture(
SkPicture* picture,
const SkISize* dimensions,
const SkMatrix* matrix,
const SkPaint* paint,
SkImages::BitDepth bitDepth,
SkColorSpace* colorSpace,
const SkSurfaceProps* props) {
return
SkImages::DeferredFromPicture(
sp(picture),
*dimensions,
matrix,
paint,
bitDepth,
sp(colorSpace),
*props
).release();
}
extern "C" SkImage* C_SkImages_RasterFromData(const SkImageInfo* info, SkData* pixels, size_t rowBytes) {
return SkImages::RasterFromData(*info, sp(pixels), rowBytes).release();
}
extern "C" SkImage* C_SkImages_MakeWithFilter(SkImage* image, const SkImageFilter* imageFilter, const SkIRect* subset, const SkIRect* clipBounds, SkIRect* outSubset, SkIPoint* offset) {
return SkImages::MakeWithFilter(sk_sp(image), imageFilter, *subset, *clipBounds, outSubset, offset).release();
}
extern "C" SkShader* C_SkImage_makeShader(
const SkImage* self,
SkTileMode tileMode1, SkTileMode tileMode2,
const SkSamplingOptions* samplingOptions, const SkMatrix* localMatrix) {
return self->makeShader(tileMode1, tileMode2, *samplingOptions, localMatrix).release();
}
extern "C" SkShader* C_SkImage_makeRawShader(
const SkImage* self,
SkTileMode tileMode1, SkTileMode tileMode2,
const SkSamplingOptions* samplingOptions, const SkMatrix* localMatrix) {
return self->makeRawShader(tileMode1, tileMode2, *samplingOptions, localMatrix).release();
}
extern "C" bool C_SkImage_isTextureBacked(const SkImage* self) {
return self->isTextureBacked();
}
extern "C" size_t C_SkImage_textureSize(const SkImage* self) {
return self->textureSize();
}
extern "C" bool C_SkImage_isValid(const SkImage* self, GrRecordingContext* context) {
return self->isValid(context);
}
extern "C" SkData* C_SkImage_refEncodedData(const SkImage* self) {
return self->refEncodedData().release();
}
extern "C" SkImage* C_SkImage_makeSubset(const SkImage* self, GrDirectContext* context, const SkIRect* subset) {
return self->makeSubset(context, *subset).release();
}
extern "C" SkImage* C_SkImage_withDefaultMipmaps(const SkImage* self) {
return self->withDefaultMipmaps().release();
}
extern "C" SkImage* C_SkImage_makeNonTextureImage(const SkImage* self, GrDirectContext* context) {
return self->makeNonTextureImage(context).release();
}
extern "C" SkImage* C_SkImage_makeRasterImage(const SkImage* self, GrDirectContext* context, SkImage::CachingHint cachingHint) {
return self->makeRasterImage(context, cachingHint).release();
}
extern "C" bool C_SkImage_isLazyGenerated(const SkImage* self) {
return self->isLazyGenerated();
}
extern "C" SkImage* C_SkImage_makeColorSpace(const SkImage* self, GrDirectContext* direct, SkColorSpace* target) {
return self->makeColorSpace(direct, sp(target)).release();
}
extern "C" SkImage* C_SkImage_reinterpretColorSpace(const SkImage* self, SkColorSpace* newColorSpace) {
return self->reinterpretColorSpace(sp(newColorSpace)).release();
}
//
// core/SkData.h
//
extern "C" void C_SkData_ref(const SkData* self) {
self->ref();
}
extern "C" void C_SkData_unref(const SkData* self) {
self->unref();
}
extern "C" bool C_SkData_unique(const SkData* self) {
return self->unique();
}
extern "C" SkData* C_SkData_MakeWithCopy(const void* data, size_t length) {
return SkData::MakeWithCopy(data, length).release();
}
extern "C" SkData* C_SkData_MakeSubset(const SkData* src, size_t offset, size_t length) {
return SkData::MakeSubset(src, offset, length).release();
}
extern "C" SkData* C_SkData_MakeUninitialized(size_t length) {
return SkData:: MakeUninitialized(length).release();
}
extern "C" SkData* C_SkData_MakeZeroInitialized(size_t length) {
return SkData:: MakeZeroInitialized(length).release();
}
extern "C" SkData* C_SkData_MakeWithCString(const char* cstr) {
return SkData::MakeWithCString(cstr).release();
}
extern "C" SkData* C_SkData_MakeWithoutCopy(const void* data, size_t length) {
return SkData::MakeWithoutCopy(data, length).release();
}
extern "C" SkData* C_SkData_MakeFromFileName(const char cstr[]) {
return SkData::MakeFromFileName(cstr).release();
}
extern "C" SkData* C_SkData_MakeFromStream(SkStream* stream, size_t size) {
return SkData::MakeFromStream(stream, size).release();
}
extern "C" SkData* C_SkData_MakeEmpty() {
return SkData::MakeEmpty().release();
}
//
// core/SkPaint.h
//
extern "C" void C_SkPaint_destruct(SkPaint* self) {
self->~SkPaint();
}
extern "C" void C_SkPaint_copy(SkPaint* self, const SkPaint* rhs) {
*self = *rhs;
}
extern "C" bool C_SkPaint_Equals(const SkPaint* lhs, const SkPaint* rhs) {
return *lhs == *rhs;
}
extern "C" SkPaint::Style C_SkPaint_getStyle(const SkPaint* self) {
return self->getStyle();
}
extern "C" uint8_t C_SkPaint_getAlpha(const SkPaint* self) {
return self->getAlpha();
}
extern "C" SkPaint::Cap C_SkPaint_getStrokeCap(const SkPaint* self) {
return self->getStrokeCap();
}
extern "C" SkPaint::Join C_SkPaint_getStrokeJoin(const SkPaint* self) {
return self->getStrokeJoin();
}
extern "C" void C_SkPaint_setShader(SkPaint* self, SkShader* shader) {
self->setShader(sp(shader));
}
extern "C" void C_SkPaint_setColorFilter(SkPaint* self, SkColorFilter* colorFilter) {
self->setColorFilter(sp(colorFilter));
}
extern "C" bool C_SkPaint_asBlendMode(const SkPaint* self, SkBlendMode* mode) {
auto r = self->asBlendMode();
if (r.has_value()) {
*mode = *r;
return true;
} else {
return false;
}
}
extern "C" void C_SkPaint_setBlender(SkPaint* self, SkBlender* blender) {
self->setBlender(sp(blender));
}
extern "C" void C_SkPaint_setPathEffect(SkPaint* self, SkPathEffect* pathEffect) {
self->setPathEffect(sp(pathEffect));
}
extern "C" void C_SkPaint_setMaskFilter(SkPaint* self, SkMaskFilter* maskFilter) {
self->setMaskFilter(sp(maskFilter));
}
extern "C" void C_SkPaint_setImageFilter(SkPaint* self, SkImageFilter* imageFilter) {
self->setImageFilter(sp(imageFilter));
}
//
// core/SkPath.h
//
extern "C" void C_SkPath_Construct(SkPath* uninitialized) {
new(uninitialized) SkPath();
}
extern "C" void C_SkPath_Make(SkPath* uninitialized,
const SkPoint pts[], int pointCount,
const uint8_t vbs[], int verbCount,
const SkScalar ws[], int wCount,
SkPathFillType ft, bool isVolatile) {
new(uninitialized) SkPath(SkPath::Make(pts, pointCount, vbs, verbCount, ws, wCount, ft, isVolatile));
}
extern "C" void C_SkPath_Rect(SkPath* uninitialized,
const SkRect& r, SkPathDirection dir) {
new(uninitialized) SkPath(SkPath::Rect(r, dir));
}
extern "C" void C_SkPath_Oval(SkPath* uninitialized,
const SkRect& r, SkPathDirection dir) {
new(uninitialized) SkPath(SkPath::Oval(r, dir));
}
extern "C" void C_SkPath_OvalWithStartIndex(SkPath* uninitialized,
const SkRect& r, SkPathDirection dir, unsigned startIndex) {
new(uninitialized) SkPath(SkPath::Oval(r, dir, startIndex));
}
extern "C" void C_SkPath_Circle(SkPath* uninitialized,
SkScalar x, SkScalar y, SkScalar r, SkPathDirection dir) {
new(uninitialized) SkPath(SkPath::Circle(x, y, r, dir));
}
extern "C" void C_SkPath_RRect(SkPath* uninitialized,
const SkRRect& rr, SkPathDirection dir) {
new(uninitialized) SkPath(SkPath::RRect(rr, dir));
}
extern "C" void C_SkPath_RRectWithStartIndex(SkPath* uninitialized,
const SkRRect& r, SkPathDirection dir, unsigned startIndex) {
new(uninitialized) SkPath(SkPath::RRect(r, dir, startIndex));
}
extern "C" void C_SkPath_Polygon(SkPath* uninitialized,
const SkPoint pts[], int count, bool isClosed,
SkPathFillType ft,
bool isVolatile) {
new(uninitialized) SkPath(SkPath::Polygon(pts, count, isClosed, ft, isVolatile));
}
extern "C" void C_SkPath_destruct(const SkPath* self) {
self->~SkPath();
}
extern "C" bool C_SkPath_Equals(const SkPath* lhs, const SkPath* rhs) {
return *lhs == *rhs;
}
extern "C" SkData* C_SkPath_serialize(const SkPath* self) {
return self->serialize().release();
}
extern "C" void C_SkPath_Iter_destruct(SkPath::Iter* self) {
self->~Iter();
}
extern "C" bool C_SkPath_Iter_isCloseLine(const SkPath::Iter* self) {
return self->isCloseLine();
}
extern "C" void C_SkPath_RawIter_Construct(SkPath::RawIter* uninitialized) {
new(uninitialized)SkPath::RawIter();
}
extern "C" void C_SkPath_RawIter_destruct(SkPath::RawIter* self) {
self->~RawIter();
}
extern "C" SkPath::Verb C_SkPath_RawIter_peek(const SkPath::RawIter* self) {
return self->peek();
}
extern "C" SkPathFillType C_SkPath_getFillType(const SkPath* self) {
return self->getFillType();
}
extern "C" SkPoint C_SkPath_getPoint(const SkPath* self, int index) {
return self->getPoint(index);
}
extern "C" const SkRect* C_SkPath_getBounds(const SkPath* self) {
return &self->getBounds();
}
extern "C" void C_SkPath_computeTightBounds(const SkPath* self, SkRect* uninitialized) {
new (uninitialized) SkRect(self->computeTightBounds());
}
//
// core/SkPathBuilder.h
//
extern "C" void C_SkPathBuilder_Construct(SkPathBuilder* uninitialized) {
new(uninitialized) SkPathBuilder();
}
/* m87: Implementation is missing.
extern "C" void C_SkPathBuilder_Construct2(SkPathBuilder* uninitialized, SkPathFillType fillType) {
new(uninitialized) SkPathBuilder(fillType);
}
*/
extern "C" void C_SkPathBuilder_Construct3(SkPathBuilder* uninitialized, const SkPath& path) {
new(uninitialized) SkPathBuilder(path);
}
extern "C" void C_SkPathBuilder_computeBounds(const SkPathBuilder* self, SkRect* uninitialized) {
new (uninitialized) SkRect(self->computeBounds());
}
extern "C" void C_SkPathBuilder_CopyConstruct(SkPathBuilder* uninitialized, const SkPathBuilder& pathBuilder) {
new(uninitialized) SkPathBuilder(pathBuilder);
}
extern "C" void C_SkPathBuilder_destruct(SkPathBuilder* self) {
self->~SkPathBuilder();
}
extern "C" void C_SkPathBuilder_snapshot(const SkPathBuilder* self, SkPath* path) {
*path = self->snapshot();
}
extern "C" void C_SkPathBuilder_detach(SkPathBuilder* self, SkPath* path) {
*path = self->detach();
}
//
// SkPathMeasure
//
extern "C" void C_SkPathMeasure_destruct(const SkPathMeasure* self) {
self->~SkPathMeasure();
}
//
// core/SkPathTypes.h
//
extern "C" void
C_SkPathTypes_Types(SkPathFillType *, SkPathDirection *, SkPathSegmentMask *, SkPathVerb *) {}
//
// core/SkPathUtils.h
//
extern "C" bool C_PathUtils_FillPathWithPaint(const SkPath* src, const SkPaint* paint, SkPath* dst, const SkRect* cullRect, const SkMatrix* matrix) {
return skpathutils::FillPathWithPaint(*src, *paint, dst, cullRect, *matrix);
}
//
// core/SkCanvas.h
// Note: bindgen layout is broken, so we are forced to allocate Canvas instances on the heap only.
//
extern "C" void C_SkCanvas_SaveLayerRec_Construct(SkCanvas::SaveLayerRec* uninitialized) {
new (uninitialized) SkCanvas::SaveLayerRec();
}
extern "C" void C_SkCanvas_SaveLayerRec_destruct(SkCanvas::SaveLayerRec* self) {
self->~SaveLayerRec();
}
extern "C" SkCanvas* C_SkCanvas_newEmpty() {
return new SkCanvas();
}
extern "C" SkCanvas* C_SkCanvas_newWidthHeightAndProps(int width, int height, const SkSurfaceProps* props) {
return new SkCanvas(width, height, props);
}
extern "C" SkCanvas* C_SkCanvas_newFromBitmap(const SkBitmap* bitmap) {
return new SkCanvas(*bitmap);
}
extern "C" SkCanvas* C_SkCanvas_newFromBitmapAndProps(const SkBitmap* bitmap, const SkSurfaceProps* props) {
return new SkCanvas(*bitmap, *props);
}
extern "C" void C_SkCanvas_delete(const SkCanvas* self) {
delete self;
}
extern "C" SkCanvas* C_SkCanvas_MakeRasterDirect(const SkImageInfo* info, void* pixels, size_t row_bytes, const SkSurfaceProps* props) {
return SkCanvas::MakeRasterDirect(*info, pixels, row_bytes, props).release();
}
extern "C" void C_SkCanvas_imageInfo(const SkCanvas* self, SkImageInfo* info) {
*info = self->imageInfo();
}
extern "C" void C_SkCanvas_getBaseLayerSize(const SkCanvas* self, SkISize* size) {
*size = self->getBaseLayerSize();
}
extern "C" SkSurface* C_SkCanvas_makeSurface(SkCanvas* self, const SkImageInfo* info, const SkSurfaceProps* props) {
return self->makeSurface(*info, props).release();
}
extern "C" void C_SkCanvas_clipShader(SkCanvas* self, SkShader* shader, SkClipOp op) {
self->clipShader(sp(shader), op);
}
extern "C" void C_SkCanvas_getLocalClipBounds(const SkCanvas* self, SkRect* uninitialized) {
new (uninitialized) SkRect(self->getLocalClipBounds());
}
extern "C" void C_SkCanvas_getDeviceClipBounds(const SkCanvas* self, SkIRect* result) {
*result = self->getDeviceClipBounds();
}
extern "C" bool C_SkCanvas_isClipEmpty(const SkCanvas* self) {
return self->isClipEmpty();
}
extern "C" bool C_SkCanvas_isClipRect(const SkCanvas* self) {
return self->isClipRect();
}
extern "C" void C_SkCanvas_getLocalToDevice(const SkCanvas* self, SkM44* uninitialized) {
new(uninitialized) SkM44(self->getLocalToDevice());
}
extern "C" void C_SkCanvas_getTotalMatrix(const SkCanvas* self, SkMatrix* matrix) {
*matrix = self->getTotalMatrix();
}
extern "C" void C_SkCanvas_discard(SkCanvas* self) {
self->discard();
}
//
// core/SkAutoCanvasRestore.h
//
extern "C" void C_SkAutoCanvasRestore_Construct(SkAutoCanvasRestore* uninitialized, SkCanvas* canvas, bool doSave) {
new(uninitialized) SkAutoCanvasRestore(canvas, doSave);
}
extern "C" void C_SkAutoCanvasRestore_destruct(const SkAutoCanvasRestore* self) {
self->~SkAutoCanvasRestore();
}
extern "C" void C_SkAutoCanvasRestore_restore(SkAutoCanvasRestore* self) {
self->restore();
}
//
// core/SkImageInfo.h
//
extern "C" void C_SkColorInfo_Construct(SkColorInfo* uninitialized) {
new (uninitialized) SkColorInfo();
}
extern "C" void C_SkColorInfo_Construct2(SkColorInfo* uninitialized, SkColorType ct, SkAlphaType at, SkColorSpace* cs) {
new (uninitialized) SkColorInfo(ct, at, sp(cs));
}
extern "C" void C_SkColorInfo_destruct(SkColorInfo* self) {
self->~SkColorInfo();
}
extern "C" void C_SkColorInfo_Copy(const SkColorInfo* from, SkColorInfo* to) {
*to = *from;
}
extern "C" bool C_SkColorInfo_Equals(const SkColorInfo* lhs, const SkColorInfo* rhs) {
return *lhs == *rhs;
}
extern "C" void C_SkColorInfo_makeAlphaType(const SkColorInfo* self, SkAlphaType newAlphaType, SkColorInfo* uninitialized) {
new (uninitialized) SkColorInfo(self->makeAlphaType(newAlphaType));
}
extern "C" void C_SkColorInfo_makeColorType(const SkColorInfo* self, SkColorType newColorType, SkColorInfo* uninitialized) {
new (uninitialized) SkColorInfo(self->makeColorType(newColorType));
}
extern "C" void C_SkColorInfo_makeColorSpace(const SkColorInfo* self, SkColorSpace* newColorSpace, SkColorInfo* uninitialized) {
new (uninitialized) SkColorInfo(self->makeColorSpace(sp(newColorSpace)));
}
extern "C" void C_SkImageInfo_Construct(SkImageInfo* uninitialized) {
new (uninitialized) SkImageInfo();
}
extern "C" void C_SkImageInfo_destruct(SkImageInfo* self) {
self->~SkImageInfo();
}
extern "C" void C_SkImageInfo_Copy(const SkImageInfo* from, SkImageInfo* to) {
*to = *from;
}
extern "C" bool C_SkImageInfo_Equals(const SkImageInfo* lhs, const SkImageInfo* rhs) {
return *lhs == *rhs;
}
extern "C" void C_SkImageInfo_Make(int width, int height, SkColorType ct, SkAlphaType at, SkColorSpace* cs, SkImageInfo* uninitialized) {
new (uninitialized) SkImageInfo(SkImageInfo::Make(width, height, ct, at, sp(cs)));
}
extern "C" void C_SkImageInfo_MakeN32(int width, int height, SkAlphaType at, SkColorSpace* cs, SkImageInfo* uninitialized) {
new (uninitialized) SkImageInfo(SkImageInfo::MakeN32(width, height, at, sp(cs)));
}
extern "C" void C_SkImageInfo_MakeS32(int width, int height, SkAlphaType at, SkImageInfo* uninitialized) {
new (uninitialized) SkImageInfo(SkImageInfo::MakeS32(width, height, at));
}
extern "C" void C_SkImageInfo_MakeN32Premul(int width, int height, SkColorSpace* cs, SkImageInfo* uninitialized) {
new (uninitialized) SkImageInfo(SkImageInfo::MakeN32Premul(width, height, sp(cs)));
}
extern "C" void C_SkImageInfo_MakeA8(int width, int height, SkImageInfo* uninitialized) {
new (uninitialized) SkImageInfo(SkImageInfo::MakeA8(width, height));
}
extern "C" void C_SkImageInfo_MakeUnknown(int width, int height, SkImageInfo* uninitialized) {
new (uninitialized) SkImageInfo(SkImageInfo::MakeUnknown(width, height));
}
extern "C" void C_SkImageInfo_makeColorSpace(const SkImageInfo* self, SkColorSpace* cs, SkImageInfo* uninitialized) {
new (uninitialized) SkImageInfo(self->makeColorSpace(sp(cs)));
}
extern "C" void C_SkImageInfo_reset(SkImageInfo* self) {
self->reset();
}
//
// core/SkColorSpace.h
//
extern "C" void C_SkColorSpace_Types(SkColorSpacePrimaries *) {}
extern "C" void C_SkColorSpace_ref(const SkColorSpace* self) {
self->ref();
}
extern "C" void C_SkColorSpace_unref(const SkColorSpace* self) {
self->unref();
}
extern "C" bool C_SkColorSpace_unique(const SkColorSpace* self) {
return self->unique();
}
extern "C" SkColorSpace* C_SkColorSpace_MakeSRGB() {
return SkColorSpace::MakeSRGB().release();
}
extern "C" SkColorSpace* C_SkColorSpace_MakeSRGBLinear() {
return SkColorSpace::MakeSRGBLinear().release();
}
extern "C" SkColorSpace* C_SkColorSpace_makeLinearGamma(const SkColorSpace* self) {
return self->makeLinearGamma().release();
}
extern "C" SkColorSpace* C_SkColorSpace_makeSRGBGamma(const SkColorSpace* self) {
return self->makeSRGBGamma().release();
}
extern "C" SkColorSpace* C_SkColorSpace_makeColorSpin(const SkColorSpace* self) {
return self->makeColorSpin().release();
}
extern "C" SkData* C_SkColorSpace_serialize(const SkColorSpace* self) {
return self->serialize().release();
}
extern "C" SkColorSpace* C_SkColorSpace_Deserialize(const void* data, size_t length) {
return SkColorSpace::Deserialize(data, length).release();
}
//
// SkM44
//
extern "C" void C_SkM44_Types(SkV2 *) {};
extern "C" bool C_SkM44_equals(const SkM44 *self, const SkM44 *other) {
return *self == *other;