summaryrefslogtreecommitdiff
path: root/apps/plugins/test_fps.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/test_fps.c')
-rw-r--r--apps/plugins/test_fps.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/apps/plugins/test_fps.c b/apps/plugins/test_fps.c
index b2fc957dc1..ddf938ac25 100644
--- a/apps/plugins/test_fps.c
+++ b/apps/plugins/test_fps.c
@@ -123,6 +123,94 @@ static void time_main_update(void)
123 log_text(str); 123 log_text(str);
124} 124}
125 125
126#if defined(HAVE_LCD_COLOR) && (MEMORYSIZE > 2)
127
128#if LCD_WIDTH >= LCD_HEIGHT
129#define YUV_WIDTH LCD_WIDTH
130#define YUV_HEIGHT LCD_HEIGHT
131#else /* Assume the screen is rotated on portrait LCDs */
132#define YUV_WIDTH LCD_HEIGHT
133#define YUV_HEIGHT LCD_WIDTH
134#endif
135
136static unsigned char ydata[YUV_HEIGHT][YUV_WIDTH];
137static unsigned char udata[YUV_HEIGHT/2][YUV_WIDTH/2];
138static unsigned char vdata[YUV_HEIGHT/2][YUV_WIDTH/2];
139
140static unsigned char * const yuvbuf[3] = {
141 (void*)ydata,
142 (void*)udata,
143 (void*)vdata
144};
145
146static void make_gradient_rect(int width, int height)
147{
148 unsigned char vline[YUV_WIDTH/2];
149 int x, y;
150
151 width /= 2;
152 height /= 2;
153
154 for (x = 0; x < width; x++)
155 vline[x] = (x << 8) / width;
156 for (y = 0; y < height; y++)
157 {
158 rb->memset(udata[y], (y << 8) / height, width);
159 rb->memcpy(vdata[y], vline, width);
160 }
161}
162
163static void time_main_yuv(void)
164{
165 char str[32]; /* text buffer */
166 long time_start; /* start tickcount */
167 long time_end; /* end tickcount */
168 int frame_count;
169 int fps;
170
171 const int part14_x = YUV_WIDTH/4; /* x-offset for 1/4 update test */
172 const int part14_w = YUV_WIDTH/2; /* x-size for 1/4 update test */
173 const int part14_y = YUV_HEIGHT/4; /* y-offset for 1/4 update test */
174 const int part14_h = YUV_HEIGHT/2; /* y-size for 1/4 update test */
175
176 log_text("Main LCD YUV");
177
178 rb->memset(ydata, 128, sizeof(ydata)); /* medium grey */
179
180 /* Test 1: full LCD update */
181 make_gradient_rect(YUV_WIDTH, YUV_HEIGHT);
182
183 frame_count = 0;
184 rb->sleep(0); /* sync to tick */
185 time_start = *rb->current_tick;
186 while((time_end = *rb->current_tick) - time_start < DURATION)
187 {
188 rb->lcd_blit_yuv(yuvbuf, 0, 0, YUV_WIDTH,
189 0, 0, YUV_WIDTH, YUV_HEIGHT);
190 frame_count++;
191 }
192 fps = calc_tenth_fps(frame_count, time_end - time_start);
193 rb->snprintf(str, sizeof(str), "1/1: %d.%d fps", fps / 10, fps % 10);
194 log_text(str);
195
196 /* Test 2: quarter LCD update */
197 make_gradient_rect(YUV_WIDTH/2, YUV_HEIGHT/2);
198
199 frame_count = 0;
200 rb->sleep(0); /* sync to tick */
201 time_start = *rb->current_tick;
202 while((time_end = *rb->current_tick) - time_start < DURATION)
203 {
204 rb->lcd_blit_yuv(yuvbuf, 0, 0, YUV_WIDTH,
205 part14_x, part14_y, part14_w, part14_h);
206 frame_count++;
207 }
208 fps = calc_tenth_fps(frame_count, time_end - time_start);
209 rb->snprintf(str, sizeof(str), "1/4: %d.%d fps", fps / 10, fps % 10);
210 log_text(str);
211}
212#endif
213
126#ifdef HAVE_REMOTE_LCD 214#ifdef HAVE_REMOTE_LCD
127static void time_remote_update(void) 215static void time_remote_update(void)
128{ 216{
@@ -318,6 +406,9 @@ enum plugin_status plugin_start(const void* parameter)
318#endif 406#endif
319 time_main_update(); 407 time_main_update();
320 rb->sleep(HZ); 408 rb->sleep(HZ);
409#if defined(HAVE_LCD_COLOR) && (MEMORYSIZE > 2)
410 time_main_yuv();
411#endif
321#if LCD_DEPTH < 4 412#if LCD_DEPTH < 4
322 time_greyscale(); 413 time_greyscale();
323#endif 414#endif