-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBlend2D.pas
17080 lines (14087 loc) · 585 KB
/
Blend2D.pas
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
unit Blend2D;
{ OPP wrappers for Blend2D C API.
Follows the C++ API where possible. The following C++ classes are not
converted because Delphi provides built-in alternatives for these:
* BLArray<T>: uses TArray<T> instead
* BLFile: uses TFileStream instead
* BLString: uses String instead
* BLVariant: not needed }
{ Updated by fatihtsp based on blend2d_win64.dll }
{$SCOPEDENUMS ON}
{$EXCESSPRECISION OFF}
interface
uses
System.Math,
System.SysUtils,
Blend2D.Api,
ftBlend2dDelphiObjectHelperRoutines;
{$REGION 'Error Handling'}
{ ============================================================================
[Error Handling - Enums]
============================================================================ }
type
{ Blend2D result code. }
TBLResultCode = (
{ Successful result code. }
Success = BL_SUCCESS,
{ Out of memory [ENOMEM]. }
OutOfMemory = BL_ERROR_OUT_OF_MEMORY,
{ Invalid value/argument [EINVAL]. }
InvalidValue = BL_ERROR_INVALID_VALUE,
{ Invalid state [EFAULT]. }
InvalidState = BL_ERROR_INVALID_STATE,
{ Invalid handle or file. [EBADF]. }
InvalidHandle = BL_ERROR_INVALID_HANDLE,
{ Value too large [EOVERFLOW]. }
ValueTooLarge = BL_ERROR_VALUE_TOO_LARGE,
{ Not initialized (some instance is built-in none when it shouldn't be). }
NotInitialized = BL_ERROR_NOT_INITIALIZED,
{ Not implemented [ENOSYS]. }
NotImplemented = BL_ERROR_NOT_IMPLEMENTED,
{ Operation not permitted [EPERM]. }
NotPermitted = BL_ERROR_NOT_PERMITTED,
{ IO error [EIO]. }
IOError = BL_ERROR_IO,
{ Device or resource busy [EBUSY]. }
Busy = BL_ERROR_BUSY,
{ Operation interrupted [EINTR]. }
Interrupted = BL_ERROR_INTERRUPTED,
{ Try again [EAGAIN]. }
TryAgain = BL_ERROR_TRY_AGAIN,
{ Timed out [ETIMEDOUT]. }
TimedOut = BL_ERROR_TIMED_OUT,
{ Broken pipe [EPIPE]. }
BrokenPipe = BL_ERROR_BROKEN_PIPE,
{ File is not seekable [ESPIPE]. }
InvalidSeek = BL_ERROR_INVALID_SEEK,
{ Too many levels of symlinks [ELOOP]. }
SymlinkLoop = BL_ERROR_SYMLINK_LOOP,
{ File is too large [EFBIG]. }
FileTooLarge = BL_ERROR_FILE_TOO_LARGE,
{ File/directory already exists [EEXIST]. }
AlreadyExists = BL_ERROR_ALREADY_EXISTS,
{ Access denied [EACCES]. }
AccessDenied = BL_ERROR_ACCESS_DENIED,
{ Media changed [Windows::ERROR_MEDIA_CHANGED]. }
MediaChanged = BL_ERROR_MEDIA_CHANGED,
{ The file/FS is read-only [EROFS]. }
ReadOnlyFS = BL_ERROR_READ_ONLY_FS,
{ Device doesn't exist [ENXIO]. }
NoDevice = BL_ERROR_NO_DEVICE,
{ Not found, no entry (fs) [ENOENT]. }
NoEntry = BL_ERROR_NO_ENTRY,
{ No media in drive/device [ENOMEDIUM]. }
NoMedia = BL_ERROR_NO_MEDIA,
{ No more data / end of file [ENODATA]. }
NoMoreData = BL_ERROR_NO_MORE_DATA,
{ No more files [ENMFILE]. }
NoMoreFiles = BL_ERROR_NO_MORE_FILES,
{ No space left on device [ENOSPC]. }
NoSpaceLeft = BL_ERROR_NO_SPACE_LEFT,
{ Directory is not empty [ENOTEMPTY]. }
NotEmpty = BL_ERROR_NOT_EMPTY,
{ Not a file [EISDIR]. }
NotFile = BL_ERROR_NOT_FILE,
{ Not a directory [ENOTDIR]. }
NotDirectory = BL_ERROR_NOT_DIRECTORY,
{ Not same device [EXDEV]. }
NotSameDevice = BL_ERROR_NOT_SAME_DEVICE,
{ Not a block device [ENOTBLK]. }
NotBlockDevice = BL_ERROR_NOT_BLOCK_DEVICE,
{ File/path name is invalid [n/a]. }
InvalidFilename = BL_ERROR_INVALID_FILE_NAME,
{ File/path name is too long [ENAMETOOLONG]. }
FilenameTooLong = BL_ERROR_FILE_NAME_TOO_LONG,
{ Too many open files [EMFILE]. }
TooManyOpenFiles = BL_ERROR_TOO_MANY_OPEN_FILES,
{ Too many open files by OS [ENFILE]. }
TooManyOpenFilesByOS = BL_ERROR_TOO_MANY_OPEN_FILES_BY_OS,
{ Too many symbolic links on FS [EMLINK]. }
TooManyLinks = BL_ERROR_TOO_MANY_LINKS,
{ Too many threads [EAGAIN]. }
TooManyThreads = BL_ERROR_TOO_MANY_THREADS,
{ File is empty (not specific to any OS error). }
FileEmpty = BL_ERROR_FILE_EMPTY,
{ File open failed [Windows::ERROR_OPEN_FAILED]. }
OpenFailed = BL_ERROR_OPEN_FAILED,
{ Not a root device/directory [Windows::ERROR_DIR_NOT_ROOT]. }
NotRootDevice = BL_ERROR_NOT_ROOT_DEVICE,
{ Unknown system error that failed to translate to Blend2D result code. }
UnknownSystemError = BL_ERROR_UNKNOWN_SYSTEM_ERROR,
{ Invalid data alignment. }
InvalidArgument = BL_ERROR_INVALID_ALIGNMENT,
{ Invalid data signature or header. }
InvalidSignature = BL_ERROR_INVALID_SIGNATURE,
{ Invalid or corrupted data. }
InvalidData = BL_ERROR_INVALID_DATA,
{ Invalid string (invalid data of either UTF8, UTF16, or UTF32). }
InvalidString = BL_ERROR_INVALID_STRING,
{ Truncated data (more data required than memory/stream provides). }
DataTruncated = BL_ERROR_DATA_TRUNCATED,
{ Input data too large to be processed. }
DataTooLarge = BL_ERROR_DATA_TOO_LARGE,
{ Decompression failed due to invalid data (RLE, Huffman, etc). }
DecompressionFailed = BL_ERROR_DECOMPRESSION_FAILED,
{ Invalid geometry (invalid path data or shape). }
InvalidGeometry = BL_ERROR_INVALID_GEOMETRY,
{ Returned when there is no matching vertex in path data. }
NoMatchingVertex = BL_ERROR_NO_MATCHING_VERTEX,
{ No matching cookie (BLContext). }
NoMatchingCookie = BL_ERROR_NO_MATCHING_COOKIE,
{ No states to restore (BLContext). }
NoStatesToRestore = BL_ERROR_NO_STATES_TO_RESTORE,
{ The size of the image is too large. }
ImageTooBig = BL_ERROR_IMAGE_TOO_LARGE,
{ Image codec for a required format doesn't exist. }
ImageNoMatchingCodec = BL_ERROR_IMAGE_NO_MATCHING_CODEC,
{ Unknown or invalid file format that cannot be read. }
ImageUnknownFileFormat = BL_ERROR_IMAGE_UNKNOWN_FILE_FORMAT,
{ Image codec doesn't support reading the file format. }
ImageDecoderNotProvided = BL_ERROR_IMAGE_DECODER_NOT_PROVIDED,
{ Image codec doesn't support writing the file format. }
ImageEncoderNotProvided = BL_ERROR_IMAGE_ENCODER_NOT_PROVIDED,
{ Multiple IHDR chunks are not allowed (PNG). }
PngMultipleIHDR = BL_ERROR_PNG_MULTIPLE_IHDR,
{ Invalid IDAT chunk (PNG). }
PngInvalidIDAT = BL_ERROR_PNG_INVALID_IDAT,
{ Invalid IEND chunk (PNG). }
PngInvalidIEND = BL_ERROR_PNG_INVALID_IEND,
{ Invalid PLTE chunk (PNG). }
PngInvalidPLTE = BL_ERROR_PNG_INVALID_PLTE,
{ Invalid tRNS chunk (PNG). }
PngInvalidTRNS = BL_ERROR_PNG_INVALID_TRNS,
{ Invalid filter type (PNG). }
PngInvalidFilter = BL_ERROR_PNG_INVALID_FILTER,
{ Unsupported feature (JPEG). }
JpegUnsupportedFeature = BL_ERROR_JPEG_UNSUPPORTED_FEATURE,
{ Invalid SOS marker or header (JPEG). }
JpegInvalidSOS = BL_ERROR_JPEG_INVALID_SOS,
{ Invalid SOF marker (JPEG). }
JpegInvalidSOF = BL_ERROR_JPEG_INVALID_SOF,
{ Multiple SOF markers (JPEG). }
JpegMultipleSOF = BL_ERROR_JPEG_MULTIPLE_SOF,
{ Unsupported SOF marker (JPEG). }
JpegUnsupportedSOF = BL_ERROR_JPEG_UNSUPPORTED_SOF,
{ Font has no character to glyph mapping data. }
FontNoCharacterMapping = BL_ERROR_FONT_NO_CHARACTER_MAPPING,
{ Font has missing an important table. }
FontMissingImportantTable = BL_ERROR_FONT_MISSING_IMPORTANT_TABLE,
{ Font feature is not available. }
FontFeatureNotAvailable = BL_ERROR_FONT_FEATURE_NOT_AVAILABLE,
{ Font has an invalid CFF data. }
FontCFFInvalidData = BL_ERROR_FONT_CFF_INVALID_DATA,
{ Font program terminated because the execution reached the limit. }
FontProgramTerminated = BL_ERROR_FONT_PROGRAM_TERMINATED,
{ Invalid glyph identifier. }
InvalidGlyph = BL_ERROR_INVALID_GLYPH);
type
_TBLResultCodeHelper = record helper for TBLResultCode
public
function ToString: String;
end;
{ ============================================================================
[Error Handling - Handlers]
============================================================================ }
type
{ Type of exception that is raised for Blend2D errors.
Exceptions are enabled by default, but can be disabled using
BLSetErrorHandler. }
EBlend2DError = class(Exception)
{$REGION 'Internal Declarations'}
private
FResultCode: TBLResultCode;
{$ENDREGION 'Internal Declarations'}
public
constructor Create(const AResultCode: TBLResultCode);
{ The Blend2D result code }
property ResultCode: TBLResultCode read FResultCode;
end;
type
{ Type of procedure that is called when a Blend2D error occurs.
Parameters:
AResultCode: the Blend2D result code
AUserData: any user data passed to BLSetErrorHandler. }
TBLErrorHandler = procedure(const AResultCode: TBLResultCode;
const AUserData: Pointer);
{ Sets a Blend2D error handler.
Parameters:
AHandler: the error handler that is called when a Blend2D error occurs.
AUserData: any data you want to pass to the handler.
The default error handler raises an exception of type EBlend2DError.
You can disable error handling completely by setting AHandler to nil. In that
case, there is no way to know if and when an error occured.
The following procedures can be used to set some default error handlers:
* BLSetExceptionErrorHandler: sets the error handler to a procedure that
raises an exception when a Blend2D error occurs. This is the default
behavior.
* BLSetGetLastErrorHandler: sets the error handler to a procedure that sets
a global error variable when a Blend2D error occurs. You can then use
BLGetLastError to retrieve this error code. }
procedure BLSetErrorHandler(const AHandler: TBLErrorHandler;
const AUserData: Pointer);
{ Sets the error handler to a procedure that raises an exception when a Blend2D
error occurs. This is the default behavior. }
procedure BLSetExceptionErrorHandler;
{ Sets the error handler to a procedure that sets a global error variable when a
Blend2D error occurs. You can then use BLGetLastError to retrieve this error
code. }
procedure BLSetGetLastErrorHandler;
{ Retrieves the last Blend2D error, or TBLResultCode.Success if there was
none.
After this call, the last error is reset to TBLResultCode.Success.
This function should only be used when BLSetGetLastErrorHandler has been
called. Otherwise, it always returns TBLResultCode.Success.
This function is not thread-safe. If Blend2D is used from multiple threads,
the returned value can be from any thread. }
function BLGetLastError: TBLResultCode;
{$ENDREGION 'Error Handling'}
{$REGION 'General'}
{ ============================================================================
[General - Types]
============================================================================ }
type
{ Tag is a 32-bit integer consisting of 4 characters in the following format:
Tag := (A shl 24) or (B shl 16) or (C shl 8) or D
Tags are used extensively by OpenType fonts and other binary formats like
PNG. In most cases TAGs should only contain ASCII letters, digits, and
spaces.
Blend2D uses TBLTag in public and internal APIs to distinguish between a
regular UInt32 and tag. }
TBLTag = BLTag;
type
{ A type used to store a pack of bits.
BitWord should be equal in size to a machine word. }
TBLBitWord = BLBitWord;
{ ============================================================================
[General - Enums]
============================================================================ }
type
{ Boolean operator. }
TBLBooleanOp = (
{ Result = B. }
Copy = BL_BOOLEAN_OP_COPY,
{ Result = A and B. }
&And = BL_BOOLEAN_OP_AND,
{ Result = A or B. }
&Or = BL_BOOLEAN_OP_OR,
{ Result = A xor B. }
&Xor = BL_BOOLEAN_OP_XOR,
{ Result = A and not B. }
Sub = BL_BOOLEAN_OP_SUB);
type
{ Extend mode. }
TBLExtendMode = (
{ Pad extend [default]. }
Pad = BL_EXTEND_MODE_PAD,
{ Repeat extend. }
&Repeat = BL_EXTEND_MODE_REPEAT,
{ Reflect extend. }
Reflect = BL_EXTEND_MODE_REFLECT,
{ Alias to Pad. }
PadXPadY = BL_EXTEND_MODE_PAD_X_PAD_Y,
{ Alias to Repeat. }
RepeatXRepeatY = BL_EXTEND_MODE_REPEAT_X_REPEAT_Y,
{ Alias to Reflect. }
ReflectXReflectY = BL_EXTEND_MODE_REFLECT_X_REFLECT_Y,
{ Pad X and repeat Y. }
PadXRepeatY = BL_EXTEND_MODE_PAD_X_REPEAT_Y,
{ Pad X and reflect Y. }
PadXReflectY = BL_EXTEND_MODE_PAD_X_REFLECT_Y,
{ Repeat X and pad Y. }
RepeatXPadY = BL_EXTEND_MODE_REPEAT_X_PAD_Y,
{ Repeat X and reflect Y. }
RepeatXReflectY = BL_EXTEND_MODE_REPEAT_X_REFLECT_Y,
{ Reflect X and pad Y. }
ReflectXPadY = BL_EXTEND_MODE_REFLECT_X_PAD_Y,
{ Reflect X and repeat Y. }
ReflectXRepeatY = BL_EXTEND_MODE_REFLECT_X_REPEAT_Y);
type
{ Style type. }
TBLStyleType = (
{ No style, nothing will be paint. }
None = BL_STYLE_TYPE_NONE,
{ Solid color style. }
Solid = BL_STYLE_TYPE_SOLID,
{ Pattern style. }
Pattern = BL_STYLE_TYPE_PATTERN,
{ Gradient style. }
Gradient = BL_STYLE_TYPE_GRADIENT);
type
{ Text encoding. }
TBLTextEncoding = (
{ UTF-8 encoding. }
UTF8 = BL_TEXT_ENCODING_UTF8,
{ UTF-16 encoding (native endian). }
UTF16 = BL_TEXT_ENCODING_UTF16,
{ UTF-32 encoding (native endian). }
UTF32 = BL_TEXT_ENCODING_UTF32,
{ LATIN1 encoding (one byte per character). }
Latin1 = BL_TEXT_ENCODING_LATIN1);
{ ============================================================================
[BLRange]
============================================================================ }
type
{ Provides start and end indexes. It's used to specify a range of an operation
related to indexed containers like IBLPath, IBLGradient, etc... }
TBLRange = record
{$REGION 'Internal Declarations'}
private
FHandle: BLRange;
function GetFinish: Integer; inline;
function GetStart: Integer; inline;
procedure SetFinish(const AValue: Integer); inline;
procedure SetStart(const AValue: Integer); inline;
{$ENDREGION 'Internal Declarations'}
public
class operator Equal(const ALeft, ARight: TBLRange): Boolean; inline; static;
class operator NotEqual(const ALeft, ARight: TBLRange): Boolean; inline; static;
public
procedure Reset; overload; inline;
procedure Reset(const AStart, AFinish: Integer); overload; inline;
function Equals(const AOther: TBLRange): Boolean; inline;
property Start: Integer read GetStart write SetStart;
property Finish: Integer read GetFinish write SetFinish;
end;
PBLRange = ^TBLRange;
function BLRange(const AStart, AFinish: Integer): TBLRange; inline;
{$ENDREGION 'General'}
{$REGION 'Array'}
{ ============================================================================
[BLArrayView]
============================================================================ }
type
{ Array view }
TBLArrayView<T> = record
public type
P = ^T;
{$REGION 'Internal Declarations'}
private
FHandle: BLArrayView;
function GetLast: Pointer; inline;
function GetLength: Integer; inline;
{$ENDREGION 'Internal Declarations'}
public
procedure Reset; overload; inline;
procedure Reset(const AData: Pointer; const ALength: Integer); overload; inline;
property Data: Pointer read FHandle.data;
property First: Pointer read FHandle.data;
property Last: Pointer read GetLast;
property Length: Integer read GetLength;
end;
{$ENDREGION 'Array'}
{$REGION 'Color'}
{ ============================================================================
[BLRgba32]
============================================================================ }
type
{ 32-bit RGBA color (8-bit per component) stored as $AARRGGBB. }
TBLRgba32 = record
{$REGION 'Internal Declarations'}
private
FHandle: BLRgba32;
function GetIsOpaque: Boolean; inline;
function GetIsTransparent: Boolean; inline;
{$ENDREGION 'Internal Declarations'}
public
class operator Implicit(const AValue: Cardinal): TBLRgba32; inline; static;
class operator Implicit(const AValue: TBLRgba32): Cardinal; inline; static;
class operator Equal(const ALeft, ARight: TBLRgba32): Boolean; inline; static;
class operator NotEqual(const ALeft, ARight: TBLRgba32): Boolean; inline; static;
public
procedure Reset; overload; inline;
procedure Reset(const AValue: Cardinal); overload; inline;
procedure Reset(const AR, AG, AB: Byte; const AA: Byte = 255); overload; inline;
property R: Byte read FHandle.r write FHandle.r;
property G: Byte read FHandle.g write FHandle.g;
property B: Byte read FHandle.b write FHandle.b;
property A: Byte read FHandle.a write FHandle.a;
property Value: Cardinal read FHandle.value write FHandle.value;
property IsOpaque: Boolean read GetIsOpaque;
property IsTransparent: Boolean read GetIsTransparent;
end;
PBLRgba32 = ^TBLRgba32;
function BLRgba32: TBLRgba32; overload; inline;
function BLRgba32(const AValue: Cardinal): TBLRgba32; overload; inline;
function BLRgba32(const AR, AG, AB: Byte; const AA: Byte = 255): TBLRgba32; overload; inline;
{ ============================================================================
[BLRgba64]
============================================================================ }
type
{ 64-bit RGBA color (16-bit per component) stored as $AAAARRRRGGGGBBBB. }
TBLRgba64 = record
{$REGION 'Internal Declarations'}
private
FHandle: BLRgba64;
function GetIsOpaque: Boolean; inline;
function GetIsTransparent: Boolean; inline;
{$ENDREGION 'Internal Declarations'}
public
class operator Implicit(const AValue: UInt64): TBLRgba64; inline; static;
class operator Implicit(const AValue: TBLRgba64): UInt64; inline; static;
class operator Equal(const ALeft, ARight: TBLRgba64): Boolean; inline; static;
class operator NotEqual(const ALeft, ARight: TBLRgba64): Boolean; inline; static;
public
procedure Reset; overload; inline;
procedure Reset(const AValue: UInt64); overload; inline;
procedure Reset(const AR, AG, AB: Word; const AA: Word = $FFFF); overload; inline;
procedure Reset(const AValue: TBLRgba32); overload; inline;
property R: Word read FHandle.r write FHandle.r;
property G: Word read FHandle.g write FHandle.g;
property B: Word read FHandle.b write FHandle.b;
property A: Word read FHandle.a write FHandle.a;
property Value: UInt64 read FHandle.value write FHandle.value;
property IsOpaque: Boolean read GetIsOpaque;
property IsTransparent: Boolean read GetIsTransparent;
end;
PBLRgba64 = ^TBLRgba64;
function BLRgba64: TBLRgba64; overload; inline;
function BLRgba64(const AValue: UInt64): TBLRgba64; overload; inline;
function BLRgba64(const AR, AG, AB: Word; const AA: Word = $FFFF): TBLRgba64; overload; inline;
function BLRgba64(const AValue: TBLRgba32): TBLRgba64; overload; inline;
type
{ Adds TBLRgba32 <-> TBLRgba64 conversion }
_TBLRgba32Helper = record helper for TBLRgba32
public
procedure Reset(const AValue: TBLRgba64); overload; inline;
end;
function BLRgba32(const AValue: TBLRgba64): TBLRgba32; overload; inline;
{ ============================================================================
[BLRgba128]
============================================================================ }
type
{ 128-bit RGBA color stored as 4 32-bit floating point values in [RGBA] order. }
TBLRgba128 = record
{$REGION 'Internal Declarations'}
private
FHandle: BLRgba128;
function GetIsOpaque: Boolean; inline;
function GetIsTransparent: Boolean; inline;
{$ENDREGION 'Internal Declarations'}
public
class operator Equal(const ALeft, ARight: TBLRgba128): Boolean; inline; static;
class operator NotEqual(const ALeft, ARight: TBLRgba128): Boolean; inline; static;
public
procedure Reset; overload; inline;
procedure Reset(const AR, AG, AB: Single; const AA: Single = 1); overload; inline;
property R: Single read FHandle.r write FHandle.r;
property G: Single read FHandle.g write FHandle.g;
property B: Single read FHandle.b write FHandle.b;
property A: Single read FHandle.a write FHandle.a;
property IsOpaque: Boolean read GetIsOpaque;
property IsTransparent: Boolean read GetIsTransparent;
end;
PBLRgba128 = ^TBLRgba128;
function BLRgba128: TBLRgba128; overload; inline;
function BLRgba128(const AR, AG, AB: Single; const AA: Single = 1): TBLRgba128; overload; inline;
{$ENDREGION 'Color'}
{$REGION 'File System'}
{ ============================================================================
[Enums]
============================================================================ }
type
{ File read flags used by IBLFileSystem.ReadFile. }
TBLFileReadFlag = (
{ Use memory mapping to read the content of the file.
The destination buffer would be configured to use the memory mapped buffer
instead of allocating its own. }
MmapEnabled = 0,
{ Avoid memory mapping of small files.
The size of small file is determined by Blend2D, however, you should
expect it to be 16kB or 64kB depending on host operating system. }
MmapAvoidSmall = 1,
{ Do not fallback to regular read if memory mapping fails. It's worth noting
that memory mapping would fail for files stored on filesystem that is not
local (like a mounted network filesystem, etc...). }
MmapNoFallback = 3);
TBLFileReadFlags = set of TBLFileReadFlag;
{$ENDREGION 'File System'}
{$REGION 'Geometry'}
{ ============================================================================
[Enums]
============================================================================ }
type
{ Direction of a geometry used by geometric primitives and paths. }
TBLGeometryDirection = (
{ No direction specified. }
None = BL_GEOMETRY_DIRECTION_NONE,
{ Clockwise direction. }
CW = BL_GEOMETRY_DIRECTION_CW,
{ Counter-clockwise direction. }
CCW = BL_GEOMETRY_DIRECTION_CCW);
type
{ Geometry type.
Geometry describes a shape or path that can be either rendered or added to
a BLPath container. Both IBLPath and IBLContext provide functionality to
work with all geometry types. Please note that each type provided here
requires to pass a matching record to the function that consumes
AGeometryType and AGeometryData arguments. }
TBLGeometryType = (
{ No geometry provided. }
None = BL_GEOMETRY_TYPE_NONE,
{ TBLBoxI record. }
BoxI = BL_GEOMETRY_TYPE_BOXI,
{ TBLBox record. }
BoxD = BL_GEOMETRY_TYPE_BOXD,
{ TBLRectI record. }
RectI = BL_GEOMETRY_TYPE_RECTI,
{ TBLRect record. }
RectD = BL_GEOMETRY_TYPE_RECTD,
{ TBLCircle record. }
Circle = BL_GEOMETRY_TYPE_CIRCLE,
{ TBLEllipse record. }
Ellipse = BL_GEOMETRY_TYPE_ELLIPSE,
{ TBLRoundRect record. }
RoundRect = BL_GEOMETRY_TYPE_ROUND_RECT,
{ TBLArc record. }
Arc = BL_GEOMETRY_TYPE_ARC,
{ TBLArc record representing chord. }
Chord = BL_GEOMETRY_TYPE_CHORD,
{ TBLArc record representing pie. }
Pie = BL_GEOMETRY_TYPE_PIE,
{ TBLLine record. }
Line = BL_GEOMETRY_TYPE_LINE,
{ TBLTriangle record. }
Triangle = BL_GEOMETRY_TYPE_TRIANGLE,
{ TBLArrayView<TBLPointI> representing a polyline. }
PolylineI = BL_GEOMETRY_TYPE_POLYLINEI,
{ TBLArrayView<TBLPoint> representing a polyline. }
PolylineD = BL_GEOMETRY_TYPE_POLYLINED,
{ TBLArrayView<TBLPointI> representing a polygon. }
PolygonI = BL_GEOMETRY_TYPE_POLYGONI,
{ TBLArrayView<TBLPoint> representing a polygon. }
PolygonD = BL_GEOMETRY_TYPE_POLYGOND,
{ TBLArrayView<TBLBoxI> record. }
ArrayViewBoxI = BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXI,
{ TBLArrayView<TBLBox> struct. }
ArrayViewBoxD = BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXD,
{ TBLArrayView<TBLRectI> record. }
ArrayviewRectI = BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTI,
{ TBLArrayView<TBLRect> record. }
ArrayViewRectD = BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTD,
{ IBLPath. }
Path = BL_GEOMETRY_TYPE_PATH,
{ IBLRegion. }
Region = BL_GEOMETRY_TYPE_REGION);
type
{ Fill rule. }
TBLFillRule = (
{ Non-zero fill-rule. }
NonZero = BL_FILL_RULE_NON_ZERO,
{ Even-odd fill-rule. }
EvenOdd = BL_FILL_RULE_EVEN_ODD);
type
{ Hit-test result. }
TBLHitTest = (
{ Fully in. }
FullyIn = BL_HIT_TEST_IN,
{ Partially in/out. }
PartiallyIn = BL_HIT_TEST_PART,
{ Fully out. }
FullyOut = BL_HIT_TEST_OUT,
{ Hit test failed (invalid argument, NaNs, etc). }
Invalid = BL_HIT_TEST_INVALID);
{ ============================================================================
[BLPointI]
============================================================================ }
type
{ Point specified as [x, y] using Integer as a storage type. }
TBLPointI = record
{$REGION 'Internal Declarations'}
private
FHandle: BLPointI;
{$ENDREGION 'Internal Declarations'}
public
class operator Equal(const ALeft, ARight: TBLPointI): Boolean; inline; static;
class operator NotEqual(const ALeft, ARight: TBLPointI): Boolean; inline; static;
class operator Negative(const AValue: TBLPointI): TBLPointI; inline; static;
class operator Add(const ALeft: TBLPointI; const ARight: Integer): TBLPointI; inline; static;
class operator Add(const ALeft: Integer; const ARight: TBLPointI): TBLPointI; inline; static;
class operator Add(const ALeft, ARight: TBLPointI): TBLPointI; inline; static;
class operator Subtract(const ALeft: TBLPointI; const ARight: Integer): TBLPointI; inline; static;
class operator Subtract(const ALeft: Integer; const ARight: TBLPointI): TBLPointI; inline; static;
class operator Subtract(const ALeft, ARight: TBLPointI): TBLPointI; inline; static;
class operator Multiply(const ALeft: TBLPointI; const ARight: Integer): TBLPointI; inline; static;
class operator Multiply(const ALeft: Integer; const ARight: TBLPointI): TBLPointI; inline; static;
class operator Multiply(const ALeft, ARight: TBLPointI): TBLPointI; inline; static;
class operator IntDivide(const ALeft: TBLPointI; const ARight: Integer): TBLPointI; inline; static;
class operator IntDivide(const ALeft: Integer; const ARight: TBLPointI): TBLPointI; inline; static;
class operator IntDivide(const ALeft, ARight: TBLPointI): TBLPointI; inline; static;
public
procedure Reset; overload; inline;
procedure Reset(const AX, AY: Integer); overload; inline;
function Equals(const AOther: TBLPointI): Boolean; inline;
property X: Integer read FHandle.x write FHandle.x;
property Y: Integer read FHandle.y write FHandle.y;
end;
PBLPointI = ^TBLPointI;
function BLPointI: TBLPointI; overload; inline;
function BLPointI(const AX, AY: Integer): TBLPointI; overload; inline;
{ ============================================================================
[SizeI]
============================================================================ }
type
{ Size specified as [w, h] using Integer as a storage type. }
TBLSizeI = record
{$REGION 'Internal Declarations'}
private
FHandle: BLSizeI;
{$ENDREGION 'Internal Declarations'}
public
class operator Equal(const ALeft, ARight: TBLSizeI): Boolean; inline; static;
class operator NotEqual(const ALeft, ARight: TBLSizeI): Boolean; inline; static;
public
procedure Reset; overload; inline;
procedure Reset(const AW, AH: Integer); overload; inline;
function Equals(const AOther: TBLSizeI): Boolean; inline;
property W: Integer read FHandle.w write FHandle.w;
property H: Integer read FHandle.h write FHandle.h;
end;
PBLSizeI = ^TBLSizeI;
function BLSizeI: TBLSizeI; overload; inline;
function BLSizeI(const AW, AH: Integer): TBLSizeI; overload; inline;
{ ============================================================================
[BLBoxI]
============================================================================ }
type
{ Box specified as [x0, y0, x1, y1] using Integer as a storage type. }
TBLBoxI = record
{$REGION 'Internal Declarations'}
private
FHandle: BLBoxI;
function GetHeight: Integer; inline;
function GetWidth: Integer; inline;
procedure SetHeight(const AValue: Integer); inline;
procedure SetWidth(const AValue: Integer); inline;
{$ENDREGION 'Internal Declarations'}
public
class operator Equal(const ALeft, ARight: TBLBoxI): Boolean; inline; static;
class operator NotEqual(const ALeft, ARight: TBLBoxI): Boolean; inline; static;
public
procedure Reset; overload; inline;
procedure Reset(const AX0, AY0, AX1, AY1: Integer); overload; inline;
function Equals(const AOther: TBLBoxI): Boolean; inline;
function Contains(const AX, AY: Integer): Boolean; overload; inline;
function Contains(const AP: TBLPointI): Boolean; overload; inline;
property X0: Integer read FHandle.x0 write FHandle.x0;
property Y0: Integer read FHandle.y0 write FHandle.y0;
property X1: Integer read FHandle.x1 write FHandle.x1;
property Y1: Integer read FHandle.y1 write FHandle.y1;
property Width: Integer read GetWidth write SetWidth;
property Height: Integer read GetHeight write SetHeight;
end;
PBLBoxI = ^TBLBoxI;
function BLBoxI: TBLBoxI; overload; inline;
function BLBoxI(const AX0, AY0, AX1, AY1: Integer): TBLBoxI; overload; inline;
{ ============================================================================
[BLRectI]
============================================================================ }
type
{ Rectangle specified as [x, y, w, h] using Integer as a storage type. }
TBLRectI = record
{$REGION 'Internal Declarations'}
private
FHandle: BLRectI;
{$ENDREGION 'Internal Declarations'}
public
class operator Equal(const ALeft, ARight: TBLRectI): Boolean; inline; static;
class operator NotEqual(const ALeft, ARight: TBLRectI): Boolean; inline; static;
public
procedure Reset; overload; inline;
procedure Reset(const AX, AY, AW, AH: Integer); overload; inline;
function Equals(const AOther: TBLRectI): Boolean; inline;
property X: Integer read FHandle.x write FHandle.x;
property Y: Integer read FHandle.y write FHandle.y;
property W: Integer read FHandle.w write FHandle.w;
property H: Integer read FHandle.h write FHandle.h;
end;
PBLRectI = ^TBLRectI;
function BLRectI: TBLRectI; overload; inline;
function BLRectI(const AX, AY, AW, AH: Integer): TBLRectI; overload; inline;
{ ============================================================================
[BLPoint]
============================================================================ }
type
{ Point specified as [x, y] using Double as a storage type. }
TBLPoint = record
{$REGION 'Internal Declarations'}
private
FHandle: BLPoint;
{$ENDREGION 'Internal Declarations'}
public
class operator Equal(const ALeft, ARight: TBLPoint): Boolean; inline; static;
class operator NotEqual(const ALeft, ARight: TBLPoint): Boolean; inline; static;
class operator Negative(const AValue: TBLPoint): TBLPoint; inline; static;
class operator Add(const ALeft: TBLPoint; const ARight: Double): TBLPoint; inline; static;
class operator Add(const ALeft: Double; const ARight: TBLPoint): TBLPoint; inline; static;
class operator Add(const ALeft, ARight: TBLPoint): TBLPoint; inline; static;
class operator Subtract(const ALeft: TBLPoint; const ARight: Double): TBLPoint; inline; static;
class operator Subtract(const ALeft: Double; const ARight: TBLPoint): TBLPoint; inline; static;
class operator Subtract(const ALeft, ARight: TBLPoint): TBLPoint; inline; static;
class operator Multiply(const ALeft: TBLPoint; const ARight: Double): TBLPoint; inline; static;
class operator Multiply(const ALeft: Double; const ARight: TBLPoint): TBLPoint; inline; static;
class operator Multiply(const ALeft, ARight: TBLPoint): TBLPoint; inline; static;
class operator Divide(const ALeft: TBLPoint; const ARight: Double): TBLPoint; inline; static;
class operator Divide(const ALeft: Double; const ARight: TBLPoint): TBLPoint; inline; static;
class operator Divide(const ALeft, ARight: TBLPoint): TBLPoint; inline; static;
public
procedure Reset; overload; inline;
procedure Reset(const AX, AY: Double); overload; inline;
function Equals(const AOther: TBLPoint): Boolean; inline;
property X: Double read FHandle.x write FHandle.x;
property Y: Double read FHandle.y write FHandle.y;
end;
PBLPoint = ^TBLPoint;
function BLPoint: TBLPoint; overload; inline;
function BLPoint(const AX, AY: Double): TBLPoint; overload; inline;
{ ============================================================================
[Size]
============================================================================ }
type
{ Size specified as [w, h] using Double as a storage type. }
TBLSize = record
{$REGION 'Internal Declarations'}
private
FHandle: BLSize;
{$ENDREGION 'Internal Declarations'}
public
class operator Equal(const ALeft, ARight: TBLSize): Boolean; inline; static;
class operator NotEqual(const ALeft, ARight: TBLSize): Boolean; inline; static;
public
procedure Reset; overload; inline;
procedure Reset(const AW, AH: Double); overload; inline;
function Equals(const AOther: TBLSize): Boolean; inline;
property W: Double read FHandle.w write FHandle.w;
property H: Double read FHandle.h write FHandle.h;