Chromium Code Reviews| 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 "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h" | 5 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h" |
| 6 | 6 |
| 7 #include "base/win/metro.h" | 7 #include "base/win/metro.h" |
| 8 #include "third_party/skia/include/core/SkPath.h" | 8 #include "third_party/skia/include/core/SkPath.h" |
| 9 #include "third_party/skia/include/core/SkRegion.h" | 9 #include "third_party/skia/include/core/SkRegion.h" |
| 10 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
| 11 #include "ui/aura/client/cursor_client.h" | 11 #include "ui/aura/client/cursor_client.h" |
| 12 #include "ui/aura/client/focus_client.h" | 12 #include "ui/aura/client/focus_client.h" |
| 13 #include "ui/aura/window_event_dispatcher.h" | 13 #include "ui/aura/window_event_dispatcher.h" |
| 14 #include "ui/aura/window_property.h" | 14 #include "ui/aura/window_property.h" |
| 15 #include "ui/base/cursor/cursor_loader_win.h" | 15 #include "ui/base/cursor/cursor_loader_win.h" |
| 16 #include "ui/base/ime/input_method.h" | 16 #include "ui/base/ime/input_method.h" |
| 17 #include "ui/base/win/shell.h" | 17 #include "ui/base/win/shell.h" |
| 18 #include "ui/base/window_resize_helper.h" | |
| 18 #include "ui/compositor/compositor_constants.h" | 19 #include "ui/compositor/compositor_constants.h" |
| 19 #include "ui/compositor/paint_context.h" | 20 #include "ui/compositor/paint_context.h" |
| 20 #include "ui/gfx/geometry/insets.h" | 21 #include "ui/gfx/geometry/insets.h" |
| 21 #include "ui/gfx/geometry/vector2d.h" | 22 #include "ui/gfx/geometry/vector2d.h" |
| 22 #include "ui/gfx/native_widget_types.h" | 23 #include "ui/gfx/native_widget_types.h" |
| 23 #include "ui/gfx/path.h" | 24 #include "ui/gfx/path.h" |
| 24 #include "ui/gfx/path_win.h" | 25 #include "ui/gfx/path_win.h" |
| 25 #include "ui/gfx/win/dpi.h" | 26 #include "ui/gfx/win/dpi.h" |
| 26 #include "ui/native_theme/native_theme_aura.h" | 27 #include "ui/native_theme/native_theme_aura.h" |
| 27 #include "ui/native_theme/native_theme_win.h" | 28 #include "ui/native_theme/native_theme_win.h" |
| (...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 901 } | 902 } |
| 902 | 903 |
| 903 void DesktopWindowTreeHostWin::HandleWindowSizeChanged() { | 904 void DesktopWindowTreeHostWin::HandleWindowSizeChanged() { |
| 904 // A resize may not have occurred if the window size happened not to have | 905 // A resize may not have occurred if the window size happened not to have |
| 905 // changed (can occur on Windows 10 when snapping a window to the side of | 906 // changed (can occur on Windows 10 when snapping a window to the side of |
| 906 // the screen). In that case do a resize to the current size to reenable | 907 // the screen). In that case do a resize to the current size to reenable |
| 907 // swaps. | 908 // swaps. |
| 908 if (compositor()) | 909 if (compositor()) |
| 909 compositor()->SetScaleAndSize(compositor()->device_scale_factor(), | 910 compositor()->SetScaleAndSize(compositor()->device_scale_factor(), |
| 910 compositor()->size()); | 911 compositor()->size()); |
| 912 | |
| 913 // If the window size has changed and this is a visible window, we may | |
| 914 // want to try to immediately produce a frame. | |
| 915 MaybeWaitForFrame(); | |
| 911 } | 916 } |
| 912 | 917 |
| 913 //////////////////////////////////////////////////////////////////////////////// | 918 //////////////////////////////////////////////////////////////////////////////// |
| 914 // DesktopWindowTreeHostWin, private: | 919 // DesktopWindowTreeHostWin, private: |
| 915 | 920 |
| 916 Widget* DesktopWindowTreeHostWin::GetWidget() { | 921 Widget* DesktopWindowTreeHostWin::GetWidget() { |
| 917 return native_widget_delegate_->AsWidget(); | 922 return native_widget_delegate_->AsWidget(); |
| 918 } | 923 } |
| 919 | 924 |
| 920 const Widget* DesktopWindowTreeHostWin::GetWidget() const { | 925 const Widget* DesktopWindowTreeHostWin::GetWidget() const { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 942 for (index = window()->children().begin(); | 947 for (index = window()->children().begin(); |
| 943 index != window()->children().end(); | 948 index != window()->children().end(); |
| 944 ++index) { | 949 ++index) { |
| 945 if ((*index)->GetProperty(aura::client::kModalKey) != | 950 if ((*index)->GetProperty(aura::client::kModalKey) != |
| 946 ui:: MODAL_TYPE_NONE && (*index)->TargetVisibility()) | 951 ui:: MODAL_TYPE_NONE && (*index)->TargetVisibility()) |
| 947 return true; | 952 return true; |
| 948 } | 953 } |
| 949 return false; | 954 return false; |
| 950 } | 955 } |
| 951 | 956 |
| 957 void DesktopWindowTreeHostWin::MaybeWaitForFrame() { | |
| 958 if (!compositor()) | |
| 959 return; | |
| 960 | |
| 961 const gfx::Size target_size = compositor()->size(); | |
| 962 | |
| 963 if (!compositor()->IsVisible() || | |
| 964 compositor()->last_swapped_frame_size() == target_size) { | |
| 965 return; | |
| 966 } | |
| 967 | |
| 968 const int kPaintMsgTimeoutMS = 55; | |
|
piman
2015/12/15 07:15:36
Any specific reason for 55 vs 50?
My gut feeling i
| |
| 969 const base::TimeTicks start_time = base::TimeTicks::Now(); | |
| 970 const base::TimeTicks timeout_time = | |
| 971 start_time + base::TimeDelta::FromMilliseconds(kPaintMsgTimeoutMS); | |
| 972 | |
| 973 ui::WindowResizeHelper* resize_helper = ui::WindowResizeHelper::Get(); | |
| 974 for (base::TimeTicks now = start_time; now < timeout_time; | |
| 975 now = base::TimeTicks::Now()) { | |
| 976 if (!resize_helper->WaitForSingleTaskToRun(timeout_time - now)) | |
| 977 return; // Timeout. | |
| 978 | |
| 979 // Since the UI thread is blocked, the size shouldn't change. | |
| 980 DCHECK(target_size == compositor()->size()); | |
| 981 if (compositor()->last_swapped_frame_size() == target_size) { | |
| 982 return; // Frame arrived. | |
| 983 } | |
| 984 } | |
| 985 } | |
| 986 | |
| 952 //////////////////////////////////////////////////////////////////////////////// | 987 //////////////////////////////////////////////////////////////////////////////// |
| 953 // DesktopWindowTreeHost, public: | 988 // DesktopWindowTreeHost, public: |
| 954 | 989 |
| 955 // static | 990 // static |
| 956 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( | 991 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( |
| 957 internal::NativeWidgetDelegate* native_widget_delegate, | 992 internal::NativeWidgetDelegate* native_widget_delegate, |
| 958 DesktopNativeWidgetAura* desktop_native_widget_aura) { | 993 DesktopNativeWidgetAura* desktop_native_widget_aura) { |
| 959 return new DesktopWindowTreeHostWin(native_widget_delegate, | 994 return new DesktopWindowTreeHostWin(native_widget_delegate, |
| 960 desktop_native_widget_aura); | 995 desktop_native_widget_aura); |
| 961 } | 996 } |
| 962 | 997 |
| 963 } // namespace views | 998 } // namespace views |
| OLD | NEW |