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

graphic.h

Go to the documentation of this file.
00001 
00002 // Flash Plugin and Player
00003 // Copyright (C) 1998 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 _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     // For rendering
00039     Color               *ramp;
00040     Matrix               imat;
00041     int has_alpha;
00042 };
00043 
00044 
00045 struct FillStyleDef {
00046     FillType     type;  // See enum FillType
00047     
00048     // Solid
00049     Color                color;
00050     
00051     // Gradient
00052     Gradient     gradient;
00053     
00054     // Bitmap
00055     Bitmap              *bitmap;
00056     Matrix              bitmap_matrix;
00057     Color               *cmap;
00058     unsigned char *alpha_table;
00059 
00060     // Gradient or Bitmap
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]; // 0 is left 1 is right
00073     int          aa;
00074     long                 dX;
00075     long                 X;
00076     
00077     struct Segment *next;
00078     struct Segment *nextValid;
00079 };
00080 
00081 /* fractional bits (we don't use twips here... too expensive) */
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;        // Matrix to fit window (shrink or expand)
00127 
00128         long                     showMore;      // Used for debugging
00129 
00130         // For Direct Graphics
00131         unsigned char           *canvasBuffer;  // A pointer to canvas'memory
00132         long                     bpl;   // Bytes per line
00133         long                     bpp;   // Bytes per pixel
00134         long                     pad;   // Scanline pad in byte
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         // Virtual functions
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 /* _GRAPHIC_H_ */

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