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

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

Issue 15067012: Move chromeos specific utility functions for display to chromeos/display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | 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 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/chromeos/chromeos_version.h" 11 #include "base/chromeos/chromeos_version.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "chromeos/display/output_util.h"
15 #include "chromeos/display/real_output_configurator_delegate.h" 16 #include "chromeos/display/real_output_configurator_delegate.h"
16 17
17 namespace chromeos { 18 namespace chromeos {
18 19
19 namespace { 20 namespace {
20 21
21 // Prefixes for the built-in displays.
22 const char kInternal_LVDS[] = "LVDS";
23 const char kInternal_eDP[] = "eDP";
24
25 // The delay to perform configuration after RRNotify. See the comment 22 // The delay to perform configuration after RRNotify. See the comment
26 // in |Dispatch()|. 23 // in |Dispatch()|.
27 const int64 kConfigureDelayMs = 500; 24 const int64 kConfigureDelayMs = 500;
28 25
29 // Returns a string describing |state|. 26 // Returns a string describing |state|.
30 std::string DisplayPowerStateToString(DisplayPowerState state) { 27 std::string DisplayPowerStateToString(DisplayPowerState state) {
31 switch (state) { 28 switch (state) {
32 case DISPLAY_POWER_ALL_ON: 29 case DISPLAY_POWER_ALL_ON:
33 return "ALL_ON"; 30 return "ALL_ON";
34 case DISPLAY_POWER_ALL_OFF: 31 case DISPLAY_POWER_ALL_OFF:
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 OutputConfigurator::OutputSnapshot::OutputSnapshot() 82 OutputConfigurator::OutputSnapshot::OutputSnapshot()
86 : output(None), 83 : output(None),
87 crtc(None), 84 crtc(None),
88 current_mode(None), 85 current_mode(None),
89 native_mode(None), 86 native_mode(None),
90 mirror_mode(None), 87 mirror_mode(None),
91 y(0), 88 y(0),
92 height(0), 89 height(0),
93 is_internal(false), 90 is_internal(false),
94 is_aspect_preserving_scaling(false), 91 is_aspect_preserving_scaling(false),
95 touch_device_id(0) {} 92 touch_device_id(0),
93 display_id(-1) {}
Jun Mukai 2013/05/14 07:03:02 can't we use gfx::Display::kInvalidDisplayID?
96 94
97 OutputConfigurator::CoordinateTransformation::CoordinateTransformation() 95 OutputConfigurator::CoordinateTransformation::CoordinateTransformation()
98 : x_scale(1.0), 96 : x_scale(1.0),
99 x_offset(0.0), 97 x_offset(0.0),
100 y_scale(1.0), 98 y_scale(1.0),
101 y_offset(0.0) {} 99 y_offset(0.0) {}
102 100
103 OutputConfigurator::CrtcConfig::CrtcConfig() 101 OutputConfigurator::CrtcConfig::CrtcConfig()
104 : crtc(None), 102 : crtc(None),
105 x(0), 103 x(0),
(...skipping 28 matching lines...) Expand all
134 132
135 if (!configurator_->configure_timer_->IsRunning()) { 133 if (!configurator_->configure_timer_->IsRunning()) {
136 LOG(ERROR) << "ConfigureOutputs() timer not running"; 134 LOG(ERROR) << "ConfigureOutputs() timer not running";
137 return false; 135 return false;
138 } 136 }
139 137
140 configurator_->ConfigureOutputs(); 138 configurator_->ConfigureOutputs();
141 return true; 139 return true;
142 } 140 }
143 141
144 // static
145 bool OutputConfigurator::IsInternalOutputName(const std::string& name) {
146 return name.find(kInternal_LVDS) == 0 || name.find(kInternal_eDP) == 0;
147 }
148
149 OutputConfigurator::OutputConfigurator() 142 OutputConfigurator::OutputConfigurator()
150 : state_controller_(NULL), 143 : state_controller_(NULL),
151 configure_display_(base::chromeos::IsRunningOnChromeOS()), 144 configure_display_(base::chromeos::IsRunningOnChromeOS()),
152 xrandr_event_base_(0), 145 xrandr_event_base_(0),
153 output_state_(STATE_INVALID), 146 output_state_(STATE_INVALID),
154 power_state_(DISPLAY_POWER_ALL_ON) { 147 power_state_(DISPLAY_POWER_ALL_ON) {
155 } 148 }
156 149
157 OutputConfigurator::~OutputConfigurator() {} 150 OutputConfigurator::~OutputConfigurator() {}
158 151
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 case 1: 496 case 1:
504 return STATE_SINGLE; 497 return STATE_SINGLE;
505 case 2: { 498 case 2: {
506 if (num_on_outputs == 1) { 499 if (num_on_outputs == 1) {
507 // If only one output is currently turned on, return the "single" 500 // If only one output is currently turned on, return the "single"
508 // state so that its native mode will be used. 501 // state so that its native mode will be used.
509 return STATE_SINGLE; 502 return STATE_SINGLE;
510 } else { 503 } else {
511 // With either both outputs on or both outputs off, use one of the 504 // With either both outputs on or both outputs off, use one of the
512 // dual modes. 505 // dual modes.
513 std::vector<OutputInfo> output_infos; 506 std::vector<int64> display_ids;
514 for (size_t i = 0; i < outputs.size(); ++i) { 507 for (size_t i = 0; i < outputs.size(); ++i)
515 output_infos.push_back(OutputInfo()); 508 display_ids.push_back(outputs[i].display_id);
516 output_infos[i].output = outputs[i].output; 509 return state_controller_->GetStateForDisplayIds(display_ids);
517 output_infos[i].output_index = i;
518 }
519 return state_controller_->GetStateForOutputs(output_infos);
520 } 510 }
521 } 511 }
522 default: 512 default:
523 NOTREACHED(); 513 NOTREACHED();
524 } 514 }
525 return STATE_INVALID; 515 return STATE_INVALID;
526 } 516 }
527 517
528 OutputConfigurator::CoordinateTransformation 518 OutputConfigurator::CoordinateTransformation
529 OutputConfigurator::GetMirrorModeCTM( 519 OutputConfigurator::GetMirrorModeCTM(
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 float width_ratio = static_cast<float>(mirror_mode_width) / 572 float width_ratio = static_cast<float>(mirror_mode_width) /
583 static_cast<float>(native_mode_width); 573 static_cast<float>(native_mode_width);
584 float height_ratio = static_cast<float>(mirror_mode_height) / 574 float height_ratio = static_cast<float>(mirror_mode_height) /
585 static_cast<float>(native_mode_height); 575 static_cast<float>(native_mode_height);
586 576
587 area_ratio = width_ratio * height_ratio; 577 area_ratio = width_ratio * height_ratio;
588 return area_ratio; 578 return area_ratio;
589 } 579 }
590 580
591 } // namespace chromeos 581 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698