@@ -343,7 +343,7 @@ static inline void write_update(const rg_surface_t *update)
343343 lcd_sync ();
344344 }
345345
346- if (lines_updated > display . screen . height * 0.80f )
346+ if (lines_updated > draw_height * 0.80f )
347347 counters .fullFrames ++ ;
348348 else
349349 counters .partFrames ++ ;
@@ -352,23 +352,25 @@ static inline void write_update(const rg_surface_t *update)
352352
353353static void update_viewport_scaling (void )
354354{
355+ int screen_width = display .screen .width ;
356+ int screen_height = display .screen .height ;
355357 int src_width = display .source .width ;
356358 int src_height = display .source .height ;
357359 int new_width = src_width ;
358360 int new_height = src_height ;
359361
360362 if (config .scaling == RG_DISPLAY_SCALING_FULL )
361363 {
362- new_width = display . screen . width ;
364+ new_width = screen_width ;
363365 new_height = display .screen .height ;
364366 }
365367 else if (config .scaling == RG_DISPLAY_SCALING_FIT )
366368 {
367- new_width = FLOAT_TO_INT (display . screen . height * ((float )src_width / src_height ));
368- new_height = display . screen . height ;
369- if (new_width > display . screen . width ) {
370- new_width = display . screen . width ;
371- new_height = FLOAT_TO_INT (display . screen . width * ((float )src_height / src_width ));
369+ new_width = FLOAT_TO_INT (screen_height * ((float )src_width / src_height ));
370+ new_height = screen_height ;
371+ if (new_width > screen_width ) {
372+ new_width = screen_width ;
373+ new_height = FLOAT_TO_INT (screen_width * ((float )src_height / src_width ));
372374 }
373375 }
374376 else if (config .scaling == RG_DISPLAY_SCALING_ZOOM )
@@ -381,8 +383,8 @@ static void update_viewport_scaling(void)
381383 new_width &= ~1 ;
382384 new_height &= ~1 ;
383385
384- display .viewport .left = (display . screen . width - new_width ) / 2 ;
385- display .viewport .top = (display . screen . height - new_height ) / 2 ;
386+ display .viewport .left = (screen_width - new_width ) / 2 ;
387+ display .viewport .top = (screen_height - new_height ) / 2 ;
386388 display .viewport .width = new_width ;
387389 display .viewport .height = new_height ;
388390
@@ -396,9 +398,9 @@ static void update_viewport_scaling(void)
396398
397399 memset (screen_line_checksum , 0 , sizeof (screen_line_checksum ));
398400
399- for (int x = 0 ; x < display . screen . width ; ++ x )
401+ for (int x = 0 ; x < screen_width ; ++ x )
400402 map_viewport_to_source_x [x ] = FLOAT_TO_INT (x * display .viewport .step_x );
401- for (int y = 0 ; y < display . screen . height ; ++ y )
403+ for (int y = 0 ; y < screen_height ; ++ y )
402404 map_viewport_to_source_y [y ] = FLOAT_TO_INT (y * display .viewport .step_y );
403405
404406 RG_LOGI ("%dx%d@%.3f => %dx%d@%.3f left:%d top:%d step_x:%.2f step_y:%.2f" , src_width , src_height ,
@@ -415,9 +417,9 @@ static bool load_border_file(const char *filename)
415417
416418 if (filename && (border = rg_surface_load_image_file (filename , 0 )))
417419 {
418- if (border -> width != display . screen . width || border -> height != display . screen . height )
420+ if (border -> width != rg_display_get_width () || border -> height != rg_display_get_height () )
419421 {
420- rg_surface_t * resized = rg_surface_resize (border , display . screen . width , display . screen . height );
422+ rg_surface_t * resized = rg_surface_resize (border , rg_display_get_width (), rg_display_get_height () );
421423 if (resized )
422424 {
423425 rg_surface_free (border );
@@ -480,6 +482,16 @@ rg_display_counters_t rg_display_get_counters(void)
480482 return counters ;
481483}
482484
485+ int rg_display_get_width (void )
486+ {
487+ return display .screen .width ;
488+ }
489+
490+ int rg_display_get_height (void )
491+ {
492+ return display .screen .height ;
493+ }
494+
483495void rg_display_set_scaling (display_scaling_t scaling )
484496{
485497 config .scaling = RG_MIN (RG_MAX (0 , scaling ), RG_DISPLAY_SCALING_COUNT - 1 );
0 commit comments