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

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

Issue 126513004: Rename RootWindowHost to WindowTreeHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 11 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
« no previous file with comments | « ui/aura/window_tree_host.h ('k') | ui/aura/window_tree_host_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/window_tree_host.h" 5 #include "ui/aura/window_tree_host.h"
6 6
7 #include "ui/aura/env.h" 7 #include "ui/aura/env.h"
8 #include "ui/aura/root_window.h" 8 #include "ui/aura/root_window.h"
9 #include "ui/aura/root_window_transformer.h" 9 #include "ui/aura/root_window_transformer.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 private: 63 private:
64 virtual ~SimpleRootWindowTransformer() {} 64 virtual ~SimpleRootWindowTransformer() {}
65 65
66 const Window* root_window_; 66 const Window* root_window_;
67 const gfx::Transform transform_; 67 const gfx::Transform transform_;
68 68
69 DISALLOW_COPY_AND_ASSIGN(SimpleRootWindowTransformer); 69 DISALLOW_COPY_AND_ASSIGN(SimpleRootWindowTransformer);
70 }; 70 };
71 71
72 //////////////////////////////////////////////////////////////////////////////// 72 ////////////////////////////////////////////////////////////////////////////////
73 // RootWindowHost, public: 73 // WindowTreeHost, public:
74 74
75 RootWindowHost::~RootWindowHost() { 75 WindowTreeHost::~WindowTreeHost() {
76 // TODO(beng): this represents an ordering change. In the old code, the 76 // TODO(beng): this represents an ordering change. In the old code, the
77 // compositor was reset before the window hierarchy was destroyed. 77 // compositor was reset before the window hierarchy was destroyed.
78 // verify that this has no adverse effects. 78 // verify that this has no adverse effects.
79 // Make sure to destroy the compositor before terminating so that state is 79 // Make sure to destroy the compositor before terminating so that state is
80 // cleared and we don't hit asserts. 80 // cleared and we don't hit asserts.
81 compositor_.reset(); 81 compositor_.reset();
82 } 82 }
83 83
84 void RootWindowHost::InitHost() { 84 void WindowTreeHost::InitHost() {
85 window()->Init(ui::LAYER_NOT_DRAWN); 85 window()->Init(ui::LAYER_NOT_DRAWN);
86 InitCompositor(); 86 InitCompositor();
87 UpdateRootWindowSize(GetBounds().size()); 87 UpdateRootWindowSize(GetBounds().size());
88 Env::GetInstance()->NotifyRootWindowInitialized(delegate_->AsRootWindow()); 88 Env::GetInstance()->NotifyRootWindowInitialized(delegate_->AsRootWindow());
89 window()->Show(); 89 window()->Show();
90 } 90 }
91 91
92 void RootWindowHost::InitCompositor() { 92 void WindowTreeHost::InitCompositor() {
93 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()), 93 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()),
94 GetBounds().size()); 94 GetBounds().size());
95 compositor_->SetRootLayer(window()->layer()); 95 compositor_->SetRootLayer(window()->layer());
96 transformer_.reset( 96 transformer_.reset(
97 new SimpleRootWindowTransformer(window(), gfx::Transform())); 97 new SimpleRootWindowTransformer(window(), gfx::Transform()));
98 } 98 }
99 99
100 aura::Window* RootWindowHost::window() { 100 aura::Window* WindowTreeHost::window() {
101 return const_cast<Window*>(const_cast<const RootWindowHost*>(this)->window()); 101 return const_cast<Window*>(const_cast<const WindowTreeHost*>(this)->window());
102 } 102 }
103 103
104 const aura::Window* RootWindowHost::window() const { 104 const aura::Window* WindowTreeHost::window() const {
105 return delegate_->AsRootWindow()->window(); 105 return delegate_->AsRootWindow()->window();
106 } 106 }
107 107
108 void RootWindowHost::SetRootWindowTransformer( 108 void WindowTreeHost::SetRootWindowTransformer(
109 scoped_ptr<RootWindowTransformer> transformer) { 109 scoped_ptr<RootWindowTransformer> transformer) {
110 transformer_ = transformer.Pass(); 110 transformer_ = transformer.Pass();
111 SetInsets(transformer_->GetHostInsets()); 111 SetInsets(transformer_->GetHostInsets());
112 window()->SetTransform(transformer_->GetTransform()); 112 window()->SetTransform(transformer_->GetTransform());
113 // If the layer is not animating, then we need to update the root window 113 // If the layer is not animating, then we need to update the root window
114 // size immediately. 114 // size immediately.
115 if (!window()->layer()->GetAnimator()->is_animating()) 115 if (!window()->layer()->GetAnimator()->is_animating())
116 UpdateRootWindowSize(GetBounds().size()); 116 UpdateRootWindowSize(GetBounds().size());
117 } 117 }
118 118
119 gfx::Transform RootWindowHost::GetRootTransform() const { 119 gfx::Transform WindowTreeHost::GetRootTransform() const {
120 float scale = ui::GetDeviceScaleFactor(window()->layer()); 120 float scale = ui::GetDeviceScaleFactor(window()->layer());
121 gfx::Transform transform; 121 gfx::Transform transform;
122 transform.Scale(scale, scale); 122 transform.Scale(scale, scale);
123 transform *= transformer_->GetTransform(); 123 transform *= transformer_->GetTransform();
124 return transform; 124 return transform;
125 } 125 }
126 126
127 void RootWindowHost::SetTransform(const gfx::Transform& transform) { 127 void WindowTreeHost::SetTransform(const gfx::Transform& transform) {
128 scoped_ptr<RootWindowTransformer> transformer( 128 scoped_ptr<RootWindowTransformer> transformer(
129 new SimpleRootWindowTransformer(window(), transform)); 129 new SimpleRootWindowTransformer(window(), transform));
130 SetRootWindowTransformer(transformer.Pass()); 130 SetRootWindowTransformer(transformer.Pass());
131 } 131 }
132 132
133 gfx::Transform RootWindowHost::GetInverseRootTransform() const { 133 gfx::Transform WindowTreeHost::GetInverseRootTransform() const {
134 float scale = ui::GetDeviceScaleFactor(window()->layer()); 134 float scale = ui::GetDeviceScaleFactor(window()->layer());
135 gfx::Transform transform; 135 gfx::Transform transform;
136 transform.Scale(1.0f / scale, 1.0f / scale); 136 transform.Scale(1.0f / scale, 1.0f / scale);
137 return transformer_->GetInverseTransform() * transform; 137 return transformer_->GetInverseTransform() * transform;
138 } 138 }
139 139
140 void RootWindowHost::UpdateRootWindowSize(const gfx::Size& host_size) { 140 void WindowTreeHost::UpdateRootWindowSize(const gfx::Size& host_size) {
141 window()->SetBounds(transformer_->GetRootWindowBounds(host_size)); 141 window()->SetBounds(transformer_->GetRootWindowBounds(host_size));
142 } 142 }
143 143
144 void RootWindowHost::ConvertPointToNativeScreen(gfx::Point* point) const { 144 void WindowTreeHost::ConvertPointToNativeScreen(gfx::Point* point) const {
145 ConvertPointToHost(point); 145 ConvertPointToHost(point);
146 gfx::Point location = GetLocationOnNativeScreen(); 146 gfx::Point location = GetLocationOnNativeScreen();
147 point->Offset(location.x(), location.y()); 147 point->Offset(location.x(), location.y());
148 } 148 }
149 149
150 void RootWindowHost::ConvertPointFromNativeScreen(gfx::Point* point) const { 150 void WindowTreeHost::ConvertPointFromNativeScreen(gfx::Point* point) const {
151 gfx::Point location = GetLocationOnNativeScreen(); 151 gfx::Point location = GetLocationOnNativeScreen();
152 point->Offset(-location.x(), -location.y()); 152 point->Offset(-location.x(), -location.y());
153 ConvertPointFromHost(point); 153 ConvertPointFromHost(point);
154 } 154 }
155 155
156 void RootWindowHost::ConvertPointToHost(gfx::Point* point) const { 156 void WindowTreeHost::ConvertPointToHost(gfx::Point* point) const {
157 gfx::Point3F point_3f(*point); 157 gfx::Point3F point_3f(*point);
158 GetRootTransform().TransformPoint(&point_3f); 158 GetRootTransform().TransformPoint(&point_3f);
159 *point = gfx::ToFlooredPoint(point_3f.AsPointF()); 159 *point = gfx::ToFlooredPoint(point_3f.AsPointF());
160 } 160 }
161 161
162 void RootWindowHost::ConvertPointFromHost(gfx::Point* point) const { 162 void WindowTreeHost::ConvertPointFromHost(gfx::Point* point) const {
163 gfx::Point3F point_3f(*point); 163 gfx::Point3F point_3f(*point);
164 GetInverseRootTransform().TransformPoint(&point_3f); 164 GetInverseRootTransform().TransformPoint(&point_3f);
165 *point = gfx::ToFlooredPoint(point_3f.AsPointF()); 165 *point = gfx::ToFlooredPoint(point_3f.AsPointF());
166 } 166 }
167 167
168 //////////////////////////////////////////////////////////////////////////////// 168 ////////////////////////////////////////////////////////////////////////////////
169 // RootWindowHost, protected: 169 // WindowTreeHost, protected:
170 170
171 RootWindowHost::RootWindowHost() 171 WindowTreeHost::WindowTreeHost()
172 : delegate_(NULL) { 172 : delegate_(NULL) {
173 } 173 }
174 174
175 void RootWindowHost::CreateCompositor( 175 void WindowTreeHost::CreateCompositor(
176 gfx::AcceleratedWidget accelerated_widget) { 176 gfx::AcceleratedWidget accelerated_widget) {
177 compositor_.reset(new ui::Compositor(GetAcceleratedWidget())); 177 compositor_.reset(new ui::Compositor(GetAcceleratedWidget()));
178 DCHECK(compositor_.get()); 178 DCHECK(compositor_.get());
179 } 179 }
180 180
181 void RootWindowHost::NotifyHostResized(const gfx::Size& new_size) { 181 void WindowTreeHost::NotifyHostResized(const gfx::Size& new_size) {
182 // The compositor should have the same size as the native root window host. 182 // The compositor should have the same size as the native root window host.
183 // Get the latest scale from display because it might have been changed. 183 // Get the latest scale from display because it might have been changed.
184 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()), 184 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()),
185 new_size); 185 new_size);
186 186
187 // The layer, and the observers should be notified of the 187 // The layer, and the observers should be notified of the
188 // transformed size of the root window. 188 // transformed size of the root window.
189 UpdateRootWindowSize(new_size); 189 UpdateRootWindowSize(new_size);
190 delegate_->OnHostResized(new_size); 190 delegate_->OnHostResized(new_size);
191 } 191 }
192 192
193 } // namespace aura 193 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window_tree_host.h ('k') | ui/aura/window_tree_host_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698