forked from Tencent/libpag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile.h
2289 lines (1808 loc) · 53.7 KB
/
file.h
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
/////////////////////////////////////////////////////////////////////////////////////////////////
//
// Tencent is pleased to support the open source community by making libpag available.
//
// Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// unless required by applicable law or agreed to in writing, software distributed under the
// license is distributed on an "as is" basis, without warranties or conditions of any kind,
// either express or implied. see the license for the specific language governing permissions
// and limitations under the license.
//
/////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <atomic>
#include <mutex>
#include "pag/types.h"
#ifdef PAG_USE_RTTR
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
#include "rttr/array_range.h"
#include "rttr/constructor.h"
#include "rttr/destructor.h"
#include "rttr/enum_flags.h"
#include "rttr/enumeration.h"
#include "rttr/library.h"
#include "rttr/method.h"
#include "rttr/property.h"
#include "rttr/rttr_cast.h"
#include "rttr/rttr_enable.h"
#include "rttr/type.h"
#pragma clang diagnostic pop
#else
#define RTTR_ENABLE(...)
#endif
namespace pag {
/**
* The maximum number of type is 1023. It only allows to add new tag to the end before
* TagCode::Count.
*/
enum class TagCode {
End = 0,
FontTables = 1,
VectorCompositionBlock = 2,
CompositionAttributes = 3,
ImageTables = 4,
LayerBlock = 5,
LayerAttributes = 6,
SolidColor = 7,
TextSource = 8,
TextMoreOption = 10,
ImageReference = 11,
CompositionReference = 12,
Transform2D = 13,
MaskBlock = 14,
ShapeGroup = 15,
Rectangle = 16,
Ellipse = 17,
PolyStar = 18,
ShapePath = 19,
Fill = 20,
Stroke = 21,
GradientFill = 22,
GradientStroke = 23,
MergePaths = 24,
TrimPaths = 25,
Repeater = 26,
RoundCorners = 27,
Performance = 28,
DropShadowStyle = 29,
CachePolicy = 30,
FileAttributes = 31,
TimeStretchMode = 32,
// 33 ~ 44 are preserved
BitmapCompositionBlock = 45,
BitmapSequence = 46,
ImageBytes = 47,
ImageBytesV2 = 48, // with scaleFactor
ImageBytesV3 = 49, // width transparent border stripped.
VideoCompositionBlock = 50,
VideoSequence = 51,
LayerAttributesV2 = 52,
MarkerList = 53,
ImageFillRule = 54,
AudioBytes = 55,
MotionTileEffect = 56,
LevelsIndividualEffect = 57,
CornerPinEffect = 58,
BulgeEffect = 59,
FastBlurEffect = 60,
GlowEffect = 61,
LayerAttributesV3 = 62,
LayerAttributesExtra = 63,
TextSourceV2 = 64,
DropShadowStyleV2 = 65,
DisplacementMapEffect = 66,
ImageFillRuleV2 = 67,
TextSourceV3 = 68,
TextPathOption = 69,
TextAnimator = 70,
TextRangeSelector = 71,
TextAnimatorPropertiesTrackingType = 72,
TextAnimatorPropertiesTrackingAmount = 73,
TextAnimatorPropertiesFillColor = 74,
TextAnimatorPropertiesStrokeColor = 75,
TextAnimatorPropertiesPosition = 76,
TextAnimatorPropertiesScale = 77,
TextAnimatorPropertiesRotation = 78,
TextAnimatorPropertiesOpacity = 79,
TextWigglySelector = 80,
RadialBlurEffect = 81,
MosaicEffect = 82,
// add new tags here...
Count
};
struct Ratio {
float value() const {
return static_cast<float>(numerator) / denominator;
}
int32_t numerator;
uint32_t denominator;
};
inline bool operator==(const Ratio& left, const Ratio& right) {
return left.numerator == right.numerator &&
(left.numerator == 0 || left.denominator == right.denominator);
}
inline bool operator!=(const Ratio& left, const Ratio& right) {
return !(left == right);
}
static constexpr Ratio DefaultRatio = {1, 1};
enum class PathDataVerb { MoveTo, LineTo, CurveTo, Close };
/**
* The Path object encapsulates information describing a path in a shape layer, or the outline path
* of a Mask.
*/
class PAG_API PathData {
public:
std::vector<PathDataVerb> verbs;
std::vector<Point> points;
void moveTo(float x, float y);
void lineTo(float x, float y);
void cubicTo(float controlX1, float controlY1, float controlX2, float controlY2, float x,
float y);
/**
* If the last point does not equal with the last moveTo point, add a lineTo verb and then close
* the path.
*/
void close();
bool isClosed() const;
void reverse();
void clear();
void interpolate(const PathData& path, PathData* result, float t);
private:
Point lastMoveTo = {};
};
typedef std::shared_ptr<PathData> PathHandle;
class PAG_API KeyframeInterpolationType {
public:
static const Enum None = 0;
static const Enum Linear = 1;
static const Enum Bezier = 2;
static const Enum Hold = 3;
};
template <typename T>
class Keyframe {
public:
virtual ~Keyframe() = default;
virtual void initialize() {
}
virtual T getValueAt(Frame) {
return startValue;
}
bool containsTime(Frame time) const {
return time >= startTime && time < endTime;
}
T startValue;
T endValue;
Frame startTime = ZeroFrame;
Frame endTime = ZeroFrame;
Enum interpolationType = KeyframeInterpolationType::Hold;
std::vector<Point> bezierOut;
std::vector<Point> bezierIn;
Point spatialOut = Point::Zero();
Point spatialIn = Point::Zero();
};
/**
* The Property object contains value information about a particular AE property of a layer.
*/
template <typename T>
class Property {
public:
T value;
virtual ~Property() = default;
virtual bool animatable() const {
return false;
}
virtual T getValueAt(Frame) {
return this->value;
}
virtual void excludeVaryingRanges(std::vector<TimeRange>*) const {
}
RTTR_ENABLE()
};
Frame PAG_API ConvertFrameByStaticTimeRanges(const std::vector<TimeRange>& timeRanges, Frame frame);
void PAG_API SubtractFromTimeRanges(std::vector<TimeRange>* timeRanges, Frame startTime,
Frame endTime);
void PAG_API SplitTimeRangesAt(std::vector<TimeRange>* timeRanges, Frame startTime);
void PAG_API MergeTimeRanges(std::vector<TimeRange>* timeRanges,
const std::vector<TimeRange>* otherRanges);
std::vector<TimeRange> PAG_API OffsetTimeRanges(const std::vector<TimeRange>& timeRanges,
Frame offsetTime);
bool PAG_API HasVaryingTimeRange(const std::vector<TimeRange>* staticTimeRanges, Frame startTime,
Frame duration);
template <typename T>
class AnimatableProperty : public Property<T> {
public:
explicit AnimatableProperty(const std::vector<Keyframe<T>*>& keyframes)
: keyframes(keyframes), lastKeyframeIndex(0) {
this->value = keyframes[0]->startValue;
for (Keyframe<T>* keyframe : keyframes) {
keyframe->initialize();
}
}
~AnimatableProperty() override {
for (auto& keyframe : keyframes) {
delete keyframe;
}
}
bool animatable() const override {
return true;
}
void excludeVaryingRanges(std::vector<TimeRange>* timeRanges) const override {
for (Keyframe<T>* keyframe : keyframes) {
switch (keyframe->interpolationType) {
case KeyframeInterpolationType::Bezier:
case KeyframeInterpolationType::Linear:
SubtractFromTimeRanges(timeRanges, keyframe->startTime, keyframe->endTime - 1);
break;
default:
SplitTimeRangesAt(timeRanges, keyframe->startTime);
SplitTimeRangesAt(timeRanges, keyframe->endTime);
break;
}
}
}
T getValueAt(Frame frame) override {
T result;
Keyframe<T>* lastKeyframe = keyframes[lastKeyframeIndex];
if (lastKeyframe->containsTime(frame)) {
return lastKeyframe->getValueAt(frame);
}
if (frame < lastKeyframe->startTime) {
while (lastKeyframeIndex > 0) {
lastKeyframeIndex--;
if (keyframes[lastKeyframeIndex]->containsTime(frame)) {
break;
}
}
} else {
while (lastKeyframeIndex < keyframes.size() - 1) {
lastKeyframeIndex++;
if (keyframes[lastKeyframeIndex]->containsTime(frame)) {
break;
}
}
}
lastKeyframe = keyframes[lastKeyframeIndex];
if (frame <= lastKeyframe->startTime) {
result = lastKeyframe->startValue;
} else if (frame >= lastKeyframe->endTime) {
result = lastKeyframe->endValue;
} else {
result = lastKeyframe->getValueAt(frame);
}
return result;
}
/**
* The keyframe list in this property.
*/
std::vector<Keyframe<T>*> keyframes;
private:
std::atomic_size_t lastKeyframeIndex;
RTTR_ENABLE(Property<T>)
};
class PAG_API Transform2D {
public:
static Transform2D* MakeDefault();
~Transform2D();
Property<Point>* anchorPoint = nullptr; // spatial
Property<Point>* position = nullptr; // spatial
Property<float>* xPosition = nullptr;
Property<float>* yPosition = nullptr;
Property<Point>* scale = nullptr; // multidimensional
Property<float>* rotation = nullptr;
Property<Opacity>* opacity = nullptr;
void excludeVaryingRanges(std::vector<TimeRange>* timeRanges) const;
bool verify() const;
};
class PAG_API MaskMode {
public:
static const Enum None = 0; // mask shape does nothing
static const Enum Add = 1; // shape is added into mask (normal behavior (really screen!))
static const Enum Subtract = 2;
static const Enum Intersect = 3;
static const Enum Lighten = 4;
static const Enum Darken = 5;
static const Enum Difference = 6;
static const Enum Accum = 7; // real add, not screen (not exposed in UI!)
};
class PAG_API MaskData {
public:
~MaskData();
ID id = ZeroID;
bool inverted = false;
Enum maskMode = MaskMode::Add;
Property<PathHandle>* maskPath = nullptr;
Property<Opacity>* maskOpacity = nullptr;
Property<float>* maskExpansion = nullptr;
void excludeVaryingRanges(std::vector<TimeRange>* timeRanges) const;
bool verify() const;
};
enum class EffectType {
Unknown,
Fill,
MotionTile,
LevelsIndividual,
CornerPin,
Bulge,
FastBlur,
Glow,
DisplacementMap,
RadialBlur,
Mosaic,
};
class PAG_API Effect {
public:
Effect();
virtual ~Effect();
/**
* Returns a globally unique id for this object.
*/
ID uniqueID = 0;
virtual EffectType type() const {
return EffectType::Unknown;
}
/**
* Indicate whether this effect process only the visible area of the input texture.
*/
virtual bool processVisibleAreaOnly() const {
return false;
}
/**
* Check whether or not this effect is visible at the specified frame.
*/
virtual bool visibleAt(Frame) const {
return false;
}
/**
* Calculate the bounds after this effect being applied.
*/
virtual void transformBounds(Rect*, const Point&, Frame) const {
}
virtual void excludeVaryingRanges(std::vector<TimeRange>* timeRanges) const;
virtual bool verify() const;
Property<Opacity>* effectOpacity = nullptr;
std::vector<MaskData*> maskReferences; // mask reference
RTTR_ENABLE()
};
class PAG_API MotionTileEffect : public Effect {
public:
~MotionTileEffect() override;
EffectType type() const override {
return EffectType::MotionTile;
}
bool visibleAt(Frame layerFrame) const override;
void transformBounds(Rect* contentBounds, const Point& filterScale,
Frame layerFrame) const override;
void excludeVaryingRanges(std::vector<TimeRange>* timeRanges) const override;
bool verify() const override;
Property<Point>* tileCenter = nullptr; // spatial
Property<float>* tileWidth = nullptr;
Property<float>* tileHeight = nullptr;
Property<float>* outputWidth = nullptr;
Property<float>* outputHeight = nullptr;
Property<bool>* mirrorEdges = nullptr;
Property<float>* phase = nullptr;
Property<bool>* horizontalPhaseShift = nullptr;
RTTR_ENABLE(Effect)
};
class PAG_API LevelsIndividualEffect : public Effect {
public:
~LevelsIndividualEffect() override;
EffectType type() const override {
return EffectType::LevelsIndividual;
}
bool processVisibleAreaOnly() const override {
return true;
}
bool visibleAt(Frame layerFrame) const override;
void transformBounds(Rect* contentBounds, const Point& filterScale,
Frame layerFrame) const override;
void excludeVaryingRanges(std::vector<TimeRange>* timeRanges) const override;
bool verify() const override;
// RGB
Property<float>* inputBlack = nullptr;
Property<float>* inputWhite = nullptr;
Property<float>* gamma = nullptr;
Property<float>* outputBlack = nullptr;
Property<float>* outputWhite = nullptr;
// Red
Property<float>* redInputBlack = nullptr;
Property<float>* redInputWhite = nullptr;
Property<float>* redGamma = nullptr;
Property<float>* redOutputBlack = nullptr;
Property<float>* redOutputWhite = nullptr;
// green
Property<float>* greenInputBlack = nullptr;
Property<float>* greenInputWhite = nullptr;
Property<float>* greenGamma = nullptr;
Property<float>* greenOutputBlack = nullptr;
Property<float>* greenOutputWhite = nullptr;
// blue
Property<float>* blueInputBlack = nullptr;
Property<float>* blueInputWhite = nullptr;
Property<float>* blueGamma = nullptr;
Property<float>* blueOutputBlack = nullptr;
Property<float>* blueOutputWhite = nullptr;
RTTR_ENABLE(Effect)
};
class PAG_API CornerPinEffect : public Effect {
public:
~CornerPinEffect() override;
EffectType type() const override {
return EffectType::CornerPin;
}
bool visibleAt(Frame layerFrame) const override;
void transformBounds(Rect* contentBounds, const Point& filterScale,
Frame layerFrame) const override;
void excludeVaryingRanges(std::vector<TimeRange>* timeRanges) const override;
bool verify() const override;
Property<Point>* upperLeft = nullptr; // spatial
Property<Point>* upperRight = nullptr; // spatial
Property<Point>* lowerLeft = nullptr; // spatial
Property<Point>* lowerRight = nullptr; // spatial
RTTR_ENABLE(Effect)
};
class PAG_API BulgeEffect : public Effect {
public:
~BulgeEffect() override;
EffectType type() const override {
return EffectType::Bulge;
}
bool visibleAt(Frame layerFrame) const override;
void transformBounds(Rect* contentBounds, const Point& filterScale,
Frame layerFrame) const override;
void excludeVaryingRanges(std::vector<TimeRange>* timeRanges) const override;
bool verify() const override;
Property<float>* horizontalRadius = nullptr;
Property<float>* verticalRadius = nullptr;
Property<Point>* bulgeCenter = nullptr; // spatial
Property<float>* bulgeHeight = nullptr;
Property<float>* taperRadius = nullptr;
Property<bool>* pinning = nullptr;
RTTR_ENABLE(Effect)
};
class PAG_API BlurDimensionsDirection {
public:
static const Enum All = 0;
static const Enum Horizontal = 1;
static const Enum Vertical = 2;
};
class PAG_API FastBlurEffect : public Effect {
public:
~FastBlurEffect() override;
EffectType type() const override {
return EffectType::FastBlur;
}
bool processVisibleAreaOnly() const override {
return true;
}
bool visibleAt(Frame layerFrame) const override;
void transformBounds(Rect* contentBounds, const Point& filterScale,
Frame layerFrame) const override;
void excludeVaryingRanges(std::vector<TimeRange>* timeRanges) const override;
bool verify() const override;
Property<float>* blurriness = nullptr;
Property<Enum>* blurDimensions = nullptr;
Property<bool>* repeatEdgePixels = nullptr;
RTTR_ENABLE(Effect)
};
class PAG_API GlowEffect : public Effect {
public:
~GlowEffect() override;
EffectType type() const override {
return EffectType::Glow;
}
bool processVisibleAreaOnly() const override {
return true;
}
bool visibleAt(Frame layerFrame) const override;
void transformBounds(Rect* contentBounds, const Point& filterScale,
Frame layerFrame) const override;
void excludeVaryingRanges(std::vector<TimeRange>* timeRanges) const override;
bool verify() const override;
Property<Percent>* glowThreshold = nullptr;
Property<float>* glowRadius = nullptr;
Property<float>* glowIntensity = nullptr;
RTTR_ENABLE(Effect)
};
class PAG_API DisplacementMapSource {
public:
static const Enum Red = 0;
static const Enum Green = 1;
static const Enum Blue = 2;
static const Enum Alpha = 3;
static const Enum Luminance = 4;
static const Enum Hue = 5;
static const Enum Lightness = 6;
static const Enum Saturation = 7;
static const Enum Full = 8;
static const Enum Half = 9;
static const Enum Off = 10;
};
class DisplacementMapBehavior {
public:
static const Enum CenterMap = 0;
static const Enum StretchMapToFit = 1;
static const Enum TileMap = 2;
};
class Layer;
class PAG_API DisplacementMapEffect : public Effect {
public:
~DisplacementMapEffect() override;
EffectType type() const override {
return EffectType::DisplacementMap;
}
bool processVisibleAreaOnly() const override {
return true;
}
bool visibleAt(Frame layerFrame) const override;
void transformBounds(Rect* contentBounds, const Point& filterScale,
Frame layerFrame) const override;
void excludeVaryingRanges(std::vector<TimeRange>* timeRanges) const override;
bool verify() const override;
Layer* displacementMapLayer = nullptr; // ref layer
Property<Enum>* useForHorizontalDisplacement = nullptr; // DisplacementMapSource
Property<float>* maxHorizontalDisplacement = nullptr;
Property<Enum>* useForVerticalDisplacement = nullptr; // DisplacementMapSource
Property<float>* maxVerticalDisplacement = nullptr;
Property<Enum>* displacementMapBehavior = nullptr; // DisplacementMapBehavior
Property<bool>* edgeBehavior = nullptr;
Property<bool>* expandOutput = nullptr;
RTTR_ENABLE(Effect)
};
class PAG_API RadialBlurMode {
public:
static const Enum Spin = 0;
static const Enum Zoom = 1;
};
class PAG_API RadialBlurAntialias {
public:
static const Enum Low = 0;
static const Enum High = 1;
};
class PAG_API RadialBlurEffect : public Effect {
public:
~RadialBlurEffect() override;
EffectType type() const override {
return EffectType::RadialBlur;
}
bool processVisibleAreaOnly() const override {
return true;
}
bool visibleAt(Frame layerFrame) const override;
void transformBounds(Rect* contentBounds, const Point& filterScale,
Frame layerFrame) const override;
void excludeVaryingRanges(std::vector<TimeRange>* timeRanges) const override;
bool verify() const override;
Property<float>* amount = nullptr;
Property<Point>* center = nullptr; // spatial
Property<Enum>* mode = nullptr;
Property<Enum>* antialias = nullptr;
RTTR_ENABLE(Effect)
};
class PAG_API MosaicEffect : public Effect {
public:
~MosaicEffect() override;
EffectType type() const override {
return EffectType::Mosaic;
}
bool processVisibleAreaOnly() const override {
return true;
}
bool visibleAt(Frame layerFrame) const override;
void transformBounds(Rect* contentBounds, const Point& filterScale,
Frame layerFrame) const override;
void excludeVaryingRanges(std::vector<TimeRange>* timeRanges) const override;
bool verify() const override;
Property<uint16_t>* horizontalBlocks = nullptr;
Property<uint16_t>* verticalBlocks = nullptr; // spatial
Property<bool>* sharpColors = nullptr;
RTTR_ENABLE(Effect)
};
enum class LayerStyleType { Unknown, DropShadow, Stroke };
enum class LayerStylePosition { Above, Blow };
class PAG_API LayerStyle {
public:
LayerStyle();
virtual ~LayerStyle() = default;
/**
* Returns a globally unique id for this object.
*/
ID uniqueID = 0;
virtual LayerStyleType type() const {
return LayerStyleType::Unknown;
}
virtual LayerStylePosition drawPosition() const {
return LayerStylePosition::Blow;
}
/**
* Check whether or not this layer style is visible at the specified frame.
*/
virtual bool visibleAt(Frame) const {
return false;
}
/**
* Calculate the bounds after this layerStyle being applied.
*/
virtual void transformBounds(Rect*, const Point&, Frame) const {
}
virtual void excludeVaryingRanges(std::vector<TimeRange>*) const {
}
virtual bool verify() const {
return true;
}
RTTR_ENABLE()
};
class PAG_API StrokePosition {
public:
static const Enum Outside = 0;
static const Enum Inside = 1;
static const Enum Center = 2;
};
class PAG_API DropShadowStyle : public LayerStyle {
public:
~DropShadowStyle() override;
LayerStyleType type() const override {
return LayerStyleType::DropShadow;
}
LayerStylePosition drawPosition() const override {
return LayerStylePosition::Blow;
}
bool visibleAt(Frame layerFrame) const override;
void transformBounds(Rect* contentBounds, const Point& filterScale,
Frame layerFrame) const override;
void excludeVaryingRanges(std::vector<TimeRange>* timeRanges) const override;
bool verify() const override;
Property<Enum>* blendMode = nullptr; // BlendMode
Property<Color>* color = nullptr;
Property<Opacity>* opacity = nullptr;
Property<float>* angle = nullptr;
Property<float>* distance = nullptr;
Property<float>* size = nullptr;
Property<Percent>* spread = nullptr;
RTTR_ENABLE(LayerStyle)
};
class PAG_API StrokeStyle : public LayerStyle {
public:
~StrokeStyle() override;
LayerStyleType type() const override {
return LayerStyleType::Stroke;
}
LayerStylePosition drawPosition() const override {
return LayerStylePosition::Above;
}
bool visibleAt(Frame layerFrame) const override;
void transformBounds(Rect* contentBounds, const Point& filterScale,
Frame layerFrame) const override;
void excludeVaryingRanges(std::vector<TimeRange>* timeRanges) const override;
bool verify() const override;
Property<Enum>* blendMode = nullptr; // BlendMode
Property<Color>* color = nullptr;
Property<float>* size = nullptr;
Property<Opacity>* opacity = nullptr;
Property<Enum>* position = nullptr; // StrokePosition
RTTR_ENABLE(LayerStyle)
};
class PAG_API TextPathOptions {
public:
~TextPathOptions();
MaskData* path = nullptr; // mask reference
Property<bool>* reversedPath = nullptr;
Property<bool>* perpendicularToPath = nullptr;
Property<bool>* forceAlignment = nullptr;
Property<float>* firstMargin = nullptr;
Property<float>* lastMargin = nullptr;
void excludeVaryingRanges(std::vector<TimeRange>* timeRanges) const;
bool verify() const;
};
class PAG_API AnchorPointGrouping {
public:
static const Enum Character = 0;
static const Enum Word = 1;
static const Enum Line = 2;
static const Enum All = 3;
};
class PAG_API TextMoreOptions {
public:
~TextMoreOptions();
Enum anchorPointGrouping = AnchorPointGrouping::Character;
Property<Point>* groupingAlignment = nullptr; // multidimensional Percent
void excludeVaryingRanges(std::vector<TimeRange>* timeRanges) const;
bool verify() const;
};
class PAG_API TextRangeSelectorUnits {
public:
static const Enum Percentage = 0;
static const Enum Index = 1;
};
class PAG_API TextSelectorBasedOn {
public:
static const Enum Characters = 0;
static const Enum CharactersExcludingSpaces = 1;
static const Enum Words = 2;
static const Enum Lines = 3;
};
class PAG_API TextSelectorMode {
public:
static const Enum None = 0;
static const Enum Add = 1;
static const Enum Subtract = 2;
static const Enum Intersect = 3;
static const Enum Min = 4;
static const Enum Max = 5;
static const Enum Difference = 6;
};
class PAG_API TextRangeSelectorShape {
public:
static const Enum Square = 0;
static const Enum RampUp = 1;
static const Enum RampDown = 2;
static const Enum Triangle = 3;
static const Enum Round = 4;
static const Enum Smooth = 5;
};
class PAG_API TextAnimatorTrackingType {
public:
static const Enum BeforeAndAfter = 0;
static const Enum Before = 1;
static const Enum After = 2;
};
class PAG_API TextSelectorType {
public:
static const Enum Range = 0;
static const Enum Wiggly = 1;
static const Enum Expression = 2;
};
class PAG_API TextSelector {
public:
virtual ~TextSelector() {
}
virtual Enum type() const = 0;
virtual void excludeVaryingRanges(std::vector<TimeRange>*) const = 0;
virtual bool verify() const = 0;
};
class PAG_API TextRangeSelector : public TextSelector {
public:
~TextRangeSelector();
Enum type() const override {
return TextSelectorType::Range;
};
Property<Percent>* start = nullptr;
Property<Percent>* end = nullptr;
Property<float>* offset = nullptr;
Enum units = TextRangeSelectorUnits::Percentage;
Enum basedOn = TextSelectorBasedOn::Characters;
Property<Enum>* mode = nullptr;
Property<Percent>* amount = nullptr;
Enum shape = TextRangeSelectorShape::Square;
Property<Percent>* smoothness = nullptr;
Property<Percent>* easeHigh = nullptr;
Property<Percent>* easeLow = nullptr;
bool randomizeOrder = false;
Property<uint16_t>* randomSeed = nullptr;
void excludeVaryingRanges(std::vector<TimeRange>* timeRanges) const override;