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 "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "content/browser/renderer_host/backing_store_skia.h" | 10 #include "content/browser/renderer_host/backing_store_skia.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // because clang doesn't like implementing multiple interfaces that have | 105 // because clang doesn't like implementing multiple interfaces that have |
106 // methods with the same name. This object is owned by the | 106 // methods with the same name. This object is owned by the |
107 // RenderWidgetHostViewAura. | 107 // RenderWidgetHostViewAura. |
108 class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver { | 108 class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver { |
109 public: | 109 public: |
110 WindowObserver(RenderWidgetHostViewAura* view) : view_(view) {} | 110 WindowObserver(RenderWidgetHostViewAura* view) : view_(view) {} |
111 virtual ~WindowObserver() {} | 111 virtual ~WindowObserver() {} |
112 | 112 |
113 // Overridden from aura::WindowObserver: | 113 // Overridden from aura::WindowObserver: |
114 virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE { | 114 virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE { |
115 // TODO: It would be better to not use aura::RootWindow here | 115 view_->RemovingFromRootWindow(); |
116 ui::Compositor* compositor = view_->GetCompositor(); | |
117 if (compositor && compositor->HasObserver(view_)) | |
118 compositor->RemoveObserver(view_); | |
119 } | 116 } |
120 | 117 |
121 private: | 118 private: |
122 RenderWidgetHostViewAura* view_; | 119 RenderWidgetHostViewAura* view_; |
123 | 120 |
124 DISALLOW_COPY_AND_ASSIGN(WindowObserver); | 121 DISALLOW_COPY_AND_ASSIGN(WindowObserver); |
125 }; | 122 }; |
126 | 123 |
127 class RenderWidgetHostViewAura::ResizeLock : | 124 class RenderWidgetHostViewAura::ResizeLock : |
128 public base::SupportsWeakPtr<RenderWidgetHostViewAura::ResizeLock> { | 125 public base::SupportsWeakPtr<RenderWidgetHostViewAura::ResizeLock> { |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 void RenderWidgetHostViewAura::OnActivated() { | 996 void RenderWidgetHostViewAura::OnActivated() { |
1000 } | 997 } |
1001 | 998 |
1002 void RenderWidgetHostViewAura::OnLostActive() { | 999 void RenderWidgetHostViewAura::OnLostActive() { |
1003 } | 1000 } |
1004 | 1001 |
1005 //////////////////////////////////////////////////////////////////////////////// | 1002 //////////////////////////////////////////////////////////////////////////////// |
1006 // RenderWidgetHostViewAura, ui::CompositorDelegate implementation: | 1003 // RenderWidgetHostViewAura, ui::CompositorDelegate implementation: |
1007 | 1004 |
1008 void RenderWidgetHostViewAura::OnCompositingEnded(ui::Compositor* compositor) { | 1005 void RenderWidgetHostViewAura::OnCompositingEnded(ui::Compositor* compositor) { |
1009 for (std::vector< base::Callback<void(void)> >::const_iterator | 1006 RunCompositingCallbacks(); |
1010 it = on_compositing_ended_callbacks_.begin(); | |
1011 it != on_compositing_ended_callbacks_.end(); ++it) { | |
1012 it->Run(); | |
1013 } | |
1014 on_compositing_ended_callbacks_.clear(); | |
1015 compositor->RemoveObserver(this); | 1007 compositor->RemoveObserver(this); |
1016 } | 1008 } |
1017 | 1009 |
1018 //////////////////////////////////////////////////////////////////////////////// | 1010 //////////////////////////////////////////////////////////////////////////////// |
1019 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: | 1011 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: |
1020 | 1012 |
1021 void RenderWidgetHostViewAura::OnLostResources(ui::Compositor* compositor) { | 1013 void RenderWidgetHostViewAura::OnLostResources(ui::Compositor* compositor) { |
1022 image_transport_clients_.clear(); | 1014 image_transport_clients_.clear(); |
1023 current_surface_ = 0; | 1015 current_surface_ = 0; |
1024 UpdateExternalTexture(); | 1016 UpdateExternalTexture(); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 gfx::Rect rect = window_->bounds(); | 1109 gfx::Rect rect = window_->bounds(); |
1118 int border_x = rect.width() * kMouseLockBorderPercentage / 100; | 1110 int border_x = rect.width() * kMouseLockBorderPercentage / 100; |
1119 int border_y = rect.height() * kMouseLockBorderPercentage / 100; | 1111 int border_y = rect.height() * kMouseLockBorderPercentage / 100; |
1120 | 1112 |
1121 return global_mouse_position_.x() < rect.x() + border_x || | 1113 return global_mouse_position_.x() < rect.x() + border_x || |
1122 global_mouse_position_.x() > rect.right() - border_x || | 1114 global_mouse_position_.x() > rect.right() - border_x || |
1123 global_mouse_position_.y() < rect.y() + border_y || | 1115 global_mouse_position_.y() < rect.y() + border_y || |
1124 global_mouse_position_.y() > rect.bottom() - border_y; | 1116 global_mouse_position_.y() > rect.bottom() - border_y; |
1125 } | 1117 } |
1126 | 1118 |
| 1119 void RenderWidgetHostViewAura::RunCompositingCallbacks() { |
| 1120 for (std::vector< base::Callback<void(void)> >::const_iterator |
| 1121 it = on_compositing_ended_callbacks_.begin(); |
| 1122 it != on_compositing_ended_callbacks_.end(); ++it) { |
| 1123 it->Run(); |
| 1124 } |
| 1125 on_compositing_ended_callbacks_.clear(); |
| 1126 } |
| 1127 |
| 1128 void RenderWidgetHostViewAura::RemovingFromRootWindow() { |
| 1129 // We are about to disconnect ourselves from the compositor, we need to issue |
| 1130 // the callbacks now, because we won't get notified when the frame is done. |
| 1131 // TODO(piman): this might in theory cause a race where the GPU process starts |
| 1132 // drawing to the buffer we haven't yet displayed. This will only show for 1 |
| 1133 // frame though, because we will reissue a new frame right away without that |
| 1134 // composited data. |
| 1135 RunCompositingCallbacks(); |
| 1136 ui::Compositor* compositor = GetCompositor(); |
| 1137 if (compositor && compositor->HasObserver(this)) |
| 1138 compositor->RemoveObserver(this); |
| 1139 } |
| 1140 |
1127 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() { | 1141 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() { |
1128 aura::RootWindow* root_window = window_->GetRootWindow(); | 1142 aura::RootWindow* root_window = window_->GetRootWindow(); |
1129 return root_window ? root_window->compositor() : NULL; | 1143 return root_window ? root_window->compositor() : NULL; |
1130 } | 1144 } |
1131 | 1145 |
1132 //////////////////////////////////////////////////////////////////////////////// | 1146 //////////////////////////////////////////////////////////////////////////////// |
1133 // RenderWidgetHostView, public: | 1147 // RenderWidgetHostView, public: |
1134 | 1148 |
1135 // static | 1149 // static |
1136 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( | 1150 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( |
1137 RenderWidgetHost* widget) { | 1151 RenderWidgetHost* widget) { |
1138 return new RenderWidgetHostViewAura(widget); | 1152 return new RenderWidgetHostViewAura(widget); |
1139 } | 1153 } |
1140 | 1154 |
1141 // static | 1155 // static |
1142 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( | 1156 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( |
1143 WebKit::WebScreenInfo* results) { | 1157 WebKit::WebScreenInfo* results) { |
1144 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); | 1158 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); |
1145 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); | 1159 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); |
1146 results->availableRect = results->rect; | 1160 results->availableRect = results->rect; |
1147 // TODO(derat): Don't hardcode this? | 1161 // TODO(derat): Don't hardcode this? |
1148 results->depth = 24; | 1162 results->depth = 24; |
1149 results->depthPerComponent = 8; | 1163 results->depthPerComponent = 8; |
1150 results->verticalDPI = 96; | 1164 results->verticalDPI = 96; |
1151 results->horizontalDPI = 96; | 1165 results->horizontalDPI = 96; |
1152 } | 1166 } |
OLD | NEW |