Commit 7f1ee85f authored by dnicoara's avatar dnicoara Committed by Commit bot

Treat displays with and without EDID the same way

Treating displays without EDID specially results in exiting mirror mode
every time a display configuration operation happens.

BUG=413278

Review URL: https://codereview.chromium.org/667753002

Cr-Commit-Position: refs/heads/master@{#300694}
parent e904389b
......@@ -579,15 +579,14 @@ void DisplayConfigurator::UpdateCachedDisplays() {
// Set |selected_mode| fields.
for (size_t i = 0; i < cached_displays_.size(); ++i) {
DisplayState* display_state = &cached_displays_[i];
if (display_state->display->has_proper_display_id()) {
gfx::Size size;
if (state_controller_ &&
state_controller_->GetResolutionForDisplayId(
display_state->display->display_id(), &size)) {
display_state->selected_mode =
FindDisplayModeMatchingSize(*display_state->display, size);
}
gfx::Size size;
if (state_controller_ &&
state_controller_->GetResolutionForDisplayId(
display_state->display->display_id(), &size)) {
display_state->selected_mode =
FindDisplayModeMatchingSize(*display_state->display, size);
}
// Fall back to native mode.
if (!display_state->selected_mode)
display_state->selected_mode = display_state->display->native_mode();
......@@ -960,12 +959,9 @@ MultipleDisplayState DisplayConfigurator::ChooseDisplayState(
// With either both displays on or both displays off, use one of the
// dual modes.
std::vector<int64_t> display_ids;
for (size_t i = 0; i < cached_displays_.size(); ++i) {
// If display id isn't available, switch to extended mode.
if (!cached_displays_[i].display->has_proper_display_id())
return MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED;
for (size_t i = 0; i < cached_displays_.size(); ++i)
display_ids.push_back(cached_displays_[i].display->display_id());
}
return state_controller_->GetStateForDisplayIds(display_ids);
}
}
......
......@@ -359,7 +359,6 @@ class DisplayConfiguratorTest : public testing::Test {
o->set_type(DISPLAY_CONNECTION_TYPE_INTERNAL);
o->set_is_aspect_preserving_scaling(true);
o->set_display_id(123);
o->set_has_proper_display_id(true);
o = &outputs_[1];
o->set_current_mode(&big_mode_);
......@@ -369,7 +368,6 @@ class DisplayConfiguratorTest : public testing::Test {
o->set_type(DISPLAY_CONNECTION_TYPE_HDMI);
o->set_is_aspect_preserving_scaling(true);
o->set_display_id(456);
o->set_has_proper_display_id(true);
UpdateOutputs(2, false);
}
......@@ -1004,18 +1002,7 @@ TEST_F(DisplayConfiguratorTest, InvalidMultipleDisplayStates) {
EXPECT_EQ(2, observer_.num_failures());
}
TEST_F(DisplayConfiguratorTest, GetMultipleDisplayStateForDisplaysWithoutId) {
outputs_[0].set_has_proper_display_id(false);
UpdateOutputs(2, false);
configurator_.Init(false);
state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR);
configurator_.ForceInitialConfigure(0);
EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED,
configurator_.display_state());
}
TEST_F(DisplayConfiguratorTest, GetMultipleDisplayStateForDisplaysWithId) {
outputs_[0].set_has_proper_display_id(true);
TEST_F(DisplayConfiguratorTest, GetMultipleDisplayStateForMirroredDisplays) {
UpdateOutputs(2, false);
configurator_.Init(false);
state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR);
......
......@@ -7,7 +7,6 @@
namespace ui {
TestDisplaySnapshot::TestDisplaySnapshot()
: DisplaySnapshot(0,
false,
gfx::Point(0, 0),
gfx::Size(0, 0),
DISPLAY_CONNECTION_TYPE_UNKNOWN,
......@@ -20,7 +19,6 @@ TestDisplaySnapshot::TestDisplaySnapshot()
TestDisplaySnapshot::TestDisplaySnapshot(
int64_t display_id,
bool has_proper_display_id,
const gfx::Point& origin,
const gfx::Size& physical_size,
DisplayConnectionType type,
......@@ -29,7 +27,6 @@ TestDisplaySnapshot::TestDisplaySnapshot(
const DisplayMode* current_mode,
const DisplayMode* native_mode)
: DisplaySnapshot(display_id,
has_proper_display_id,
origin,
physical_size,
type,
......
......@@ -14,7 +14,6 @@ class DISPLAY_EXPORT TestDisplaySnapshot : public DisplaySnapshot {
public:
TestDisplaySnapshot();
TestDisplaySnapshot(int64_t display_id,
bool has_proper_display_id,
const gfx::Point& origin,
const gfx::Size& physical_size,
DisplayConnectionType type,
......@@ -34,9 +33,6 @@ class DISPLAY_EXPORT TestDisplaySnapshot : public DisplaySnapshot {
is_aspect_preserving_scaling_ = state;
}
void set_display_id(int64_t id) { display_id_ = id; }
void set_has_proper_display_id(bool has_display_id) {
has_proper_display_id_ = has_display_id;
}
// DisplaySnapshot overrides:
virtual std::string ToString() const override;
......
......@@ -11,7 +11,6 @@ namespace ui {
DisplaySnapshotX11::DisplaySnapshotX11(
int64_t display_id,
bool has_proper_display_id,
const gfx::Point& origin,
const gfx::Size& physical_size,
DisplayConnectionType type,
......@@ -25,7 +24,6 @@ DisplaySnapshotX11::DisplaySnapshotX11(
RRCrtc crtc,
int index)
: DisplaySnapshot(display_id,
has_proper_display_id,
origin,
physical_size,
type,
......
......@@ -18,7 +18,6 @@ namespace ui {
class DISPLAY_EXPORT DisplaySnapshotX11 : public DisplaySnapshot {
public:
DisplaySnapshotX11(int64_t display_id,
bool has_proper_display_id,
const gfx::Point& origin,
const gfx::Size& physical_size,
DisplayConnectionType type,
......
......@@ -308,8 +308,8 @@ DisplaySnapshotX11* NativeDisplayDelegateX11::InitDisplaySnapshot(
RRCrtc* last_used_crtc,
int index) {
int64_t display_id = 0;
bool has_display_id = GetDisplayId(
output, static_cast<uint8_t>(index), &display_id);
if (!GetDisplayId(output, static_cast<uint8_t>(index), &display_id))
display_id = index;
bool has_overscan = false;
GetOutputOverscanFlag(output, &has_overscan);
......@@ -318,17 +318,6 @@ DisplaySnapshotX11* NativeDisplayDelegateX11::InitDisplaySnapshot(
if (type == DISPLAY_CONNECTION_TYPE_UNKNOWN)
LOG(ERROR) << "Unknown link type: " << info->name;
// Use the index as a valid display ID even if the internal
// display doesn't have valid EDID because the index
// will never change.
if (!has_display_id) {
if (type == DISPLAY_CONNECTION_TYPE_INTERNAL)
has_display_id = true;
// Fallback to output index.
display_id = index;
}
RRMode native_mode_id = GetOutputNativeMode(info);
RRMode current_mode_id = None;
gfx::Point origin;
......@@ -369,7 +358,6 @@ DisplaySnapshotX11* NativeDisplayDelegateX11::InitDisplaySnapshot(
DisplaySnapshotX11* display_snapshot =
new DisplaySnapshotX11(display_id,
has_display_id,
origin,
gfx::Size(info->mm_width, info->mm_height),
type,
......
......@@ -24,7 +24,6 @@ DisplaySnapshotX11* CreateOutput(RROutput output, RRCrtc crtc) {
DisplaySnapshotX11* snapshot = new DisplaySnapshotX11(
0,
false,
gfx::Point(0, 0),
gfx::Size(0, 0),
DISPLAY_CONNECTION_TYPE_UNKNOWN,
......
......@@ -7,7 +7,6 @@
namespace ui {
DisplaySnapshot::DisplaySnapshot(int64_t display_id,
bool has_proper_display_id,
const gfx::Point& origin,
const gfx::Size& physical_size,
DisplayConnectionType type,
......@@ -18,7 +17,6 @@ DisplaySnapshot::DisplaySnapshot(int64_t display_id,
const DisplayMode* current_mode,
const DisplayMode* native_mode)
: display_id_(display_id),
has_proper_display_id_(has_proper_display_id),
origin_(origin),
physical_size_(physical_size),
type_(type),
......
......@@ -20,7 +20,6 @@ namespace ui {
class DISPLAY_TYPES_EXPORT DisplaySnapshot {
public:
DisplaySnapshot(int64_t display_id,
bool has_proper_display_id,
const gfx::Point& origin,
const gfx::Size& physical_size,
DisplayConnectionType type,
......@@ -42,7 +41,6 @@ class DISPLAY_TYPES_EXPORT DisplaySnapshot {
std::string display_name() const { return display_name_; }
int64_t display_id() const { return display_id_; }
bool has_proper_display_id() const { return has_proper_display_id_; }
const DisplayMode* current_mode() const { return current_mode_; }
const DisplayMode* native_mode() const { return native_mode_; }
......@@ -59,7 +57,6 @@ class DISPLAY_TYPES_EXPORT DisplaySnapshot {
protected:
// Display id for this output.
int64_t display_id_;
bool has_proper_display_id_;
// Display's origin on the framebuffer.
gfx::Point origin_;
......
......@@ -20,7 +20,6 @@ bool SameModes(const DisplayMode_Params& lhs, const DisplayMode_Params& rhs) {
DisplaySnapshotProxy::DisplaySnapshotProxy(const DisplaySnapshot_Params& params)
: DisplaySnapshot(params.display_id,
params.has_proper_display_id,
params.origin,
params.physical_size,
params.type,
......
......@@ -22,7 +22,6 @@ DisplaySnapshot_Params GetDisplaySnapshotParams(
const DisplaySnapshot& display) {
DisplaySnapshot_Params params;
params.display_id = display.display_id();
params.has_proper_display_id = display.has_proper_display_id();
params.origin = display.origin();
params.physical_size = display.physical_size();
params.type = display.type();
......
......@@ -13,7 +13,6 @@ DisplayMode_Params::~DisplayMode_Params() {}
DisplaySnapshot_Params::DisplaySnapshot_Params()
: display_id(0),
has_proper_display_id(false),
origin(),
physical_size(),
type(ui::DISPLAY_CONNECTION_TYPE_NONE),
......
......@@ -28,7 +28,6 @@ struct DisplaySnapshot_Params {
~DisplaySnapshot_Params();
int64_t display_id;
bool has_proper_display_id;
gfx::Point origin;
gfx::Size physical_size;
DisplayConnectionType type;
......
......@@ -32,7 +32,6 @@ IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(ui::DisplaySnapshot_Params)
IPC_STRUCT_TRAITS_MEMBER(display_id)
IPC_STRUCT_TRAITS_MEMBER(has_proper_display_id)
IPC_STRUCT_TRAITS_MEMBER(origin)
IPC_STRUCT_TRAITS_MEMBER(physical_size)
IPC_STRUCT_TRAITS_MEMBER(type)
......
......@@ -67,7 +67,6 @@ DisplaySnapshotDri::DisplaySnapshotDri(DriWrapper* drm,
drmModeCrtc* crtc,
uint32_t index)
: DisplaySnapshot(index,
false,
gfx::Point(crtc->x, crtc->y),
gfx::Size(connector->mmWidth, connector->mmHeight),
GetDisplayType(connector),
......@@ -91,7 +90,9 @@ DisplaySnapshotDri::DisplaySnapshotDri(DriWrapper* drm,
static_cast<uint8_t*>(edid_blob->data),
static_cast<uint8_t*>(edid_blob->data) + edid_blob->length);
has_proper_display_id_ = GetDisplayIdFromEDID(edid, index, &display_id_);
if (!GetDisplayIdFromEDID(edid, index, &display_id_))
display_id_ = index;
ParseOutputDeviceData(edid, NULL, &display_name_);
ParseOutputOverscanFlag(edid, &overscan_flag_);
} else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment