Diffstat (limited to 'core/multimedia/opieplayer/libflash/graphic.h') (more/less context) (show whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/libflash/graphic.h | 174 |
1 files changed, 174 insertions, 0 deletions
diff --git a/core/multimedia/opieplayer/libflash/graphic.h b/core/multimedia/opieplayer/libflash/graphic.h new file mode 100644 index 0000000..63ebd99 --- a/dev/null +++ b/core/multimedia/opieplayer/libflash/graphic.h | |||
@@ -0,0 +1,174 @@ | |||
1 | ///////////////////////////////////////////////////////////// | ||
2 | // Flash Plugin and Player | ||
3 | // Copyright (C) 1998 Olivier Debon | ||
4 | // | ||
5 | // This program is free software; you can redistribute it and/or | ||
6 | // modify it under the terms of the GNU General Public License | ||
7 | // as published by the Free Software Foundation; either version 2 | ||
8 | // of the License, or (at your option) any later version. | ||
9 | // | ||
10 | // This program is distributed in the hope that it will be useful, | ||
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | // GNU General Public License for more details. | ||
14 | // | ||
15 | // You should have received a copy of the GNU General Public License | ||
16 | // along with this program; if not, write to the Free Software | ||
17 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | // | ||
19 | /////////////////////////////////////////////////////////////// | ||
20 | #ifndef _GRAPHIC_H_ | ||
21 | #define _GRAPHIC_H_ | ||
22 | |||
23 | #define ALPHA_OPAQUE 255 | ||
24 | |||
25 | enum FillType { | ||
26 | f_Solid = 0x00, | ||
27 | f_LinearGradient = 0x10, | ||
28 | f_RadialGradient = 0x12, | ||
29 | f_TiledBitmap = 0x40, | ||
30 | f_clippedBitmap = 0x41, | ||
31 | f_None = 0x80 | ||
32 | }; | ||
33 | |||
34 | struct Gradient { | ||
35 | int nbGradients; | ||
36 | unsigned char ratio[8]; | ||
37 | Color color[8]; | ||
38 | // For rendering | ||
39 | Color *ramp; | ||
40 | Matrix imat; | ||
41 | int has_alpha; | ||
42 | }; | ||
43 | |||
44 | |||
45 | struct FillStyleDef { | ||
46 | FillType type;// See enum FillType | ||
47 | |||
48 | // Solid | ||
49 | Color color; | ||
50 | |||
51 | // Gradient | ||
52 | Gradient gradient; | ||
53 | |||
54 | // Bitmap | ||
55 | Bitmap *bitmap; | ||
56 | Matrix bitmap_matrix; | ||
57 | Color *cmap; | ||
58 | unsigned char *alpha_table; | ||
59 | |||
60 | // Gradient or Bitmap | ||
61 | Matrix matrix; | ||
62 | |||
63 | FillStyleDef() { | ||
64 | style_size += sizeof(FillStyleDef); | ||
65 | style_nb++; | ||
66 | } | ||
67 | }; | ||
68 | |||
69 | struct Segment { | ||
70 | long x1,x2; | ||
71 | long ymax; | ||
72 | FillStyleDef *fs[2];// 0 is left 1 is right | ||
73 | int aa; | ||
74 | long dX; | ||
75 | long X; | ||
76 | |||
77 | struct Segment *next; | ||
78 | struct Segment *nextValid; | ||
79 | }; | ||
80 | |||
81 | /* fractional bits (we don't use twips here... too expensive) */ | ||
82 | #define FRAC_BITS 5 | ||
83 | #define FRAC (1 << FRAC_BITS) | ||
84 | #define NB_SEGMENT_MAX (2048*4) | ||
85 | #define SEGFRAC 8 | ||
86 | |||
87 | class GraphicDevice { | ||
88 | int targetWidth; | ||
89 | int targetHeight; | ||
90 | Rect viewPort; | ||
91 | int movieWidth; | ||
92 | int movieHeight; | ||
93 | int zoom; | ||
94 | unsigned long redMask; | ||
95 | unsigned long greenMask; | ||
96 | unsigned long blueMask; | ||
97 | int clipping; | ||
98 | |||
99 | public: | ||
100 | FlashDisplay *flashDisplay; | ||
101 | int bgInitialized; | ||
102 | Color backgroundColor; | ||
103 | Color foregroundColor; | ||
104 | |||
105 | public: | ||
106 | void *scan_line_func_id; | ||
107 | ScanLineFunc scan_line_func; | ||
108 | Rect clip_rect; | ||
109 | |||
110 | private: | ||
111 | Segment **segs; | ||
112 | int ymin,ymax; | ||
113 | int height; | ||
114 | Segment *seg_pool; | ||
115 | Segment *seg_pool_cur; | ||
116 | |||
117 | Segment * allocSeg(); | ||
118 | Segment * progressSegments(Segment * curSegs, long y); | ||
119 | Segment * newSegments(Segment *curSegs, Segment *newSegs); | ||
120 | void renderScanLine(long y, Segment *curSegs); | ||
121 | |||
122 | protected: | ||
123 | long clip(long &y, long &start, long &end); | ||
124 | |||
125 | public: | ||
126 | Matrix *adjust;// Matrix to fit window (shrink or expand) | ||
127 | |||
128 | long showMore;// Used for debugging | ||
129 | |||
130 | // For Direct Graphics | ||
131 | unsigned char *canvasBuffer;// A pointer to canvas'memory | ||
132 | long bpl;// Bytes per line | ||
133 | long bpp;// Bytes per pixel | ||
134 | long pad;// Scanline pad in byte | ||
135 | |||
136 | GraphicDevice(FlashDisplay *fd); | ||
137 | virtual ~GraphicDevice(); | ||
138 | |||
139 | int setBackgroundColor(Color); | ||
140 | void setForegroundColor(Color); | ||
141 | Color getBackgroundColor(); | ||
142 | Color getForegroundColor(); | ||
143 | void setMovieDimension(long width, long height); | ||
144 | void setMovieZoom(int zoom); | ||
145 | void setMovieOffset(long x, long y); | ||
146 | long getWidth(); | ||
147 | long getHeight(); | ||
148 | Color *getColormap(Color *old, long n, Cxform *cxform); | ||
149 | |||
150 | void drawBox(long x1, long y1, long x2, long y2); | ||
151 | |||
152 | void addSegment(long x1, long y1, long x2, long y2, | ||
153 | FillStyleDef *f0, | ||
154 | FillStyleDef *f1, | ||
155 | int aa); | ||
156 | |||
157 | void drawPolygon(void); | ||
158 | |||
159 | void updateClippingRegion(Rect *); | ||
160 | void setClipping(int); | ||
161 | |||
162 | // Virtual functions | ||
163 | virtual void clearCanvas(); | ||
164 | virtual long allocColor(Color color); | ||
165 | virtual void fillLineBitmap(FillStyleDef *f, long y, long start, long end); | ||
166 | virtual void fillLineLG(Gradient *grad, long y, long start, long end); | ||
167 | virtual void fillLineRG(Gradient *grad, long y, long start, long end); | ||
168 | virtual void fillLine(FillStyleDef *f, long y, long start, long end); | ||
169 | virtual void fillLineAA(FillStyleDef *f, long y, long start, long end); | ||
170 | virtual void drawLine(long x1, long y1, long x2, long y2, long width); | ||
171 | |||
172 | }; | ||
173 | |||
174 | #endif /* _GRAPHIC_H_ */ | ||