Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

shape.h

Go to the documentation of this file.
00001 
00002 // Flash Plugin and Player
00003 // Copyright (C) 1998,1999 Olivier Debon
00004 // 
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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         // Non Edge
00048         ShapeFlags       flags;
00049         long             x,y;   // Moveto
00050         long             fillStyle0;
00051         long             fillStyle1;
00052         long             lineStyle;
00053         FillStyleDef    *newFillStyles; // Array
00054         long             nbNewFillStyles;
00055         LineStyleDef    *newLineStyles; // Array
00056         long             nbNewLineStyles;
00057 
00058         // Curve Edge
00059         long             ctrlX, ctrlY;
00060         long             anchorX, anchorY;
00061 
00062         // Straight Line
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; // Array
00094     long                 nbNewFillStyles;
00095     LineStyleDef        *newLineStyles; // Array
00096     long                 nbNewLineStyles;
00097     
00098     StyleList *next;
00099 };
00100 
00101 
00102 /* fast bit parser */
00103 struct BitParser {
00104     // Bit Handling
00105     S32 m_bitPos;
00106     U32 m_bitBuf;
00107 
00108     U8 *ptr;
00109 };
00110 
00111 class Shape;
00112 
00113 /* state of the shape parser */
00114 struct ShapeParser {
00115     Dict *dict;         /* XXX: should be put elsewhere */
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     /* line rasteriser */
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; // 1,2 or 3
00140         
00141 
00142         Rect             boundary;
00143         FillStyleDef     defaultFillStyle;
00144         LineStyleDef     defaultLineStyle;
00145 
00146         Matrix           lastMat;
00147         /* parsing for the rendering stage (saves a lot of memory &
00148            may not reduce significantly the size). These variables
00149            should be in another structure (no state need to be
00150            maintained between two renderings) */
00151         int getAlpha, getStyles;
00152         unsigned char *file_ptr;
00153         Dict *dict;         /* XXX: should be put elsewhere */
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 /* _SHAPE_H_ */

Generated on Sat Nov 5 16:15:36 2005 for OPIE by  doxygen 1.4.2