comparison src/cs/drivers/drv_app/r2d/lcds/Horizontal/R2D_horizontal_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 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
127 r2d_dithered_value(0,0)
128 r2d_set_dithering_matrix_entry(gc->p_background_dithered_cache,
129 dvalue,0,0);
130
131 r2d_dithered_value(0,1)
132 r2d_set_dithering_matrix_entry(gc->p_background_dithered_cache,
133 dvalue,0,1);
134
135 r2d_dithered_value(1,1)
136 r2d_set_dithering_matrix_entry(gc->p_background_dithered_cache,
137 dvalue,1,1);
138
139 r2d_dithered_value(1,0)
140 r2d_set_dithering_matrix_entry(gc->p_background_dithered_cache,
141 dvalue,1,0);
142
143
144 }
145 #else
146 lightness=(lightness >> (8 - R2D_PIXEL_DEPTH)) & R2D_PIXEL_MASK;
147 gc->background_pixel_value=lightness;
148 #endif
149
150
151
152
153
154 }
155
156 // blit_rect may use the foreground and background color
157 // to do the copy. So, one must knows which source pixels
158 // are corresponding to the background color,
159 // which ones are corresponding to the foreground color
160 // and do the conversion of the color selected
161 // according to the destination framebuffer
162
163 // This files gives routines for:
164 // - Selecting a color according to the value in the LCD framebuffer
165 // - Converting a color to LCD
166
167
168 // Convert a LCD value (not color) to a value
169 // to be written into the 24bpp framebuffer
170 // In general, the value written is a packed
171 // representation of the ARGB color
172 // but it may be different according to the framebuffer
173 // internal format
174 BOOLEAN r2d_lcd_foreground_pixel(UINT32 lcd_value,T_R2D_GC_PTR src_gc)
175 {
176 if (lcd_value)
177 return(TRUE); // Foreground pixel
178 else
179 return(FALSE); // Background pixel
180 }
181
182 // Assume than color framebuffer contains ARGB packed values
183 // Convert color to LCD with on the fly dithering
184 UINT32 r2d_color_to_lcd(UINT32 pixel_value,INT16 x,INT16 y)
185 {
186
187 INT16 red,green,blue;
188 UINT32 lightness;
189 UINT32 dvalue;
190 UINT16 dithering_group;
191
192 pixel_value=(~pixel_value) & 0x00FFFFFF;
193 red=r2d_red(pixel_value);
194 green=r2d_green(pixel_value);
195 blue=r2d_blue(pixel_value);
196
197 // Compute global intensity for monochrome LCD
198 lightness=(~((r2d_max_color(red,green,blue) + r2d_min_color(red,green,blue)) >> 1) & 0xFF);
199
200
201 r2d_dithering_group_and_lightness();
202
203 r2d_dithered_value(x & 1,y & 1);
204
205 return(dvalue);
206 }
207
208 // Lcd to pixel value
209 UINT32 r2d_lcd_to_color(UINT32 color)
210 {
211
212 if (color)
213 return(0x00FFFFFF); // 24 bpp framebuffer pixel value for white
214 else
215 return(0x00000000);
216 }
217
218
219