summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-20 01:45:11 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-20 01:45:11 +0000
commit141e64b54c11354f0e1edf6bc463904039cc07a8 (patch)
tree47349d0febe586521d128a957f6e98b96099ccdb
parent8520ebd2d0fad750b0841f4d8dae1e517f0c400f (diff)
downloadchromium_src-141e64b54c11354f0e1edf6bc463904039cc07a8.zip
chromium_src-141e64b54c11354f0e1edf6bc463904039cc07a8.tar.gz
chromium_src-141e64b54c11354f0e1edf6bc463904039cc07a8.tar.bz2
Revert 236017 "Move some non-event related functionality from Ro..."
> Move some non-event related functionality from RootWindow onto RootWindowHost. > > - Transform logic > - Compositor > > R=sky@chromium.org > http://crbug.com/308843 > > Review URL: https://codereview.chromium.org/70103020 TBR=ben@chromium.org Review URL: https://codereview.chromium.org/77233002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236094 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/autoclick/autoclick_controller.cc2
-rw-r--r--ash/debug.cc6
-rw-r--r--ash/display/display_controller.cc4
-rw-r--r--ash/display/display_controller_unittest.cc28
-rw-r--r--ash/display/display_manager_unittest.cc4
-rw-r--r--ash/display/mirror_window_controller.cc11
-rw-r--r--ash/display/screen_position_controller.cc2
-rw-r--r--ash/magnifier/magnification_controller.cc5
-rw-r--r--ash/wm/window_manager_unittest.cc2
-rw-r--r--content/browser/aura/compositor_resize_lock.cc2
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura.cc8
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura_unittest.cc6
-rw-r--r--content/browser/renderer_host/touch_smooth_scroll_gesture_aura.cc2
-rw-r--r--ui/aura/bench/bench_main.cc4
-rw-r--r--ui/aura/env.h2
-rw-r--r--ui/aura/remote_root_window_host_win.cc3
-rw-r--r--ui/aura/root_window.cc146
-rw-r--r--ui/aura/root_window.h35
-rw-r--r--ui/aura/root_window_host_ozone.cc1
-rw-r--r--ui/aura/root_window_host_win.cc11
-rw-r--r--ui/aura/root_window_host_x11.cc11
-rw-r--r--ui/aura/root_window_host_x11_unittest.cc6
-rw-r--r--ui/aura/test/event_generator.cc3
-rw-r--r--ui/aura/test/test_screen.cc8
-rw-r--r--ui/aura/window_tree_host.cc154
-rw-r--r--ui/aura/window_tree_host.h57
-rw-r--r--ui/aura/window_tree_host_delegate.h4
-rw-r--r--ui/aura/window_unittest.cc8
-rw-r--r--ui/snapshot/snapshot_aura.cc2
-rw-r--r--ui/snapshot/snapshot_aura_unittest.cc4
-rw-r--r--ui/views/widget/desktop_aura/desktop_cursor_loader_updater_auralinux.cc2
-rw-r--r--ui/views/widget/desktop_aura/desktop_root_window_host_win.cc8
-rw-r--r--ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc9
33 files changed, 267 insertions, 293 deletions
diff --git a/ash/autoclick/autoclick_controller.cc b/ash/autoclick/autoclick_controller.cc
index d09cbce..9b49ca2 100644
--- a/ash/autoclick/autoclick_controller.cc
+++ b/ash/autoclick/autoclick_controller.cc
@@ -186,7 +186,7 @@ void AutoclickControllerImpl::DoAutoclick() {
wm::ConvertPointFromScreen(root_window, &click_location);
aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher();
- dispatcher->host()->ConvertPointToHost(&click_location);
+ dispatcher->ConvertPointToHost(&click_location);
ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED,
click_location,
diff --git a/ash/debug.cc b/ash/debug.cc
index a54759b..f5c6220 100644
--- a/ash/debug.cc
+++ b/ash/debug.cc
@@ -18,7 +18,7 @@ void ToggleShowDebugBorders() {
scoped_ptr<bool> value;
for (aura::Window::Windows::iterator it = root_windows.begin();
it != root_windows.end(); ++it) {
- ui::Compositor* compositor = (*it)->GetDispatcher()->host()->compositor();
+ ui::Compositor* compositor = (*it)->GetDispatcher()->compositor();
cc::LayerTreeDebugState state = compositor->GetLayerTreeDebugState();
if (!value.get())
value.reset(new bool(!state.show_debug_borders));
@@ -33,7 +33,7 @@ void ToggleShowFpsCounter() {
scoped_ptr<bool> value;
for (aura::Window::Windows::iterator it = root_windows.begin();
it != root_windows.end(); ++it) {
- ui::Compositor* compositor = (*it)->GetDispatcher()->host()->compositor();
+ ui::Compositor* compositor = (*it)->GetDispatcher()->compositor();
cc::LayerTreeDebugState state = compositor->GetLayerTreeDebugState();
if (!value.get())
value.reset(new bool(!state.show_fps_counter));
@@ -48,7 +48,7 @@ void ToggleShowPaintRects() {
scoped_ptr<bool> value;
for (aura::Window::Windows::iterator it = root_windows.begin();
it != root_windows.end(); ++it) {
- ui::Compositor* compositor = (*it)->GetDispatcher()->host()->compositor();
+ ui::Compositor* compositor = (*it)->GetDispatcher()->compositor();
cc::LayerTreeDebugState state = compositor->GetLayerTreeDebugState();
if (!value.get())
value.reset(new bool(!state.show_paint_rects));
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc
index 09927b3..ee5d25a 100644
--- a/ash/display/display_controller.cc
+++ b/ash/display/display_controller.cc
@@ -124,7 +124,7 @@ void SetDisplayPropertiesOnHostWindow(aura::RootWindow* root,
#endif
scoped_ptr<aura::RootWindowTransformer> transformer(
internal::CreateRootWindowTransformerForDisplay(root->window(), display));
- root->host()->SetRootWindowTransformer(transformer.Pass());
+ root->SetRootWindowTransformer(transformer.Pass());
}
} // namespace
@@ -761,7 +761,7 @@ aura::RootWindow* DisplayController::AddRootWindowForDisplay(
aura::RootWindow* root_window = new aura::RootWindow(params);
root_window->window()->SetName(
base::StringPrintf("RootWindow-%d", root_window_count++));
- root_window->host()->compositor()->SetBackgroundColor(SK_ColorBLACK);
+ root_window->compositor()->SetBackgroundColor(SK_ColorBLACK);
// No need to remove RootWindowObserver because
// the DisplayController object outlives RootWindow objects.
root_window->AddRootWindowObserver(this);
diff --git a/ash/display/display_controller_unittest.cc b/ash/display/display_controller_unittest.cc
index 640fa8c..88a3e7e 100644
--- a/ash/display/display_controller_unittest.cc
+++ b/ash/display/display_controller_unittest.cc
@@ -920,12 +920,12 @@ TEST_F(DisplayControllerTest, CursorDeviceScaleFactorSwapPrimary) {
test::CursorManagerTestApi test_api(Shell::GetInstance()->cursor_manager());
- EXPECT_EQ(1.0f, primary_root->GetDispatcher()->host()->compositor()->
- device_scale_factor());
+ EXPECT_EQ(1.0f, primary_root->GetDispatcher()->AsRootWindowHostDelegate()->
+ GetDeviceScaleFactor());
primary_root->MoveCursorTo(gfx::Point(50, 50));
EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor());
- EXPECT_EQ(2.0f, secondary_root->GetDispatcher()->host()->compositor()->
- device_scale_factor());
+ EXPECT_EQ(2.0f, secondary_root->GetDispatcher()->AsRootWindowHostDelegate()->
+ GetDeviceScaleFactor());
secondary_root->MoveCursorTo(gfx::Point(50, 50));
EXPECT_EQ(2.0f, test_api.GetDisplay().device_scale_factor());
@@ -934,13 +934,13 @@ TEST_F(DisplayControllerTest, CursorDeviceScaleFactorSwapPrimary) {
// Cursor's device scale factor should be updated accroding to the swap of
// primary and secondary.
- EXPECT_EQ(1.0f, secondary_root->GetDispatcher()->host()->compositor()->
- device_scale_factor());
+ EXPECT_EQ(1.0f, secondary_root->GetDispatcher()->AsRootWindowHostDelegate()->
+ GetDeviceScaleFactor());
secondary_root->MoveCursorTo(gfx::Point(50, 50));
EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor());
primary_root->MoveCursorTo(gfx::Point(50, 50));
- EXPECT_EQ(2.0f, primary_root->GetDispatcher()->host()->compositor()->
- device_scale_factor());
+ EXPECT_EQ(2.0f, primary_root->GetDispatcher()->AsRootWindowHostDelegate()->
+ GetDeviceScaleFactor());
EXPECT_EQ(2.0f, test_api.GetDisplay().device_scale_factor());
// Deleting 2nd display.
@@ -951,8 +951,8 @@ TEST_F(DisplayControllerTest, CursorDeviceScaleFactorSwapPrimary) {
EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor());
primary_root->MoveCursorTo(gfx::Point(50, 50));
- EXPECT_EQ(1.0f, primary_root->GetDispatcher()->host()->compositor()->
- device_scale_factor());
+ EXPECT_EQ(1.0f, primary_root->GetDispatcher()->AsRootWindowHostDelegate()->
+ GetDeviceScaleFactor());
EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor());
}
@@ -993,13 +993,13 @@ TEST_F(DisplayControllerTest, OverscanInsets) {
UpdateDisplay("400x300*2,600x400/o");
root_windows = Shell::GetAllRootWindows();
gfx::Point point;
- Shell::GetAllRootWindows()[1]->GetDispatcher()->host()->
+ Shell::GetAllRootWindows()[1]->GetDispatcher()->
GetRootTransform().TransformPoint(&point);
EXPECT_EQ("15,10", point.ToString());
display_controller->SwapPrimaryDisplay();
point.SetPoint(0, 0);
- Shell::GetAllRootWindows()[1]->GetDispatcher()->host()->
+ Shell::GetAllRootWindows()[1]->GetDispatcher()->
GetRootTransform().TransformPoint(&point);
EXPECT_EQ("15,10", point.ToString());
@@ -1252,7 +1252,7 @@ TEST_F(DisplayControllerTest, DockToSingle) {
display_info_list.push_back(external_display_info);
display_manager->OnNativeDisplaysChanged(display_info_list);
EXPECT_EQ(1U, display_manager->GetNumDisplays());
- EXPECT_FALSE(Shell::GetPrimaryRootWindow()->GetDispatcher()->host()->
+ EXPECT_FALSE(Shell::GetPrimaryRootWindow()->GetDispatcher()->
GetRootTransform().IsIdentityOrIntegerTranslation());
// Switch to single mode and make sure the transform is the one
@@ -1260,7 +1260,7 @@ TEST_F(DisplayControllerTest, DockToSingle) {
display_info_list.clear();
display_info_list.push_back(internal_display_info);
display_manager->OnNativeDisplaysChanged(display_info_list);
- EXPECT_TRUE(Shell::GetPrimaryRootWindow()->GetDispatcher()->host()->
+ EXPECT_TRUE(Shell::GetPrimaryRootWindow()->GetDispatcher()->
GetRootTransform().IsIdentityOrIntegerTranslation());
}
diff --git a/ash/display/display_manager_unittest.cc b/ash/display/display_manager_unittest.cc
index 2563627..f6bd59e 100644
--- a/ash/display/display_manager_unittest.cc
+++ b/ash/display/display_manager_unittest.cc
@@ -384,11 +384,11 @@ TEST_F(DisplayManagerTest, TestDeviceScaleOnlyChange) {
UpdateDisplay("1000x600");
aura::WindowEventDispatcher* dispatcher =
Shell::GetPrimaryRootWindow()->GetDispatcher();
- EXPECT_EQ(1, dispatcher->host()->compositor()->device_scale_factor());
+ EXPECT_EQ(1, dispatcher->compositor()->device_scale_factor());
EXPECT_EQ("1000x600",
Shell::GetPrimaryRootWindow()->bounds().size().ToString());
UpdateDisplay("1000x600*2");
- EXPECT_EQ(2, dispatcher->host()->compositor()->device_scale_factor());
+ EXPECT_EQ(2, dispatcher->compositor()->device_scale_factor());
EXPECT_EQ("500x300",
Shell::GetPrimaryRootWindow()->bounds().size().ToString());
}
diff --git a/ash/display/mirror_window_controller.cc b/ash/display/mirror_window_controller.cc
index 9a16898..7e812a4c 100644
--- a/ash/display/mirror_window_controller.cc
+++ b/ash/display/mirror_window_controller.cc
@@ -168,7 +168,7 @@ void MirrorWindowController::UpdateWindow(const DisplayInfo& display_info) {
root_window_.reset(new aura::RootWindow(params));
root_window_->window()->SetName(
base::StringPrintf("MirrorRootWindow-%d", mirror_root_window_count++));
- root_window_->host()->compositor()->SetBackgroundColor(SK_ColorBLACK);
+ root_window_->compositor()->SetBackgroundColor(SK_ColorBLACK);
// No need to remove RootWindowObserver because
// the DisplayController object outlives RootWindow objects.
root_window_->AddRootWindowObserver(
@@ -193,7 +193,7 @@ void MirrorWindowController::UpdateWindow(const DisplayInfo& display_info) {
mirror_window->SetBounds(root_window_->window()->bounds());
mirror_window->Show();
reflector_ = ui::ContextFactory::GetInstance()->CreateReflector(
- Shell::GetPrimaryRootWindow()->GetDispatcher()->host()->compositor(),
+ Shell::GetPrimaryRootWindow()->GetDispatcher()->compositor(),
mirror_window->layer());
cursor_window_ = new aura::Window(cursor_window_delegate_.get());
@@ -215,7 +215,7 @@ void MirrorWindowController::UpdateWindow(const DisplayInfo& display_info) {
internal::CreateRootWindowTransformerForMirroredDisplay(
source_display_info,
display_info));
- root_window_->host()->SetRootWindowTransformer(transformer.Pass());
+ root_window_->SetRootWindowTransformer(transformer.Pass());
UpdateCursorLocation();
}
@@ -250,8 +250,7 @@ void MirrorWindowController::UpdateCursorLocation() {
if (cursor_window_) {
// TODO(oshima): Rotate cursor image (including hotpoint).
gfx::Point point = aura::Env::GetInstance()->last_mouse_location();
- Shell::GetPrimaryRootWindow()->GetDispatcher()->host()->ConvertPointToHost(
- &point);
+ Shell::GetPrimaryRootWindow()->GetDispatcher()->ConvertPointToHost(&point);
point.Offset(-hot_point_.x(), -hot_point_.y());
gfx::Rect bounds = cursor_window_->bounds();
bounds.set_origin(point);
@@ -326,7 +325,7 @@ void MirrorWindowController::OnRootWindowHostResized(
return;
mirror_window_host_size_ = root->host()->GetBounds().size();
reflector_->OnMirroringCompositorResized();
- root_window_->host()->SetRootWindowTransformer(
+ root_window_->SetRootWindowTransformer(
CreateRootWindowTransformer().Pass());
UpdateCursorLocation();
}
diff --git a/ash/display/screen_position_controller.cc b/ash/display/screen_position_controller.cc
index 624a0cd..e9f7a42 100644
--- a/ash/display/screen_position_controller.cc
+++ b/ash/display/screen_position_controller.cc
@@ -140,7 +140,7 @@ void ScreenPositionController::ConvertHostPointToScreen(
aura::Window* root_window,
gfx::Point* point) {
aura::Window* root = root_window->GetRootWindow();
- root->GetDispatcher()->host()->ConvertPointFromHost(point);
+ root->GetDispatcher()->ConvertPointFromHost(point);
std::pair<aura::Window*, gfx::Point> pair =
GetRootWindowRelativeToWindow(root, *point);
*point = pair.second;
diff --git a/ash/magnifier/magnification_controller.cc b/ash/magnifier/magnification_controller.cc
index 66bebf2..0df6e12 100644
--- a/ash/magnifier/magnification_controller.cc
+++ b/ash/magnifier/magnification_controller.cc
@@ -44,7 +44,7 @@ const int kPanningMergin = 100;
void MoveCursorTo(aura::RootWindow* root_window,
const gfx::Point& root_location) {
gfx::Point3F host_location_3f(root_location);
- root_window->host()->GetRootTransform().TransformPoint(&host_location_3f);
+ root_window->GetRootTransform().TransformPoint(&host_location_3f);
root_window->MoveCursorToHostLocation(
gfx::ToCeiledPoint(host_location_3f.AsPointF()));
}
@@ -273,8 +273,7 @@ bool MagnificationControllerImpl::RedrawDIP(const gfx::PointF& position_in_dip,
Shell::GetScreen()->GetDisplayNearestWindow(root_window_);
scoped_ptr<aura::RootWindowTransformer> transformer(
internal::CreateRootWindowTransformerForDisplay(root_window_, display));
- root_window_->GetDispatcher()->host()->SetRootWindowTransformer(
- transformer.Pass());
+ root_window_->GetDispatcher()->SetRootWindowTransformer(transformer.Pass());
if (animate)
is_on_animation_ = true;
diff --git a/ash/wm/window_manager_unittest.cc b/ash/wm/window_manager_unittest.cc
index 65c2f97..2b97e52 100644
--- a/ash/wm/window_manager_unittest.cc
+++ b/ash/wm/window_manager_unittest.cc
@@ -592,7 +592,7 @@ TEST_F(WindowManagerTest, MAYBE_TransformActivate) {
gfx::Transform transform;
transform.Translate(size.width(), 0);
transform.Rotate(90.0f);
- root_window->GetDispatcher()->host()->SetTransform(transform);
+ root_window->GetDispatcher()->SetTransform(transform);
test::TestActivationDelegate d1;
aura::test::TestWindowDelegate wd;
diff --git a/content/browser/aura/compositor_resize_lock.cc b/content/browser/aura/compositor_resize_lock.cc
index a0f17aa..e80baba 100644
--- a/content/browser/aura/compositor_resize_lock.cc
+++ b/content/browser/aura/compositor_resize_lock.cc
@@ -51,7 +51,7 @@ void CompositorResizeLock::UnlockCompositor() {
void CompositorResizeLock::LockCompositor() {
ResizeLock::LockCompositor();
- compositor_lock_ = root_window_->host()->compositor()->GetCompositorLock();
+ compositor_lock_ = root_window_->compositor()->GetCompositorLock();
}
void CompositorResizeLock::CancelLock() {
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index 0fdd811..ce93991 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -632,10 +632,10 @@ void RenderWidgetHostViewAura::MaybeCreateResizeLock() {
if (!ShouldCreateResizeLock())
return;
DCHECK(window_->GetDispatcher());
- DCHECK(window_->GetDispatcher()->host()->compositor());
+ DCHECK(window_->GetDispatcher()->compositor());
// Listen to changes in the compositor lock state.
- ui::Compositor* compositor = window_->GetDispatcher()->host()->compositor();
+ ui::Compositor* compositor = window_->GetDispatcher()->compositor();
if (!compositor->HasObserver(this))
compositor->AddObserver(this);
@@ -677,7 +677,7 @@ bool RenderWidgetHostViewAura::ShouldCreateResizeLock() {
if (!dispatcher)
return false;
- ui::Compositor* compositor = dispatcher->host()->compositor();
+ ui::Compositor* compositor = dispatcher->compositor();
if (!compositor)
return false;
@@ -3347,7 +3347,7 @@ void RenderWidgetHostViewAura::RemovingFromRootWindow() {
ui::Compositor* RenderWidgetHostViewAura::GetCompositor() const {
aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher();
- return dispatcher ? dispatcher->host()->compositor() : NULL;
+ return dispatcher ? dispatcher->compositor() : NULL;
}
void RenderWidgetHostViewAura::DetachFromInputMethod() {
diff --git a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
index a6a7dd8b..ee93871 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
@@ -133,7 +133,7 @@ class FakeRenderWidgetHostViewAura : public RenderWidgetHostViewAura {
}
void RunOnCompositingDidCommit() {
- OnCompositingDidCommit(window()->GetDispatcher()->host()->compositor());
+ OnCompositingDidCommit(window()->GetDispatcher()->compositor());
}
// A lock that doesn't actually do anything to the compositor, and does not
@@ -748,7 +748,7 @@ TEST_F(RenderWidgetHostViewAuraTest, FullscreenResize) {
view_->OnSwapCompositorFrame(
0, MakeGLFrame(1.f, params.a.new_size, gfx::Rect(params.a.new_size)));
ui::DrawWaiterForTest::WaitForCommit(
- root_window->GetDispatcher()->host()->compositor());
+ root_window->GetDispatcher()->compositor());
}
widget_host_->ResetSizeAndRepaintPendingFlags();
@@ -769,7 +769,7 @@ TEST_F(RenderWidgetHostViewAuraTest, FullscreenResize) {
view_->OnSwapCompositorFrame(
0, MakeGLFrame(1.f, params.a.new_size, gfx::Rect(params.a.new_size)));
ui::DrawWaiterForTest::WaitForCommit(
- root_window->GetDispatcher()->host()->compositor());
+ root_window->GetDispatcher()->compositor());
}
}
diff --git a/content/browser/renderer_host/touch_smooth_scroll_gesture_aura.cc b/content/browser/renderer_host/touch_smooth_scroll_gesture_aura.cc
index c2d8430..45f0d74 100644
--- a/content/browser/renderer_host/touch_smooth_scroll_gesture_aura.cc
+++ b/content/browser/renderer_host/touch_smooth_scroll_gesture_aura.cc
@@ -22,7 +22,7 @@ void InjectTouchEvent(const gfx::Point& location,
aura::Window::ConvertPointToTarget(window, root_window, &screen_location);
// Then convert the location from RootWindow to screen.
aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher();
- dispatcher->host()->ConvertPointToHost(&screen_location);
+ dispatcher->ConvertPointToHost(&screen_location);
ui::TouchEvent touch(type, screen_location, 0, 0, ui::EventTimeForNow(),
1.0f, 1.0f, 1.0f, 1.0f);
dispatcher->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch);
diff --git a/ui/aura/bench/bench_main.cc b/ui/aura/bench/bench_main.cc
index a921f14..8b85f7d 100644
--- a/ui/aura/bench/bench_main.cc
+++ b/ui/aura/bench/bench_main.cc
@@ -351,11 +351,11 @@ int main(int argc, char** argv) {
if (command_line->HasSwitch("bench-software-scroll")) {
bench.reset(new SoftwareScrollBench(&page_background,
- root_window->host()->compositor(),
+ root_window->compositor(),
frames));
} else {
bench.reset(new WebGLBench(&page_background,
- root_window->host()->compositor(),
+ root_window->compositor(),
frames));
}
diff --git a/ui/aura/env.h b/ui/aura/env.h
index ec52005..4968d39 100644
--- a/ui/aura/env.h
+++ b/ui/aura/env.h
@@ -79,7 +79,7 @@ class AURA_EXPORT Env : public ui::EventTarget {
private:
friend class test::EnvTestHelper;
friend class Window;
- friend class RootWindowHost;
+ friend class RootWindow;
void Init();
diff --git a/ui/aura/remote_root_window_host_win.cc b/ui/aura/remote_root_window_host_win.cc
index 9043e0a..6084885e 100644
--- a/ui/aura/remote_root_window_host_win.cc
+++ b/ui/aura/remote_root_window_host_win.cc
@@ -136,7 +136,6 @@ RemoteRootWindowHostWin::RemoteRootWindowHostWin(const gfx::Rect& bounds)
ignore_mouse_moves_until_set_cursor_ack_(false),
event_flags_(0) {
prop_.reset(new ui::ViewProp(NULL, kRootWindowHostWinKey, this));
- CreateCompositor(GetAcceleratedWidget());
}
RemoteRootWindowHostWin::~RemoteRootWindowHostWin() {
@@ -330,7 +329,7 @@ gfx::Rect RemoteRootWindowHostWin::GetBounds() const {
}
void RemoteRootWindowHostWin::SetBounds(const gfx::Rect& bounds) {
- NotifyHostResized(bounds.size());
+ delegate_->OnHostResized(bounds.size());
}
gfx::Insets RemoteRootWindowHostWin::GetInsets() const {
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index ee2bc4f..c2c1ab58 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -18,6 +18,7 @@
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window_observer.h"
+#include "ui/aura/root_window_transformer.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_tracker.h"
@@ -30,7 +31,11 @@
#include "ui/events/event.h"
#include "ui/events/gestures/gesture_recognizer.h"
#include "ui/events/gestures/gesture_types.h"
+#include "ui/gfx/display.h"
+#include "ui/gfx/point3_f.h"
+#include "ui/gfx/point_conversions.h"
#include "ui/gfx/screen.h"
+#include "ui/gfx/size_conversions.h"
using std::vector;
@@ -52,6 +57,13 @@ bool IsNonClientLocation(Window* target, const gfx::Point& location) {
return hit_test_code != HTCLIENT && hit_test_code != HTNOWHERE;
}
+float GetDeviceScaleFactorFromDisplay(Window* window) {
+ gfx::Display display = gfx::Screen::GetScreenFor(window)->
+ GetDisplayNearestWindow(window);
+ DCHECK(display.is_valid());
+ return display.device_scale_factor();
+}
+
Window* ConsumerToWindow(ui::GestureConsumer* consumer) {
return consumer ? static_cast<Window*>(consumer) : NULL;
}
@@ -77,6 +89,47 @@ RootWindowHost* CreateHost(RootWindow* root_window,
return host;
}
+class SimpleRootWindowTransformer : public RootWindowTransformer {
+ public:
+ SimpleRootWindowTransformer(const Window* root_window,
+ const gfx::Transform& transform)
+ : root_window_(root_window),
+ transform_(transform) {
+ }
+
+ // RootWindowTransformer overrides:
+ virtual gfx::Transform GetTransform() const OVERRIDE {
+ return transform_;
+ }
+
+ virtual gfx::Transform GetInverseTransform() const OVERRIDE {
+ gfx::Transform invert;
+ if (!transform_.GetInverse(&invert))
+ return transform_;
+ return invert;
+ }
+
+ virtual gfx::Rect GetRootWindowBounds(
+ const gfx::Size& host_size) const OVERRIDE {
+ gfx::Rect bounds(host_size);
+ gfx::RectF new_bounds(ui::ConvertRectToDIP(root_window_->layer(), bounds));
+ transform_.TransformRect(&new_bounds);
+ return gfx::Rect(gfx::ToFlooredSize(new_bounds.size()));
+ }
+
+ virtual gfx::Insets GetHostInsets() const OVERRIDE {
+ return gfx::Insets();
+ }
+
+ private:
+ virtual ~SimpleRootWindowTransformer() {}
+
+ const Window* root_window_;
+ const gfx::Transform transform_;
+
+ DISALLOW_COPY_AND_ASSIGN(SimpleRootWindowTransformer);
+};
+
} // namespace
RootWindow::CreateParams::CreateParams(const gfx::Rect& a_initial_bounds)
@@ -102,6 +155,9 @@ RootWindow::RootWindow(const CreateParams& params)
window()->set_dispatcher(this);
window()->SetName("RootWindow");
+ compositor_.reset(new ui::Compositor(host_->GetAcceleratedWidget()));
+ DCHECK(compositor_.get());
+
prop_.reset(new ui::ViewProp(host_->GetAcceleratedWidget(),
kRootWindowForAcceleratedWidget,
this));
@@ -113,6 +169,10 @@ RootWindow::~RootWindow() {
ui::GestureRecognizer::Get()->RemoveGestureEventHelper(this);
+ // Make sure to destroy the compositor before terminating so that state is
+ // cleared and we don't hit asserts.
+ compositor_.reset();
+
// An observer may have been added by an animation on the RootWindow.
window()->layer()->GetAnimator()->RemoveObserver(this);
@@ -137,7 +197,15 @@ RootWindow* RootWindow::GetForAcceleratedWidget(
}
void RootWindow::Init() {
- host()->InitHost();
+ compositor()->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()),
+ host_->GetBounds().size());
+ window()->Init(ui::LAYER_NOT_DRAWN);
+ compositor()->SetRootLayer(window()->layer());
+ transformer_.reset(
+ new SimpleRootWindowTransformer(window(), gfx::Transform()));
+ UpdateRootWindowSize(host_->GetBounds().size());
+ Env::GetInstance()->NotifyRootWindowInitialized(this);
+ window()->Show();
}
void RootWindow::PrepareForShutdown() {
@@ -227,16 +295,20 @@ void RootWindow::OnMouseEventsEnableStateChanged(bool enabled) {
void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) {
gfx::Point host_location(location_in_dip);
- host()->ConvertPointToHost(&host_location);
+ ConvertPointToHost(&host_location);
MoveCursorToInternal(location_in_dip, host_location);
}
void RootWindow::MoveCursorToHostLocation(const gfx::Point& host_location) {
gfx::Point root_location(host_location);
- host()->ConvertPointFromHost(&root_location);
+ ConvertPointFromHost(&root_location);
MoveCursorToInternal(root_location, host_location);
}
+void RootWindow::ScheduleRedrawRect(const gfx::Rect& damage_rect) {
+ compositor_->ScheduleRedrawRect(damage_rect);
+}
+
Window* RootWindow::GetGestureTarget(ui::GestureEvent* event) {
Window* target = client::GetCaptureWindow(window());
if (!target) {
@@ -334,6 +406,18 @@ void RootWindow::RemoveRootWindowObserver(RootWindowObserver* observer) {
observers_.RemoveObserver(observer);
}
+void RootWindow::ConvertPointToHost(gfx::Point* point) const {
+ gfx::Point3F point_3f(*point);
+ GetRootTransform().TransformPoint(&point_3f);
+ *point = gfx::ToFlooredPoint(point_3f.AsPointF());
+}
+
+void RootWindow::ConvertPointFromHost(gfx::Point* point) const {
+ gfx::Point3F point_3f(*point);
+ GetInverseRootTransform().TransformPoint(&point_3f);
+ *point = gfx::ToFlooredPoint(point_3f.AsPointF());
+}
+
void RootWindow::ProcessedTouchEvent(ui::TouchEvent* event,
Window* window,
ui::EventResult result) {
@@ -377,11 +461,36 @@ gfx::Point RootWindow::GetLastMouseLocationInRoot() const {
return location;
}
+void RootWindow::SetRootWindowTransformer(
+ scoped_ptr<RootWindowTransformer> transformer) {
+ transformer_ = transformer.Pass();
+ host_->SetInsets(transformer_->GetHostInsets());
+ window()->SetTransform(transformer_->GetTransform());
+ // If the layer is not animating, then we need to update the root window
+ // size immediately.
+ if (!window()->layer()->GetAnimator()->is_animating())
+ UpdateRootWindowSize(host_->GetBounds().size());
+}
+
+gfx::Transform RootWindow::GetRootTransform() const {
+ float scale = ui::GetDeviceScaleFactor(window()->layer());
+ gfx::Transform transform;
+ transform.Scale(scale, scale);
+ transform *= transformer_->GetTransform();
+ return transform;
+}
+
+void RootWindow::SetTransform(const gfx::Transform& transform) {
+ scoped_ptr<RootWindowTransformer> transformer(
+ new SimpleRootWindowTransformer(window(), transform));
+ SetRootWindowTransformer(transformer.Pass());
+}
+
////////////////////////////////////////////////////////////////////////////////
// RootWindow, private:
void RootWindow::TransformEventForDeviceScaleFactor(ui::LocatedEvent* event) {
- event->UpdateForRootTransform(host()->GetInverseRootTransform());
+ event->UpdateForRootTransform(GetInverseRootTransform());
}
void RootWindow::MoveCursorToInternal(const gfx::Point& root_location,
@@ -498,6 +607,10 @@ void RootWindow::CleanupGestureRecognizerState(Window* window) {
}
}
+void RootWindow::UpdateRootWindowSize(const gfx::Size& host_size) {
+ window()->SetBounds(transformer_->GetRootWindowBounds(host_size));
+}
+
////////////////////////////////////////////////////////////////////////////////
// RootWindow, aura::client::CaptureDelegate implementation:
@@ -577,7 +690,7 @@ void RootWindow::DispatchCancelTouchEvent(ui::TouchEvent* event) {
void RootWindow::OnLayerAnimationEnded(
ui::LayerAnimationSequence* animation) {
- host()->UpdateRootWindowSize(host_->GetBounds().size());
+ UpdateRootWindowSize(host_->GetBounds().size());
}
void RootWindow::OnLayerAnimationScheduled(
@@ -691,6 +804,10 @@ void RootWindow::OnHostLostMouseGrab() {
mouse_moved_handler_ = NULL;
}
+void RootWindow::OnHostPaint(const gfx::Rect& damage_rect) {
+ compositor_->ScheduleRedrawRect(damage_rect);
+}
+
void RootWindow::OnHostMoved(const gfx::Point& origin) {
TRACE_EVENT1("ui", "RootWindow::OnHostMoved",
"origin", origin.ToString());
@@ -706,11 +823,21 @@ void RootWindow::OnHostResized(const gfx::Size& size) {
DispatchDetails details = DispatchHeldEvents();
if (details.dispatcher_destroyed)
return;
+ // The compositor should have the same size as the native root window host.
+ // Get the latest scale from display because it might have been changed.
+ compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()), size);
+ // The layer, and the observers should be notified of the
+ // transformed size of the root window.
+ UpdateRootWindowSize(size);
FOR_EACH_OBSERVER(RootWindowObserver, observers_,
OnRootWindowHostResized(this));
}
+float RootWindow::GetDeviceScaleFactor() {
+ return compositor()->device_scale_factor();
+}
+
RootWindow* RootWindow::AsRootWindow() {
return this;
}
@@ -982,7 +1109,7 @@ ui::EventDispatchDetails RootWindow::SynthesizeMouseMoveEvent() {
if (!window()->bounds().Contains(root_mouse_location))
return details;
gfx::Point host_mouse_location = root_mouse_location;
- host()->ConvertPointToHost(&host_mouse_location);
+ ConvertPointToHost(&host_mouse_location);
ui::MouseEvent event(ui::ET_MOUSE_MOVED,
host_mouse_location,
@@ -997,4 +1124,11 @@ void RootWindow::SynthesizeMouseMoveEventAsync() {
return;
}
+gfx::Transform RootWindow::GetInverseRootTransform() const {
+ float scale = ui::GetDeviceScaleFactor(window()->layer());
+ gfx::Transform transform;
+ transform.Scale(1.0f / scale, 1.0f / scale);
+ return transformer_->GetInverseTransform() * transform;
+}
+
} // namespace aura
diff --git a/ui/aura/root_window.h b/ui/aura/root_window.h
index 7f8d0b1..3254f8f 100644
--- a/ui/aura/root_window.h
+++ b/ui/aura/root_window.h
@@ -26,6 +26,7 @@
#include "ui/events/gestures/gesture_types.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/point.h"
+#include "ui/gfx/transform.h"
namespace gfx {
class Size;
@@ -47,6 +48,7 @@ namespace aura {
class RootWindow;
class RootWindowHost;
class RootWindowObserver;
+class RootWindowTransformer;
class TestScreen;
// RootWindow is responsible for hosting a set of windows.
@@ -84,6 +86,7 @@ class AURA_EXPORT RootWindow : public ui::EventDispatcherDelegate,
const_cast<const RootWindow*>(this)->host());
}
const RootWindowHost* host() const { return host_.get(); }
+ ui::Compositor* compositor() { return compositor_.get(); }
gfx::NativeCursor last_cursor() const { return last_cursor_; }
Window* mouse_pressed_handler() { return mouse_pressed_handler_; }
Window* mouse_moved_handler() { return mouse_moved_handler_; }
@@ -125,6 +128,9 @@ class AURA_EXPORT RootWindow : public ui::EventDispatcherDelegate,
// Moves the cursor to the |host_location| given in host coordinates.
void MoveCursorToHostLocation(const gfx::Point& host_location);
+ // Draw the damage_rect.
+ void ScheduleRedrawRect(const gfx::Rect& damage_rect);
+
// Returns a target window for the given gesture event.
Window* GetGestureTarget(ui::GestureEvent* event);
@@ -168,6 +174,14 @@ class AURA_EXPORT RootWindow : public ui::EventDispatcherDelegate,
void AddRootWindowObserver(RootWindowObserver* observer);
void RemoveRootWindowObserver(RootWindowObserver* observer);
+ // Converts |point| from the root window's coordinate system to the
+ // host window's.
+ void ConvertPointToHost(gfx::Point* point) const;
+
+ // Converts |point| from the host window's coordinate system to the
+ // root window's.
+ void ConvertPointFromHost(gfx::Point* point) const;
+
// Gesture Recognition -------------------------------------------------------
// When a touch event is dispatched to a Window, it may want to process the
@@ -193,6 +207,11 @@ class AURA_EXPORT RootWindow : public ui::EventDispatcherDelegate,
// coordinates. This may return a point outside the root window's bounds.
gfx::Point GetLastMouseLocationInRoot() const;
+ void SetRootWindowTransformer(scoped_ptr<RootWindowTransformer> transformer);
+ gfx::Transform GetRootTransform() const;
+
+ void SetTransform(const gfx::Transform& transform);
+
private:
FRIEND_TEST_ALL_PREFIXES(RootWindowTest, KeepTranslatedEventInRoot);
@@ -242,6 +261,10 @@ class AURA_EXPORT RootWindow : public ui::EventDispatcherDelegate,
// |window| itself).
void CleanupGestureRecognizerState(Window* window);
+ // Updates the root window's size using |host_size|, current
+ // transform and insets.
+ void UpdateRootWindowSize(const gfx::Size& host_size);
+
// Overridden from aura::client::CaptureDelegate:
virtual void UpdateCapture(Window* old_capture, Window* new_capture) OVERRIDE;
virtual void OnOtherRootGotCapture() OVERRIDE;
@@ -273,8 +296,10 @@ class AURA_EXPORT RootWindow : public ui::EventDispatcherDelegate,
virtual void OnHostActivated() OVERRIDE;
virtual void OnHostLostWindowCapture() OVERRIDE;
virtual void OnHostLostMouseGrab() OVERRIDE;
+ virtual void OnHostPaint(const gfx::Rect& damage_rect) OVERRIDE;
virtual void OnHostMoved(const gfx::Point& origin) OVERRIDE;
virtual void OnHostResized(const gfx::Size& size) OVERRIDE;
+ virtual float GetDeviceScaleFactor() OVERRIDE;
virtual RootWindow* AsRootWindow() OVERRIDE;
virtual const RootWindow* AsRootWindow() const OVERRIDE;
@@ -309,9 +334,13 @@ class AURA_EXPORT RootWindow : public ui::EventDispatcherDelegate,
// is no a pending task.
void PostMouseMoveEventAfterWindowChange();
+ gfx::Transform GetInverseRootTransform() const;
+
// TODO(beng): evaluate the ideal ownership model.
scoped_ptr<Window> window_;
+ scoped_ptr<ui::Compositor> compositor_;
+
scoped_ptr<RootWindowHost> host_;
// Touch ids that are currently down.
@@ -327,6 +356,10 @@ class AURA_EXPORT RootWindow : public ui::EventDispatcherDelegate,
Window* event_dispatch_target_;
bool synthesize_mouse_move_;
+ bool waiting_on_compositing_end_;
+ bool draw_on_compositing_end_;
+
+ bool defer_draw_scheduling_;
// How many move holds are outstanding. We try to defer dispatching
// touch/mouse moves while the count is > 0.
@@ -338,6 +371,8 @@ class AURA_EXPORT RootWindow : public ui::EventDispatcherDelegate,
scoped_ptr<ui::ViewProp> prop_;
+ scoped_ptr<RootWindowTransformer> transformer_;
+
// Used to schedule reposting an event.
base::WeakPtrFactory<RootWindow> repost_event_factory_;
diff --git a/ui/aura/root_window_host_ozone.cc b/ui/aura/root_window_host_ozone.cc
index 9f324c2..937b70f 100644
--- a/ui/aura/root_window_host_ozone.cc
+++ b/ui/aura/root_window_host_ozone.cc
@@ -28,7 +28,6 @@ RootWindowHostOzone::RootWindowHostOzone(const gfx::Rect& bounds)
surface_factory->AttemptToResizeAcceleratedWidget(widget_, bounds_);
base::MessagePumpOzone::Current()->AddDispatcherForRootWindow(this);
- CreateCompositor(GetAcceleratedWidget());
}
RootWindowHostOzone::~RootWindowHostOzone() {
diff --git a/ui/aura/root_window_host_win.cc b/ui/aura/root_window_host_win.cc
index 7bf4284..931c11e 100644
--- a/ui/aura/root_window_host_win.cc
+++ b/ui/aura/root_window_host_win.cc
@@ -48,7 +48,6 @@ RootWindowHostWin::RootWindowHostWin(const gfx::Rect& bounds)
set_window_style(WS_POPUP);
Init(NULL, bounds);
SetWindowText(hwnd(), L"aura::RootWindow!");
- CreateCompositor(GetAcceleratedWidget());
}
RootWindowHostWin::~RootWindowHostWin() {
@@ -133,14 +132,14 @@ void RootWindowHostWin::SetBounds(const gfx::Rect& bounds) {
window_rect.bottom - window_rect.top,
SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOREPOSITION);
- // Explicity call NotifyHostResized when the scale has changed because
+ // Explicity call OnHostResized when the scale has changed because
// the window size may not have changed.
- float current_scale = compositor()->device_scale_factor();
+ float current_scale = delegate_->GetDeviceScaleFactor();
float new_scale = gfx::Screen::GetScreenFor(
delegate_->AsRootWindow()->window())->GetDisplayNearestWindow(
delegate_->AsRootWindow()->window()).device_scale_factor();
if (current_scale != new_scale)
- NotifyHostResized(bounds.size());
+ delegate_->OnHostResized(bounds.size());
}
gfx::Insets RootWindowHostWin::GetInsets() const {
@@ -287,7 +286,7 @@ void RootWindowHostWin::OnPaint(HDC dc) {
RECT update_rect = {0};
if (GetUpdateRect(hwnd(), &update_rect, FALSE))
damage_rect = gfx::Rect(update_rect);
- compositor()->ScheduleRedrawRect(damage_rect);
+ delegate_->OnHostPaint(damage_rect);
ValidateRect(hwnd(), NULL);
}
@@ -295,7 +294,7 @@ void RootWindowHostWin::OnSize(UINT param, const CSize& size) {
// Minimizing resizes the window to 0x0 which causes our layout to go all
// screwy, so we just ignore it.
if (delegate_ && param != SIZE_MINIMIZED)
- NotifyHostResized(gfx::Size(size.cx, size.cy));
+ delegate_->OnHostResized(gfx::Size(size.cx, size.cy));
}
namespace test {
diff --git a/ui/aura/root_window_host_x11.cc b/ui/aura/root_window_host_x11.cc
index 55c21c6..08c8ca6 100644
--- a/ui/aura/root_window_host_x11.cc
+++ b/ui/aura/root_window_host_x11.cc
@@ -395,7 +395,6 @@ RootWindowHostX11::RootWindowHostX11(const gfx::Rect& bounds)
XRRSelectInput(xdisplay_, x_root_window_,
RRScreenChangeNotifyMask | RROutputChangeNotifyMask);
Env::GetInstance()->AddObserver(this);
- CreateCompositor(GetAcceleratedWidget());
}
RootWindowHostX11::~RootWindowHostX11() {
@@ -439,7 +438,7 @@ bool RootWindowHostX11::Dispatch(const base::NativeEvent& event) {
case Expose: {
gfx::Rect damage_rect(xev->xexpose.x, xev->xexpose.y,
xev->xexpose.width, xev->xexpose.height);
- compositor()->ScheduleRedrawRect(damage_rect);
+ delegate_->AsRootWindow()->ScheduleRedrawRect(damage_rect);
break;
}
case KeyPress: {
@@ -510,7 +509,7 @@ bool RootWindowHostX11::Dispatch(const base::NativeEvent& event) {
ConfineCursorToRootWindow();
}
if (size_changed)
- NotifyHostResized(bounds.size());
+ delegate_->OnHostResized(bounds.size());
if (origin_changed)
delegate_->OnHostMoved(bounds_.origin());
break;
@@ -633,7 +632,7 @@ gfx::Rect RootWindowHostX11::GetBounds() const {
void RootWindowHostX11::SetBounds(const gfx::Rect& bounds) {
// Even if the host window's size doesn't change, aura's root window
// size, which is in DIP, changes when the scale changes.
- float current_scale = compositor()->device_scale_factor();
+ float current_scale = delegate_->GetDeviceScaleFactor();
float new_scale = gfx::Screen::GetScreenFor(
delegate_->AsRootWindow()->window())->GetDisplayNearestWindow(
delegate_->AsRootWindow()->window()).device_scale_factor();
@@ -666,7 +665,7 @@ void RootWindowHostX11::SetBounds(const gfx::Rect& bounds) {
if (origin_changed)
delegate_->OnHostMoved(bounds.origin());
if (size_changed || current_scale != new_scale) {
- NotifyHostResized(bounds.size());
+ delegate_->OnHostResized(bounds.size());
} else {
delegate_->AsRootWindow()->window()->SchedulePaintInRect(
delegate_->AsRootWindow()->window()->bounds());
@@ -1021,7 +1020,7 @@ void RootWindowHostX11::TranslateAndDispatchMouseEvent(
// host window, then convert it back to this host window's coordinate.
screen_position_client->ConvertHostPointToScreen(root_window, &location);
screen_position_client->ConvertPointFromScreen(root_window, &location);
- ConvertPointToHost(&location);
+ root_window->GetDispatcher()->ConvertPointToHost(&location);
event->set_location(location);
event->set_root_location(location);
}
diff --git a/ui/aura/root_window_host_x11_unittest.cc b/ui/aura/root_window_host_x11_unittest.cc
index bdf1104..1552d49 100644
--- a/ui/aura/root_window_host_x11_unittest.cc
+++ b/ui/aura/root_window_host_x11_unittest.cc
@@ -50,9 +50,15 @@ class TestRootWindowHostDelegate : public aura::RootWindowHostDelegate {
// window move on our behalf, but we should still paint as if we're active.
virtual void OnHostLostMouseGrab() OVERRIDE {}
+ virtual void OnHostPaint(const gfx::Rect& damage_rect) OVERRIDE {}
+
virtual void OnHostMoved(const gfx::Point& origin) OVERRIDE {}
virtual void OnHostResized(const gfx::Size& size) OVERRIDE {}
+ virtual float GetDeviceScaleFactor() OVERRIDE {
+ return 1.0f;
+ }
+
virtual aura::RootWindow* AsRootWindow() OVERRIDE {
return NULL;
}
diff --git a/ui/aura/test/event_generator.cc b/ui/aura/test/event_generator.cc
index ada197c..f11ab21 100644
--- a/ui/aura/test/event_generator.cc
+++ b/ui/aura/test/event_generator.cc
@@ -9,7 +9,6 @@
#include "base/message_loop/message_loop_proxy.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/root_window.h"
-#include "ui/aura/window_tree_host.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
#include "ui/gfx/vector2d_conversions.h"
@@ -162,7 +161,7 @@ void EventGenerator::MoveMouseToInHost(const gfx::Point& point_in_host) {
Dispatch(&mouseev);
current_location_ = point_in_host;
- current_root_window_->host()->ConvertPointFromHost(&current_location_);
+ current_root_window_->ConvertPointFromHost(&current_location_);
}
void EventGenerator::MoveMouseTo(const gfx::Point& point_in_screen,
diff --git a/ui/aura/test/test_screen.cc b/ui/aura/test/test_screen.cc
index 225e56e..54f36ec 100644
--- a/ui/aura/test/test_screen.cc
+++ b/ui/aura/test/test_screen.cc
@@ -41,14 +41,13 @@ RootWindow* TestScreen::CreateRootWindowForPrimaryDisplay() {
void TestScreen::SetDeviceScaleFactor(float device_scale_factor) {
gfx::Rect bounds_in_pixel(display_.GetSizeInPixel());
display_.SetScaleAndBounds(device_scale_factor, bounds_in_pixel);
- root_window_->host()->NotifyHostResized(bounds_in_pixel.size());
+ root_window_->OnHostResized(bounds_in_pixel.size());
}
void TestScreen::SetDisplayRotation(gfx::Display::Rotation rotation) {
display_.set_rotation(rotation);
// TODO(oshima|mukai): Update the display_ as well.
- root_window_->host()->SetTransform(
- GetRotationTransform() * GetUIScaleTransform());
+ root_window_->SetTransform(GetRotationTransform() * GetUIScaleTransform());
}
void TestScreen::SetUIScale(float ui_scale) {
@@ -57,8 +56,7 @@ void TestScreen::SetUIScale(float ui_scale) {
gfx::Rect new_bounds = gfx::ToNearestRect(
gfx::ScaleRect(bounds_in_pixel, 1.0f / ui_scale));
display_.SetScaleAndBounds(display_.device_scale_factor(), new_bounds);
- root_window_->host()->SetTransform(
- GetRotationTransform() * GetUIScaleTransform());
+ root_window_->SetTransform(GetRotationTransform() * GetUIScaleTransform());
}
gfx::Transform TestScreen::GetRotationTransform() const {
diff --git a/ui/aura/window_tree_host.cc b/ui/aura/window_tree_host.cc
index 2702f2f..1bee923 100644
--- a/ui/aura/window_tree_host.cc
+++ b/ui/aura/window_tree_host.cc
@@ -4,141 +4,20 @@
#include "ui/aura/window_tree_host.h"
-#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
-#include "ui/aura/root_window_transformer.h"
-#include "ui/aura/window.h"
#include "ui/aura/window_tree_host_delegate.h"
-#include "ui/compositor/dip_util.h"
-#include "ui/compositor/layer.h"
-#include "ui/gfx/display.h"
-#include "ui/gfx/insets.h"
#include "ui/gfx/point.h"
-#include "ui/gfx/point3_f.h"
-#include "ui/gfx/point_conversions.h"
-#include "ui/gfx/screen.h"
-#include "ui/gfx/size_conversions.h"
namespace aura {
-float GetDeviceScaleFactorFromDisplay(Window* window) {
- gfx::Display display = gfx::Screen::GetScreenFor(window)->
- GetDisplayNearestWindow(window);
- DCHECK(display.is_valid());
- return display.device_scale_factor();
-}
-
-class SimpleRootWindowTransformer : public RootWindowTransformer {
- public:
- SimpleRootWindowTransformer(const Window* root_window,
- const gfx::Transform& transform)
- : root_window_(root_window),
- transform_(transform) {
- }
-
- // RootWindowTransformer overrides:
- virtual gfx::Transform GetTransform() const OVERRIDE {
- return transform_;
- }
-
- virtual gfx::Transform GetInverseTransform() const OVERRIDE {
- gfx::Transform invert;
- if (!transform_.GetInverse(&invert))
- return transform_;
- return invert;
- }
-
- virtual gfx::Rect GetRootWindowBounds(
- const gfx::Size& host_size) const OVERRIDE {
- gfx::Rect bounds(host_size);
- gfx::RectF new_bounds(ui::ConvertRectToDIP(root_window_->layer(), bounds));
- transform_.TransformRect(&new_bounds);
- return gfx::Rect(gfx::ToFlooredSize(new_bounds.size()));
- }
-
- virtual gfx::Insets GetHostInsets() const OVERRIDE {
- return gfx::Insets();
- }
-
- private:
- virtual ~SimpleRootWindowTransformer() {}
-
- const Window* root_window_;
- const gfx::Transform transform_;
-
- DISALLOW_COPY_AND_ASSIGN(SimpleRootWindowTransformer);
-};
-
////////////////////////////////////////////////////////////////////////////////
// RootWindowHost, public:
RootWindowHost::~RootWindowHost() {
- // TODO(beng): this represents an ordering change. In the old code, the
- // compositor was reset before the window hierarchy was destroyed.
- // verify that this has no adverse effects.
- // Make sure to destroy the compositor before terminating so that state is
- // cleared and we don't hit asserts.
- compositor_.reset();
-}
-
-void RootWindowHost::InitHost() {
- compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()),
- GetBounds().size());
- window()->Init(ui::LAYER_NOT_DRAWN);
- compositor_->SetRootLayer(window()->layer());
- transformer_.reset(
- new SimpleRootWindowTransformer(window(), gfx::Transform()));
- UpdateRootWindowSize(GetBounds().size());
- Env::GetInstance()->NotifyRootWindowInitialized(delegate_->AsRootWindow());
- window()->Show();
-}
-
-aura::Window* RootWindowHost::window() {
- return const_cast<Window*>(const_cast<const RootWindowHost*>(this)->window());
-}
-
-const aura::Window* RootWindowHost::window() const {
- return delegate_->AsRootWindow()->window();
-}
-
-void RootWindowHost::SetRootWindowTransformer(
- scoped_ptr<RootWindowTransformer> transformer) {
- transformer_ = transformer.Pass();
- SetInsets(transformer_->GetHostInsets());
- window()->SetTransform(transformer_->GetTransform());
- // If the layer is not animating, then we need to update the root window
- // size immediately.
- if (!window()->layer()->GetAnimator()->is_animating())
- UpdateRootWindowSize(GetBounds().size());
-}
-
-gfx::Transform RootWindowHost::GetRootTransform() const {
- float scale = ui::GetDeviceScaleFactor(window()->layer());
- gfx::Transform transform;
- transform.Scale(scale, scale);
- transform *= transformer_->GetTransform();
- return transform;
-}
-
-void RootWindowHost::SetTransform(const gfx::Transform& transform) {
- scoped_ptr<RootWindowTransformer> transformer(
- new SimpleRootWindowTransformer(window(), transform));
- SetRootWindowTransformer(transformer.Pass());
-}
-
-gfx::Transform RootWindowHost::GetInverseRootTransform() const {
- float scale = ui::GetDeviceScaleFactor(window()->layer());
- gfx::Transform transform;
- transform.Scale(1.0f / scale, 1.0f / scale);
- return transformer_->GetInverseTransform() * transform;
-}
-
-void RootWindowHost::UpdateRootWindowSize(const gfx::Size& host_size) {
- window()->SetBounds(transformer_->GetRootWindowBounds(host_size));
}
void RootWindowHost::ConvertPointToNativeScreen(gfx::Point* point) const {
- ConvertPointToHost(point);
+ delegate_->AsRootWindow()->ConvertPointToHost(point);
gfx::Point location = GetLocationOnNativeScreen();
point->Offset(location.x(), location.y());
}
@@ -146,19 +25,7 @@ void RootWindowHost::ConvertPointToNativeScreen(gfx::Point* point) const {
void RootWindowHost::ConvertPointFromNativeScreen(gfx::Point* point) const {
gfx::Point location = GetLocationOnNativeScreen();
point->Offset(-location.x(), -location.y());
- ConvertPointFromHost(point);
-}
-
-void RootWindowHost::ConvertPointToHost(gfx::Point* point) const {
- gfx::Point3F point_3f(*point);
- GetRootTransform().TransformPoint(&point_3f);
- *point = gfx::ToFlooredPoint(point_3f.AsPointF());
-}
-
-void RootWindowHost::ConvertPointFromHost(gfx::Point* point) const {
- gfx::Point3F point_3f(*point);
- GetInverseRootTransform().TransformPoint(&point_3f);
- *point = gfx::ToFlooredPoint(point_3f.AsPointF());
+ delegate_->AsRootWindow()->ConvertPointFromHost(point);
}
////////////////////////////////////////////////////////////////////////////////
@@ -168,22 +35,5 @@ RootWindowHost::RootWindowHost()
: delegate_(NULL) {
}
-void RootWindowHost::CreateCompositor(
- gfx::AcceleratedWidget accelerated_widget) {
- compositor_.reset(new ui::Compositor(GetAcceleratedWidget()));
- DCHECK(compositor_.get());
-}
-
-void RootWindowHost::NotifyHostResized(const gfx::Size& new_size) {
- // The compositor should have the same size as the native root window host.
- // Get the latest scale from display because it might have been changed.
- compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()),
- new_size);
-
- // The layer, and the observers should be notified of the
- // transformed size of the root window.
- UpdateRootWindowSize(new_size);
- delegate_->OnHostResized(new_size);
-}
} // namespace aura
diff --git a/ui/aura/window_tree_host.h b/ui/aura/window_tree_host.h
index 8e1ddd0..5aaa65c 100644
--- a/ui/aura/window_tree_host.h
+++ b/ui/aura/window_tree_host.h
@@ -17,18 +17,12 @@ class Insets;
class Point;
class Rect;
class Size;
-class Transform;
-}
-
-namespace ui {
-class Compositor;
}
namespace aura {
class RootWindow;
class RootWindowHostDelegate;
-class RootWindowTransformer;
// RootWindowHost bridges between a native window and the embedded RootWindow.
// It provides the accelerated widget and maps events from the native os to
@@ -40,25 +34,6 @@ class AURA_EXPORT RootWindowHost {
// Creates a new RootWindowHost. The caller owns the returned value.
static RootWindowHost* Create(const gfx::Rect& bounds);
- void InitHost();
-
- // TODO(beng): these will become trivial accessors in a future CL.
- aura::Window* window();
- const aura::Window* window() const;
-
- ui::Compositor* compositor() { return compositor_.get(); }
-
- void SetRootWindowTransformer(scoped_ptr<RootWindowTransformer> transformer);
- gfx::Transform GetRootTransform() const;
-
- void SetTransform(const gfx::Transform& transform);
-
- gfx::Transform GetInverseRootTransform() const;
-
- // Updates the root window's size using |host_size|, current
- // transform and insets.
- void UpdateRootWindowSize(const gfx::Size& host_size);
-
// Returns the actual size of the screen.
// (gfx::Screen only reports on the virtual desktop exposed by Aura.)
static gfx::Size GetNativeScreenSize();
@@ -67,21 +42,6 @@ class AURA_EXPORT RootWindowHost {
delegate_ = delegate;
}
- // Converts |point| from the root window's coordinate system to native
- // screen's.
- void ConvertPointToNativeScreen(gfx::Point* point) const;
-
- // Converts |point| from native screen coordinate system to the root window's.
- void ConvertPointFromNativeScreen(gfx::Point* point) const;
-
- // Converts |point| from the root window's coordinate system to the
- // host window's.
- void ConvertPointToHost(gfx::Point* point) const;
-
- // Converts |point| from the host window's coordinate system to the
- // root window's.
- void ConvertPointFromHost(gfx::Point* point) const;
-
virtual RootWindow* GetRootWindow() = 0;
// Returns the accelerated widget.
@@ -105,6 +65,13 @@ class AURA_EXPORT RootWindowHost {
virtual gfx::Insets GetInsets() const = 0;
virtual void SetInsets(const gfx::Insets& insets) = 0;
+ // Converts |point| from the root window's coordinate system to native
+ // screen's.
+ void ConvertPointToNativeScreen(gfx::Point* point) const;
+
+ // Converts |point| from native screen coordinate system to the root window's.
+ void ConvertPointFromNativeScreen(gfx::Point* point) const;
+
// Sets the OS capture to the root window.
virtual void SetCapture() = 0;
@@ -146,24 +113,14 @@ class AURA_EXPORT RootWindowHost {
virtual void PrepareForShutdown() = 0;
protected:
- friend class TestScreen; // TODO(beng): see if we can remove/consolidate.
-
RootWindowHost();
- void CreateCompositor(gfx::AcceleratedWidget accelerated_widget);
-
// Returns the location of the RootWindow on native screen.
virtual gfx::Point GetLocationOnNativeScreen() const = 0;
- void NotifyHostResized(const gfx::Size& new_size);
-
RootWindowHostDelegate* delegate_;
private:
- scoped_ptr<ui::Compositor> compositor_;
-
- scoped_ptr<RootWindowTransformer> transformer_;
-
DISALLOW_COPY_AND_ASSIGN(RootWindowHost);
};
diff --git a/ui/aura/window_tree_host_delegate.h b/ui/aura/window_tree_host_delegate.h
index e99903b..fc40a1f 100644
--- a/ui/aura/window_tree_host_delegate.h
+++ b/ui/aura/window_tree_host_delegate.h
@@ -45,9 +45,13 @@ class AURA_EXPORT RootWindowHostDelegate {
// window move on our behalf, but we should still paint as if we're active.
virtual void OnHostLostMouseGrab() = 0;
+ virtual void OnHostPaint(const gfx::Rect& damage_rect) = 0;
+
virtual void OnHostMoved(const gfx::Point& origin) = 0;
virtual void OnHostResized(const gfx::Size& size) = 0;
+ virtual float GetDeviceScaleFactor() = 0;
+
virtual RootWindow* AsRootWindow() = 0;
virtual const RootWindow* AsRootWindow() const = 0;
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
index a891825..4ab7110 100644
--- a/ui/aura/window_unittest.cc
+++ b/ui/aura/window_unittest.cc
@@ -369,7 +369,7 @@ TEST_F(WindowTest, MoveCursorToWithTransformRootWindow) {
transform.Translate(100.0, 100.0);
transform.Rotate(90.0);
transform.Scale(2.0, 5.0);
- dispatcher()->host()->SetTransform(transform);
+ dispatcher()->SetTransform(transform);
dispatcher()->MoveCursorTo(gfx::Point(10, 10));
#if !defined(OS_WIN)
gfx::Point mouse_location;
@@ -450,7 +450,7 @@ TEST_F(WindowTest, MoveCursorToWithComplexTransform) {
transform.Translate(10.0, 20.0);
transform.Rotate(10.0);
transform.Scale(0.3f, 0.5f);
- dispatcher()->host()->SetTransform(root_transform);
+ dispatcher()->SetTransform(root_transform);
w1->SetTransform(transform);
w11->SetTransform(transform);
w111->SetTransform(transform);
@@ -1544,7 +1544,7 @@ TEST_F(WindowTest, Transform) {
gfx::Transform transform;
transform.Translate(size.height(), 0);
transform.Rotate(90.0);
- dispatcher()->host()->SetTransform(transform);
+ dispatcher()->SetTransform(transform);
// The size should be the transformed size.
gfx::Size transformed_size(size.height(), size.width());
@@ -1572,7 +1572,7 @@ TEST_F(WindowTest, TransformGesture) {
gfx::Transform transform;
transform.Translate(size.height(), 0.0);
transform.Rotate(90.0);
- dispatcher()->host()->SetTransform(transform);
+ dispatcher()->SetTransform(transform);
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(size.height() - 10, 10), 0, getTime());
diff --git a/ui/snapshot/snapshot_aura.cc b/ui/snapshot/snapshot_aura.cc
index 8f7baa0..1cebfe9 100644
--- a/ui/snapshot/snapshot_aura.cc
+++ b/ui/snapshot/snapshot_aura.cc
@@ -42,7 +42,7 @@ bool GrabWindowSnapshot(gfx::NativeWindow window,
window->GetBoundsInRootWindow().origin().OffsetFromOrigin());
aura::WindowEventDispatcher* dispatcher = window->GetDispatcher();
if (dispatcher)
- dispatcher->host()->GetRootTransform().TransformRect(&read_pixels_bounds);
+ dispatcher->GetRootTransform().TransformRect(&read_pixels_bounds);
gfx::Rect read_pixels_bounds_in_pixel =
gfx::ToEnclosingRect(read_pixels_bounds);
diff --git a/ui/snapshot/snapshot_aura_unittest.cc b/ui/snapshot/snapshot_aura_unittest.cc
index 16e58114..da46bcc 100644
--- a/ui/snapshot/snapshot_aura_unittest.cc
+++ b/ui/snapshot/snapshot_aura_unittest.cc
@@ -85,8 +85,8 @@ class SnapshotAuraTest : public testing::Test {
aura::TestScreen* test_screen() { return helper_->test_screen(); }
void WaitForDraw() {
- dispatcher()->host()->compositor()->ScheduleDraw();
- ui::DrawWaiterForTest::Wait(dispatcher()->host()->compositor());
+ dispatcher()->compositor()->ScheduleDraw();
+ ui::DrawWaiterForTest::Wait(dispatcher()->compositor());
}
void SetupTestWindow(const gfx::Rect& window_bounds) {
diff --git a/ui/views/widget/desktop_aura/desktop_cursor_loader_updater_auralinux.cc b/ui/views/widget/desktop_aura/desktop_cursor_loader_updater_auralinux.cc
index 71490cac..80d99d1 100644
--- a/ui/views/widget/desktop_aura/desktop_cursor_loader_updater_auralinux.cc
+++ b/ui/views/widget/desktop_aura/desktop_cursor_loader_updater_auralinux.cc
@@ -55,7 +55,7 @@ DesktopCursorLoaderUpdaterAuraLinux::~DesktopCursorLoaderUpdaterAuraLinux() {}
void DesktopCursorLoaderUpdaterAuraLinux::OnCreate(
aura::RootWindow* window,
ui::CursorLoader* loader) {
- LoadImageCursors(window->host()->compositor()->device_scale_factor(), loader);
+ LoadImageCursors(window->compositor()->device_scale_factor(), loader);
}
void DesktopCursorLoaderUpdaterAuraLinux::OnDisplayUpdated(
diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc
index b1969b3..40908c2 100644
--- a/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc
+++ b/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc
@@ -142,7 +142,6 @@ void DesktopRootWindowHostWin::Init(
gfx::Rect pixel_bounds = gfx::win::DIPToScreenRect(params.bounds);
message_handler_->Init(parent_hwnd, pixel_bounds);
- CreateCompositor(GetAcceleratedWidget());
rw_create_params->host = this;
}
@@ -786,7 +785,7 @@ void DesktopRootWindowHostWin::HandleVisibilityChanged(bool visible) {
void DesktopRootWindowHostWin::HandleClientSizeChanged(
const gfx::Size& new_size) {
if (delegate_)
- NotifyHostResized(new_size);
+ delegate_->OnHostResized(new_size);
}
void DesktopRootWindowHostWin::HandleFrameChanged() {
@@ -881,7 +880,7 @@ bool DesktopRootWindowHostWin::HandlePaintAccelerated(
}
void DesktopRootWindowHostWin::HandlePaint(gfx::Canvas* canvas) {
- compositor()->ScheduleRedrawRect(gfx::Rect());
+ delegate_->OnHostPaint(gfx::Rect());
}
bool DesktopRootWindowHostWin::HandleTooltipNotify(int w_param,
@@ -926,8 +925,7 @@ HWND DesktopRootWindowHostWin::GetHWND() const {
void DesktopRootWindowHostWin::SetWindowTransparency() {
bool transparent = ShouldUseNativeFrame() && !IsFullscreen();
- root_window_->host()->compositor()->SetHostHasTransparentBackground(
- transparent);
+ root_window_->compositor()->SetHostHasTransparentBackground(transparent);
root_window_->window()->SetTransparent(transparent);
content_window_->SetTransparent(transparent);
}
diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc
index f958123..2dd03d8 100644
--- a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc
@@ -779,9 +779,9 @@ void DesktopRootWindowHostX11::SetBounds(const gfx::Rect& bounds) {
if (origin_changed)
native_widget_delegate_->AsWidget()->OnNativeWidgetMove();
if (size_changed)
- NotifyHostResized(bounds.size());
+ delegate_->OnHostResized(bounds.size());
else
- compositor()->ScheduleRedrawRect(gfx::Rect(bounds.size()));
+ delegate_->OnHostPaint(gfx::Rect(bounds.size()));
}
gfx::Insets DesktopRootWindowHostX11::GetInsets() const {
@@ -1057,7 +1057,6 @@ void DesktopRootWindowHostX11::InitX11Window(
if (window_icon) {
SetWindowIcons(gfx::ImageSkia(), *window_icon);
}
- CreateCompositor(GetAcceleratedWidget());
}
bool DesktopRootWindowHostX11::IsWindowManagerPresent() {
@@ -1183,7 +1182,7 @@ bool DesktopRootWindowHostX11::Dispatch(const base::NativeEvent& event) {
case Expose: {
gfx::Rect damage_rect(xev->xexpose.x, xev->xexpose.y,
xev->xexpose.width, xev->xexpose.height);
- compositor()->ScheduleRedrawRect(damage_rect);
+ delegate_->OnHostPaint(damage_rect);
break;
}
case KeyPress: {
@@ -1260,7 +1259,7 @@ bool DesktopRootWindowHostX11::Dispatch(const base::NativeEvent& event) {
previous_bounds_ = bounds_;
bounds_ = bounds;
if (size_changed)
- NotifyHostResized(bounds.size());
+ delegate_->OnHostResized(bounds.size());
if (origin_changed)
delegate_->OnHostMoved(bounds_.origin());
ResetWindowRegion();