OLD | NEW |
---|---|
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 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
936 output->transform = GetExtendedModeCTM(*output, width, height); | 936 output->transform = GetExtendedModeCTM(*output, width, height); |
937 } | 937 } |
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(); ) { |
Daniel Erat
2013/12/21 14:25:54
please structure this code in a more logical way:
| |
947 const OutputSnapshot& output = updated_outputs[i]; | 947 const OutputSnapshot& output = updated_outputs[i]; |
948 if (delegate_->ConfigureCrtc(output.crtc, output.current_mode, | 948 if (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) | 950 if (output.touch_device_id) |
951 delegate_->ConfigureCTM(output.touch_device_id, output.transform); | 951 delegate_->ConfigureCTM(output.touch_device_id, output.transform); |
952 cached_outputs_[i] = updated_outputs[i]; | 952 cached_outputs_[i] = updated_outputs[i]; |
953 } else { | 953 } else { |
954 LOG(WARNING) << "Unable to configure CRTC " << output.crtc << ":" | 954 LOG(WARNING) << "Unable to configure CRTC " << output.crtc << ":" |
955 << " mode=" << output.current_mode | 955 << " mode=" << output.current_mode |
956 << " output=" << output.output | 956 << " output=" << output.output |
957 << " x=" << output.x | 957 << " x=" << output.x |
958 << " y=" << output.y; | 958 << " y=" << output.y; |
959 | |
960 int best_mode_pixels = 0; | |
961 const ModeInfo mode_info = | |
962 output.mode_infos.find(output.current_mode)->second; | |
Daniel Erat
2013/12/21 14:25:54
indent 4 spaces, not 7
| |
963 int pixels = mode_info.width * mode_info.height; | |
Daniel Erat
2013/12/21 14:25:54
give this a better name like current_mode_pixels
| |
964 for (ModeInfoMap::const_iterator it = output.mode_infos.begin(); | |
965 it != output.mode_infos.end(); it++) { | |
966 int pixel_count = it->second.width * it->second.height; | |
967 if ((pixel_count < pixels) && (pixel_count > best_mode_pixels)) { | |
968 updated_outputs[i].current_mode = it->first; | |
969 best_mode_pixels = pixel_count; | |
970 } | |
971 } | |
marcheu
2013/12/21 01:56:15
If we are in mirror mode, and modeset fails on one
| |
972 | |
973 if (best_mode_pixels != 0) | |
974 continue; | |
Daniel Erat
2013/12/21 14:25:54
indent 2 spaces, not 0
| |
959 } | 975 } |
976 i++; | |
960 } | 977 } |
961 } | 978 } |
962 | 979 |
963 output_state_ = output_state; | 980 output_state_ = output_state; |
964 power_state_ = power_state; | 981 power_state_ = power_state; |
965 return true; | 982 return true; |
966 } | 983 } |
967 | 984 |
968 OutputState OutputConfigurator::ChooseOutputState( | 985 OutputState OutputConfigurator::ChooseOutputState( |
969 DisplayPowerState power_state) const { | 986 DisplayPowerState power_state) const { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1085 float width_ratio = static_cast<float>(mirror_mode_info->width) / | 1102 float width_ratio = static_cast<float>(mirror_mode_info->width) / |
1086 static_cast<float>(native_mode_info->width); | 1103 static_cast<float>(native_mode_info->width); |
1087 float height_ratio = static_cast<float>(mirror_mode_info->height) / | 1104 float height_ratio = static_cast<float>(mirror_mode_info->height) / |
1088 static_cast<float>(native_mode_info->height); | 1105 static_cast<float>(native_mode_info->height); |
1089 | 1106 |
1090 area_ratio = width_ratio * height_ratio; | 1107 area_ratio = width_ratio * height_ratio; |
1091 return area_ratio; | 1108 return area_ratio; |
1092 } | 1109 } |
1093 | 1110 |
1094 } // namespace chromeos | 1111 } // namespace chromeos |
OLD | NEW |