00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020 #ifndef _SHAPE_H_
00021 #define _SHAPE_H_
00022
00023 struct LineStyleDef {
00024 long width;
00025 Color color;
00026 FillStyleDef fillstyle;
00027 };
00028
00029 enum ShapeRecordType {
00030 shapeNonEdge,
00031 shapeCurve,
00032 shapeLine
00033 };
00034
00035 enum ShapeFlags {
00036 flagsMoveTo = 0x01,
00037 flagsFill0 = 0x02,
00038 flagsFill1 = 0x04,
00039 flagsLine = 0x08,
00040 flagsNewStyles = 0x10,
00041 flagsEndShape = 0x80
00042 };
00043
00044 struct ShapeRecord {
00045 ShapeRecordType type;
00046
00047
00048 ShapeFlags flags;
00049 long x,y;
00050 long fillStyle0;
00051 long fillStyle1;
00052 long lineStyle;
00053 FillStyleDef *newFillStyles;
00054 long nbNewFillStyles;
00055 LineStyleDef *newLineStyles;
00056 long nbNewLineStyles;
00057
00058
00059 long ctrlX, ctrlY;
00060 long anchorX, anchorY;
00061
00062
00063 long dX,dY;
00064
00065 struct ShapeRecord *next;
00066
00067 ShapeRecord() {
00068 shaperecord_size += sizeof(ShapeRecord);
00069 shaperecord_nb++;
00070 }
00071
00072 };
00073
00074 enum ShapeAction {
00075 ShapeDraw,
00076 ShapeGetRegion
00077 };
00078
00079 struct LineSegment {
00080 long x1,y1,x2,y2;
00081 char first;
00082 LineStyleDef *l;
00083 struct LineSegment *next;
00084 };
00085
00086 struct Path {
00087 long lastX,lastY;
00088 int nb_edges;
00089 int nb_segments;
00090 };
00091
00092 struct StyleList {
00093 FillStyleDef *newFillStyles;
00094 long nbNewFillStyles;
00095 LineStyleDef *newLineStyles;
00096 long nbNewLineStyles;
00097
00098 StyleList *next;
00099 };
00100
00101
00102
00103 struct BitParser {
00104
00105 S32 m_bitPos;
00106 U32 m_bitBuf;
00107
00108 U8 *ptr;
00109 };
00110
00111 class Shape;
00112
00113
00114 struct ShapeParser {
00115 Dict *dict;
00116
00117 BitParser bit_parser;
00118 S32 m_nFillBits;
00119 S32 m_nLineBits;
00120
00121 StyleList *style_list;
00122 Matrix *matrix;
00123 Path curPath;
00124 int reverse;
00125
00126
00127 LineSegment *first_line,*last_line;
00128 GraphicDevice *gd;
00129 Cxform *cxform;
00130 Shape *shape;
00131
00132 FillStyleDef *f0;
00133 FillStyleDef *f1;
00134 LineStyleDef *l;
00135 };
00136
00137 class Shape : public Character {
00138 public:
00139 int defLevel;
00140
00141
00142 Rect boundary;
00143 FillStyleDef defaultFillStyle;
00144 LineStyleDef defaultLineStyle;
00145
00146 Matrix lastMat;
00147
00148
00149
00150
00151 int getAlpha, getStyles;
00152 unsigned char *file_ptr;
00153 Dict *dict;
00154
00155 protected:
00156 void drawLines(GraphicDevice *gd, Matrix *matrix, Cxform *cxform, long, long);
00157 void buildSegmentList(Segment **segs, int height, long &n, Matrix *matrix, int update, int reverse);
00158 Segment *progressSegments(Segment *, long);
00159 Segment *newSegments(Segment *, Segment *);
00160
00161 public:
00162 Shape(long id = 0 , int level = 1);
00163 ~Shape();
00164
00165 void setBoundingBox(Rect rect);
00166 int execute(GraphicDevice *gd, Matrix *matrix, Cxform *cxform);
00167 void getRegion(GraphicDevice *gd, Matrix *matrix,
00168 void *id, ScanLineFunc scan_line_func);
00169
00170 void getBoundingBox(Rect *bb, DisplayListEntry *);
00171
00172 #ifdef DUMP
00173 void dump(BitStream *bs);
00174 void dumpShapeRecords(BitStream *bs, int alpha);
00175 void dumpFillStyles(BitStream *bs, FillStyleDef *defs, long n, int alpha);
00176 void dumpLineStyles(BitStream *bs, LineStyleDef *defs, long n, int alpha);
00177 void checkBitmaps(BitStream *bs);
00178 #endif
00179 };
00180
00181 #endif