FreeCalypso > hg > fc-tourmaline
comparison src/cs/drivers/drv_app/r2d/lcds/ColorPC/R2D_pc_color_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_erase_operator(UINT32 old,UINT32 value) | |
38 { | |
39 if ((value&0x00FFFFFF)==0) | |
40 return(0xFFFFFF); | |
41 else | |
42 return(old); | |
43 } | |
44 | |
45 static UINT32 r2d_lcd_alpha_operator(UINT32 old,UINT32 value) | |
46 { | |
47 INT16 a,rs,gs,bs,rd,gd,bd; | |
48 | |
49 | |
50 | |
51 a=(value >> 24) & 0x0FF; | |
52 | |
53 | |
54 if (a) | |
55 { | |
56 | |
57 bs=value&0xFF; | |
58 | |
59 value=value>>8; | |
60 gs=value&0xFF; | |
61 | |
62 value=value>>8; | |
63 rs=value&0xFF; | |
64 | |
65 bd=old&0xFF; | |
66 | |
67 old=old>>8; | |
68 gd=old&0xFF; | |
69 | |
70 old=old>>8; | |
71 rd=old&0xFF; | |
72 | |
73 // Pixel value has been complemented before being | |
74 // saved so that the white correspond to 0 and be | |
75 // compatible with formulas for other modes. | |
76 // But alpha value is not complemented | |
77 // So a=0xFF correspond tranparency | |
78 bd=((a)*bd+(0x100 - a)*bs) >> 8; | |
79 gd=((a)*gd+(0x100 - a)*gs) >> 8; | |
80 rd=((a)*rd+(0x100 - a)*rs) >> 8; | |
81 | |
82 | |
83 old=((rd << 16) | (gd << 8) | bd) & 0x00FFFFFF; | |
84 return(old); | |
85 } | |
86 else return(value); | |
87 } | |
88 | |
89 const T_R2D_DRAWING_OPERATORS r2d_g_lcd_operators= | |
90 { | |
91 &r2d_lcd_copy_operator, | |
92 &r2d_lcd_or_operator, | |
93 &r2d_lcd_and_operator, | |
94 &r2d_lcd_xor_operator, | |
95 &r2d_lcd_not_copy_operator, | |
96 &r2d_lcd_not_or_operator, | |
97 &r2d_lcd_not_and_operator, | |
98 &r2d_lcd_not_xor_operator, | |
99 &r2d_lcd_alpha_operator, | |
100 &r2d_lcd_erase_operator | |
101 }; | |
102 | |
103 | |
104 | |
105 | |
106 | |
107 | |
108 | |
109 | |
110 // Return the pixel value to write on the LCD or the offscreen | |
111 // pixmap | |
112 // (Convert Riviera color to Windows RGB Format with complement) | |
113 void r2d_convert_foreground_color(T_R2D_GC *gc,UINT32 color) | |
114 { | |
115 /*gc->foreground_pixel_value=r2d_alpha(color); | |
116 gc->foreground_pixel_value<<=24; | |
117 | |
118 gc->foreground_pixel_value|=((RGB(r2d_red(color), | |
119 r2d_green(color),r2d_blue(color)))) & 0x00FFFFFF;*/ | |
120 | |
121 gc->foreground_pixel_value=color; | |
122 } | |
123 | |
124 // Return the pixel value to write on the LCD or the offscreen | |
125 // pixmap | |
126 // (Convert ribviera color to windows RGB format with complement) | |
127 void r2d_convert_background_color(T_R2D_GC *gc,UINT32 color) | |
128 { | |
129 /*gc->background_pixel_value=r2d_alpha(color); | |
130 gc->background_pixel_value<<=24; | |
131 | |
132 gc->background_pixel_value|=((RGB(r2d_red(color), | |
133 r2d_green(color),r2d_blue(color)))) & 0x00FFFFFF;*/ | |
134 | |
135 gc->background_pixel_value=color; | |
136 } | |
137 | |
138 // Convert a LCD value (not color) to a value | |
139 // to be written into the 24bpp framebuffer | |
140 // In general, the value written is a packed | |
141 // representation of the ARGB color | |
142 // but it may be different according to the framebuffer | |
143 // internal format | |
144 BOOLEAN r2d_lcd_foreground_pixel(UINT32 lcd_value,T_R2D_GC_PTR src_gc) | |
145 { | |
146 if (lcd_value&0x0FFFFFF==0x0FFFFFF) | |
147 return(FALSE); | |
148 else | |
149 return(TRUE); | |
150 } | |
151 | |
152 // Assume than color framebuffer contains ARGB packed values | |
153 // Convert color to LCD with on the fly dithering | |
154 // Riviera complemented RGB to Windows complemented one | |
155 // Convert from pixel_value to LCD | |
156 UINT32 r2d_color_to_lcd(UINT32 pixel_value,INT16 x,INT16 y) | |
157 { | |
158 return((((~pixel_value)&0x00FFFFFF)) | (pixel_value&0xFF000000)); | |
159 } | |
160 | |
161 // Windows RGB format to pixel value for 24 bpp framebuffer | |
162 UINT32 r2d_lcd_to_color(UINT32 color) | |
163 { | |
164 | |
165 // INT16 r,g,b; | |
166 // UINT32 a; | |
167 | |
168 /*a=color&0xFF000000; | |
169 | |
170 color=color; | |
171 r=GetRValue(color); | |
172 g=GetGValue(color); | |
173 b=GetBValue(color); | |
174 | |
175 return(((~((r<<16) + (g<<8)+b)) & 0x00FFFFFF) | a);*/ | |
176 return((~(color&0xFFFFFF)) | (color&0xFF000000)); | |
177 } | |
178 | |
179 |