forked from lightspark/lightspark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
swftypes.h
1237 lines (1137 loc) · 24.6 KB
/
swftypes.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
/**************************************************************************
Lightspark, a free flash player implementation
Copyright (C) 2009,2010 Alessandro Pignotti ([email protected])
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#ifndef SWFTYPES_H
#define SWFTYPES_H
#include "compat.h"
#include <llvm/System/DataTypes.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <list>
#include "logger.h"
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "exceptions.h"
#ifndef WIN32
// TODO: Proper CMake check
#include <arpa/inet.h>
#endif
namespace lightspark
{
enum STACK_TYPE{STACK_NONE=0,STACK_OBJECT,STACK_INT,STACK_UINT,STACK_NUMBER,STACK_BOOLEAN};
enum TRISTATE { TFALSE=0, TTRUE, TUNDEFINED };
typedef double number_t;
class ASObject;
class Bitmap;
class tiny_string
{
friend std::ostream& operator<<(std::ostream& s, const tiny_string& r);
private:
enum TYPE { READONLY=0, STATIC, DYNAMIC };
#define TS_SIZE 64
char _buf_static[TS_SIZE];
char* buf;
TYPE type;
//TODO: use static buffer again if reassigning to short string
void makePrivateCopy(const char* s)
{
resetToStatic();
if(strlen(s)>(TS_SIZE-1))
createBuffer();
assert_and_throw(strlen(s)<=4096);
strcpy(buf,s);
}
void createBuffer()
{
type=DYNAMIC;
buf=new char[4096];
}
void resetToStatic()
{
if(type==DYNAMIC)
delete[] buf;
buf=_buf_static;
type=STATIC;
}
public:
tiny_string():buf(_buf_static),type(STATIC){buf[0]=0;}
tiny_string(const char* s,bool copy=false):buf(_buf_static),type(READONLY)
{
if(copy)
makePrivateCopy(s);
else
buf=(char*)s; //This is an unsafe conversion, we have to take care of the RO data
}
tiny_string(const tiny_string& r):buf(_buf_static),type(STATIC)
{
if(strlen(r.buf)>(TS_SIZE-1))
createBuffer();
assert_and_throw(strlen(r.buf)<=4096);
strcpy(buf,r.buf);
}
tiny_string(const std::string& r):buf(_buf_static),type(STATIC)
{
if(r.size()>(TS_SIZE-1))
{
createBuffer();
assert_and_throw(r.size()<=4096);
//Comment this assertion and uncomment the following lines to just crop the strings
//if(r.size()>4096)
//{
// LOG(LOG_NO_INFO, _("tiny_string::tiny_string(): std::string is too big for tiny_string, cropping: ") << r.size() <<_(">")<<4096);
// strcpy(buf,r.substr(0,4096).c_str());
// return;
//}
}
strcpy(buf,r.c_str());
}
~tiny_string()
{
resetToStatic();
}
explicit tiny_string(int i):buf(_buf_static),type(STATIC)
{
sprintf(buf,"%i",i);
}
explicit tiny_string(number_t d):buf(_buf_static),type(STATIC)
{
sprintf(buf,"%g",d);
}
tiny_string& operator=(const tiny_string& s)
{
resetToStatic();
if(s.len()>(TS_SIZE-1))
createBuffer();
//Lenght is already checked by the other tiny_string
strcpy(buf,s.buf);
return *this;
}
tiny_string& operator=(const std::string& s)
{
resetToStatic();
if(s.size()>(TS_SIZE-1))
{
createBuffer();
assert_and_throw(s.size()<=4096);
//Comment this assertion and uncomment the following lines to just crop the strings
//if(s.size()>4096)
//{
// LOG(LOG_NO_INFO, _("tiny_string::operator=(): std::string is too big for tiny_string, cropping: ") << s.size() <<_(">")<<4096);
// strcpy(buf,s.substr(0,4096).c_str());
// return *this;
//}
}
//Lenght is already checked by the assertion
strcpy(buf,s.c_str());
return *this;
}
tiny_string& operator=(const char* s)
{
resetToStatic();
type=READONLY;
buf=(char*)s; //This is an unsafe conversion, we have to take care of the RO data
return *this;
}
tiny_string& operator+=(const char* s)
{
assert_and_throw((strlen(buf)+strlen(s)+1)<=4096);
if(type==READONLY)
{
char* tmp=buf;
makePrivateCopy(tmp);
}
if(type==STATIC && (strlen(buf)+strlen(s)+1)>TS_SIZE)
{
createBuffer();
strcpy(buf,_buf_static);
}
strcat(buf,s);
return *this;
}
tiny_string& operator+=(const tiny_string& r)
{
assert_and_throw((strlen(buf)+strlen(r.buf)+1)<=4096);
if(type==READONLY)
{
char* tmp=buf;
makePrivateCopy(tmp);
}
if(type==STATIC && (strlen(buf)+strlen(r.buf)+1)>TS_SIZE)
{
createBuffer();
strcpy(buf,_buf_static);
}
strcat(buf,r.buf);
return *this;
}
const tiny_string operator+(const tiny_string& r)
{
tiny_string ret(buf);
ret+=r;
return ret;
}
bool operator<(const tiny_string& r) const
{
return strcmp(buf,r.buf)<0;
}
bool operator==(const tiny_string& r) const
{
return strcmp(buf,r.buf)==0;
}
bool operator!=(const tiny_string& r) const
{
return strcmp(buf,r.buf)!=0;
}
bool operator==(const char* r) const
{
return strcmp(buf,r)==0;
}
bool operator!=(const char* r) const
{
return strcmp(buf,r)!=0;
}
const char* raw_buf() const
{
return buf;
}
char operator[](int i) const
{
return *(buf+i);
}
int len() const
{
return strlen(buf);
}
tiny_string substr(int start, int end) const
{
tiny_string ret;
assert_and_throw((end-start+1)<TS_SIZE);
strncpy(ret.buf,buf+start,end-start);
ret.buf[end-start]=0;
return ret;
}
};
class QName
{
public:
tiny_string ns;
tiny_string name;
QName(const tiny_string& _name, const tiny_string& _ns):ns(_ns),name(_name){}
bool operator<(const QName& r) const
{
if(ns==r.ns)
return name<r.name;
else
return ns<r.ns;
}
};
class UI32
{
friend std::istream& operator>>(std::istream& s, UI32& v);
private:
uint32_t val;
public:
UI32():val(0){}
UI32(uint32_t v):val(v){}
operator uint32_t() const{ return val; }
void bswap() { val=ntohl(val); }
};
class UI24
{
friend std::istream& operator>>(std::istream& s, UI24& v);
private:
uint32_t val;
public:
UI24():val(0){}
operator uint32_t() const { return val; }
void bswap()
{
val=ntohl(val)>>8; //The most significant byte is discarted
}
};
class SI24
{
friend std::istream& operator>>(std::istream& s, SI24& v);
private:
int32_t val;
public:
SI24():val(0){}
operator int32_t() const { return val; }
void bswap()
{
val=ntohl(val)>>8; //The most significant byte is discarted
//Check for sign extension
if(val&0x800000)
val|=(0xff000000);
}
};
class UI16
{
friend std::istream& operator>>(std::istream& s, UI16& v);
private:
uint16_t val;
public:
UI16():val(0){}
UI16(uint16_t v):val(v){}
operator uint16_t() const { return val; }
operator UI32() const { return val; }
void bswap() { val=ntohs(val); }
};
class UI8
{
friend std::istream& operator>>(std::istream& s, UI8& v);
private:
uint8_t val;
public:
UI8():val(0){}
UI8(uint8_t v):val(v){}
operator uint8_t() const { return val; }
operator UI16(){ return val; }
};
class STRING
{
friend std::ostream& operator<<(std::ostream& s, const STRING& r);
friend std::istream& operator>>(std::istream& stream, STRING& v);
friend class ASString;
private:
std::string String;
public:
STRING():String(){};
STRING(const char* s):String(s)
{
}
bool operator==(const STRING& s)
{
if(String.size()!=s.String.size())
return false;
for(uint32_t i=0;i<String.size();i++)
{
if(String[i]!=s.String[i])
return false;
}
return true;
}
/*STRING operator+(const STRING& s)
{
STRING ret(*this);
for(unsigned int i=0;i<s.String.size();i++)
ret.String.push_back(s.String[i]);
return ret;
}*/
bool isNull() const
{
return !String.size();
}
operator const std::string&() const
{
return String;
}
operator const char*() const
{
return String.c_str();
}
int size()
{
return String.size();
}
};
//Numbers taken from AVM2 specs
enum NS_KIND { NAMESPACE=0x08, PACKAGE_NAMESPACE=0x16, PACKAGE_INTERNAL_NAMESPACE=0x17, PROTECTED_NAMESPACE=0x18,
EXPLICIT_NAMESPACE=0x19, STATIC_PROTECTED_NAMESPACE=0x1A, PRIVATE_NAMESPACE=0x05 };
struct nsNameAndKind
{
tiny_string name;
NS_KIND kind;
nsNameAndKind(const tiny_string& _name, NS_KIND _kind):name(_name),kind(_kind){}
nsNameAndKind(const char* _name, NS_KIND _kind):name(_name),kind(_kind){}
bool operator<(const nsNameAndKind& r) const
{
return name < r.name;
}
bool operator==(const nsNameAndKind& r) const
{
return /*kind==r.kind &&*/ name==r.name;
}
};
struct multiname
{
enum NAME_TYPE {NAME_STRING,NAME_INT,NAME_NUMBER,NAME_OBJECT};
NAME_TYPE name_type;
tiny_string name_s;
union
{
int32_t name_i;
number_t name_d;
ASObject* name_o;
};
std::vector<nsNameAndKind> ns;
tiny_string qualifiedString() const;
};
class FLOAT
{
friend std::istream& operator>>(std::istream& s, FLOAT& v);
private:
float val;
public:
FLOAT():val(0){}
FLOAT(float v):val(v){}
operator float(){ return val; }
};
class DOUBLE
{
friend std::istream& operator>>(std::istream& s, DOUBLE& v);
private:
double val;
public:
DOUBLE():val(0){}
DOUBLE(double v):val(v){}
operator double(){ return val; }
};
class SI16
{
friend std::istream& operator>>(std::istream& s, SI16& v);
private:
int16_t val;
public:
SI16():val(0){}
SI16(int16_t v):val(v){}
operator int16_t(){ return val; }
};
//TODO: Really implement or suppress
typedef UI32 SI32;
//TODO: Really implement or suppress
typedef UI32 FIXED;
//TODO: Really implement or suppress
typedef UI16 FIXED8;
class RECORDHEADER
{
friend std::istream& operator>>(std::istream& s, RECORDHEADER& v);
private:
UI16 CodeAndLen;
SI32 Length;
public:
unsigned int getLength() const
{
if((CodeAndLen&0x3f)==0x3f)
return Length;
else
return CodeAndLen&0x3f;
}
unsigned int getTagType() const
{
return CodeAndLen>>6;
}
};
class RGB
{
public:
RGB(){};
RGB(int r,int g, int b):Red(r),Green(g),Blue(b){};
UI8 Red;
UI8 Green;
UI8 Blue;
};
class RGBA
{
public:
RGBA():Red(0),Green(0),Blue(0),Alpha(255){}
RGBA(int r, int g, int b, int a):Red(r),Green(g),Blue(b),Alpha(a){}
UI8 Red;
UI8 Green;
UI8 Blue;
UI8 Alpha;
RGBA& operator=(const RGB& r)
{
Red=r.Red;
Green=r.Green;
Blue=r.Blue;
Alpha=255;
return *this;
}
float rf() const
{
float ret=Red;
ret/=255;
return ret;
}
float gf() const
{
float ret=Green;
ret/=255;
return ret;
}
float bf() const
{
float ret=Blue;
ret/=255;
return ret;
}
float af() const
{
float ret=Alpha;
ret/=255;
return ret;
}
};
typedef UI8 LANGCODE;
std::istream& operator>>(std::istream& s, RGB& v);
inline std::istream& operator>>(std::istream& s, UI8& v)
{
s.read((char*)&v.val,1);
return s;
}
inline std::istream& operator>>(std::istream& s, SI16& v)
{
s.read((char*)&v.val,2);
return s;
}
inline std::istream& operator>>(std::istream& s, UI16& v)
{
s.read((char*)&v.val,2);
return s;
}
inline std::istream& operator>>(std::istream& s, UI24& v)
{
assert_and_throw(v.val==0);
s.read((char*)&v.val,3);
return s;
}
inline std::istream& operator>>(std::istream& s, SI24& v)
{
assert_and_throw(v.val==0);
s.read((char*)&v.val,3);
//Check for sign extesion
if(v.val&0x800000)
v.val|=0xff000000;
return s;
}
inline std::istream& operator>>(std::istream& s, UI32& v)
{
s.read((char*)&v.val,4);
return s;
}
inline std::istream& operator>>(std::istream& s, FLOAT& v)
{
s.read((char*)&v.val,4);
return s;
}
inline std::istream& operator>>(std::istream& s, DOUBLE& v)
{
// "Wacky format" is 45670123. Thanks to Gnash for reversing :-)
s.read(((char*)&v.val)+4,4);
s.read(((char*)&v.val),4);
return s;
}
inline std::istream& operator>>(std::istream& s, RECORDHEADER& v)
{
s >> v.CodeAndLen;
if((v.CodeAndLen&0x3f)==0x3f)
s >> v.Length;
return s;
}
class BitStream
{
public:
std::istream& f;
unsigned char buffer;
unsigned char pos;
public:
BitStream(std::istream& in):f(in),pos(0){};
unsigned int readBits(unsigned int num)
{
unsigned int ret=0;
while(num)
{
if(!pos)
{
pos=8;
f.read((char*)&buffer,1);
}
ret<<=1;
ret|=(buffer>>(pos-1))&1;
pos--;
num--;
}
return ret;
}
};
class FB
{
int32_t buf;
int size;
public:
FB() { buf=0; }
FB(int s,BitStream& stream):size(s)
{
if(s>32)
LOG(LOG_ERROR,_("Fixed point bit field wider than 32 bit not supported"));
buf=stream.readBits(s);
if(buf>>(s-1)&1)
{
for(int i=31;i>=s;i--)
buf|=(1<<i);
}
}
operator float() const
{
if(buf>=0)
{
int32_t b=buf;
return b/65536.0f;
}
else
{
int32_t b=-buf;
return -(b/65536.0f);
}
//return (buf>>16)+(buf&0xffff)/65536.0f;
}
};
class UB
{
uint32_t buf;
int size;
public:
UB() { buf=0; }
UB(int s,BitStream& stream):size(s)
{
/* if(s%8)
buf=new uint8_t[s/8+1];
else
buf=new uint8_t[s/8];
int i=0;
while(!s)
{
buf[i]=stream.readBits(imin(s,8));
s-=imin(s,8);
i++;
}*/
if(s>32)
LOG(LOG_ERROR,_("Unsigned bit field wider than 32 bit not supported"));
buf=stream.readBits(s);
}
operator int() const
{
return buf;
}
};
class SB
{
int32_t buf;
int size;
public:
SB() { buf=0; }
SB(int s,BitStream& stream):size(s)
{
if(s>32)
LOG(LOG_ERROR,_("Signed bit field wider than 32 bit not supported"));
buf=stream.readBits(s);
if(buf>>(s-1)&1)
{
for(int i=31;i>=s;i--)
buf|=(1<<i);
}
}
operator int() const
{
return buf;
}
};
class RECT
{
friend std::ostream& operator<<(std::ostream& s, const RECT& r);
friend std::istream& operator>>(std::istream& stream, RECT& v);
public:
int Xmin;
int Xmax;
int Ymin;
int Ymax;
public:
RECT();
RECT(int xmin, int xmax, int ymin, int ymax);
};
class MATRIX
{
friend std::istream& operator>>(std::istream& stream, MATRIX& v);
friend std::ostream& operator<<(std::ostream& s, const MATRIX& r);
public:
number_t ScaleX;
number_t ScaleY;
number_t RotateSkew0;
number_t RotateSkew1;
int TranslateX;
int TranslateY;
public:
MATRIX():ScaleX(1),ScaleY(1),RotateSkew0(0),RotateSkew1(0),TranslateX(0),TranslateY(0){}
void get4DMatrix(float matrix[16]) const;
void multiply2D(number_t xin, number_t yin, number_t& xout, number_t& yout) const;
MATRIX multiplyMatrix(const MATRIX& r) const;
const bool operator!=(const MATRIX& r) const;
MATRIX getInverted() const;
};
class GRADRECORD
{
friend std::istream& operator>>(std::istream& s, GRADRECORD& v);
public:
GRADRECORD(int v):version(v){}
int version;
UI8 Ratio;
RGBA Color;
bool operator<(const GRADRECORD& g) const
{
return Ratio<g.Ratio;
}
};
class GRADIENT
{
friend std::istream& operator>>(std::istream& s, GRADIENT& v);
public:
GRADIENT(int v):version(v){}
int version;
int SpreadMode;
int InterpolationMode;
int NumGradient;
std::vector<GRADRECORD> GradientRecords;
};
class FOCALGRADIENT
{
friend std::istream& operator>>(std::istream& s, FOCALGRADIENT& v);
public:
int version;
int SpreadMode;
int InterpolationMode;
int NumGradient;
std::vector<GRADRECORD> GradientRecords;
float FocalPoint;
};
class FILLSTYLEARRAY;
class MORPHFILLSTYLE;
enum FILL_STYLE_TYPE { SOLID_FILL=0x00, LINEAR_GRADIENT=0x10, RADIAL_GRADIENT=0x12, FOCAL_RADIAL_GRADIENT=0x13, REPEATING_BITMAP=0x40,
CLIPPED_BITMAP=0x41, NON_SMOOTHED_REPEATING_BITMAP=0x42, NON_SMOOTHED_CLIPPED_BITMAP=0x43};
class FILLSTYLE
{
public:
FILLSTYLE(int v):version(v),Gradient(v){}
int version;
FILL_STYLE_TYPE FillStyleType;
RGBA Color;
MATRIX Matrix;
GRADIENT Gradient;
FOCALGRADIENT FocalGradient;
Bitmap* bitmap;
virtual ~FILLSTYLE(){}
};
class MORPHFILLSTYLE:public FILLSTYLE
{
public:
MORPHFILLSTYLE():FILLSTYLE(1){}
RGBA StartColor;
RGBA EndColor;
MATRIX StartGradientMatrix;
MATRIX EndGradientMatrix;
UI8 NumGradients;
std::vector<UI8> StartRatios;
std::vector<UI8> EndRatios;
std::vector<RGBA> StartColors;
std::vector<RGBA> EndColors;
~MORPHFILLSTYLE(){}
};
class LINESTYLE
{
public:
LINESTYLE(int v):version(v){}
int version;
UI16 Width;
RGBA Color;
};
class LINESTYLE2
{
public:
LINESTYLE2(int v):version(v),FillType(v){}
int version;
UI16 Width;
UB StartCapStyle;
UB JointStyle;
UB HasFillFlag;
UB NoHScaleFlag;
UB NoVScaleFlag;
UB PixelHintingFlag;
UB NoClose;
UB EndCapStyle;
UI16 MiterLimitFactor;
RGBA Color;
FILLSTYLE FillType;
};
class MORPHLINESTYLE
{
public:
UI16 StartWidth;
UI16 EndWidth;
RGBA StartColor;
RGBA EndColor;
};
class LINESTYLEARRAY
{
public:
LINESTYLEARRAY(int v):version(v){}
int version;
void appendStyles(const LINESTYLEARRAY& r);
UI8 LineStyleCount;
std::list<LINESTYLE> LineStyles;
std::list<LINESTYLE2> LineStyles2;
};
class MORPHLINESTYLEARRAY
{
public:
UI8 LineStyleCount;
MORPHLINESTYLE* LineStyles;
};
class FILLSTYLEARRAY
{
public:
FILLSTYLEARRAY(int v):version(v){}
int version;
void appendStyles(const FILLSTYLEARRAY& r);
UI8 FillStyleCount;
std::list<FILLSTYLE> FillStyles;
};
class MORPHFILLSTYLEARRAY
{
public:
UI8 FillStyleCount;
MORPHFILLSTYLE* FillStyles;
};
class SHAPE;
class SHAPEWITHSTYLE;
class SHAPERECORD
{
public:
SHAPE* parent;
bool TypeFlag;
bool StateNewStyles;
bool StateLineStyle;
bool StateFillStyle1;
bool StateFillStyle0;
bool StateMoveTo;
uint32_t MoveBits;
int32_t MoveDeltaX;
int32_t MoveDeltaY;
unsigned int FillStyle1;
unsigned int FillStyle0;
unsigned int LineStyle;
//Edge record
bool StraightFlag;
uint32_t NumBits;
bool GeneralLineFlag;
bool VertLineFlag;
int32_t DeltaX;
int32_t DeltaY;
int32_t ControlDeltaX;
int32_t ControlDeltaY;
int32_t AnchorDeltaX;
int32_t AnchorDeltaY;
SHAPERECORD(SHAPE* p,BitStream& bs);
};
class TEXTRECORD;
class GLYPHENTRY
{
public:
UB GlyphIndex;
SB GlyphAdvance;
TEXTRECORD* parent;
GLYPHENTRY(TEXTRECORD* p,BitStream& bs);
};
class DefineTextTag;
class TEXTRECORD
{
public:
UB TextRecordType;
UB StyleFlagsReserved;
UB StyleFlagsHasFont;
UB StyleFlagsHasColor;
UB StyleFlagsHasYOffset;
UB StyleFlagsHasXOffset;
UI16 FontID;
RGBA TextColor;
SI16 XOffset;
SI16 YOffset;
UI16 TextHeight;
UI8 GlyphCount;
std::vector <GLYPHENTRY> GlyphEntries;
DefineTextTag* parent;
TEXTRECORD(DefineTextTag* p):parent(p){}
};
class SHAPE
{
friend std::istream& operator>>(std::istream& stream, SHAPE& v);
friend std::istream& operator>>(std::istream& stream, SHAPEWITHSTYLE& v);
public:
SHAPE():fillOffset(0),lineOffset(0){}
virtual ~SHAPE(){};
UB NumFillBits;
UB NumLineBits;
unsigned int fillOffset;
unsigned int lineOffset;
std::vector<SHAPERECORD> ShapeRecords;
};
class SHAPEWITHSTYLE : public SHAPE
{
friend std::istream& operator>>(std::istream& stream, SHAPEWITHSTYLE& v);
public:
SHAPEWITHSTYLE(int v):version(v),FillStyles(v),LineStyles(v){}
const int version;
FILLSTYLEARRAY FillStyles;
LINESTYLEARRAY LineStyles;
};
class CXFORMWITHALPHA
{
friend std::istream& operator>>(std::istream& stream, CXFORMWITHALPHA& v);
private:
UB HasAddTerms;
UB HasMultTerms;
UB NBits;
SB RedMultTerm;
SB GreenMultTerm;
SB BlueMultTerm;
SB AlphaMultTerm;
SB RedAddTerm;
SB GreenAddTerm;
SB BlueAddTerm;
SB AlphaAddTerm;
};
class CXFORM
{
};
class DROPSHADOWFILTER
{
public:
RGBA DropShadowColor;