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

Side by Side Diff: ui/aura/root_window.cc

Issue 12746002: Re-implement overscan & Implement Display Rotation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 "ui/aura/root_window.h" 5 #include "ui/aura/root_window.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 event_dispatch_target_(NULL), 112 event_dispatch_target_(NULL),
113 ALLOW_THIS_IN_INITIALIZER_LIST( 113 ALLOW_THIS_IN_INITIALIZER_LIST(
114 gesture_recognizer_(ui::GestureRecognizer::Create(this))), 114 gesture_recognizer_(ui::GestureRecognizer::Create(this))),
115 synthesize_mouse_move_(false), 115 synthesize_mouse_move_(false),
116 waiting_on_compositing_end_(false), 116 waiting_on_compositing_end_(false),
117 draw_on_compositing_end_(false), 117 draw_on_compositing_end_(false),
118 defer_draw_scheduling_(false), 118 defer_draw_scheduling_(false),
119 mouse_move_hold_count_(0), 119 mouse_move_hold_count_(0),
120 ALLOW_THIS_IN_INITIALIZER_LIST(held_mouse_event_factory_(this)) { 120 ALLOW_THIS_IN_INITIALIZER_LIST(held_mouse_event_factory_(this)) {
121 SetName("RootWindow"); 121 SetName("RootWindow");
122 host_->SetInsets(params.initial_insets);
122 123
123 compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget())); 124 compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget()));
124 DCHECK(compositor_.get()); 125 DCHECK(compositor_.get());
125 compositor_->AddObserver(this); 126 compositor_->AddObserver(this);
126 127
127 prop_.reset(new ui::ViewProp(host_->GetAcceleratedWidget(), 128 prop_.reset(new ui::ViewProp(host_->GetAcceleratedWidget(),
128 kRootWindowForAcceleratedWidget, 129 kRootWindowForAcceleratedWidget,
129 this)); 130 this));
130 } 131 }
131 132
(...skipping 15 matching lines...) Expand all
147 gfx::AcceleratedWidget widget) { 148 gfx::AcceleratedWidget widget) {
148 return reinterpret_cast<RootWindow*>( 149 return reinterpret_cast<RootWindow*>(
149 ui::ViewProp::GetValue(widget, kRootWindowForAcceleratedWidget)); 150 ui::ViewProp::GetValue(widget, kRootWindowForAcceleratedWidget));
150 } 151 }
151 152
152 void RootWindow::Init() { 153 void RootWindow::Init() {
153 compositor()->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(this), 154 compositor()->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(this),
154 host_->GetBounds().size()); 155 host_->GetBounds().size());
155 Window::Init(ui::LAYER_NOT_DRAWN); 156 Window::Init(ui::LAYER_NOT_DRAWN);
156 compositor()->SetRootLayer(layer()); 157 compositor()->SetRootLayer(layer());
157 SetBounds( 158 SetTransformInternal(gfx::Transform());
158 ui::ConvertRectToDIP(layer(), gfx::Rect(host_->GetBounds().size()))); 159 UpdateWindowSize(host_->GetBounds().size());
159 Env::GetInstance()->NotifyRootWindowInitialized(this); 160 Env::GetInstance()->NotifyRootWindowInitialized(this);
160 Show(); 161 Show();
161 } 162 }
162 163
163 void RootWindow::ShowRootWindow() { 164 void RootWindow::ShowRootWindow() {
164 host_->Show(); 165 host_->Show();
165 } 166 }
166 167
167 void RootWindow::HideRootWindow() { 168 void RootWindow::HideRootWindow() {
168 host_->Hide(); 169 host_->Hide();
(...skipping 21 matching lines...) Expand all
190 SetLastMouseLocation(this, ui::ConvertPointToDIP(layer(), point)); 191 SetLastMouseLocation(this, ui::ConvertPointToDIP(layer(), point));
191 192
192 synthesize_mouse_move_ = false; 193 synthesize_mouse_move_ = false;
193 } 194 }
194 195
195 gfx::Size RootWindow::GetHostSize() const { 196 gfx::Size RootWindow::GetHostSize() const {
196 return host_->GetBounds().size(); 197 return host_->GetBounds().size();
197 } 198 }
198 199
199 void RootWindow::SetHostBounds(const gfx::Rect& bounds_in_pixel) { 200 void RootWindow::SetHostBounds(const gfx::Rect& bounds_in_pixel) {
201 SetHostBoundsAndInsets(bounds_in_pixel, gfx::Insets());
202 }
203
204 void RootWindow::SetHostBoundsAndInsets(const gfx::Rect& bounds_in_pixel,
205 const gfx::Insets& insets_in_pixel) {
200 DCHECK(!bounds_in_pixel.IsEmpty()); 206 DCHECK(!bounds_in_pixel.IsEmpty());
201 DispatchHeldMouseMove(); 207 DispatchHeldMouseMove();
208 host_->SetInsets(insets_in_pixel);
202 host_->SetBounds(bounds_in_pixel); 209 host_->SetBounds(bounds_in_pixel);
203 synthesize_mouse_move_ = false; 210 synthesize_mouse_move_ = false;
204 } 211 }
205 212
206 gfx::Point RootWindow::GetHostOrigin() const { 213 gfx::Point RootWindow::GetHostOrigin() const {
207 return host_->GetBounds().origin(); 214 return host_->GetBounds().origin();
208 } 215 }
209 216
210 void RootWindow::SetCursor(gfx::NativeCursor cursor) { 217 void RootWindow::SetCursor(gfx::NativeCursor cursor) {
211 last_cursor_ = cursor; 218 last_cursor_ = cursor;
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 443
437 RootWindow* RootWindow::GetRootWindow() { 444 RootWindow* RootWindow::GetRootWindow() {
438 return this; 445 return this;
439 } 446 }
440 447
441 const RootWindow* RootWindow::GetRootWindow() const { 448 const RootWindow* RootWindow::GetRootWindow() const {
442 return this; 449 return this;
443 } 450 }
444 451
445 void RootWindow::SetTransform(const gfx::Transform& transform) { 452 void RootWindow::SetTransform(const gfx::Transform& transform) {
446 Window::SetTransform(transform); 453 SetTransformInternal(transform);
447 454
448 // If the layer is not animating, then we need to update the host size 455 // If the layer is not animating, then we need to update the host size
449 // immediately. 456 // immediately.
450 if (!layer()->GetAnimator()->is_animating()) 457 if (!layer()->GetAnimator()->is_animating())
451 OnHostResized(host_->GetBounds().size()); 458 OnHostResized(host_->GetBounds().size());
452 } 459 }
453 460
461 void RootWindow::SetTransformInternal(const gfx::Transform& transform) {
462 gfx::Transform t;
463 gfx::Insets insets = host_->GetInsets();
464 if (insets.top() != 0 || insets.left() != 0) {
465 float device_scale_factor = GetDeviceScaleFactor();
466 t.Translate(insets.left() / device_scale_factor,
467 insets.top() / device_scale_factor);
468 }
469 Window::SetTransform(t * transform);
470 }
471
454 //////////////////////////////////////////////////////////////////////////////// 472 ////////////////////////////////////////////////////////////////////////////////
455 // RootWindow, ui::EventTarget implementation: 473 // RootWindow, ui::EventTarget implementation:
456 474
457 ui::EventTarget* RootWindow::GetParentTarget() { 475 ui::EventTarget* RootWindow::GetParentTarget() {
458 return client::GetEventClient(this) ? 476 return client::GetEventClient(this) ?
459 client::GetEventClient(this)->GetToplevelEventTarget() : 477 client::GetEventClient(this)->GetToplevelEventTarget() :
460 Env::GetInstance(); 478 Env::GetInstance();
461 } 479 }
462 480
463 //////////////////////////////////////////////////////////////////////////////// 481 ////////////////////////////////////////////////////////////////////////////////
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 void RootWindow::CleanupGestureRecognizerState(Window* window) { 733 void RootWindow::CleanupGestureRecognizerState(Window* window) {
716 gesture_recognizer_->CleanupStateForConsumer(window); 734 gesture_recognizer_->CleanupStateForConsumer(window);
717 Windows windows = window->children(); 735 Windows windows = window->children();
718 for (Windows::const_iterator iter = windows.begin(); 736 for (Windows::const_iterator iter = windows.begin();
719 iter != windows.end(); 737 iter != windows.end();
720 ++iter) { 738 ++iter) {
721 CleanupGestureRecognizerState(*iter); 739 CleanupGestureRecognizerState(*iter);
722 } 740 }
723 } 741 }
724 742
743 void RootWindow::UpdateWindowSize(const gfx::Size& host_size) {
744 gfx::Rect bounds(host_size);
745 bounds.Inset(host_->GetInsets());
746 bounds = ui::ConvertRectToDIP(layer(), bounds);
747 gfx::RectF new_bounds(bounds);
748 layer()->transform().TransformRect(&new_bounds);
749 // Ignore the origin because RootWindow's insets are handled by
750 // the transform.
751 SetBounds(gfx::Rect(gfx::ToNearestRect(new_bounds).size()));
752 }
753
725 void RootWindow::OnWindowAddedToRootWindow(Window* attached) { 754 void RootWindow::OnWindowAddedToRootWindow(Window* attached) {
726 if (attached->IsVisible() && 755 if (attached->IsVisible() &&
727 attached->ContainsPointInRoot(GetLastMouseLocationInRoot())) 756 attached->ContainsPointInRoot(GetLastMouseLocationInRoot()))
728 PostMouseMoveEventAfterWindowChange(); 757 PostMouseMoveEventAfterWindowChange();
729 } 758 }
730 759
731 bool RootWindow::CanDispatchToTarget(ui::EventTarget* target) { 760 bool RootWindow::CanDispatchToTarget(ui::EventTarget* target) {
732 return event_dispatch_target_ == target; 761 return event_dispatch_target_ == target;
733 } 762 }
734 763
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 946
918 void RootWindow::OnHostResized(const gfx::Size& size) { 947 void RootWindow::OnHostResized(const gfx::Size& size) {
919 DispatchHeldMouseMove(); 948 DispatchHeldMouseMove();
920 // The compositor should have the same size as the native root window host. 949 // The compositor should have the same size as the native root window host.
921 // Get the latest scale from display because it might have been changed. 950 // Get the latest scale from display because it might have been changed.
922 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(this), size); 951 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(this), size);
923 952
924 // The layer, and all the observers should be notified of the 953 // The layer, and all the observers should be notified of the
925 // transformed size of the root window. 954 // transformed size of the root window.
926 gfx::Size old(bounds().size()); 955 gfx::Size old(bounds().size());
927 gfx::RectF bounds(ui::ConvertSizeToDIP(layer(), size)); 956 UpdateWindowSize(size);
928 layer()->transform().TransformRect(&bounds); 957 // TODO(oshima): Rename this to OnHostWindowResized.
929 // The transform is expected to produce an integer rect as its output.
930 SetBounds(gfx::ToNearestRect(bounds));
931 FOR_EACH_OBSERVER(RootWindowObserver, observers_, 958 FOR_EACH_OBSERVER(RootWindowObserver, observers_,
932 OnRootWindowResized(this, old)); 959 OnRootWindowResized(this, old));
933 } 960 }
934 961
935 float RootWindow::GetDeviceScaleFactor() { 962 float RootWindow::GetDeviceScaleFactor() {
936 return compositor()->device_scale_factor(); 963 return compositor()->device_scale_factor();
937 } 964 }
938 965
939 RootWindow* RootWindow::AsRootWindow() { 966 RootWindow* RootWindow::AsRootWindow() {
940 return this; 967 return this;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 // currently broken. See/ crbug.com/107931. 1066 // currently broken. See/ crbug.com/107931.
1040 ui::MouseEvent event(ui::ET_MOUSE_MOVED, 1067 ui::MouseEvent event(ui::ET_MOUSE_MOVED,
1041 orig_mouse_location, 1068 orig_mouse_location,
1042 orig_mouse_location, 1069 orig_mouse_location,
1043 ui::EF_IS_SYNTHESIZED); 1070 ui::EF_IS_SYNTHESIZED);
1044 event.set_system_location(Env::GetInstance()->last_mouse_location()); 1071 event.set_system_location(Env::GetInstance()->last_mouse_location());
1045 OnHostMouseEvent(&event); 1072 OnHostMouseEvent(&event);
1046 } 1073 }
1047 1074
1048 } // namespace aura 1075 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698