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

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

Issue 2950183002: color: Use ICCProfile from display::Display instead of FromBestMonitor (Closed)
Patch Set: Use forced color profile in display::Display ctor Created 3 years, 5 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
« no previous file with comments | « ui/aura/window_tree_host.h ('k') | ui/compositor/compositor.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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/threading/thread_task_runner_handle.h" 8 #include "base/threading/thread_task_runner_handle.h"
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "cc/base/switches.h" 10 #include "cc/base/switches.h"
(...skipping 19 matching lines...) Expand all
30 #include "ui/gfx/geometry/point_conversions.h" 30 #include "ui/gfx/geometry/point_conversions.h"
31 #include "ui/gfx/geometry/rect_conversions.h" 31 #include "ui/gfx/geometry/rect_conversions.h"
32 #include "ui/gfx/geometry/size_conversions.h" 32 #include "ui/gfx/geometry/size_conversions.h"
33 #include "ui/gfx/icc_profile.h" 33 #include "ui/gfx/icc_profile.h"
34 34
35 namespace aura { 35 namespace aura {
36 36
37 const char kWindowTreeHostForAcceleratedWidget[] = 37 const char kWindowTreeHostForAcceleratedWidget[] =
38 "__AURA_WINDOW_TREE_HOST_ACCELERATED_WIDGET__"; 38 "__AURA_WINDOW_TREE_HOST_ACCELERATED_WIDGET__";
39 39
40 float GetDeviceScaleFactorFromDisplay(Window* window) {
41 return ui::GetScaleFactorForNativeView(window);
42 }
43
44 //////////////////////////////////////////////////////////////////////////////// 40 ////////////////////////////////////////////////////////////////////////////////
45 // WindowTreeHost, public: 41 // WindowTreeHost, public:
46 42
47 WindowTreeHost::~WindowTreeHost() { 43 WindowTreeHost::~WindowTreeHost() {
48 DCHECK(!compositor_) << "compositor must be destroyed before root window"; 44 DCHECK(!compositor_) << "compositor must be destroyed before root window";
49 if (owned_input_method_) { 45 if (owned_input_method_) {
50 delete input_method_; 46 delete input_method_;
51 input_method_ = nullptr; 47 input_method_ = nullptr;
52 } 48 }
53 } 49 }
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 base::ThreadTaskRunnerHandle::Get(), enable_surface_synchronization)); 267 base::ThreadTaskRunnerHandle::Get(), enable_surface_synchronization));
272 if (!dispatcher()) { 268 if (!dispatcher()) {
273 window()->Init(ui::LAYER_NOT_DRAWN); 269 window()->Init(ui::LAYER_NOT_DRAWN);
274 window()->set_host(this); 270 window()->set_host(this);
275 window()->SetName("RootWindow"); 271 window()->SetName("RootWindow");
276 dispatcher_.reset(new WindowEventDispatcher(this)); 272 dispatcher_.reset(new WindowEventDispatcher(this));
277 } 273 }
278 } 274 }
279 275
280 void WindowTreeHost::InitCompositor() { 276 void WindowTreeHost::InitCompositor() {
281 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()), 277 display::Display display =
278 display::Screen::GetScreen()->GetDisplayNearestWindow(window());
279 compositor_->SetScaleAndSize(display.device_scale_factor(),
282 GetBoundsInPixels().size()); 280 GetBoundsInPixels().size());
283 compositor_->SetRootLayer(window()->layer()); 281 compositor_->SetRootLayer(window()->layer());
284 compositor_->SetDisplayColorProfile(GetICCProfileForCurrentDisplay()); 282 compositor_->SetDisplayColorSpace(display.color_space());
285 } 283 }
286 284
287 void WindowTreeHost::OnAcceleratedWidgetAvailable() { 285 void WindowTreeHost::OnAcceleratedWidgetAvailable() {
288 compositor_->SetAcceleratedWidget(GetAcceleratedWidget()); 286 compositor_->SetAcceleratedWidget(GetAcceleratedWidget());
289 prop_.reset(new ui::ViewProp(GetAcceleratedWidget(), 287 prop_.reset(new ui::ViewProp(GetAcceleratedWidget(),
290 kWindowTreeHostForAcceleratedWidget, this)); 288 kWindowTreeHostForAcceleratedWidget, this));
291 } 289 }
292 290
293 void WindowTreeHost::OnHostMovedInPixels( 291 void WindowTreeHost::OnHostMovedInPixels(
294 const gfx::Point& new_location_in_pixels) { 292 const gfx::Point& new_location_in_pixels) {
295 TRACE_EVENT1("ui", "WindowTreeHost::OnHostMovedInPixels", "origin", 293 TRACE_EVENT1("ui", "WindowTreeHost::OnHostMovedInPixels", "origin",
296 new_location_in_pixels.ToString()); 294 new_location_in_pixels.ToString());
297 295
298 for (WindowTreeHostObserver& observer : observers_) 296 for (WindowTreeHostObserver& observer : observers_)
299 observer.OnHostMovedInPixels(this, new_location_in_pixels); 297 observer.OnHostMovedInPixels(this, new_location_in_pixels);
300 } 298 }
301 299
302 void WindowTreeHost::OnHostResizedInPixels( 300 void WindowTreeHost::OnHostResizedInPixels(
303 const gfx::Size& new_size_in_pixels) { 301 const gfx::Size& new_size_in_pixels) {
304 gfx::Size adjusted_size(new_size_in_pixels); 302 gfx::Size adjusted_size(new_size_in_pixels);
305 adjusted_size.Enlarge(output_surface_padding_in_pixels_.width(), 303 adjusted_size.Enlarge(output_surface_padding_in_pixels_.width(),
306 output_surface_padding_in_pixels_.height()); 304 output_surface_padding_in_pixels_.height());
307 // The compositor should have the same size as the native root window host. 305 // The compositor should have the same size as the native root window host.
308 // Get the latest scale from display because it might have been changed. 306 // Get the latest scale from display because it might have been changed.
309 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()), 307 compositor_->SetScaleAndSize(ui::GetScaleFactorForNativeView(window()),
310 adjusted_size); 308 adjusted_size);
311 309
312 gfx::Size layer_size = GetBoundsInPixels().size(); 310 gfx::Size layer_size = GetBoundsInPixels().size();
313 // The layer, and the observers should be notified of the 311 // The layer, and the observers should be notified of the
314 // transformed size of the root window. 312 // transformed size of the root window.
315 UpdateRootWindowSizeInPixels(layer_size); 313 UpdateRootWindowSizeInPixels(layer_size);
316 for (WindowTreeHostObserver& observer : observers_) 314 for (WindowTreeHostObserver& observer : observers_)
317 observer.OnHostResized(this); 315 observer.OnHostResized(this);
318 } 316 }
319 317
(...skipping 10 matching lines...) Expand all
330 void WindowTreeHost::OnHostActivated() { 328 void WindowTreeHost::OnHostActivated() {
331 Env::GetInstance()->NotifyHostActivated(this); 329 Env::GetInstance()->NotifyHostActivated(this);
332 } 330 }
333 331
334 void WindowTreeHost::OnHostLostWindowCapture() { 332 void WindowTreeHost::OnHostLostWindowCapture() {
335 Window* capture_window = client::GetCaptureWindow(window()); 333 Window* capture_window = client::GetCaptureWindow(window());
336 if (capture_window && capture_window->GetRootWindow() == window()) 334 if (capture_window && capture_window->GetRootWindow() == window())
337 capture_window->ReleaseCapture(); 335 capture_window->ReleaseCapture();
338 } 336 }
339 337
340 gfx::ICCProfile WindowTreeHost::GetICCProfileForCurrentDisplay() {
341 // TODO(hubbe): Get the color space from the *current* monitor and
342 // update it when window is moved or color space configuration changes.
343 return gfx::ICCProfile::FromBestMonitor();
344 }
345
346 ui::EventSink* WindowTreeHost::GetEventSink() { 338 ui::EventSink* WindowTreeHost::GetEventSink() {
347 return dispatcher_.get(); 339 return dispatcher_.get();
348 } 340 }
349 341
350 //////////////////////////////////////////////////////////////////////////////// 342 ////////////////////////////////////////////////////////////////////////////////
351 // WindowTreeHost, private: 343 // WindowTreeHost, private:
352 344
353 void WindowTreeHost::MoveCursorToInternal(const gfx::Point& root_location, 345 void WindowTreeHost::MoveCursorToInternal(const gfx::Point& root_location,
354 const gfx::Point& host_location) { 346 const gfx::Point& host_location) {
355 last_cursor_request_position_in_host_ = host_location; 347 last_cursor_request_position_in_host_ = host_location;
356 MoveCursorToScreenLocationInPixels(host_location); 348 MoveCursorToScreenLocationInPixels(host_location);
357 client::CursorClient* cursor_client = client::GetCursorClient(window()); 349 client::CursorClient* cursor_client = client::GetCursorClient(window());
358 if (cursor_client) { 350 if (cursor_client) {
359 const display::Display& display = 351 const display::Display& display =
360 display::Screen::GetScreen()->GetDisplayNearestWindow(window()); 352 display::Screen::GetScreen()->GetDisplayNearestWindow(window());
361 cursor_client->SetDisplay(display); 353 cursor_client->SetDisplay(display);
362 } 354 }
363 dispatcher()->OnCursorMovedToRootLocation(root_location); 355 dispatcher()->OnCursorMovedToRootLocation(root_location);
364 } 356 }
365 357
366 } // namespace aura 358 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window_tree_host.h ('k') | ui/compositor/compositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698