@@ -211,7 +211,7 @@ static inline void write_update(const rg_surface_t *update)
211
211
// for both virtual keyboard and info labels. Maybe make it configurable later...
212
212
}
213
213
214
- if (lines_updated > display . screen . height * 0.80f )
214
+ if (lines_updated > draw_height * 0.80f )
215
215
counters .fullFrames ++ ;
216
216
else
217
217
counters .partFrames ++ ;
@@ -220,23 +220,25 @@ static inline void write_update(const rg_surface_t *update)
220
220
221
221
static void update_viewport_scaling (void )
222
222
{
223
+ int screen_width = display .screen .width ;
224
+ int screen_height = display .screen .height ;
223
225
int src_width = display .source .width ;
224
226
int src_height = display .source .height ;
225
227
int new_width = src_width ;
226
228
int new_height = src_height ;
227
229
228
230
if (config .scaling == RG_DISPLAY_SCALING_FULL )
229
231
{
230
- new_width = display . screen . width ;
231
- new_height = display . screen . height ;
232
+ new_width = screen_width ;
233
+ new_height = screen_height ;
232
234
}
233
235
else if (config .scaling == RG_DISPLAY_SCALING_FIT )
234
236
{
235
- new_width = FLOAT_TO_INT (display . screen . height * ((float )src_width / src_height ));
236
- new_height = display . screen . height ;
237
- if (new_width > display . screen . width ) {
238
- new_width = display . screen . width ;
239
- new_height = FLOAT_TO_INT (display . screen . width * ((float )src_height / src_width ));
237
+ new_width = FLOAT_TO_INT (screen_height * ((float )src_width / src_height ));
238
+ new_height = screen_height ;
239
+ if (new_width > screen_width ) {
240
+ new_width = screen_width ;
241
+ new_height = FLOAT_TO_INT (screen_width * ((float )src_height / src_width ));
240
242
}
241
243
}
242
244
else if (config .scaling == RG_DISPLAY_SCALING_ZOOM )
@@ -249,8 +251,8 @@ static void update_viewport_scaling(void)
249
251
new_width &= ~1 ;
250
252
new_height &= ~1 ;
251
253
252
- display .viewport .left = (display . screen . width - new_width ) / 2 ;
253
- display .viewport .top = (display . screen . height - new_height ) / 2 ;
254
+ display .viewport .left = (screen_width - new_width ) / 2 ;
255
+ display .viewport .top = (screen_height - new_height ) / 2 ;
254
256
display .viewport .width = new_width ;
255
257
display .viewport .height = new_height ;
256
258
@@ -264,9 +266,9 @@ static void update_viewport_scaling(void)
264
266
265
267
memset (screen_line_checksum , 0 , sizeof (screen_line_checksum ));
266
268
267
- for (int x = 0 ; x < display . screen . width ; ++ x )
269
+ for (int x = 0 ; x < screen_width ; ++ x )
268
270
map_viewport_to_source_x [x ] = FLOAT_TO_INT (x * display .viewport .step_x );
269
- for (int y = 0 ; y < display . screen . height ; ++ y )
271
+ for (int y = 0 ; y < screen_height ; ++ y )
270
272
map_viewport_to_source_y [y ] = FLOAT_TO_INT (y * display .viewport .step_y );
271
273
272
274
RG_LOGI ("%dx%d@%.3f => %dx%d@%.3f left:%d top:%d step_x:%.2f step_y:%.2f" , src_width , src_height ,
@@ -283,9 +285,9 @@ static bool load_border_file(const char *filename)
283
285
284
286
if (filename && (border = rg_surface_load_image_file (filename , 0 )))
285
287
{
286
- if (border -> width != display . screen . width || border -> height != display . screen . height )
288
+ if (border -> width != rg_display_get_width () || border -> height != rg_display_get_height () )
287
289
{
288
- rg_surface_t * resized = rg_surface_resize (border , display . screen . width , display . screen . height );
290
+ rg_surface_t * resized = rg_surface_resize (border , rg_display_get_width (), rg_display_get_height () );
289
291
if (resized )
290
292
{
291
293
rg_surface_free (border );
@@ -348,6 +350,16 @@ rg_display_counters_t rg_display_get_counters(void)
348
350
return counters ;
349
351
}
350
352
353
+ int rg_display_get_width (void )
354
+ {
355
+ return display .screen .width ;
356
+ }
357
+
358
+ int rg_display_get_height (void )
359
+ {
360
+ return display .screen .height ;
361
+ }
362
+
351
363
void rg_display_set_scaling (display_scaling_t scaling )
352
364
{
353
365
config .scaling = RG_MIN (RG_MAX (0 , scaling ), RG_DISPLAY_SCALING_COUNT - 1 );
0 commit comments