Skip to content

Commit d3761a0

Browse files
Evan BirenbaumGerrit Code Review
Evan Birenbaum
authored and
Gerrit Code Review
committed
Merge "ui: Remove the "-scale" flag and "window scale" command." into emu-master-dev
2 parents a0aa7fe + 6795766 commit d3761a0

File tree

8 files changed

+26
-178
lines changed

8 files changed

+26
-178
lines changed

android/cmdline-options.h

-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ OPT_PARAM( onion, "<image>", "use overlay PNG image over screen" )
123123
OPT_PARAM( onion_alpha, "<%age>", "specify onion-skin translucency" )
124124
OPT_PARAM( onion_rotation, "0|1|2|3", "specify onion-skin rotation" )
125125

126-
OPT_PARAM( scale, "<scale>", "scale emulator window" )
127126
OPT_PARAM( dpi_device, "<dpi>", "specify device's resolution in dpi (default "
128127
STRINGIFY(DEFAULT_DEVICE_DPI) ")" )
129128

android/console.c

+1-54
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2007-2015 The Android Open Source Project
1+
/* Copyright (C) 2007-2016 The Android Open Source Project
22
**
33
** This software is licensed under the terms of the GNU General Public
44
** License version 2, as published by the Free Software Foundation, and
@@ -53,8 +53,6 @@
5353
#include <string.h>
5454
#include <unistd.h>
5555

56-
extern void android_emulator_set_window_scale(double, int);
57-
5856
#define DEBUG 1
5957

6058
#if 1
@@ -2567,53 +2565,6 @@ static const CommandDefRec fingerprint_commands[] =
25672565
{ NULL, NULL, NULL, NULL, NULL, NULL }
25682566
};
25692567

2570-
/********************************************************************************************/
2571-
/********************************************************************************************/
2572-
/***** ******/
2573-
/***** M A I N C O M M A N D S ******/
2574-
/***** ******/
2575-
/********************************************************************************************/
2576-
/********************************************************************************************/
2577-
2578-
static int
2579-
do_window_scale( ControlClient client, char* args )
2580-
{
2581-
double scale;
2582-
int is_dpi = 0;
2583-
char* end;
2584-
2585-
if (!args) {
2586-
control_write( client, "KO: argument missing, try 'window scale <scale>'\r\n" );
2587-
return -1;
2588-
}
2589-
2590-
scale = strtol( args, &end, 10 );
2591-
if (end > args && !memcmp( end, "dpi", 4 )) {
2592-
is_dpi = 1;
2593-
}
2594-
else {
2595-
scale = strtod( args, &end );
2596-
if (end == args || end[0]) {
2597-
control_write( client, "KO: argument <scale> must be a real number, or an integer followed by 'dpi'\r\n" );
2598-
return -1;
2599-
}
2600-
}
2601-
2602-
android_emulator_set_window_scale(scale, is_dpi);
2603-
return 0;
2604-
}
2605-
2606-
static const CommandDefRec window_commands[] =
2607-
{
2608-
{ "scale", "change the window scale",
2609-
"'window scale <scale>' allows you to change the scale of the emulator window at runtime\r\n"
2610-
"<scale> must be either a real number between 0.1 and 3.0, or an integer followed by\r\n"
2611-
"the 'dpi' prefix (as in '120dpi')\r\n",
2612-
NULL, do_window_scale, NULL },
2613-
2614-
{ NULL, NULL, NULL, NULL, NULL, NULL }
2615-
};
2616-
26172568
/********************************************************************************************/
26182569
/********************************************************************************************/
26192570
/***** ******/
@@ -2715,10 +2666,6 @@ static const CommandDefRec main_commands[] =
27152666
"allows you to control (e.g. start/stop) the execution of the virtual device\r\n", NULL,
27162667
NULL, vm_commands },
27172668

2718-
{ "window", "manage emulator window",
2719-
"allows you to modify the emulator window\r\n", NULL,
2720-
NULL, window_commands },
2721-
27222669
{ "qemu", "QEMU-specific commands",
27232670
"allows to connect to the QEMU virtual machine monitor\r\n", NULL,
27242671
NULL, qemu_commands },

android/emulator-window.c

+1-81
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2006-2015 The Android Open Source Project
1+
/* Copyright (C) 2006-2016 The Android Open Source Project
22
**
33
** This software is licensed under the terms of the GNU General Public
44
** License version 2, as published by the Free Software Foundation, and
@@ -33,8 +33,6 @@
3333

3434
#define D(...) do { if (VERBOSE_CHECK(init)) dprint(__VA_ARGS__); } while (0)
3535

36-
static double get_default_scale( AndroidOptions* opts );
37-
3836
int qemu_net_disable = 0;
3937

4038
/* EmulatorWindow structure instance. */
@@ -203,7 +201,6 @@ emulator_window_setup( EmulatorWindow* emulator )
203201

