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 "chrome/browser/chromeos/display/overscan_calibrator.h" | 5 #include "chrome/browser/chromeos/display/overscan_calibrator.h" |
6 | 6 |
7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/display/display_info.h" | |
9 #include "ash/display/display_manager.h" | |
8 #include "ash/shell.h" | 10 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 11 #include "ash/shell_window_ids.h" |
10 #include "base/callback.h" | 12 #include "base/callback.h" |
11 #include "chrome/browser/chromeos/display/display_preferences.h" | |
12 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
13 #include "ui/compositor/layer.h" | 14 #include "ui/compositor/layer.h" |
14 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
15 | 16 |
16 namespace chromeos { | 17 namespace chromeos { |
17 namespace { | 18 namespace { |
18 | 19 |
19 // The opacity for the grey out borders. | 20 // The opacity for the grey out borders. |
20 const float kBorderOpacity = 0.5; | 21 const float kBorderOpacity = 0.5; |
21 | 22 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 const gfx::Display& target_display, const gfx::Insets& initial_insets) | 66 const gfx::Display& target_display, const gfx::Insets& initial_insets) |
66 : display_(target_display), | 67 : display_(target_display), |
67 insets_(initial_insets), | 68 insets_(initial_insets), |
68 initial_insets_(initial_insets), | 69 initial_insets_(initial_insets), |
69 committed_(false) { | 70 committed_(false) { |
70 // Undo the overscan calibration temporarily so that the user can see | 71 // Undo the overscan calibration temporarily so that the user can see |
71 // dark boundary and current overscan region. | 72 // dark boundary and current overscan region. |
72 ash::Shell::GetInstance()->display_controller()->SetOverscanInsets( | 73 ash::Shell::GetInstance()->display_controller()->SetOverscanInsets( |
73 display_.id(), gfx::Insets()); | 74 display_.id(), gfx::Insets()); |
74 | 75 |
76 ash::internal::DisplayInfo info = ash::Shell::GetInstance()-> | |
77 display_manager()->GetDisplayInfo(display_.id()); | |
78 if (info.has_overscan()) { | |
79 info.clear_has_custom_overscan_insets(); | |
80 info.UpdateDisplaySize(); | |
81 native_insets_ = info.overscan_insets_in_dip(); | |
82 } | |
83 | |
75 aura::RootWindow* root = ash::Shell::GetInstance()->display_controller()-> | 84 aura::RootWindow* root = ash::Shell::GetInstance()->display_controller()-> |
76 GetRootWindowForDisplayId(display_.id()); | 85 GetRootWindowForDisplayId(display_.id()); |
77 ui::Layer* parent_layer = ash::Shell::GetContainer( | 86 ui::Layer* parent_layer = ash::Shell::GetContainer( |
78 root, ash::internal::kShellWindowId_OverlayContainer)->layer(); | 87 root, ash::internal::kShellWindowId_OverlayContainer)->layer(); |
79 | 88 |
80 calibration_layer_.reset(new ui::Layer()); | 89 calibration_layer_.reset(new ui::Layer()); |
81 calibration_layer_->SetOpacity(0.5f); | 90 calibration_layer_->SetOpacity(0.5f); |
82 calibration_layer_->SetBounds(parent_layer->bounds()); | 91 calibration_layer_->SetBounds(parent_layer->bounds()); |
83 calibration_layer_->set_delegate(this); | 92 calibration_layer_->set_delegate(this); |
84 parent_layer->Add(calibration_layer_.get()); | 93 parent_layer->Add(calibration_layer_.get()); |
85 } | 94 } |
86 | 95 |
87 OverscanCalibrator::~OverscanCalibrator() { | 96 OverscanCalibrator::~OverscanCalibrator() { |
88 // Overscan calibration has finished without commit, so the display has to | 97 // Overscan calibration has finished without commit, so the display has to |
89 // be the original offset. | 98 // be the original offset. |
90 if (!committed_) { | 99 if (!committed_) { |
91 ash::Shell::GetInstance()->display_controller()->SetOverscanInsets( | 100 ash::Shell::GetInstance()->display_controller()->SetOverscanInsets( |
92 display_.id(), initial_insets_); | 101 display_.id(), initial_insets_); |
93 } | 102 } |
94 } | 103 } |
95 | 104 |
96 void OverscanCalibrator::Commit() { | 105 void OverscanCalibrator::Commit() { |
97 SetAndStoreDisplayOverscan(display_, insets_); | 106 if (insets_ == native_insets_) { |
Jun Mukai
2013/03/22 00:53:07
Can we move this logic to the display controller?
oshima
2013/03/22 02:06:51
I think this is specific to calibration UI. There
| |
107 ash::Shell::GetInstance()->display_controller()->ClearCustomOverscanInsets( | |
108 display_.id()); | |
109 } else { | |
110 ash::Shell::GetInstance()->display_controller()->SetOverscanInsets( | |
111 display_.id(), insets_); | |
112 } | |
98 committed_ = true; | 113 committed_ = true; |
99 } | 114 } |
100 | 115 |
116 void OverscanCalibrator::Reset() { | |
117 if (!native_insets_.empty()) { | |
118 insets_ = native_insets_; | |
119 } else { | |
120 insets_ = initial_insets_; | |
121 } | |
122 calibration_layer_->SchedulePaint(calibration_layer_->bounds()); | |
123 } | |
124 | |
101 void OverscanCalibrator::UpdateInsets(const gfx::Insets& insets) { | 125 void OverscanCalibrator::UpdateInsets(const gfx::Insets& insets) { |
102 insets_.Set(std::max(insets.top(), 0), | 126 insets_.Set(std::max(insets.top(), 0), |
103 std::max(insets.left(), 0), | 127 std::max(insets.left(), 0), |
104 std::max(insets.bottom(), 0), | 128 std::max(insets.bottom(), 0), |
105 std::max(insets.right(), 0)); | 129 std::max(insets.right(), 0)); |
106 calibration_layer_->SchedulePaint(calibration_layer_->bounds()); | 130 calibration_layer_->SchedulePaint(calibration_layer_->bounds()); |
107 } | 131 } |
108 | 132 |
109 void OverscanCalibrator::OnPaintLayer(gfx::Canvas* canvas) { | 133 void OverscanCalibrator::OnPaintLayer(gfx::Canvas* canvas) { |
110 static const SkColor kTransparent = SkColorSetARGB(0, 0, 0, 0); | 134 static const SkColor kTransparent = SkColorSetARGB(0, 0, 0, 0); |
(...skipping 17 matching lines...) Expand all Loading... | |
128 float device_scale_factor) { | 152 float device_scale_factor) { |
129 // TODO(mukai): Cancel the overscan calibration when the device | 153 // TODO(mukai): Cancel the overscan calibration when the device |
130 // configuration has changed. | 154 // configuration has changed. |
131 } | 155 } |
132 | 156 |
133 base::Closure OverscanCalibrator::PrepareForLayerBoundsChange() { | 157 base::Closure OverscanCalibrator::PrepareForLayerBoundsChange() { |
134 return base::Closure(); | 158 return base::Closure(); |
135 } | 159 } |
136 | 160 |
137 } // namespace chromeos | 161 } // namespace chromeos |
OLD | NEW |