FreeCalypso > hg > fc-tourmaline
comparison src/cs/drivers/drv_app/r2d/lcds/PC_DSAMPLE/R2D_pc_dsample_lcd_i.c @ 0:4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 16 Oct 2020 06:23:26 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4e78acac3d88 |
---|---|
1 static UINT32 r2d_lcd_copy_operator(UINT32 old,UINT32 value) | |
2 { | |
3 return(value); | |
4 } | |
5 static UINT32 r2d_lcd_or_operator(UINT32 old,UINT32 value) | |
6 { | |
7 if ((value&0x00FFFFFF)==0x0FFFFFF) | |
8 return(old); | |
9 else | |
10 return(value); | |
11 } | |
12 static UINT32 r2d_lcd_and_operator(UINT32 old,UINT32 value) | |
13 { | |
14 return((~(~old) & (~value))); | |
15 } | |
16 static UINT32 r2d_lcd_xor_operator(UINT32 old,UINT32 value) | |
17 { | |
18 return(~((~old) ^ (~value))) ; | |
19 } | |
20 static UINT32 r2d_lcd_not_copy_operator(UINT32 old,UINT32 value) | |
21 { | |
22 return(~value); | |
23 } | |
24 static UINT32 r2d_lcd_not_or_operator(UINT32 old,UINT32 value) | |
25 { | |
26 return(((~old) | (~value))); | |
27 } | |
28 static UINT32 r2d_lcd_not_and_operator(UINT32 old,UINT32 value) | |
29 { | |
30 return(((~old) & (~value))); | |
31 } | |
32 static UINT32 r2d_lcd_not_xor_operator(UINT32 old,UINT32 value) | |
33 { | |
34 return(((~old) ^ (~value))) ; | |
35 } | |
36 | |
37 static UINT32 r2d_lcd_alpha_operator(UINT32 old,UINT32 value) | |
38 { | |
39 INT16 a,rs,gs,bs,rd,gd,bd; | |
40 | |
41 | |
42 | |
43 a=(value >> 24) & 0x0FF; | |
44 | |
45 | |
46 if (a) | |
47 { | |
48 | |
49 bs=value&0xFF; | |
50 | |
51 value=value>>8; | |
52 gs=value&0xFF; | |
53 | |
54 value=value>>8; | |
55 rs=value&0xFF; | |
56 | |
57 bd=old&0xFF; | |
58 | |
59 old=old>>8; | |
60 gd=old&0xFF; | |
61 | |
62 old=old>>8; | |
63 rd=old&0xFF; | |
64 | |
65 // Pixel value has been complemented before being | |
66 // saved so that the white correspond to 0 and be | |
67 // compatible with formulas for other modes. | |
68 // But alpha value is not complemented | |
69 // So a=0xFF correspond tranparency | |
70 bd=((a)*bd+(0x100 - a)*bs) >> 8; | |
71 gd=((a)*gd+(0x100 - a)*gs) >> 8; | |
72 rd=((a)*rd+(0x100 - a)*rs) >> 8; | |
73 | |
74 | |
75 old=((rd << 16) | (gd << 8) | bd) & 0x00FFFFFF; | |
76 return(old); | |
77 } | |
78 else return(value); | |
79 } | |
80 | |
81 const T_R2D_DRAWING_OPERATORS r2d_g_lcd_operators= | |
82 { | |
83 &r2d_lcd_copy_operator, | |
84 &r2d_lcd_or_operator, | |
85 &r2d_lcd_and_operator, | |
86 &r2d_lcd_xor_operator, | |
87 &r2d_lcd_not_copy_operator, | |
88 &r2d_lcd_not_or_operator, | |
89 &r2d_lcd_not_and_operator, | |
90 &r2d_lcd_not_xor_operator, | |
91 &r2d_lcd_alpha_operator | |
92 }; | |
93 | |
94 | |
95 | |
96 | |
97 | |
98 | |
99 | |
100 | |
101 // Return the pixel value to write on the LCD or the offscreen | |
102 // pixmap | |
103 // (Convert Riviera color to Windows RGB Format with complement) | |
104 void r2d_convert_foreground_color(T_R2D_GC *gc,UINT32 color) | |
105 { | |
106 /*gc->foreground_pixel_value=r2d_alpha(color); | |
107 gc->foreground_pixel_value<<=24; | |
108 | |
109 gc->foreground_pixel_value|=((RGB(r2d_red(color), | |
110 r2d_green(color),r2d_blue(color)))) & 0x00FFFFFF;*/ | |
111 | |
112 gc->foreground_pixel_value=color; | |
113 } | |
114 | |
115 // Return the pixel value to write on the LCD or the offscreen | |
116 // pixmap | |
117 // (Convert ribviera color to windows RGB format with complement) | |
118 void r2d_convert_background_color(T_R2D_GC *gc,UINT32 color) | |
119 { | |
120 /*gc->background_pixel_value=r2d_alpha(color); | |
121 gc->background_pixel_value<<=24; | |
122 | |
123 gc->background_pixel_value|=((RGB(r2d_red(color), | |
124 r2d_green(color),r2d_blue(color)))) & 0x00FFFFFF;*/ | |
125 | |
126 gc->background_pixel_value=color; | |
127 } | |
128 | |
129 // Convert a LCD value (not color) to a value | |
130 // to be written into the 24bpp framebuffer | |
131 // In general, the value written is a packed | |
132 // representation of the ARGB color | |
133 // but it may be different according to the framebuffer | |
134 // internal format | |
135 BOOLEAN r2d_lcd_foreground_pixel(UINT32 lcd_value,T_R2D_GC_PTR src_gc) | |
136 { | |
137 if (lcd_value&0x0FFFFFF==0x0FFFFFF) | |
138 return(FALSE); | |
139 else | |
140 return(TRUE); | |
141 } | |
142 | |
143 // Assume than color framebuffer contains ARGB packed values | |
144 // Convert color to LCD with on the fly dithering | |
145 // Riviera complemented RGB to Windows complemented one | |
146 // Convert from pixel_value to LCD | |
147 UINT32 r2d_color_to_lcd(UINT32 pixel_value,INT16 x,INT16 y) | |
148 { | |
149 INT16 r,g,b; | |
150 UINT32 alpha; | |
151 //UINT32 tmp; | |
152 | |
153 /*alpha=pixel_value & 0xFF000000; | |
154 | |
155 pixel_value=~pixel_value; | |
156 | |
157 b=pixel_value&0xFF; | |
158 | |
159 pixel_value=pixel_value>>8; | |
160 g=pixel_value&0xFF; | |
161 | |
162 pixel_value=pixel_value>>8; | |
163 r=pixel_value&0xFF; | |
164 | |
165 | |
166 //tmp=(~RGB(r,g,b)) & 0x00FFFFFF; | |
167 return(((RGB(r,g,b)) & 0x00FFFFFF) | (alpha ));*/ | |
168 return((~(pixel_value&0x00FFFFFF)) | (pixel_value&0xFF000000)); | |
169 } | |
170 | |
171 // Windows RGB format to pixel value for 24 bpp framebuffer | |
172 UINT32 r2d_lcd_to_color(UINT32 color) | |
173 { | |
174 | |
175 INT16 r,g,b; | |
176 UINT32 a; | |
177 | |
178 /*a=color&0xFF000000; | |
179 | |
180 color=color; | |
181 r=GetRValue(color); | |
182 g=GetGValue(color); | |
183 b=GetBValue(color); | |
184 | |
185 return(((~((r<<16) + (g<<8)+b)) & 0x00FFFFFF) | a);*/ | |
186 return((~(color&0xFFFFFF)) | (color&0xFF000000)); | |
187 } | |
188 | |
189 |