204202
.window_x = emulator->win_x,
205203
.window_y = emulator->win_y,
206-
.window_scale = get_default_scale(emulator->opts),
207204

208205
.keyboard_charmap = emulator->opts->charmap,
209206
.keyboard_raw_keys = emulator->opts->raw_keys != 0,
@@ -432,66 +429,6 @@ get_device_dpi( AndroidOptions* opts )
432429
return dpi_device;
433430
}
434431

435-
static double
436-
get_default_scale( AndroidOptions* opts )
437-
{
438-
int dpi_device = get_device_dpi( opts );
439-
int dpi_monitor = -1;
440-
double scale = 0.0;
441-
442-
/* possible values for the 'scale' option are
443-
* 'auto' : try to determine the scale automatically
444-
* '<number>dpi' : indicates the host monitor dpi, compute scale accordingly
445-
* '<fraction>' : use direct scale coefficient
446-
*/
447-
448-
if (opts->scale) {
449-
if (!strcmp(opts->scale, "auto"))
450-
{
451-
/* we need to get the host dpi resolution ? */
452-
int xdpi, ydpi;
453-
454-
if (skin_winsys_get_monitor_dpi(&xdpi, &ydpi) < 0) {
455-
fprintf(stderr, "could not get monitor DPI resolution from system. please use -dpi-monitor to specify one\n" );
456-
exit(1);
457-
}
458-
D( "system reported monitor resolutions: xdpi=%d ydpi=%d\n", xdpi, ydpi);
459-
dpi_monitor = (xdpi + ydpi+1)/2;
460-
}
461-
else
462-
{
463-
char* end;
464-
scale = strtod( opts->scale, &end );
465-
466-
if (end && end[0] == 'd' && end[1] == 'p' && end[2] == 'i' && end[3] == 0) {
467-
if ( scale < 20 || scale > 1000 ) {
468-
fprintf(stderr, "emulator: ignoring bad -scale argument '%s': %s\n", opts->scale,
469-
"host dpi number must be between 20 and 1000" );
470-
exit(1);
471-
}
472-
dpi_monitor = scale;
473-
scale = 0.0;
474-
}
475-
else if (end == NULL || *end != 0) {
476-
fprintf(stderr, "emulator: ignoring bad -scale argument '%s': %s\n", opts->scale,
477-
"not a number or the 'auto' keyword" );
478-
exit(1);
479-
}
480-
else if ( scale < 0.1 || scale > 3. ) {
481-
fprintf(stderr, "emulator: ignoring bad -window-scale argument '%s': %s\n", opts->scale,
482-
"must be between 0.1 and 3.0" );
483-
exit(1);
484-
}
485-
}
486-
}
487-
488-
if (scale == 0.0 && dpi_monitor > 0)
489-
scale = dpi_monitor*1.0/dpi_device;
490-
491-
return scale;
492-
}
493-
494-
495432
/* called periodically to poll for user input events */
496433
static void emulator_window_refresh(EmulatorWindow* emulator)
497434
{
@@ -509,23 +446,6 @@ static void emulator_window_refresh(EmulatorWindow* emulator)
509446
}
510447
}
511448

512-
/*
513-
* android-qemu1-glue/console.c helper routines.
514-
*/
515-
516-
void
517-
android_emulator_set_window_scale(double scale, int is_dpi)
518-
{
519-
EmulatorWindow* emulator = qemulator;
520-
521-
if (is_dpi)
522-
scale /= get_device_dpi( emulator->opts );
523-
524-
if (emulator->ui) {
525-
skin_ui_set_scale(emulator->ui, scale);
526-
}
527-
}
528-
529449

530450
void
531451
android_emulator_set_base_port( int port )

