FreeCalypso > hg > fc-selenite
comparison src/cs/drivers/drv_app/r2d/lcds/Customer/R2D_customer_lcd_i.c @ 0:b6a5e36de839
src/cs: initial import from Magnetite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 15 Jul 2018 04:39:26 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:b6a5e36de839 |
---|---|
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 return(old | value) ; | |
8 } | |
9 static UINT32 r2d_lcd_and_operator(UINT32 old,UINT32 value) | |
10 { | |
11 return(old & value); | |
12 } | |
13 static UINT32 r2d_lcd_xor_operator(UINT32 old,UINT32 value) | |
14 { | |
15 return(old ^ value) ; | |
16 } | |
17 static UINT32 r2d_lcd_not_copy_operator(UINT32 old,UINT32 value) | |
18 { | |
19 return(~value); | |
20 } | |
21 static UINT32 r2d_lcd_not_or_operator(UINT32 old,UINT32 value) | |
22 { | |
23 return(~(old | value)); | |
24 } | |
25 static UINT32 r2d_lcd_not_and_operator(UINT32 old,UINT32 value) | |
26 { | |
27 return(~(old & value)); | |
28 } | |
29 static UINT32 r2d_lcd_not_xor_operator(UINT32 old,UINT32 value) | |
30 { | |
31 return(~(old ^ value)) ; | |
32 } | |
33 | |
34 const T_R2D_DRAWING_OPERATORS r2d_g_lcd_operators= | |
35 { | |
36 &r2d_lcd_copy_operator, | |
37 &r2d_lcd_or_operator, | |
38 &r2d_lcd_and_operator, | |
39 &r2d_lcd_xor_operator, | |
40 &r2d_lcd_not_copy_operator, | |
41 &r2d_lcd_not_or_operator, | |
42 &r2d_lcd_not_and_operator, | |
43 &r2d_lcd_not_xor_operator, | |
44 NULL | |
45 }; | |
46 | |
47 // Return the pixel value to write on the LCD or the offscreen | |
48 // pixmap | |
49 // LCD DEPENDENT | |
50 void r2d_convert_foreground_color(T_R2D_GC *gc,UINT32 color) | |
51 { | |
52 | |
53 // If one is writing to the LCD framebuffer (the only | |
54 // one which is not 24 bits) then color conversion is required | |
55 UINT16 red,green,blue; | |
56 UINT32 lightness; | |
57 | |
58 | |
59 red=r2d_red(color); | |
60 green=r2d_green(color); | |
61 blue=r2d_blue(color); | |
62 | |
63 // Compute global intensity for monochrome LCD | |
64 lightness=(~((r2d_max_color(red,green,blue) + r2d_min_color(red,green,blue)) >> 1) & 0xFF); | |
65 | |
66 #if (R2D_DITHERING == R2D_ON) | |
67 { | |
68 UINT32 dvalue; | |
69 UINT16 dithering_group; | |
70 | |
71 r2d_dithering_group_and_lightness(); | |
72 | |
73 r2d_dithered_value(0,0) | |
74 r2d_set_dithering_matrix_entry(gc->p_foreground_dithered_cache, | |
75 dvalue,0,0); | |
76 | |
77 r2d_dithered_value(0,1) | |
78 r2d_set_dithering_matrix_entry(gc->p_foreground_dithered_cache, | |
79 dvalue,0,1); | |
80 | |
81 r2d_dithered_value(1,1) | |
82 r2d_set_dithering_matrix_entry(gc->p_foreground_dithered_cache, | |
83 dvalue,1,1); | |
84 | |
85 r2d_dithered_value(1,0) | |
86 r2d_set_dithering_matrix_entry(gc->p_foreground_dithered_cache, | |
87 dvalue,1,0); | |
88 | |
89 | |
90 } | |
91 #else | |
92 lightness=(lightness >> (8 - R2D_PIXEL_DEPTH)) & R2D_PIXEL_MASK; | |
93 gc->foreground_pixel_value=lightness; | |
94 #endif | |
95 | |
96 | |
97 | |
98 } | |
99 | |
100 // Return the pixel value to write on the LCD or the offscreen | |
101 // pixmap | |
102 // LCD DEPENDENT | |
103 void r2d_convert_background_color(T_R2D_GC *gc,UINT32 color) | |
104 { | |
105 | |
106 // If one is writing to the LCD framebuffer (the only | |
107 // one which is not 24 bits) then color conversion is required | |
108 UINT16 red,green,blue; | |
109 UINT32 lightness; | |
110 | |
111 | |
112 red=r2d_red(color); | |
113 green=r2d_green(color); | |
114 blue=r2d_blue(color); | |
115 | |
116 // Compute global intensity for monochrome LCD | |
117 lightness=(~((r2d_max_color(red,green,blue) + r2d_min_color(red,green,blue)) >> 1) & 0xFF); | |
118 | |
119 #if (R2D_DITHERING == R2D_ON) | |
120 { | |
121 UINT32 dvalue; | |
122 UINT16 dithering_group; | |
123 | |
124 r2d_dithering_group_and_lightness(); | |
125 | |
126 r2d_dithered_value(0,0) | |
127 r2d_set_dithering_matrix_entry(gc->p_background_dithered_cache, | |
128 dvalue,0,0); | |
129 | |
130 r2d_dithered_value(0,1) | |
131 r2d_set_dithering_matrix_entry(gc->p_background_dithered_cache, | |
132 dvalue,0,1); | |
133 | |
134 r2d_dithered_value(1,1) | |
135 r2d_set_dithering_matrix_entry(gc->p_background_dithered_cache, | |
136 dvalue,1,1); | |
137 | |
138 r2d_dithered_value(1,0) | |
139 r2d_set_dithering_matrix_entry(gc->p_background_dithered_cache, | |
140 dvalue,1,0); | |
141 | |
142 | |
143 } | |
144 #else | |
145 lightness=(lightness >> (8 - R2D_PIXEL_DEPTH)) & R2D_PIXEL_MASK; | |
146 gc->background_pixel_value=lightness; | |
147 #endif | |
148 | |
149 | |
150 | |
151 | |
152 | |
153 } | |
154 | |
155 // blit_rect may use the foreground and background color | |
156 // to do the copy. So, one must knows which source pixels | |
157 // are corresponding to the background color, | |
158 // which ones are corresponding to the foreground color | |
159 // and do the conversion of the color selected | |
160 // according to the destination framebuffer | |
161 | |
162 // This files gives routines for: | |
163 // - Selecting a color according to the value in the LCD framebuffer | |
164 // - Converting a color to LCD | |
165 | |
166 | |
167 // Convert a LCD value (not color) to a value | |
168 // to be written into the 24bpp framebuffer | |
169 // In general, the value written is a packed | |
170 // representation of the ARGB color | |
171 // but it may be different according to the framebuffer | |
172 // internal format | |
173 BOOLEAN r2d_lcd_foreground_pixel(UINT32 lcd_value,T_R2D_GC_PTR src_gc) | |
174 { | |
175 if (lcd_value) | |
176 return(TRUE); // Foreground pixel | |
177 else | |
178 return(FALSE); // Background pixel | |
179 } | |
180 | |
181 // Assume than color framebuffer contains ARGB packed values | |
182 // Convert color to LCD with on the fly dithering | |
183 UINT32 r2d_color_to_lcd(UINT32 pixel_value,INT16 x,INT16 y) | |
184 { | |
185 | |
186 INT16 red,green,blue; | |
187 UINT32 lightness; | |
188 UINT32 dvalue; | |
189 UINT16 dithering_group; | |
190 | |
191 pixel_value=(~pixel_value) & 0x00FFFFFF; | |
192 red=r2d_red(pixel_value); | |
193 green=r2d_green(pixel_value); | |
194 blue=r2d_blue(pixel_value); | |
195 | |
196 // Compute global intensity for monochrome LCD | |
197 lightness=(~((r2d_max_color(red,green,blue) + r2d_min_color(red,green,blue)) >> 1) & 0xFF); | |
198 | |
199 | |
200 r2d_dithering_group_and_lightness(); | |
201 | |
202 r2d_dithered_value(x & 1,y & 1); | |
203 | |
204 return(dvalue); | |
205 } | |
206 | |
207 // Lcd to pixel value | |
208 UINT32 r2d_lcd_to_color(UINT32 color) | |
209 { | |
210 | |
211 if (color) | |
212 return(0x00FFFFFF); // 24 bpp framebuffer pixel value for white | |
213 else | |
214 return(0x00000000); | |
215 } | |
216 | |
217 | |
218 |