Consider the following code:
int64_t display_id = ...;
gfx::Rect bounds_in_pixel = ...;
gfx::Rect work_area_in_pixel = bounds_in_pixel;
gfx::Display display(display_id, bounds_in_pixel);
display.set_work_area(work_area_in_pixel);
EXPECT_EQ(display.work_area(), display.bounds());
In normal cases, this works and runs fine. If, however, the --force-device-scale-factor=2 flag is used, then it fails. The bounds sent when creating the gfx::Display instance is in pixel-space, and when the cmdline flag is used to set the DSF, it automagically converts the bounds to DIP-space. However, the rest of the functions, e.g. set_bounds(), set_work_area() etc. do not do any pixel-to-DIP conversion, which makes it really easy to unknowingly create a gfx::Display instance with incorrect values.
For an example, see https://codereview.chromium.org/1903003002/
It would be nice to change the gfx::Display API so that it's not easy to create an inconsistent gfx::Display instance.
Comment 1 by bugdroid1@chromium.org
, Apr 20 2016