/
bindings.cpp
1380 lines (1090 loc) · 42.7 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
// core/
#include "SkTypes.h"
#include "SkCanvas.h"
#include "SkColor.h"
#include "SkColorFilter.h"
#include "SkDocument.h"
#include "SkFont.h"
#include "SkFontMetrics.h"
#include "SkImageFilter.h"
#include "SkImageInfo.h"
#include "SkMaskFilter.h"
#include "SkPaint.h"
#include "SkPath.h"
#include "SkPicture.h"
#include "SkPictureRecorder.h"
#include "SkPoint3.h"
#include "SkRect.h"
#include "SkRegion.h"
#include "SkStream.h"
#include "SkStrokeRec.h"
#include "SkSurface.h"
#include "SkTextBlob.h"
#include "SkTypeface.h"
#include "SkYUVAIndex.h"
// docs/
#include "SkPDFDocument.h"
// effects/
#include "Sk1DPathEffect.h"
#include "Sk2DPathEffect.h"
#include "SkCornerPathEffect.h"
#include "SkDashPathEffect.h"
#include "SkDiscretePathEffect.h"
#include "SkGradientShader.h"
#include "SkPerlinNoiseShader.h"
#include "SkTableColorFilter.h"
// gpu/
#include "GrContext.h"
// gpu/gl
#include "gl/GrGLInterface.h"
#include "SkRect.h"
#if defined(SK_VULKAN)
#include "vk/GrVkVulkan.h"
#include "vk/GrVkTypes.h"
#include "vk/GrVkBackendContext.h"
#include "GrBackendSurface.h"
#endif
#if defined(SK_XML)
#include "SkSVGCanvas.h"
#include "SkXMLWriter.h"
#endif
template<typename T>
inline sk_sp<T> spFromConst(const T* pt) {
return sk_sp<T>(const_cast<T*>(pt));
}
//
// SkSurface
//
extern "C" SkSurface* C_SkSurface_MakeRasterDirect(const SkImageInfo* imageInfo, void* pixels, size_t rowBytes, const SkSurfaceProps* surfaceProps) {
return SkSurface::MakeRasterDirect(*imageInfo, pixels, rowBytes, surfaceProps).release();
}
extern "C" SkSurface* C_SkSurface_MakeRaster(const SkImageInfo* imageInfo, size_t rowBytes, const SkSurfaceProps* surfaceProps) {
return SkSurface::MakeRaster(*imageInfo, rowBytes, surfaceProps).release();
}
extern "C" SkSurface* C_SkSurface_MakeRasterN32Premul(int width, int height, const SkSurfaceProps* surfaceProps) {
return SkSurface::MakeRasterN32Premul(width, height, surfaceProps).release();
}
extern "C" SkSurface* C_SkSurface_MakeFromBackendTexture(
GrContext* context,
const GrBackendTexture* backendTexture,
GrSurfaceOrigin origin,
int sampleCnt,
SkColorType colorType,
const SkColorSpace* colorSpace,
const SkSurfaceProps* surfaceProps) {
return SkSurface::MakeFromBackendTexture(
context,
*backendTexture,
origin,
sampleCnt,
colorType,
spFromConst(colorSpace), surfaceProps).release();
}
extern "C" SkSurface* C_SkSurface_MakeFromBackendRenderTarget(
GrContext* context,
const GrBackendRenderTarget* backendRenderTarget,
GrSurfaceOrigin origin,
SkColorType colorType,
const SkColorSpace* colorSpace,
const SkSurfaceProps* surfaceProps
) {
return SkSurface::MakeFromBackendRenderTarget(
context,
*backendRenderTarget,
origin,
colorType,
spFromConst(colorSpace),
surfaceProps).release();
}
extern "C" SkSurface* C_SkSurface_MakeFromBackendTextureAsRenderTarget(
GrContext* context,
const GrBackendTexture* backendTexture,
GrSurfaceOrigin origin,
int sampleCnt,
SkColorType colorType,
const SkColorSpace* colorSpace,
const SkSurfaceProps* surfaceProps) {
return SkSurface::MakeFromBackendTextureAsRenderTarget(
context,
*backendTexture,
origin,
sampleCnt,
colorType,
spFromConst(colorSpace), surfaceProps).release();
}
extern "C" SkSurface* C_SkSurface_MakeRenderTarget(
GrContext* context,
SkBudgeted budgeted,
const SkImageInfo* imageInfo,
int sampleCount, GrSurfaceOrigin surfaceOrigin,
const SkSurfaceProps* surfaceProps,
bool shouldCreateWithMips) {
return SkSurface::MakeRenderTarget(
context,
budgeted,
*imageInfo,
sampleCount,
surfaceOrigin,
surfaceProps,
shouldCreateWithMips).release();
}
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" void C_SkSurface_getBackendTexture(
SkSurface* self,
SkSurface::BackendHandleAccess handleAccess,
GrBackendTexture* backendTexture) {
*backendTexture = self->getBackendTexture(handleAccess);
}
extern "C" void C_SkSurface_getBackendRenderTarget(
SkSurface* self,
SkSurface::BackendHandleAccess handleAccess,
GrBackendRenderTarget *backendRenderTarget) {
*backendRenderTarget = self->getBackendRenderTarget(handleAccess);
}
extern "C" SkSurface* C_SkSurface_makeSurface(
SkSurface* self,
const SkImageInfo* imageInfo) {
return self->makeSurface(*imageInfo).release();
}
//
// SkImage
//
extern "C" SkImage* C_SkImage_MakeRasterData(const SkImageInfo* info, SkData* pixels, size_t rowBytes) {
return SkImage::MakeRasterData(*info, sk_sp<SkData>(pixels), rowBytes).release();
}
extern "C" SkImage* C_SkImage_MakeFromBitmap(const SkBitmap* bitmap) {
return SkImage::MakeFromBitmap(*bitmap).release();
}
extern "C" SkImage* C_SkImage_MakeFromEncoded(const SkData* encoded, const SkIRect* subset) {
return SkImage::MakeFromEncoded(spFromConst(encoded), subset).release();
}
extern "C" SkImage* C_SkImage_MakeFromCompressed(GrContext* context, const SkData* encoded, int width, int height, SkImage::CompressionType type) {
return SkImage::MakeFromCompressed(context, spFromConst(encoded), width, height, type).release();
}
extern "C" SkImage* C_SkImage_MakeFromTexture(
GrContext* context,
const GrBackendTexture* backendTexture,
GrSurfaceOrigin origin,
SkColorType colorType,
SkAlphaType alphaType,
const SkColorSpace* colorSpace) {
return SkImage::MakeFromTexture(context, *backendTexture, origin, colorType, alphaType, spFromConst(colorSpace)).release();
}
extern "C" SkImage* C_SkImage_MakeCrossContextFromEncoded(
GrContext* context,
const SkData* data,
bool buildMips,
const SkColorSpace* dstColorSpace,
bool limitToMaxTextureSize
) {
return SkImage::MakeCrossContextFromEncoded(context, spFromConst(data), buildMips, const_cast<SkColorSpace*>(dstColorSpace), limitToMaxTextureSize).release();
}
extern "C" SkImage* C_SkImage_MakeFromAdoptedTexture(
GrContext* context,
const GrBackendTexture* backendTexture,
GrSurfaceOrigin origin,
SkColorType colorType,
SkAlphaType alphaType,
const SkColorSpace* colorSpace) {
return SkImage::MakeFromAdoptedTexture(context, *backendTexture, origin, colorType, alphaType, spFromConst(colorSpace)).release();
}
extern "C" SkImage* C_SkImage_MakeFromYUVATexturesCopy(
GrContext* context,
SkYUVColorSpace yuvColorSpace,
const GrBackendTexture yuvaTextures[],
const SkYUVAIndex yuvaIndices[4],
SkISize imageSize,
GrSurfaceOrigin imageOrigin,
const SkColorSpace* colorSpace) {
return SkImage::MakeFromYUVATexturesCopy(
context,
yuvColorSpace, yuvaTextures, yuvaIndices,
imageSize, imageOrigin, spFromConst(colorSpace)).release();
}
extern "C" SkImage* C_SkImage_MakeFromYUVATexturesCopyWithExternalBackend(
GrContext* context,
SkYUVColorSpace yuvColorSpace,
const GrBackendTexture yuvaTextures[],
const SkYUVAIndex yuvaIndices[4],
SkISize imageSize,
GrSurfaceOrigin imageOrigin,
const GrBackendTexture& backendTexture,
const SkColorSpace* colorSpace) {
return SkImage::MakeFromYUVATexturesCopyWithExternalBackend(
context,
yuvColorSpace, yuvaTextures, yuvaIndices,
imageSize, imageOrigin, backendTexture,
spFromConst(colorSpace)).release();
}
extern "C" SkImage* C_SkImage_MakeFromYUVATextures(
GrContext* context,
SkYUVColorSpace yuvColorSpace,
const GrBackendTexture yuvaTextures[],
const SkYUVAIndex yuvaIndices[4],
SkISize imageSize,
GrSurfaceOrigin imageOrigin,
const SkColorSpace* colorSpace) {
return SkImage::MakeFromYUVATextures(
context,
yuvColorSpace, yuvaTextures, yuvaIndices,
imageSize, imageOrigin, spFromConst(colorSpace)).release();
}
extern "C" SkImage* C_SkImage_MakeFromNV12TexturesCopy(
GrContext* context,
SkYUVColorSpace yuvColorSpace,
const GrBackendTexture nv12Textures[2],
GrSurfaceOrigin imageOrigin,
const SkColorSpace* imageColorSpace) {
return SkImage::MakeFromNV12TexturesCopy(
context, yuvColorSpace, nv12Textures, imageOrigin,
spFromConst(imageColorSpace)).release();
}
extern "C" SkImage* C_SkImage_MakeFromNV12TexturesCopyWithExternalBackend(
GrContext* context,
SkYUVColorSpace yuvColorSpace,
const GrBackendTexture nv12Textures[2],
GrSurfaceOrigin imageOrigin,
const GrBackendTexture* backendTexture,
const SkColorSpace* imageColorSpace) {
return SkImage::MakeFromNV12TexturesCopyWithExternalBackend(
context,
yuvColorSpace, nv12Textures, imageOrigin, *backendTexture,
spFromConst(imageColorSpace)).release();
}
extern "C" SkImage* C_SkImage_MakeFromPicture(
const SkPicture* picture,
const SkISize* dimensions,
const SkMatrix* matrix,
const SkPaint* paint,
SkImage::BitDepth bitDepth,
const SkColorSpace* colorSpace) {
return SkImage::MakeFromPicture(spFromConst(picture), *dimensions, matrix, paint, bitDepth, spFromConst(colorSpace)).release();
}
extern "C" SkShader* C_SkImage_makeShader(const SkImage* self, SkShader::TileMode tileMode1, SkShader::TileMode tileMode2, const SkMatrix* localMatrix) {
return self->makeShader(tileMode1, tileMode2, localMatrix).release();
}
extern "C" void C_SkImage_getBackendTexture(
const SkImage* self,
bool flushPendingGrContextIO,
GrSurfaceOrigin* origin,
GrBackendTexture* result)
{
*result = self->getBackendTexture(flushPendingGrContextIO, origin);
}
extern "C" SkData* C_SkImage_encodeToData(const SkImage* self, SkEncodedImageFormat imageFormat) {
return self->encodeToData(imageFormat, 100).release();
}
extern "C" SkData* C_SkImage_refEncodedData(const SkImage* self) {
return self->refEncodedData().release();
}
extern "C" SkImage* C_SkImage_makeSubset(const SkImage* self, const SkIRect* subset) {
return self->makeSubset(*subset).release();
}
extern "C" SkImage* C_SkImage_makeTextureImage(
const SkImage* self,
GrContext* context,
const SkColorSpace* dstColorSpace,
GrMipMapped mipMapped) {
return self->makeTextureImage(context, const_cast<SkColorSpace*>(dstColorSpace), mipMapped).release();
}
extern "C" SkImage* C_SkImage_makeNonTextureImage(const SkImage* self) {
return self->makeNonTextureImage().release();
}
extern "C" SkImage* C_SkImage_makeRasterImage(const SkImage* self) {
return self->makeRasterImage().release();
}
extern "C" SkImage* C_SkImage_makeColorSpace(const SkImage* self, const SkColorSpace* target) {
return self->makeColorSpace(spFromConst(target)).release();
}
//
// SkData
//
extern "C" void C_SkData_ref(const SkData* self) {
self->ref();
}
extern "C" void C_SkData_unref(const SkData* self) {
self->unref();
}
extern "C" SkData* C_SkData_MakeWithCopy(const void* data, size_t length) {
return SkData::MakeWithCopy(data, length).release();
}
extern "C" SkData* C_SkData_MakeWithoutCopy(const void* data, size_t length) {
return SkData::MakeWithoutCopy(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_MakeEmpty() {
return SkData::MakeEmpty().release();
}
//
// SkPaint
//
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" void C_SkPaint_setShader(SkPaint* self, const SkShader* shader) {
self->setShader(spFromConst(shader));
}
extern "C" void C_SkPaint_setColorFilter(SkPaint* self, const SkColorFilter* colorFilter) {
self->setColorFilter(spFromConst(colorFilter));
}
extern "C" void C_SkPaint_setPathEffect(SkPaint* self, const SkPathEffect* pathEffect) {
self->setPathEffect(spFromConst(pathEffect));
}
extern "C" void C_SkPaint_setMaskFilter(SkPaint* self, const SkMaskFilter* maskFilter) {
self->setMaskFilter(spFromConst(maskFilter));
}
extern "C" SkFontHinting C_SkPaint_getHinting(const SkPaint* self) {
return self->getHinting();
}
// postponed
/*
extern "C" void C_SkPaint_setImageFilter(SkPaint* self, SkImageFilter* imageFilter) {
self->setImageFilter(sk_sp<SkImageFilter>(imageFilter));
}
*/
//
// SkPath
//
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" SkPath::FillType C_SkPath_ConvertToNonInverseFillType(SkPath::FillType fill) {
return SkPath::ConvertToNonInverseFillType(fill);
}
//
// SkCanvas
// Note: bindgen layout is broken, so we are forced to allocate Canvas instances on the heap only.
//
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" GrContext* C_SkCanvas_getGrContext(SkCanvas* self) {
return self->getGrContext();
}
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_discard(SkCanvas* self) {
self->discard();
}
//
// SkAutoCanvasRestore
//
#undef SkAutoCanvasRestore
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();
}
//
// SkImageInfo
//
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" void C_SkImageInfo_Make(SkImageInfo* self, int width, int height, SkColorType ct, SkAlphaType at, const SkColorSpace* cs) {
*self = SkImageInfo::Make(width, height, ct, at, spFromConst(cs));
}
extern "C" void C_SkImageInfo_MakeS32(SkImageInfo* self, int width, int height, SkAlphaType at) {
*self = SkImageInfo::MakeS32(width, height, at);
}
extern "C" SkColorSpace* C_SkImageInfo_colorSpace(const SkImageInfo* self) {
// note: colorSpace returns just a pointer without increasing the reference counter.
SkColorSpace* cs = self->colorSpace();
if (cs) cs->ref();
return cs;
}
//
// SkColorSpace
//
extern "C" void C_SkColorSpace_ref(const SkColorSpace* self) {
self->ref();
}
extern "C" void C_SkColorSpace_unref(const SkColorSpace* self) {
self->unref();
}
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();
}
//
// SkMatrix44
//
extern "C" void C_SkMatrix44_Construct(SkMatrix44* uninitialized) {
new(uninitialized) SkMatrix44();
}
extern "C" void C_SkMatrix44_CopyConstruct(SkMatrix44* uninitialized, const SkMatrix44* source) {
new(uninitialized) SkMatrix44(*source);
}
extern "C" void C_SkMatrix44_ConstructIdentity(SkMatrix44* uninitialized) {
new(uninitialized) SkMatrix44(SkMatrix44::kIdentity_Constructor);
}
extern "C" void C_SkMatrix44_destruct(SkMatrix44* self) {
self->~SkMatrix44();
}
// SkMatrix44_Equals is not generated by bindgen.
extern "C" bool C_SkMatrix44_Equals(const SkMatrix44* self, const SkMatrix44* rhs) {
return *self == *rhs;
}
// SkMatrix44_SkMatrix conversion.
extern "C" void C_SkMatrix44_SkMatrix(const SkMatrix44* self, SkMatrix* m) {
*m = *self;
}
extern "C" void C_SkMatrix44_Mul(const SkMatrix44* self, const SkMatrix44* rhs, SkMatrix44* result) {
*result = *self * *rhs;
}
extern "C" void C_SkMatrix44_MulV4(const SkMatrix44* self, const SkVector4* rhs, SkVector4* result) {
*result = *self * *rhs;
}
//
// SkMatrix
//
extern "C" bool C_SkMatrix_Equals(const SkMatrix* self, const SkMatrix* rhs) {
return *self == *rhs;
}
extern "C" SkScalar* C_SkMatrix_SubscriptMut(SkMatrix* self, size_t index) {
return &((*self)[static_cast<int>(index)]);
}
//
// SkSurfaceProps
//
extern "C" bool C_SkSurfaceProps_Equals(const SkSurfaceProps* self, const SkSurfaceProps* rhs) {
return *self == *rhs;
}
//
// SkBitmap
//
extern "C" void C_SkBitmap_Construct(SkBitmap* uninitialized) {
new (uninitialized) SkBitmap();
}
extern "C" void C_SkBitmap_destruct(SkBitmap* self) {
self->~SkBitmap();
}
extern "C" void C_SkBitmap_Copy(const SkBitmap* from, SkBitmap* to) {
*to = *from;
}
extern "C" SkColorSpace* C_SkBitmap_colorSpace(const SkBitmap* self) {
// note: colorSpace returns a pointer without increasing the reference counter.
SkColorSpace* cs = self->colorSpace();
if (cs) cs->ref();
return cs;
}
extern "C" bool C_SkBitmap_ComputeIsOpaque(const SkBitmap* self) {
return SkBitmap::ComputeIsOpaque(*self);
}
extern "C" bool C_SkBitmap_tryAllocN32Pixels(SkBitmap* self, int width, int height, bool isOpaque) {
return self->tryAllocN32Pixels(width, height, isOpaque);
}
extern "C" bool C_SkBitmap_tryAllocPixels(SkBitmap* self) {
return self->tryAllocPixels();
}
extern "C" bool C_SkBitmap_readyToDraw(const SkBitmap* self) {
return self->readyToDraw();
}
extern "C" void C_SkBitmap_eraseARGB(const SkBitmap* self, U8CPU a, U8CPU r, U8CPU g, U8CPU b) {
self->eraseARGB(a, r, g, b);
}
extern "C" float C_SkBitmap_getAlphaf(const SkBitmap* self, int x, int y) {
return self->getAlphaf(x, y);
}
extern "C" bool C_SkBitmap_extractAlpha(const SkBitmap* self, SkBitmap* dst, const SkPaint* paint, SkIPoint* offset) {
return self->extractAlpha(dst, paint, offset);
}
//
// SkPicture
//
extern "C" SkPicture* C_SkPicture_MakeFromData(const SkData* data) {
return SkPicture::MakeFromData(data).release();
}
extern "C" SkData* C_SkPicture_serialize(const SkPicture* self) {
return self->serialize().release();
}
extern "C" SkPicture* C_SkPicture_MakePlaceholder(const SkRect& cull) {
return SkPicture::MakePlaceholder(cull).release();
}
extern "C" void C_SkPicture_playback(const SkPicture* self, SkCanvas* canvas) {
self->playback(canvas);
}
extern "C" SkRect C_SkPicture_cullRect(const SkPicture* self) {
return self->cullRect();
}
extern "C" int C_SkPicture_approximateOpCount(const SkPicture* self) {
return self->approximateOpCount();
}
// note: returning size_t produces a linker error.
extern "C" void C_SkPicture_approximateBytesUsed(const SkPicture* self, size_t* out) {
*out = self->approximateBytesUsed();
}
//
// SkRRect
//
extern "C" bool C_SkRRect_Equals(const SkRRect* lhs, const SkRRect* rhs) {
return *lhs == *rhs;
}
//
// GrBackendTexture
//
extern "C" void C_GrBackendTexture_destruct(const GrBackendTexture* self) {
self->~GrBackendTexture();
}
//
// SkRegion
//
extern "C" void C_SkRegion_destruct(SkRegion* region) {
region->~SkRegion();
}
extern "C" bool C_SkRegion_Equals(const SkRegion* lhs, const SkRegion* rhs) {
return *lhs == *rhs;
}
//
// SkFontStyle
//
extern "C" void C_SkFontStyle_Construct(SkFontStyle* uninitialized) {
new(uninitialized) SkFontStyle();
}
extern "C" bool C_SkFontStyle_Equals(const SkFontStyle* lhs, const SkFontStyle* rhs) {
return *lhs == *rhs;
}
//
// SkTextBlob
//
extern "C" void C_SkTextBlob_ref(const SkTextBlob* self) {
self->ref();
}
extern "C" void C_SkTextBlob_unref(const SkTextBlob* self) {
self->unref();
}
extern "C" SkTextBlob* C_SkTextBlob_MakeFromText(const void* text, size_t byteLength, const SkFont* font, SkTextEncoding encoding) {
return SkTextBlob::MakeFromText(text, byteLength, *font, encoding).release();
}
//
// SkTypeface
//
extern "C" SkTypeface* C_SkTypeface_MakeDefault() {
return SkTypeface::MakeDefault().release();
}
extern "C" SkTypeface* C_SkTypeface_MakeFromName(const char familyName[], SkFontStyle fontStyle) {
return SkTypeface::MakeFromName(familyName, fontStyle).release();
}
extern "C" SkTypeface* C_SkTypeface_MakeFromFile(const char path[], int index) {
return SkTypeface::MakeFromFile(path, index).release();
}
extern "C" SkTypeface* C_SkTypeface_MakeFromData(const SkData* data, int index) {
return SkTypeface::MakeFromData(sk_sp<SkData>(const_cast<SkData*>(data)), index).release();
}
extern "C" SkData* C_SkTypeface_serialize(const SkTypeface* self, SkTypeface::SerializeBehavior behavior) {
return self->serialize(behavior).release();
}
//
// SkFont
//
extern "C" void C_SkFont_ConstructFromTypeface(SkFont* uninitialized, const SkTypeface* typeface) {
new(uninitialized) SkFont(spFromConst(typeface));
}
extern "C" void C_SkFont_ConstructFromTypefaceWithSize(SkFont* uninitialized, const SkTypeface* typeface, SkScalar size) {
new(uninitialized) SkFont(spFromConst(typeface), size);
}
extern "C" void C_SkFont_ConstructFromTypefaceWithSizeScaleAndSkew(SkFont* uninitialized, const SkTypeface* typeface, SkScalar size, SkScalar scaleX, SkScalar skewX) {
new(uninitialized) SkFont(spFromConst(typeface), size, scaleX, skewX);
}
extern "C" bool C_SkFont_Equals(const SkFont* self, const SkFont* other) {
return *self == *other;
}
extern "C" void C_SkFont_makeWithSize(const SkFont* self, SkScalar size, SkFont* result) {
*result = self->makeWithSize(size);
}
extern "C" SkTypeface* C_SkFont_getTypeface(SkFont* self) {
return self->getTypeface();
}
extern "C" void C_SkFont_setTypeface(SkFont* self, const SkTypeface* tf) {
self->setTypeface(spFromConst(tf));
}
extern "C" void C_SkFont_destruct(SkFont* self) {
self->~SkFont();
}
//
// SkVertices
//
extern "C" void C_SkVertices_ref(const SkVertices* self) {
self->ref();
}
extern "C" void C_SkVertices_unref(const SkVertices* self) {
self->unref();
}
extern "C" SkVertices* C_SkVertices_MakeCopy(
SkVertices::VertexMode mode, int vertexCount,
const SkPoint positions[],
const SkPoint texs[],
const SkColor colors[],
const SkVertices::BoneIndices boneIndices[],
const SkVertices::BoneWeights boneWeights[],
int indexCount,
const uint16_t indices[],
bool isVolatile) {
return SkVertices::MakeCopy(mode, vertexCount, positions, texs, colors, boneIndices, boneWeights, indexCount, indices, isVolatile).release();
}
extern "C" SkVertices* C_SkVertices_applyBones(const SkVertices* self, const SkVertices::Bone bones[], int boneCount) {
return self->applyBones(bones, boneCount).release();
}
extern "C" SkVertices* C_SkVertices_Decode(const void* buffer, size_t length) {
return SkVertices::Decode(buffer, length).release();
}
extern "C" SkData* C_SkVertices_encode(const SkVertices* self) {
return self->encode().release();
}
//
// SkVertices::Builder
//
extern "C" void C_SkVertices_Builder_destruct(SkVertices::Builder* builder) {
builder->~Builder();
}
extern "C" SkVertices* C_SkVertices_Builder_detach(SkVertices::Builder* builder) {
return builder->detach().release();
}
//
// SkPictureRecorder
//
extern "C" void C_SkPictureRecorder_destruct(SkPictureRecorder *self) {
self->~SkPictureRecorder();
}
extern "C" SkPicture* C_SkPictureRecorder_finishRecordingAsPicture(SkPictureRecorder* self, const SkRect* cullRect) {
if (cullRect){
return self->finishRecordingAsPictureWithCull(*cullRect).release();
} else {
return self->finishRecordingAsPicture().release();
}
}
//
// SkColorFilter
//
extern "C" SkColorFilter* C_SkColorFilter_MakeModeFilter(const SkColor* c, const SkBlendMode* blendMode) {
return SkColorFilter::MakeModeFilter(*c, *blendMode).release();
}
extern "C" SkColorFilter* C_SkColorFilter_makeComposed(const SkColorFilter* self, const SkColorFilter* inner) {
return self->makeComposed(spFromConst(inner)).release();
}
extern "C" SkColorFilter* C_SkColorFilter_MakeMatrixFilterRowMajor255(const SkScalar array[20]) {
return SkColorFilter::MakeMatrixFilterRowMajor255(array).release();
}
extern "C" SkColorFilter* C_SkColorFilter_MakeLinearToSRGBGamma() {
return SkColorFilter::MakeLinearToSRGBGamma().release();
}
extern "C" SkColorFilter* C_SkColorFilter_MakeSRGBToLinearGamma() {
return SkColorFilter::MakeSRGBToLinearGamma().release();
}
extern "C" bool C_SkColorFilter_asColorMode(const SkColorFilter* self, SkColor* color, SkBlendMode* mode) {
return self->asColorMode(color, mode);
}
extern "C" bool C_SkColorFilter_asColorMatrix(const SkColorFilter* self, SkScalar matrix[20]) {
return self->asColorMatrix(matrix);
}
extern "C" bool C_SkColorFilter_asComponentTable(const SkColorFilter* self, SkBitmap* table) {
return self->asComponentTable(table);
}
extern "C" uint32_t C_SkColorFilter_getFlags(const SkColorFilter* self) {
return self->getFlags();
}
//
// SkString
//
extern "C" void C_SkString_destruct(SkString* self) {
self->~SkString();
}
//
// SkStrokeRec
//
extern "C" void C_SkStrokeRec_destruct(SkStrokeRec* self) {
self->~SkStrokeRec();
}
extern "C" void C_SkStrokeRec_copy(const SkStrokeRec* self, SkStrokeRec* other) {
*other = *self;
}
extern "C" bool C_SkStrokeRec_hasEqualEffect(const SkStrokeRec* self, const SkStrokeRec* other) {
return self->hasEqualEffect(*other);
}
//
// SkPathEffect
//
extern "C" SkPathEffect* C_SkPathEffect_MakeSum(const SkPathEffect* first, const SkPathEffect* second) {
return SkPathEffect::MakeSum(spFromConst(first), spFromConst(second)).release();
}
extern "C" SkPathEffect* C_SkPathEffect_MakeCompose(const SkPathEffect* outer, const SkPathEffect* inner) {
return SkPathEffect::MakeCompose(spFromConst(outer), spFromConst(inner)).release();
}
extern "C" void C_SkPathEffect_PointData_Construct(SkPathEffect::PointData* unitialized) {
new(unitialized) SkPathEffect::PointData();
}
extern "C" void C_SkPathEffect_PointData_deletePoints(SkPathEffect::PointData* self) {
delete [] self->fPoints;
self->fPoints = nullptr;
}
//
// SkMaskFilter
//
extern "C" SkMaskFilter* C_SkMaskFilter_MakeBlur(SkBlurStyle style, SkScalar sigma, bool respectCTM) {
return SkMaskFilter::MakeBlur(style, sigma, respectCTM).release();
}
extern "C" SkMaskFilter* C_SkMaskFilter_Compose(const SkMaskFilter* outer, const SkMaskFilter* inner) {
return SkMaskFilter::MakeCompose(spFromConst(outer), spFromConst(inner)).release();