android/emulator-window.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2006-2010 The Android Open Source Project
1+
/* Copyright (C) 2006-2016 The Android Open Source Project
22
**
33
** This software is licensed under the terms of the GNU General Public
44
** License version 2, as published by the Free Software Foundation, and
@@ -42,9 +42,6 @@ typedef struct {
4242
EmulatorWindow*
4343
emulator_window_get(void);
4444

45-
void
46-
android_emulator_set_window_scale(double scale, int is_dpi);
47-
4845
/* Initializes EmulatorWindow structure instance. */
4946
int
5047
emulator_window_init(EmulatorWindow* emulator,

android/skin/ui.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2006-2015 The Android Open Source Project
1+
/* Copyright (C) 2006-2016 The Android Open Source Project
22
**
33
** This software is licensed under the terms of the GNU General Public
44
** License version 2, as published by the Free Software Foundation, and
@@ -97,8 +97,7 @@ SkinUI* skin_ui_create(SkinFile* layout_file,
9797

9898
ui->window = skin_window_create(
9999
ui->layout, ui->ui_params.window_x, ui->ui_params.window_y,
100-
ui->ui_params.window_scale, 0, use_emugl_subwindow,
101-
ui->ui_funcs->window_funcs);
100+
0, use_emugl_subwindow, ui->ui_funcs->window_funcs);
102101
if (!ui->window) {
103102
skin_ui_free(ui);
104103
return NULL;

android/skin/ui.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2006-2010 The Android Open Source Project
1+
/* Copyright (C) 2006-2016 The Android Open Source Project
22
**
33
** This software is licensed under the terms of the GNU General Public
44
** License version 2, as published by the Free Software Foundation, and
@@ -67,7 +67,6 @@ typedef struct SkinUIParams {
6767
char window_name[64];
6868
int window_x;
6969
int window_y;
70-
double window_scale;
7170

7271
bool enable_touch;
7372
bool enable_dpad;

android/skin/window.c

+20-32
Original file line numberDiff line numberDiff line change
@@ -1330,46 +1330,14 @@ static int skin_window_reset_internal (SkinWindow*, SkinLayout*);
13301330
SkinWindow* skin_window_create(SkinLayout* slayout,
13311331
int x,
13321332
int y,
1333-
double scale,
13341333
int no_display,
13351334
bool use_emugl_subwindow,
13361335
const SkinWindowFuncs* win_funcs) {
13371336
SkinWindow* window;
13381337

1339-
/* If scale is <= 0, we want to check that the window's default size if
1340-
* not larger than the current screen. Otherwise, we need to compute
1341-
* a new scale to ensure it is.
1342-
*/
1343-
if (scale <= 0) {
1344-
SkinRect monitor;
1345-
int screen_w, screen_h;
1346-
int win_w = slayout->size.w;
1347-
int win_h = slayout->size.h;
1348-
double scale_w, scale_h;
1349-
1350-
/* To account for things like menu bars, window decorations etc..
1351-
* We only compute 85% of the real screen size. */
1352-
skin_winsys_get_monitor_rect(&monitor);
1353-
screen_w = monitor.size.w * 0.85;
1354-
screen_h = monitor.size.h * 0.85;
1355-
1356-
scale_w = 1.0;
1357-
scale_h = 1.0;
1358-
1359-
if (screen_w < win_w && win_w > 1.)
1360-
scale_w = 1.0 * screen_w / win_w;
1361-
if (screen_h < win_h && win_h > 1.)
1362-
scale_h = 1.0 * screen_h / win_h;
1363-
1364-
scale = (scale_w <= scale_h) ? scale_w : scale_h;
1365-
1366-
VERBOSE_PRINT(init,"autoconfig: -scale %g", scale);
1367-
}
1368-
13691338
ANEW0(window);
13701339

13711340
window->win_funcs = win_funcs;
1372-
window->scale = scale;
13731341
window->no_display = no_display;
13741342
window->use_emugl_subwindow = use_emugl_subwindow;
13751343
window->surface = NULL;
@@ -1384,6 +1352,26 @@ SkinWindow* skin_window_create(SkinLayout* slayout,
13841352
window->y_pos = y;
13851353
window->scroll_h = 0;
13861354

1355+
SkinRect monitor;
1356+
int screen_w, screen_h;
1357+
int win_w = slayout->size.w;
1358+
int win_h = slayout->size.h;
1359+
double scale_w = 1.0;
1360+
double scale_h = 1.0;
1361+
1362+
/* To account for things like menu bars, window decorations etc..
1363+
* We only compute 85% of the real screen size. */
1364+
skin_winsys_get_monitor_rect(&monitor);
1365+
screen_w = monitor.size.w * 0.85;
1366+
screen_h = monitor.size.h * 0.85;
1367+
1368+
if (screen_w < win_w && win_w > 1.)
1369+
scale_w = 1.0 * screen_w / win_w;
1370+
if (screen_h < win_h && win_h > 1.)
1371+
scale_h = 1.0 * screen_h / win_h;
1372+
1373+
window->scale = (scale_w <= scale_h) ? scale_w : scale_h;
1374+
13871375
if (skin_window_reset_internal(window, slayout) < 0) {
13881376
skin_window_free(window);
13891377
return NULL;

android/skin/window.h

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ typedef struct SkinWindowFuncs {
4646
extern SkinWindow* skin_window_create(SkinLayout* layout,
4747
int x,
4848
int y,
49-
double scale,
5049
int no_display,
5150
bool use_emugl_subwindow,
5251
const SkinWindowFuncs* win_funcs);

0 commit comments

Comments
 (0)