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

Side by Side Diff: chromeos/display/output_configurator.cc

Issue 120223003: Support failing modeset (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update based on review feedback Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chromeos/display/output_configurator.h" 5 #include "chromeos/display/output_configurator.h"
6 6
7 #include <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 #include <X11/extensions/Xrandr.h> 8 #include <X11/extensions/Xrandr.h>
9 #include <X11/extensions/XInput2.h> 9 #include <X11/extensions/XInput2.h>
10 10
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 break; 938 break;
939 } 939 }
940 } 940 }
941 941
942 // Finally, apply the desired changes. 942 // Finally, apply the desired changes.
943 DCHECK_EQ(cached_outputs_.size(), updated_outputs.size()); 943 DCHECK_EQ(cached_outputs_.size(), updated_outputs.size());
944 if (!updated_outputs.empty()) { 944 if (!updated_outputs.empty()) {
945 delegate_->CreateFrameBuffer(width, height, updated_outputs); 945 delegate_->CreateFrameBuffer(width, height, updated_outputs);
946 for (size_t i = 0; i < updated_outputs.size(); ++i) { 946 for (size_t i = 0; i < updated_outputs.size(); ++i) {
947 const OutputSnapshot& output = updated_outputs[i]; 947 const OutputSnapshot& output = updated_outputs[i];
948 if (delegate_->ConfigureCrtc(output.crtc, output.current_mode, 948 while (!delegate_->ConfigureCrtc(output.crtc, output.current_mode,
949 output.output, output.x, output.y)) { 949 output.output, output.x, output.y)) {
950 if (output.touch_device_id)
951 delegate_->ConfigureCTM(output.touch_device_id, output.transform);
952 cached_outputs_[i] = updated_outputs[i];
953 } else {
954 LOG(WARNING) << "Unable to configure CRTC " << output.crtc << ":" 950 LOG(WARNING) << "Unable to configure CRTC " << output.crtc << ":"
955 << " mode=" << output.current_mode 951 << " mode=" << output.current_mode
956 << " output=" << output.output 952 << " output=" << output.output
957 << " x=" << output.x 953 << " x=" << output.x
958 << " y=" << output.y; 954 << " y=" << output.y;
955
956 int best_mode_pixels = 0;
Daniel Erat 2014/01/06 17:15:29 nit: add a comment before this line summarizing wh
dsodman 2014/01/08 20:55:36 Done.
957 const ModeInfo mode_info =
958 output.mode_infos.find(output.current_mode)->second;
Daniel Erat 2014/01/06 17:15:29 nit: do this instead? const ModeInfo* mode_info
dsodman 2014/01/08 20:55:36 Done.
959 int current_mode_pixels = mode_info.width * mode_info.height;
960 for (ModeInfoMap::const_iterator it = output.mode_infos.begin();
961 it != output.mode_infos.end(); it++) {
962 int pixel_count = it->second.width * it->second.height;
963 if ((pixel_count < current_mode_pixels) &&
964 (pixel_count > best_mode_pixels)) {
965 updated_outputs[i].current_mode = it->first;
966 best_mode_pixels = current_mode_pixels;
Daniel Erat 2014/01/06 17:15:29 shouldn't this be: best_mode_pixels = pixel_cou
dsodman 2014/01/08 20:55:36 Thanks for catching this. You are right. I also
967 }
968 }
969
970 if (best_mode_pixels == 0)
971 break;
959 } 972 }
973
974 // if we are trying to set mirror mode and one of the modeset's fails,
Daniel Erat 2014/01/06 17:15:29 nit: s/if/If/
dsodman 2014/01/08 20:55:36 Done.
975 // then the two monitors will be mis-matched. In this case, return
976 // false to let the observer's be aware
Daniel Erat 2014/01/06 17:15:29 nit: s/observer's/observers/, also add trailing pe
dsodman 2014/01/08 20:55:36 Done.
977 if (output_state == STATE_DUAL_MIRROR)
Daniel Erat 2014/01/06 17:15:29 style guide requires curly brackets on the outermo
dsodman 2014/01/08 20:55:36 Done.
978 if (output_power[i] && output.current_mode != output.mirror_mode)
979 return false;
Daniel Erat 2014/01/06 17:15:29 shouldn't you only return after you've finished it
dsodman 2014/01/08 20:55:36 Done.
980
981 if (output.touch_device_id)
982 delegate_->ConfigureCTM(output.touch_device_id, output.transform);
Daniel Erat 2014/01/06 17:15:29 shouldn't this come before the previous return sta
983 cached_outputs_[i] = updated_outputs[i];
Daniel Erat 2014/01/06 17:15:29 i think that this also needs to happen before the
dsodman 2014/01/08 20:55:36 Done.
960 } 984 }
961 } 985 }
962 986
963 output_state_ = output_state; 987 output_state_ = output_state;
964 power_state_ = power_state; 988 power_state_ = power_state;
965 return true; 989 return true;
966 } 990 }
967 991
968 OutputState OutputConfigurator::ChooseOutputState( 992 OutputState OutputConfigurator::ChooseOutputState(
969 DisplayPowerState power_state) const { 993 DisplayPowerState power_state) const {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 float width_ratio = static_cast<float>(mirror_mode_info->width) / 1109 float width_ratio = static_cast<float>(mirror_mode_info->width) /
1086 static_cast<float>(native_mode_info->width); 1110 static_cast<float>(native_mode_info->width);
1087 float height_ratio = static_cast<float>(mirror_mode_info->height) / 1111 float height_ratio = static_cast<float>(mirror_mode_info->height) /
1088 static_cast<float>(native_mode_info->height); 1112 static_cast<float>(native_mode_info->height);
1089 1113
1090 area_ratio = width_ratio * height_ratio; 1114 area_ratio = width_ratio * height_ratio;
1091 return area_ratio; 1115 return area_ratio;
1092 } 1116 }
1093 1117
1094 } // namespace chromeos 1118 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromeos/display/output_configurator_unittest.cc » ('j') | chromeos/display/output_configurator_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698