00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020 #ifndef _GRAPHIC_H_
00021 #define _GRAPHIC_H_
00022
00023 #define ALPHA_OPAQUE 255
00024
00025 enum FillType {
00026 f_Solid = 0x00,
00027 f_LinearGradient = 0x10,
00028 f_RadialGradient = 0x12,
00029 f_TiledBitmap = 0x40,
00030 f_clippedBitmap = 0x41,
00031 f_None = 0x80
00032 };
00033
00034 struct Gradient {
00035 int nbGradients;
00036 unsigned char ratio[8];
00037 Color color[8];
00038
00039 Color *ramp;
00040 Matrix imat;
00041 int has_alpha;
00042 };
00043
00044
00045 struct FillStyleDef {
00046 FillType type;
00047
00048
00049 Color color;
00050
00051
00052 Gradient gradient;
00053
00054
00055 Bitmap *bitmap;
00056 Matrix bitmap_matrix;
00057 Color *cmap;
00058 unsigned char *alpha_table;
00059
00060
00061 Matrix matrix;
00062
00063 FillStyleDef() {
00064 style_size += sizeof(FillStyleDef);
00065 style_nb++;
00066 }
00067 };
00068
00069 struct Segment {
00070 long x1,x2;
00071 long ymax;
00072 FillStyleDef *fs[2];
00073 int aa;
00074 long dX;
00075 long X;
00076
00077 struct Segment *next;
00078 struct Segment *nextValid;
00079 };
00080
00081
00082 #define FRAC_BITS 5
00083 #define FRAC (1 << FRAC_BITS)
00084 #define NB_SEGMENT_MAX (2048*4)
00085 #define SEGFRAC 8
00086
00087 class GraphicDevice {
00088 int targetWidth;
00089 int targetHeight;
00090 Rect viewPort;
00091 int movieWidth;
00092 int movieHeight;
00093 int zoom;
00094 unsigned long redMask;
00095 unsigned long greenMask;
00096 unsigned long blueMask;
00097 int clipping;
00098
00099 public:
00100 FlashDisplay *flashDisplay;
00101 int bgInitialized;
00102 Color backgroundColor;
00103 Color foregroundColor;
00104
00105 public:
00106 void *scan_line_func_id;
00107 ScanLineFunc scan_line_func;
00108 Rect clip_rect;
00109
00110 private:
00111 Segment **segs;
00112 int ymin,ymax;
00113 int height;
00114 Segment *seg_pool;
00115 Segment *seg_pool_cur;
00116
00117 Segment * allocSeg();
00118 Segment * progressSegments(Segment * curSegs, long y);
00119 Segment * newSegments(Segment *curSegs, Segment *newSegs);
00120 void renderScanLine(long y, Segment *curSegs);
00121
00122 protected:
00123 long clip(long &y, long &start, long &end);
00124
00125 public:
00126 Matrix *adjust;
00127
00128 long showMore;
00129
00130
00131 unsigned char *canvasBuffer;
00132 long bpl;
00133 long bpp;
00134 long pad;
00135
00136 GraphicDevice(FlashDisplay *fd);
00137 virtual ~GraphicDevice();
00138
00139 int setBackgroundColor(Color);
00140 void setForegroundColor(Color);
00141 Color getBackgroundColor();
00142 Color getForegroundColor();
00143 void setMovieDimension(long width, long height);
00144 void setMovieZoom(int zoom);
00145 void setMovieOffset(long x, long y);
00146 long getWidth();
00147 long getHeight();
00148 Color *getColormap(Color *old, long n, Cxform *cxform);
00149
00150 void drawBox(long x1, long y1, long x2, long y2);
00151
00152 void addSegment(long x1, long y1, long x2, long y2,
00153 FillStyleDef *f0,
00154 FillStyleDef *f1,
00155 int aa);
00156
00157 void drawPolygon(void);
00158
00159 void updateClippingRegion(Rect *);
00160 void setClipping(int);
00161
00162
00163 virtual void clearCanvas();
00164 virtual long allocColor(Color color);
00165 virtual void fillLineBitmap(FillStyleDef *f, long y, long start, long end);
00166 virtual void fillLineLG(Gradient *grad, long y, long start, long end);
00167 virtual void fillLineRG(Gradient *grad, long y, long start, long end);
00168 virtual void fillLine(FillStyleDef *f, long y, long start, long end);
00169 virtual void fillLineAA(FillStyleDef *f, long y, long start, long end);
00170 virtual void drawLine(long x1, long y1, long x2, long y2, long width);
00171
00172 };
00173
00174 #endif