OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/mus/native_widget_mus.h" | 5 #include "ui/views/mus/native_widget_mus.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
12 #include "services/ui/common/gpu_service.h" | 12 #include "services/ui/common/gpu_service.h" |
13 #include "services/ui/public/cpp/bitmap_uploader.h" | |
14 #include "services/ui/public/cpp/property_type_converters.h" | 13 #include "services/ui/public/cpp/property_type_converters.h" |
15 #include "services/ui/public/cpp/window.h" | 14 #include "services/ui/public/cpp/window.h" |
16 #include "services/ui/public/cpp/window_observer.h" | 15 #include "services/ui/public/cpp/window_observer.h" |
17 #include "services/ui/public/cpp/window_property.h" | 16 #include "services/ui/public/cpp/window_property.h" |
18 #include "services/ui/public/cpp/window_tree_client.h" | 17 #include "services/ui/public/cpp/window_tree_client.h" |
19 #include "services/ui/public/interfaces/cursor.mojom.h" | 18 #include "services/ui/public/interfaces/cursor.mojom.h" |
20 #include "services/ui/public/interfaces/window_manager.mojom.h" | 19 #include "services/ui/public/interfaces/window_manager.mojom.h" |
21 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" | 20 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" |
22 #include "services/ui/public/interfaces/window_tree.mojom.h" | 21 #include "services/ui/public/interfaces/window_tree.mojom.h" |
23 #include "ui/aura/client/default_capture_client.h" | 22 #include "ui/aura/client/default_capture_client.h" |
24 #include "ui/aura/client/window_tree_client.h" | 23 #include "ui/aura/client/window_tree_client.h" |
25 #include "ui/aura/env.h" | 24 #include "ui/aura/env.h" |
26 #include "ui/aura/layout_manager.h" | 25 #include "ui/aura/layout_manager.h" |
27 #include "ui/aura/mus/mus_util.h" | 26 #include "ui/aura/mus/mus_util.h" |
28 #include "ui/aura/window.h" | 27 #include "ui/aura/window.h" |
29 #include "ui/aura/window_property.h" | 28 #include "ui/aura/window_property.h" |
30 #include "ui/base/hit_test.h" | 29 #include "ui/base/hit_test.h" |
31 #include "ui/base/view_prop.h" | |
32 #include "ui/display/display.h" | 30 #include "ui/display/display.h" |
33 #include "ui/display/screen.h" | 31 #include "ui/display/screen.h" |
34 #include "ui/events/event.h" | 32 #include "ui/events/event.h" |
35 #include "ui/gfx/canvas.h" | 33 #include "ui/gfx/canvas.h" |
36 #include "ui/gfx/path.h" | 34 #include "ui/gfx/path.h" |
37 #include "ui/native_theme/native_theme_aura.h" | 35 #include "ui/native_theme/native_theme_aura.h" |
38 #include "ui/platform_window/platform_window_delegate.h" | 36 #include "ui/platform_window/platform_window_delegate.h" |
39 #include "ui/views/mus/surface_context_factory.h" | 37 #include "ui/views/mus/surface_context_factory.h" |
40 #include "ui/views/mus/window_manager_constants_converters.h" | 38 #include "ui/views/mus/window_manager_constants_converters.h" |
41 #include "ui/views/mus/window_manager_frame_values.h" | 39 #include "ui/views/mus/window_manager_frame_values.h" |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 | 520 |
523 // TODO(fsamuel): Figure out lifetime of |window_|. | 521 // TODO(fsamuel): Figure out lifetime of |window_|. |
524 aura::SetMusWindow(content_, window_); | 522 aura::SetMusWindow(content_, window_); |
525 window->SetLocalProperty(kNativeWidgetMusKey, this); | 523 window->SetLocalProperty(kNativeWidgetMusKey, this); |
526 | 524 |
527 // WindowTreeHost creates the compositor using the ContextFactory from | 525 // WindowTreeHost creates the compositor using the ContextFactory from |
528 // aura::Env. Install |context_factory_| there so that |context_factory_| is | 526 // aura::Env. Install |context_factory_| there so that |context_factory_| is |
529 // picked up. | 527 // picked up. |
530 ui::ContextFactory* default_context_factory = | 528 ui::ContextFactory* default_context_factory = |
531 aura::Env::GetInstance()->context_factory(); | 529 aura::Env::GetInstance()->context_factory(); |
532 // For Chrome, we need the GpuProcessTransportFactory so that renderer and | |
533 // browser pixels are composited into a single backing SoftwareOutputDeviceMus | |
534 // (which also requires the BitmapUploader). | |
535 bool needs_bitmap_uploader = false; | |
536 if (!default_context_factory) { | 530 if (!default_context_factory) { |
537 context_factory_.reset( | 531 context_factory_.reset( |
538 new SurfaceContextFactory(connector, window_, surface_type_)); | 532 new SurfaceContextFactory(connector, window_, surface_type_)); |
539 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); | 533 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); |
540 } else if (!ui::GpuService::UseChromeGpuCommandBuffer()) { | |
541 // Only use the BitmapUploader when the mojo command buffer is being used. | |
542 needs_bitmap_uploader = true; | |
543 } | 534 } |
544 | 535 |
545 window_tree_host_.reset(new WindowTreeHostMus(this, window_)); | 536 window_tree_host_.reset(new WindowTreeHostMus(this, window_)); |
546 if (needs_bitmap_uploader) { | |
547 bitmap_uploader_.reset(new ui::BitmapUploader(window)); | |
548 bitmap_uploader_->Init(connector); | |
549 prop_ = base::MakeUnique<ui::ViewProp>( | |
550 window_tree_host_->GetAcceleratedWidget(), | |
551 ui::kBitmapUploaderForAcceleratedWidget, | |
552 bitmap_uploader_.get()); | |
553 } | |
554 | |
555 aura::Env::GetInstance()->set_context_factory(default_context_factory); | 537 aura::Env::GetInstance()->set_context_factory(default_context_factory); |
556 } | 538 } |
557 | 539 |
558 NativeWidgetMus::~NativeWidgetMus() { | 540 NativeWidgetMus::~NativeWidgetMus() { |
559 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) { | 541 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) { |
560 DCHECK(!window_); | 542 DCHECK(!window_); |
561 delete native_widget_delegate_; | 543 delete native_widget_delegate_; |
562 } else { | 544 } else { |
563 if (window_) | 545 if (window_) |
564 window_->set_input_event_handler(nullptr); | 546 window_->set_input_event_handler(nullptr); |
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 | 1419 |
1438 gfx::Path mask_path; | 1420 gfx::Path mask_path; |
1439 native_widget_delegate_->GetHitTestMask(&mask_path); | 1421 native_widget_delegate_->GetHitTestMask(&mask_path); |
1440 // TODO(jamescook): Use the full path for the mask. | 1422 // TODO(jamescook): Use the full path for the mask. |
1441 gfx::Rect mask_rect = | 1423 gfx::Rect mask_rect = |
1442 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); | 1424 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); |
1443 window_->SetHitTestMask(mask_rect); | 1425 window_->SetHitTestMask(mask_rect); |
1444 } | 1426 } |
1445 | 1427 |
1446 } // namespace views | 1428 } // namespace views |
OLD | NEW |