Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Side by Side Diff: ui/ozone/common/display_util.cc

Issue 1131813003: [2/2][Ozone-Drm] Scan for displays on browser size during startup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@handle-display-init3
Patch Set: rebased Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/ozone/common/display_util.h ('k') | ui/ozone/common/display_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/ozone/common/display_util.h" 5 #include "ui/ozone/common/display_util.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "ui/display/types/display_mode.h" 10 #include "ui/display/types/display_mode.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 snapshot_out->modes.push_back(mode_param); 89 snapshot_out->modes.push_back(mode_param);
90 snapshot_out->type = DISPLAY_CONNECTION_TYPE_INTERNAL; 90 snapshot_out->type = DISPLAY_CONNECTION_TYPE_INTERNAL;
91 snapshot_out->physical_size = gfx::Size(physical_width, physical_height); 91 snapshot_out->physical_size = gfx::Size(physical_width, physical_height);
92 snapshot_out->has_current_mode = true; 92 snapshot_out->has_current_mode = true;
93 snapshot_out->current_mode = mode_param; 93 snapshot_out->current_mode = mode_param;
94 snapshot_out->has_native_mode = true; 94 snapshot_out->has_native_mode = true;
95 snapshot_out->native_mode = mode_param; 95 snapshot_out->native_mode = mode_param;
96 return true; 96 return true;
97 } 97 }
98 98
99 bool CreateSnapshotFromEDID(bool internal,
100 const std::vector<uint8_t>& edid,
101 DisplaySnapshot_Params* snapshot_out) {
102 uint16_t manufacturer_id = 0;
103 gfx::Size resolution;
104
105 DisplayMode_Params mode_param;
106 mode_param.refresh_rate = 60.0f;
107
108 if (!ParseOutputDeviceData(edid, &manufacturer_id,
109 &snapshot_out->display_name, &mode_param.size,
110 &snapshot_out->physical_size) ||
111 !GetDisplayIdFromEDID(edid, 0, &snapshot_out->display_id)) {
112 return false;
113 }
114 ParseOutputOverscanFlag(edid, &snapshot_out->has_overscan);
115
116 snapshot_out->modes.push_back(mode_param);
117 // Use VGA for external display for now.
118 // TODO(oshima): frecon should set this value in the display_info.bin file.
119 snapshot_out->type =
120 internal ? DISPLAY_CONNECTION_TYPE_INTERNAL : DISPLAY_CONNECTION_TYPE_VGA;
121 snapshot_out->has_current_mode = true;
122 snapshot_out->current_mode = mode_param;
123 snapshot_out->has_native_mode = true;
124 snapshot_out->native_mode = mode_param;
125 return true;
126 }
127
128 bool CreateSnapshotFromEDIDFile(const base::FilePath& file,
129 DisplaySnapshot_Params* snapshot_out) {
130 std::string raw_display_info;
131 const int kEDIDMaxSize = 128;
132 if (!base::ReadFileToString(file, &raw_display_info, kEDIDMaxSize + 1) ||
133 raw_display_info.size() < 10) {
134 return false;
135 }
136 std::vector<uint8_t> edid;
137 // The head of the file contains one byte flag that indicates the type of
138 // display.
139 bool internal = raw_display_info[0] == 1;
140 edid.assign(raw_display_info.c_str() + 1,
141 raw_display_info.c_str() + raw_display_info.size());
142 return CreateSnapshotFromEDID(internal, edid, snapshot_out);
143 }
144
145 } // namespace ui 99 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/common/display_util.h ('k') | ui/ozone/common/display_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698