summaryrefslogtreecommitdiff
path: root/firmware/drivers/lcd-16bit-common.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2012-03-20 22:39:48 +0100
committerThomas Martitz <kugel@rockbox.org>2012-03-20 22:42:31 +0100
commitbae247075868986910dd426909370f2230b9331d (patch)
tree34b5741fcd39638baad8cf9ae26e3457abd10d6d /firmware/drivers/lcd-16bit-common.c
parent94139ac0bd3e1ca5d384ac8ac5ad2a915d633a82 (diff)
downloadrockbox-bae247075868986910dd426909370f2230b9331d.tar.gz
rockbox-bae247075868986910dd426909370f2230b9331d.zip
Refactor lcd_clear_viewport().
* Unify 16bit implementaitons (move to 16bit-common.c). * Add viewport clipping (within #ifdef HAVE_VIEWPORT_CLIP) like other lcd_* functions have. Change-Id: I4e96b2efdb94d2f7bc5bcdb710554117989579ec
Diffstat (limited to 'firmware/drivers/lcd-16bit-common.c')
-rw-r--r--firmware/drivers/lcd-16bit-common.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/firmware/drivers/lcd-16bit-common.c b/firmware/drivers/lcd-16bit-common.c
index c9e88b2137..bd6a0da956 100644
--- a/firmware/drivers/lcd-16bit-common.c
+++ b/firmware/drivers/lcd-16bit-common.c
@@ -111,6 +111,90 @@ void lcd_update_viewport_rect(int x, int y, int width, int height)
111 lcd_update_rect(current_vp->x + x, current_vp->y + y, width, height); 111 lcd_update_rect(current_vp->x + x, current_vp->y + y, width, height);
112} 112}
113 113
114/* Clear the current viewport */
115void lcd_clear_viewport(void)
116{
117 fb_data *dst, *dst_end;
118 int x, y, width, height;
119 int len, step;
120
121 x = current_vp->x;
122 y = current_vp->y;
123 width = current_vp->width;
124 height = current_vp->height;
125
126#if defined(HAVE_VIEWPORT_CLIP)
127 /********************* Viewport on screen clipping ********************/
128 /* nothing to draw? */
129 if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
130 || (x + width <= 0) || (y + height <= 0))
131 return;
132
133 /* clip image in viewport in screen */
134 if (x < 0)
135 {
136 width += x;
137 x = 0;
138 }
139 if (y < 0)
140 {
141 height += y;
142 y = 0;
143 }
144 if (x + width > LCD_WIDTH)
145 width = LCD_WIDTH - x;
146 if (y + height > LCD_HEIGHT)
147 height = LCD_HEIGHT - y;
148#endif
149
150 len = STRIDE_MAIN(width, height);
151 step = STRIDE_MAIN(ROW_INC, COL_INC);
152
153 dst = FBADDR(x, y);
154 dst_end = FBADDR(x + width - 1 , y + height - 1);
155
156 if (current_vp->drawmode & DRMODE_INVERSEVID)
157 {
158 do
159 {
160 memset16(dst, current_vp->fg_pattern, len);
161 dst += step;
162 }
163 while (dst < dst_end);
164 }
165 else
166 {
167 if (!lcd_backdrop)
168 {
169 do
170 {
171 memset16(dst, current_vp->bg_pattern, len);
172 dst += step;
173 }
174 while (dst < dst_end);
175 }
176 else
177 {
178 do
179 {
180 memcpy(dst, (void *)((long)dst + lcd_backdrop_offset),
181 len * sizeof(fb_data));
182 dst += step;
183 }
184 while (dst < dst_end);
185 }
186 }
187
188 if (current_vp == &default_vp)
189 {
190 lcd_scroll_info.lines = 0;
191 }
192 else
193 {
194 lcd_scroll_stop(current_vp);
195 }
196}
197
114/*** parameter handling ***/ 198/*** parameter handling ***/
115 199
116void lcd_set_drawmode(int mode) 200void lcd_set_drawmode(int mode)