comparison chipsetsw/drivers/drv_app/r2d/lcds/ColorBoard/R2D_board_color_lcd_i.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1
2
3 static UINT32 r2d_lcd_copy_operator(UINT32 old,UINT32 value)
4 {
5 return(value);
6 }
7 static UINT32 r2d_lcd_or_operator(UINT32 old,UINT32 value)
8 {
9 if ((value&0x0FF)==0)
10 return(old);
11 else
12 return(value);
13 }
14 static UINT32 r2d_lcd_and_operator(UINT32 old,UINT32 value)
15 {
16 return(old & value);
17 }
18 static UINT32 r2d_lcd_xor_operator(UINT32 old,UINT32 value)
19 {
20 return(old ^ value) ;
21 }
22 static UINT32 r2d_lcd_not_copy_operator(UINT32 old,UINT32 value)
23 {
24 return(~value);
25 }
26 static UINT32 r2d_lcd_not_or_operator(UINT32 old,UINT32 value)
27 {
28 return(~(old | value));
29 }
30 static UINT32 r2d_lcd_not_and_operator(UINT32 old,UINT32 value)
31 {
32 return(~(old & value));
33 }
34 static UINT32 r2d_lcd_not_xor_operator(UINT32 old,UINT32 value)
35 {
36 return(~(old ^ value)) ;
37 }
38 static UINT32 r2d_lcd_erase_operator(UINT32 old,UINT32 value)
39 {
40 if ((value&0x0FF)==0xFF)
41 return(0);
42 else
43 return(old);
44 }
45
46
47 UINT32 r2d_lcd_alpha_operator(UINT32 old,UINT32 value)
48 {
49 INT16 a,rs,gs,bs,rd,gd,bd;
50
51 a=(value >> 8) & 0x0FF;
52
53 if (a)
54 {
55
56 value=(~value) & 0xFF;
57 old=(~old) & 0xFF;
58
59
60 bs=value&0x3;
61 value=value>>2;
62 gs=value&7;
63 value=value>>3;
64 rs=value&7;
65
66
67 bd=old&0x3;
68 old=old>>2;
69 gd=old&7;
70 old=old>>3;
71 rd=old&7;
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 rd=rd<<5;
83 gd=gd<<2;
84
85 old=(~(rd|gd|bd)) & 0x00FF;
86 return(old);
87 }
88 else
89 return(value);
90 }
91
92
93 const T_R2D_DRAWING_OPERATORS r2d_g_lcd_operators=
94 {
95 &r2d_lcd_copy_operator,
96 &r2d_lcd_or_operator,
97 &r2d_lcd_and_operator,
98 &r2d_lcd_xor_operator,
99 &r2d_lcd_not_copy_operator,
100 &r2d_lcd_not_or_operator,
101 &r2d_lcd_not_and_operator,
102 &r2d_lcd_not_xor_operator,
103 &r2d_lcd_alpha_operator,
104 &r2d_lcd_erase_operator
105 };
106
107
108 // Return the pixel value to write on the LCD or the offscreen
109 // pixmap
110 // (Convert Riviera color to Windows RGB Format with complement)
111 void r2d_convert_foreground_color(T_R2D_GC *gc,UINT32 color)
112 {
113 INT16 r,g,b,a;
114
115 gc->foreground_pixel_value=0;
116
117 a=(r2d_alpha(color)) <<8;
118 gc->foreground_pixel_value|=a;
119
120 r=(r2d_red(color)) >> 5;
121 g=(r2d_green(color)) >> 5;
122 b=(r2d_blue(color)) >> 6;
123
124 gc->foreground_pixel_value|= (~((r<<5) | (g<<2) | b)) & 0x0FFFF;
125
126
127 }
128
129 // Return the pixel value to write on the LCD or the offscreen
130 // pixmap
131 // (Convert riviera color to windows RGB format with complement)
132 void r2d_convert_background_color(T_R2D_GC *gc,UINT32 color)
133 {
134 INT16 r,g,b,a;
135
136 gc->background_pixel_value=0;
137
138 a=(r2d_alpha(color)) <<8;
139 gc->background_pixel_value|=a;
140
141 r=(r2d_red(color)) >> 5;
142 g=(r2d_green(color)) >> 5;
143 b=(r2d_blue(color)) >> 6;
144
145 gc->background_pixel_value|= (~((r<<5) | (g<<2) | b)) & 0xFF;
146
147 }
148
149
150
151 // Convert a LCD value (not color) to a value
152 // to be written into the 24bpp framebuffer
153 // In general, the value written is a packed
154 // representation of the ARGB color
155 // but it may be different according to the framebuffer
156 // internal format
157 BOOLEAN r2d_lcd_foreground_pixel(UINT32 lcd_value,T_R2D_GC_PTR src_gc)
158 {
159 if (lcd_value)
160 return(TRUE);
161 else
162 return(FALSE);
163 }
164
165 // Color framebuffer to color LCD
166 UINT32 r2d_color_to_lcd(UINT32 pixel_value,INT16 x,INT16 y)
167 {
168
169 INT16 red,green,blue;
170 UINT32 alpha;
171
172 alpha=pixel_value & 0xFF000000;
173 alpha=alpha >> 16;
174
175
176 pixel_value=(~pixel_value) & 0x00FFFFFF;
177 red=r2d_red(pixel_value);
178 green=r2d_green(pixel_value);
179 blue=r2d_blue(pixel_value);
180
181 red=red>>5;
182 green=green>>5;
183 blue=blue>>6;
184
185 return(((~((red<<5) | (green << 2) | blue)) & 0x00FF) | alpha);
186 }
187
188 // Color LCD to color framebuffer
189 UINT32 r2d_lcd_to_color(UINT32 color)
190 {
191
192 INT16 r,g,b;
193 UINT32 alpha;
194
195 alpha=color & 0xFF00;
196 alpha=alpha << 16;
197
198 color=~color;
199 b=color&0x3;
200 color=color>>2;
201 g=color&7;
202 color=color>>3;
203 r=color&7;
204
205 b=b<<6;
206 g=g<<5;
207 r=r<<5;
208
209 return(((~((r<<16) + (g<<8)+b)) & 0x00FFFFFF) | alpha);
210 }
211
212