00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef SWFTYPES_H
00021 #define SWFTYPES_H
00022
00023 #include "compat.h"
00024 #include <llvm/System/DataTypes.h>
00025 #include <iostream>
00026 #include <fstream>
00027 #include <vector>
00028 #include <list>
00029
00030 #include "logger.h"
00031 #include <stdlib.h>
00032 #include <string.h>
00033 #include <assert.h>
00034 #include "exceptions.h"
00035 #ifndef WIN32
00036
00037 #include <arpa/inet.h>
00038 #endif
00039
00040 namespace lightspark
00041 {
00042
00043 enum STACK_TYPE{STACK_NONE=0,STACK_OBJECT,STACK_INT,STACK_UINT,STACK_NUMBER,STACK_BOOLEAN};
00044
00045 enum TRISTATE { TFALSE=0, TTRUE, TUNDEFINED };
00046
00047 typedef double number_t;
00048
00049 class ASObject;
00050 struct arrayElem;
00051
00052 class tiny_string
00053 {
00054 friend std::ostream& operator<<(std::ostream& s, const tiny_string& r);
00055 private:
00056 enum TYPE { READONLY=0, STATIC, DYNAMIC };
00057 #define TS_SIZE 64
00058 char _buf_static[TS_SIZE];
00059 char* buf;
00060 TYPE type;
00061
00062 void makePrivateCopy(const char* s)
00063 {
00064 resetToStatic();
00065 if(strlen(s)>(TS_SIZE-1))
00066 createBuffer();
00067 assert_and_throw(strlen(s)<=4096);
00068 strcpy(buf,s);
00069 }
00070 void createBuffer()
00071 {
00072 type=DYNAMIC;
00073 buf=new char[4096];
00074 }
00075 void resetToStatic()
00076 {
00077 if(type==DYNAMIC)
00078 delete[] buf;
00079 buf=_buf_static;
00080 type=STATIC;
00081 }
00082 public:
00083 tiny_string():buf(_buf_static),type(STATIC){buf[0]=0;}
00084 tiny_string(const char* s,bool copy=false):buf(_buf_static),type(READONLY)
00085 {
00086 if(copy)
00087 makePrivateCopy(s);
00088 else
00089 buf=(char*)s;
00090 }
00091 tiny_string(const tiny_string& r):buf(_buf_static),type(STATIC)
00092 {
00093 if(strlen(r.buf)>(TS_SIZE-1))
00094 createBuffer();
00095 assert_and_throw(strlen(r.buf)<=4096);
00096 strcpy(buf,r.buf);
00097 }
00098 tiny_string(const std::string& r):buf(_buf_static),type(STATIC)
00099 {
00100 if(r.size()>(TS_SIZE-1))
00101 {
00102 createBuffer();
00103 assert_and_throw(r.size()<=4096);
00104
00105
00106
00107
00108
00109
00110
00111 }
00112 strcpy(buf,r.c_str());
00113 }
00114 ~tiny_string()
00115 {
00116 resetToStatic();
00117 }
00118 explicit tiny_string(int i):buf(_buf_static),type(STATIC)
00119 {
00120 sprintf(buf,"%i",i);
00121 }
00122 explicit tiny_string(number_t d):buf(_buf_static),type(STATIC)
00123 {
00124 sprintf(buf,"%g",d);
00125 }
00126 tiny_string& operator=(const tiny_string& s)
00127 {
00128 resetToStatic();
00129 if(s.len()>(TS_SIZE-1))
00130 createBuffer();
00131
00132 strcpy(buf,s.buf);
00133 return *this;
00134 }
00135 tiny_string& operator=(const std::string& s)
00136 {
00137 resetToStatic();
00138 if(s.size()>(TS_SIZE-1))
00139 {
00140 createBuffer();
00141 assert_and_throw(s.size()<=4096);
00142
00143
00144
00145
00146
00147
00148
00149 }
00150
00151 strcpy(buf,s.c_str());
00152 return *this;
00153 }
00154 tiny_string& operator=(const char* s)
00155 {
00156 resetToStatic();
00157 type=READONLY;
00158 buf=(char*)s;
00159 return *this;
00160 }
00161 tiny_string& operator+=(const char* s)
00162 {
00163 assert_and_throw((strlen(buf)+strlen(s)+1)<=4096);
00164 if(type==READONLY)
00165 {
00166 char* tmp=buf;
00167 makePrivateCopy(tmp);
00168 }
00169 if(type==STATIC && (strlen(buf)+strlen(s)+1)>TS_SIZE)
00170 {
00171 createBuffer();
00172 strcpy(buf,_buf_static);
00173 }
00174 strcat(buf,s);
00175 return *this;
00176 }
00177 tiny_string& operator+=(const tiny_string& r)
00178 {
00179 assert_and_throw((strlen(buf)+strlen(r.buf)+1)<=4096);
00180 if(type==READONLY)
00181 {
00182 char* tmp=buf;
00183 makePrivateCopy(tmp);
00184 }
00185 if(type==STATIC && (strlen(buf)+strlen(r.buf)+1)>TS_SIZE)
00186 {
00187 createBuffer();
00188 strcpy(buf,_buf_static);
00189 }
00190 strcat(buf,r.buf);
00191 return *this;
00192 }
00193 const tiny_string operator+(const tiny_string& r)
00194 {
00195 tiny_string ret(buf);
00196 ret+=r;
00197 return ret;
00198 }
00199 bool operator<(const tiny_string& r) const
00200 {
00201 return strcmp(buf,r.buf)<0;
00202 }
00203 bool operator==(const tiny_string& r) const
00204 {
00205 return strcmp(buf,r.buf)==0;
00206 }
00207 bool operator!=(const tiny_string& r) const
00208 {
00209 return strcmp(buf,r.buf)!=0;
00210 }
00211 bool operator==(const char* r) const
00212 {
00213 return strcmp(buf,r)==0;
00214 }
00215 bool operator!=(const char* r) const
00216 {
00217 return strcmp(buf,r)!=0;
00218 }
00219 const char* raw_buf() const
00220 {
00221 return buf;
00222 }
00223 char operator[](int i) const
00224 {
00225 return *(buf+i);
00226 }
00227 int len() const
00228 {
00229 return strlen(buf);
00230 }
00231 tiny_string substr(int start, int end) const
00232 {
00233 tiny_string ret;
00234 assert_and_throw((end-start+1)<TS_SIZE);
00235 strncpy(ret.buf,buf+start,end-start);
00236 ret.buf[end-start]=0;
00237 return ret;
00238 }
00239 };
00240
00241 class QName
00242 {
00243 public:
00244 tiny_string ns;
00245 tiny_string name;
00246 QName(const tiny_string& _name, const tiny_string& _ns):ns(_ns),name(_name){}
00247 bool operator<(const QName& r) const
00248 {
00249 if(ns==r.ns)
00250 return name<r.name;
00251 else
00252 return ns<r.ns;
00253 }
00254 };
00255
00256 class UI32
00257 {
00258 friend std::istream& operator>>(std::istream& s, UI32& v);
00259 private:
00260 uint32_t val;
00261 public:
00262 UI32():val(0){}
00263 UI32(uint32_t v):val(v){}
00264 operator uint32_t() const{ return val; }
00265 void bswap() { val=ntohl(val); }
00266 };
00267
00268 class UI24
00269 {
00270 friend std::istream& operator>>(std::istream& s, UI24& v);
00271 private:
00272 uint32_t val;
00273 public:
00274 UI24():val(0){}
00275 operator uint32_t() const { return val; }
00276 void bswap()
00277 {
00278 val=ntohl(val)>>8;
00279 }
00280 };
00281
00282 class SI24
00283 {
00284 friend std::istream& operator>>(std::istream& s, SI24& v);
00285 private:
00286 int32_t val;
00287 public:
00288 SI24():val(0){}
00289 operator int32_t() const { return val; }
00290 void bswap()
00291 {
00292 val=ntohl(val)>>8;
00293
00294 if(val&0x800000)
00295 val|=(0xff000000);
00296 }
00297 };
00298
00299 class UI16
00300 {
00301 friend std::istream& operator>>(std::istream& s, UI16& v);
00302 private:
00303 uint16_t val;
00304 public:
00305 UI16():val(0){}
00306 UI16(uint16_t v):val(v){}
00307 operator uint16_t() const { return val; }
00308 operator UI32() const { return val; }
00309 void bswap() { val=ntohs(val); }
00310 };
00311
00312 class UI8
00313 {
00314 friend std::istream& operator>>(std::istream& s, UI8& v);
00315 private:
00316 uint8_t val;
00317 public:
00318 UI8():val(0){}
00319 UI8(uint8_t v):val(v){}
00320 operator uint8_t() const { return val; }
00321 operator UI16(){ return val; }
00322 };
00323
00324 class STRING
00325 {
00326 friend std::ostream& operator<<(std::ostream& s, const STRING& r);
00327 friend std::istream& operator>>(std::istream& stream, STRING& v);
00328 friend class ASString;
00329 private:
00330 std::string String;
00331 public:
00332 STRING():String(){};
00333 STRING(const char* s):String(s)
00334 {
00335 }
00336 bool operator==(const STRING& s)
00337 {
00338 if(String.size()!=s.String.size())
00339 return false;
00340 for(uint32_t i=0;i<String.size();i++)
00341 {
00342 if(String[i]!=s.String[i])
00343 return false;
00344 }
00345 return true;
00346 }
00347
00348
00349
00350
00351
00352
00353
00354 bool isNull() const
00355 {
00356 return !String.size();
00357 }
00358 operator const std::string&() const
00359 {
00360 return String;
00361 }
00362 operator const char*() const
00363 {
00364 return String.c_str();
00365 }
00366 int size()
00367 {
00368 return String.size();
00369 }
00370 };
00371
00372 struct nsNameAndKind
00373 {
00374 tiny_string name;
00375 int kind;
00376 nsNameAndKind(const tiny_string& _name, int _kind):name(_name),kind(_kind){}
00377 nsNameAndKind(const char* _name, int _kind):name(_name),kind(_kind){}
00378 bool operator<(const nsNameAndKind& r) const
00379 {
00380 return name < r.name;
00381 }
00382 bool operator<(const tiny_string& r) const
00383 {
00384 return name < r;
00385 }
00386
00387
00388 operator const tiny_string&() const
00389 {
00390 return name;
00391 }
00392 };
00393
00394 struct multiname
00395 {
00396 enum NAME_TYPE {NAME_STRING,NAME_INT,NAME_NUMBER,NAME_OBJECT};
00397 NAME_TYPE name_type;
00398 tiny_string name_s;
00399 union
00400 {
00401 int32_t name_i;
00402 number_t name_d;
00403 ASObject* name_o;
00404 };
00405 std::vector<nsNameAndKind> ns;
00406 tiny_string qualifiedString() const;
00407 };
00408
00409 class FLOAT
00410 {
00411 friend std::istream& operator>>(std::istream& s, FLOAT& v);
00412 private:
00413 float val;
00414 public:
00415 FLOAT():val(0){}
00416 FLOAT(float v):val(v){}
00417 operator float(){ return val; }
00418 };
00419
00420 class DOUBLE
00421 {
00422 friend std::istream& operator>>(std::istream& s, DOUBLE& v);
00423 private:
00424 double val;
00425 public:
00426 DOUBLE():val(0){}
00427 DOUBLE(double v):val(v){}
00428 operator double(){ return val; }
00429 };
00430
00431 class SI16
00432 {
00433 friend std::istream& operator>>(std::istream& s, SI16& v);
00434 private:
00435 int16_t val;
00436 public:
00437 SI16():val(0){}
00438 SI16(int16_t v):val(v){}
00439 operator int16_t(){ return val; }
00440 };
00441
00442
00443 typedef UI32 SI32;
00444
00445
00446 typedef UI32 FIXED;
00447
00448
00449 typedef UI16 FIXED8;
00450
00451 class RECORDHEADER
00452 {
00453 friend std::istream& operator>>(std::istream& s, RECORDHEADER& v);
00454 private:
00455 UI16 CodeAndLen;
00456 SI32 Length;
00457 public:
00458 unsigned int getLength() const
00459 {
00460 if((CodeAndLen&0x3f)==0x3f)
00461 return Length;
00462 else
00463 return CodeAndLen&0x3f;
00464 }
00465 unsigned int getTagType() const
00466 {
00467 return CodeAndLen>>6;
00468 }
00469 };
00470
00471 class RGB
00472 {
00473 public:
00474 RGB(){};
00475 RGB(int r,int g, int b):Red(r),Green(g),Blue(b){};
00476 UI8 Red;
00477 UI8 Green;
00478 UI8 Blue;
00479 };
00480
00481 class RGBA
00482 {
00483 public:
00484 RGBA():Red(0),Green(0),Blue(0),Alpha(255){}
00485 RGBA(int r, int g, int b, int a):Red(r),Green(g),Blue(b),Alpha(a){}
00486 UI8 Red;
00487 UI8 Green;
00488 UI8 Blue;
00489 UI8 Alpha;
00490 RGBA& operator=(const RGB& r)
00491 {
00492 Red=r.Red;
00493 Green=r.Green;
00494 Blue=r.Blue;
00495 Alpha=255;
00496 return *this;
00497 }
00498 };
00499
00500 typedef UI8 LANGCODE;
00501
00502 std::istream& operator>>(std::istream& s, RGB& v);
00503
00504 inline std::istream& operator>>(std::istream& s, UI8& v)
00505 {
00506 s.read((char*)&v.val,1);
00507 return s;
00508 }
00509
00510 inline std::istream& operator>>(std::istream& s, SI16& v)
00511 {
00512 s.read((char*)&v.val,2);
00513 return s;
00514 }
00515
00516 inline std::istream& operator>>(std::istream& s, UI16& v)
00517 {
00518 s.read((char*)&v.val,2);
00519 return s;
00520 }
00521
00522 inline std::istream& operator>>(std::istream& s, UI24& v)
00523 {
00524 assert_and_throw(v.val==0);
00525 s.read((char*)&v.val,3);
00526 return s;
00527 }
00528
00529 inline std::istream& operator>>(std::istream& s, SI24& v)
00530 {
00531 assert_and_throw(v.val==0);
00532 s.read((char*)&v.val,3);
00533
00534 if(v.val&0x800000)
00535 v.val|=0xff000000;
00536 return s;
00537 }
00538
00539 inline std::istream& operator>>(std::istream& s, UI32& v)
00540 {
00541 s.read((char*)&v.val,4);
00542 return s;
00543 }
00544
00545 inline std::istream& operator>>(std::istream& s, FLOAT& v)
00546 {
00547 s.read((char*)&v.val,4);
00548 return s;
00549 }
00550
00551 inline std::istream& operator>>(std::istream& s, DOUBLE& v)
00552 {
00553
00554 s.read(((char*)&v.val)+4,4);
00555 s.read(((char*)&v.val),4);
00556 return s;
00557 }
00558
00559 inline std::istream& operator>>(std::istream& s, RECORDHEADER& v)
00560 {
00561 s >> v.CodeAndLen;
00562 if((v.CodeAndLen&0x3f)==0x3f)
00563 s >> v.Length;
00564 return s;
00565 }
00566
00567 class BitStream
00568 {
00569 public:
00570 std::istream& f;
00571 unsigned char buffer;
00572 unsigned char pos;
00573 public:
00574 BitStream(std::istream& in):f(in),pos(0){};
00575 unsigned int readBits(unsigned int num)
00576 {
00577 unsigned int ret=0;
00578 while(num)
00579 {
00580 if(!pos)
00581 {
00582 pos=8;
00583 f.read((char*)&buffer,1);
00584 }
00585 ret<<=1;
00586 ret|=(buffer>>(pos-1))&1;
00587 pos--;
00588 num--;
00589 }
00590 return ret;
00591 }
00592 };
00593
00594 class FB
00595 {
00596 int32_t buf;
00597 int size;
00598 public:
00599 FB() { buf=0; }
00600 FB(int s,BitStream& stream):size(s)
00601 {
00602 if(s>32)
00603 LOG(LOG_ERROR,_("Fixed point bit field wider than 32 bit not supported"));
00604 buf=stream.readBits(s);
00605 if(buf>>(s-1)&1)
00606 {
00607 for(int i=31;i>=s;i--)
00608 buf|=(1<<i);
00609 }
00610 }
00611 operator float() const
00612 {
00613 if(buf>=0)
00614 {
00615 int32_t b=buf;
00616 return b/65536.0f;
00617 }
00618 else
00619 {
00620 int32_t b=-buf;
00621 return -(b/65536.0f);
00622 }
00623
00624 }
00625 };
00626
00627 class UB
00628 {
00629 uint32_t buf;
00630 int size;
00631 public:
00632 UB() { buf=0; }
00633 UB(int s,BitStream& stream):size(s)
00634 {
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646 if(s>32)
00647 LOG(LOG_ERROR,_("Unsigned bit field wider than 32 bit not supported"));
00648 buf=stream.readBits(s);
00649 }
00650 operator int() const
00651 {
00652 return buf;
00653 }
00654 };
00655
00656 class SB
00657 {
00658 int32_t buf;
00659 int size;
00660 public:
00661 SB() { buf=0; }
00662 SB(int s,BitStream& stream):size(s)
00663 {
00664 if(s>32)
00665 LOG(LOG_ERROR,_("Signed bit field wider than 32 bit not supported"));
00666 buf=stream.readBits(s);
00667 if(buf>>(s-1)&1)
00668 {
00669 for(int i=31;i>=s;i--)
00670 buf|=(1<<i);
00671 }
00672 }
00673 operator int() const
00674 {
00675 return buf;
00676 }
00677 };
00678
00679 class RECT
00680 {
00681 friend std::ostream& operator<<(std::ostream& s, const RECT& r);
00682 friend std::istream& operator>>(std::istream& stream, RECT& v);
00683 public:
00684 int Xmin;
00685 int Xmax;
00686 int Ymin;
00687 int Ymax;
00688 public:
00689 RECT();
00690 RECT(int xmin, int xmax, int ymin, int ymax);
00691 };
00692
00693 class MATRIX
00694 {
00695 friend std::istream& operator>>(std::istream& stream, MATRIX& v);
00696 friend std::ostream& operator<<(std::ostream& s, const MATRIX& r);
00697 public:
00698 float ScaleX;
00699 float ScaleY;
00700 float RotateSkew0;
00701 float RotateSkew1;
00702 int TranslateX;
00703 int TranslateY;
00704 public:
00705 MATRIX():ScaleX(1),ScaleY(1),RotateSkew0(0),RotateSkew1(0),TranslateX(0),TranslateY(0){}
00706 void get4DMatrix(float matrix[16]) const;
00707 void getTranslation(int& x, int& y) const;
00708 void multiply2D(number_t xin, number_t yin, number_t& xout, number_t& yout) const;
00709 };
00710
00711 class GRADRECORD
00712 {
00713 friend std::istream& operator>>(std::istream& s, GRADRECORD& v);
00714 public:
00715 int version;
00716 UI8 Ratio;
00717 RGBA Color;
00718 bool operator<(const GRADRECORD& g) const
00719 {
00720 return Ratio<g.Ratio;
00721 }
00722 };
00723
00724 class GRADIENT
00725 {
00726 friend std::istream& operator>>(std::istream& s, GRADIENT& v);
00727 public:
00728 int version;
00729 int SpreadMode;
00730 int InterpolationMode;
00731 int NumGradient;
00732 std::vector<GRADRECORD> GradientRecords;
00733 };
00734
00735 class FOCALGRADIENT
00736 {
00737 friend std::istream& operator>>(std::istream& s, FOCALGRADIENT& v);
00738 public:
00739 int version;
00740 int SpreadMode;
00741 int InterpolationMode;
00742 int NumGradient;
00743 std::vector<GRADRECORD> GradientRecords;
00744 float FocalPoint;
00745 };
00746
00747 class FILLSTYLEARRAY;
00748 class MORPHFILLSTYLE;
00749
00750 class FILLSTYLE
00751 {
00752 friend std::istream& operator>>(std::istream& s, FILLSTYLEARRAY& v);
00753 friend std::istream& operator>>(std::istream& s, FILLSTYLE& v);
00754 friend std::istream& operator>>(std::istream& s, MORPHFILLSTYLE& v);
00755 friend class DefineTextTag;
00756 friend class DefineShape2Tag;
00757 friend class DefineShape3Tag;
00758 friend class GeomShape;
00759 friend class Graphics;
00760 private:
00761 int version;
00762 UI8 FillStyleType;
00763 RGBA Color;
00764 MATRIX GradientMatrix;
00765 GRADIENT Gradient;
00766 FOCALGRADIENT FocalGradient;
00767 UI16 BitmapId;
00768 MATRIX BitmapMatrix;
00769
00770 public:
00771 virtual void setFragmentProgram() const;
00772 static void fixedColor(float r, float g, float b);
00773 virtual void setVertexData(arrayElem* elem);
00774 virtual ~FILLSTYLE(){}
00775 };
00776
00777 class MORPHFILLSTYLE:public FILLSTYLE
00778 {
00779 public:
00780 RGBA StartColor;
00781 RGBA EndColor;
00782 MATRIX StartGradientMatrix;
00783 MATRIX EndGradientMatrix;
00784 UI8 NumGradients;
00785 std::vector<UI8> StartRatios;
00786 std::vector<UI8> EndRatios;
00787 std::vector<RGBA> StartColors;
00788 std::vector<RGBA> EndColors;
00789 virtual ~MORPHFILLSTYLE(){}
00790 };
00791
00792 class LINESTYLE
00793 {
00794 public:
00795 int version;
00796 UI16 Width;
00797 RGBA Color;
00798 };
00799
00800 class LINESTYLE2
00801 {
00802 public:
00803 UI16 Width;
00804 UB StartCapStyle;
00805 UB JointStyle;
00806 UB HasFillFlag;
00807 UB NoHScaleFlag;
00808 UB NoVScaleFlag;
00809 UB PixelHintingFlag;
00810 UB NoClose;
00811 UB EndCapStyle;
00812 UI16 MiterLimitFactor;
00813 RGBA Color;
00814 FILLSTYLE FillType;
00815 };
00816
00817 class MORPHLINESTYLE
00818 {
00819 public:
00820 UI16 StartWidth;
00821 UI16 EndWidth;
00822 RGBA StartColor;
00823 RGBA EndColor;
00824 };
00825
00826 class LINESTYLEARRAY
00827 {
00828 public:
00829 LINESTYLEARRAY():version(-1){}
00830 void appendStyles(const LINESTYLEARRAY& r);
00831 int version;
00832 UI8 LineStyleCount;
00833 std::list<LINESTYLE> LineStyles;
00834 std::list<LINESTYLE2> LineStyles2;
00835 };
00836
00837 class MORPHLINESTYLEARRAY
00838 {
00839 public:
00840 UI8 LineStyleCount;
00841 MORPHLINESTYLE* LineStyles;
00842 };
00843
00844 class FILLSTYLEARRAY
00845 {
00846 public:
00847 FILLSTYLEARRAY():version(-1){}
00848 void appendStyles(const FILLSTYLEARRAY& r);
00849 int version;
00850 UI8 FillStyleCount;
00851 std::list<FILLSTYLE> FillStyles;
00852 };
00853
00854 class MORPHFILLSTYLEARRAY
00855 {
00856 public:
00857 UI8 FillStyleCount;
00858 MORPHFILLSTYLE* FillStyles;
00859 };
00860
00861 class SHAPE;
00862 class SHAPEWITHSTYLE;
00863
00864 class SHAPERECORD
00865 {
00866 public:
00867 SHAPE* parent;
00868 bool TypeFlag;
00869 bool StateNewStyles;
00870 bool StateLineStyle;
00871 bool StateFillStyle1;
00872 bool StateFillStyle0;
00873 bool StateMoveTo;
00874
00875 uint32_t MoveBits;
00876 int32_t MoveDeltaX;
00877 int32_t MoveDeltaY;
00878
00879 unsigned int FillStyle1;
00880 unsigned int FillStyle0;
00881 unsigned int LineStyle;
00882
00883
00884 bool StraightFlag;
00885 uint32_t NumBits;
00886 bool GeneralLineFlag;
00887 bool VertLineFlag;
00888 int32_t DeltaX;
00889 int32_t DeltaY;
00890
00891 int32_t ControlDeltaX;
00892 int32_t ControlDeltaY;
00893 int32_t AnchorDeltaX;
00894 int32_t AnchorDeltaY;
00895
00896
00897
00898 SHAPERECORD(SHAPE* p,BitStream& bs);
00899 };
00900
00901 class TEXTRECORD;
00902
00903 class GLYPHENTRY
00904 {
00905 public:
00906 UB GlyphIndex;
00907 SB GlyphAdvance;
00908 TEXTRECORD* parent;
00909 GLYPHENTRY(TEXTRECORD* p,BitStream& bs);
00910 };
00911
00912 class DefineTextTag;
00913
00914 class TEXTRECORD
00915 {
00916 public:
00917 UB TextRecordType;
00918 UB StyleFlagsReserved;
00919 UB StyleFlagsHasFont;
00920 UB StyleFlagsHasColor;
00921 UB StyleFlagsHasYOffset;
00922 UB StyleFlagsHasXOffset;
00923 UI16 FontID;
00924 RGBA TextColor;
00925 SI16 XOffset;
00926 SI16 YOffset;
00927 UI16 TextHeight;
00928 UI8 GlyphCount;
00929 std::vector <GLYPHENTRY> GlyphEntries;
00930 DefineTextTag* parent;
00931 TEXTRECORD(DefineTextTag* p):parent(p){}
00932 };
00933
00934 class GeomShape;
00935
00936 class SHAPE
00937 {
00938 friend std::istream& operator>>(std::istream& stream, SHAPE& v);
00939 friend std::istream& operator>>(std::istream& stream, SHAPEWITHSTYLE& v);
00940 public:
00941 SHAPE():fillOffset(0),lineOffset(0){}
00942 virtual ~SHAPE(){};
00943 UB NumFillBits;
00944 UB NumLineBits;
00945 unsigned int fillOffset;
00946 unsigned int lineOffset;
00947 std::vector<SHAPERECORD> ShapeRecords;
00948 };
00949
00950 class SHAPEWITHSTYLE : public SHAPE
00951 {
00952 friend std::istream& operator>>(std::istream& stream, SHAPEWITHSTYLE& v);
00953 public:
00954 int version;
00955 FILLSTYLEARRAY FillStyles;
00956 LINESTYLEARRAY LineStyles;
00957 };
00958
00959 class CXFORMWITHALPHA
00960 {
00961 friend std::istream& operator>>(std::istream& stream, CXFORMWITHALPHA& v);
00962 private:
00963 UB HasAddTerms;
00964 UB HasMultTerms;
00965 UB NBits;
00966 SB RedMultTerm;
00967 SB GreenMultTerm;
00968 SB BlueMultTerm;
00969 SB AlphaMultTerm;
00970 SB RedAddTerm;
00971 SB GreenAddTerm;
00972 SB BlueAddTerm;
00973 SB AlphaAddTerm;
00974 };
00975
00976 class CXFORM
00977 {
00978 };
00979
00980 class DROPSHADOWFILTER
00981 {
00982 public:
00983 RGBA DropShadowColor;
00984 FIXED BlurX;
00985 FIXED BlurY;
00986 FIXED Angle;
00987 FIXED Distance;
00988 FIXED8 Strength;
00989 bool InnerShadow;
00990 bool Knockout;
00991 bool CompositeSource;
00992 UB Passes;
00993 };
00994
00995 class BLURFILTER
00996 {
00997 public:
00998 FIXED BlurX;
00999 FIXED BlurY;
01000 UB Passes;
01001 };
01002
01003 class GLOWFILTER
01004 {
01005 public:
01006 RGBA GlowColor;
01007 FIXED BlurX;
01008 FIXED BlurY;
01009 FIXED8 Strength;
01010 bool InnerGlow;
01011 bool Knockout;
01012 bool CompositeSource;
01013 UB Passes;
01014 };
01015
01016 class BEVELFILTER
01017 {
01018 public:
01019 RGBA ShadowColor;
01020 RGBA HighlightColor;
01021 FIXED BlurX;
01022 FIXED BlurY;
01023 FIXED Angle;
01024 FIXED Distance;
01025 FIXED8 Strength;
01026 bool InnerShadow;
01027 bool Knockout;
01028 bool CompositeSource;
01029 bool OnTop;
01030 UB Passes;
01031 };
01032
01033 class GRADIENTGLOWFILTER
01034 {
01035 public:
01036 UI8 NumColors;
01037 std::vector<RGBA> GradientColors;
01038 std::vector<UI8> GradientRatio;
01039 FIXED BlurX;
01040 FIXED BlurY;
01041 FIXED Angle;
01042 FIXED Distance;
01043 FIXED8 Strength;
01044 bool InnerGlow;
01045 bool Knockout;
01046 bool CompositeSource;
01047 UB Passes;
01048 };
01049
01050 class CONVOLUTIONFILTER
01051 {
01052 public:
01053 UI8 MatrixX;
01054 UI8 MatrixY;
01055 FLOAT Divisor;
01056 FLOAT Bias;
01057 std::vector<FLOAT> Matrix;
01058 RGBA DefaultColor;
01059 bool Clamp;
01060 bool PreserveAlpha;
01061 };
01062
01063 class COLORMATRIXFILTER
01064 {
01065 public:
01066 FLOAT Matrix[20];
01067 };
01068
01069 class GRADIENTBEVELFILTER
01070 {
01071 public:
01072 UI8 NumColors;
01073 std::vector<RGBA> GradientColors;
01074 std::vector<UI8> GradientRatio;
01075 FIXED BlurX;
01076 FIXED BlurY;
01077 FIXED Angle;
01078 FIXED Distance;
01079 FIXED8 Strength;
01080 bool InnerShadow;
01081 bool Knockout;
01082 bool CompositeSource;
01083 bool OnTop;
01084 UB Passes;
01085 };
01086
01087 class FILTER
01088 {
01089 public:
01090 UI8 FilterID;
01091 DROPSHADOWFILTER DropShadowFilter;
01092 BLURFILTER BlurFilter;
01093 GLOWFILTER GlowFilter;
01094 BEVELFILTER BevelFilter;
01095 GRADIENTGLOWFILTER GradientGlowFilter;
01096 CONVOLUTIONFILTER ConvolutionFilter;
01097 COLORMATRIXFILTER ColorMatrixFilter;
01098 GRADIENTBEVELFILTER GradientBevelFilter;
01099 };
01100
01101 class FILTERLIST
01102 {
01103 public:
01104 UI8 NumberOfFilters;
01105 std::vector<FILTER> Filters;
01106 };
01107
01108 class BUTTONRECORD
01109 {
01110 public:
01111 BUTTONRECORD(int v):buttonVersion(v){}
01112 int buttonVersion;
01113 UB ButtonReserved;
01114 UB ButtonHasBlendMode;
01115 UB ButtonHasFilterList;
01116 UB ButtonStateHitTest;
01117 UB ButtonStateDown;
01118 UB ButtonStateOver;
01119 UB ButtonStateUp;
01120 UI16 CharacterID;
01121 UI16 PlaceDepth;
01122 MATRIX PlaceMatrix;
01123 CXFORMWITHALPHA ColorTransform;
01124 FILTERLIST FilterList;
01125 UI8 BlendMode;
01126
01127 bool isNull() const
01128 {
01129 return !(ButtonReserved | ButtonHasBlendMode | ButtonHasFilterList | ButtonStateHitTest | ButtonStateDown | ButtonStateOver | ButtonStateUp);
01130 }
01131 };
01132
01133 class CLIPEVENTFLAGS
01134 {
01135 public:
01136 UI32 toParse;
01137 bool isNull();
01138 };
01139
01140 class CLIPACTIONRECORD
01141 {
01142 public:
01143 CLIPEVENTFLAGS EventFlags;
01144 UI32 ActionRecordSize;
01145 bool isLast();
01146 };
01147
01148 class CLIPACTIONS
01149 {
01150 public:
01151 UI16 Reserved;
01152 CLIPEVENTFLAGS AllEventFlags;
01153 std::vector<CLIPACTIONRECORD> ClipActionRecords;
01154 };
01155
01156 class RunState
01157 {
01158 public:
01159 unsigned int FP;
01160 unsigned int next_FP;
01161 unsigned int max_FP;
01162 bool stop_FP;
01163 bool explicit_FP;
01164 RunState();
01165 void prepareNextFP();
01166 };
01167
01168 ASObject* abstract_i(intptr_t i);
01169 ASObject* abstract_b(bool i);
01170 ASObject* abstract_d(number_t i);
01171
01172 void stringToQName(const tiny_string& tmp, tiny_string& name, tiny_string& ns);
01173
01174 std::ostream& operator<<(std::ostream& s, const RECT& r);
01175 std::ostream& operator<<(std::ostream& s, const RGB& r);
01176 std::ostream& operator<<(std::ostream& s, const RGBA& r);
01177 std::ostream& operator<<(std::ostream& s, const STRING& r);
01178 std::ostream& operator<<(std::ostream& s, const multiname& r);
01179 std::ostream& operator<<(std::ostream& s, const tiny_string& r) DLL_PUBLIC;
01180 std::ostream& operator<<(std::ostream& s, const QName& r);
01181
01182 std::istream& operator>>(std::istream& s, RECT& v);
01183 std::istream& operator>>(std::istream& s, CLIPEVENTFLAGS& v);
01184 std::istream& operator>>(std::istream& s, CLIPACTIONRECORD& v);
01185 std::istream& operator>>(std::istream& s, CLIPACTIONS& v);
01186 std::istream& operator>>(std::istream& s, RGB& v);
01187 std::istream& operator>>(std::istream& s, RGBA& v);
01188 std::istream& operator>>(std::istream& stream, SHAPEWITHSTYLE& v);
01189 std::istream& operator>>(std::istream& stream, SHAPE& v);
01190 std::istream& operator>>(std::istream& stream, FILLSTYLEARRAY& v);
01191 std::istream& operator>>(std::istream& stream, MORPHFILLSTYLEARRAY& v);
01192 std::istream& operator>>(std::istream& stream, LINESTYLEARRAY& v);
01193 std::istream& operator>>(std::istream& stream, MORPHLINESTYLEARRAY& v);
01194 std::istream& operator>>(std::istream& stream, LINESTYLE& v);
01195 std::istream& operator>>(std::istream& stream, LINESTYLE2& v);
01196 std::istream& operator>>(std::istream& stream, MORPHLINESTYLE& v);
01197 std::istream& operator>>(std::istream& stream, FILLSTYLE& v);
01198 std::istream& operator>>(std::istream& stream, MORPHFILLSTYLE& v);
01199 std::istream& operator>>(std::istream& stream, SHAPERECORD& v);
01200 std::istream& operator>>(std::istream& stream, TEXTRECORD& v);
01201 std::istream& operator>>(std::istream& stream, MATRIX& v);
01202 std::istream& operator>>(std::istream& stream, CXFORMWITHALPHA& v);
01203 std::istream& operator>>(std::istream& stream, GLYPHENTRY& v);
01204 std::istream& operator>>(std::istream& stream, STRING& v);
01205 std::istream& operator>>(std::istream& stream, BUTTONRECORD& v);
01206 std::istream& operator>>(std::istream& stream, RECORDHEADER& v);
01207 std::istream& operator>>(std::istream& stream, FILTERLIST& v);
01208 std::istream& operator>>(std::istream& stream, FILTER& v);
01209 std::istream& operator>>(std::istream& stream, DROPSHADOWFILTER& v);
01210 std::istream& operator>>(std::istream& stream, BLURFILTER& v);
01211 std::istream& operator>>(std::istream& stream, GLOWFILTER& v);
01212 std::istream& operator>>(std::istream& stream, BEVELFILTER& v);
01213 std::istream& operator>>(std::istream& stream, GRADIENTGLOWFILTER& v);
01214 std::istream& operator>>(std::istream& stream, CONVOLUTIONFILTER& v);
01215 std::istream& operator>>(std::istream& stream, COLORMATRIXFILTER& v);
01216 std::istream& operator>>(std::istream& stream, GRADIENTBEVELFILTER& v);
01217
01218
01219 };
01220 #endif