| 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" |
| 13 #include "services/ui/public/cpp/property_type_converters.h" | 14 #include "services/ui/public/cpp/property_type_converters.h" |
| 14 #include "services/ui/public/cpp/window.h" | 15 #include "services/ui/public/cpp/window.h" |
| 15 #include "services/ui/public/cpp/window_observer.h" | 16 #include "services/ui/public/cpp/window_observer.h" |
| 16 #include "services/ui/public/cpp/window_property.h" | 17 #include "services/ui/public/cpp/window_property.h" |
| 17 #include "services/ui/public/cpp/window_tree_client.h" | 18 #include "services/ui/public/cpp/window_tree_client.h" |
| 18 #include "services/ui/public/interfaces/cursor.mojom.h" | 19 #include "services/ui/public/interfaces/cursor.mojom.h" |
| 19 #include "services/ui/public/interfaces/window_manager.mojom.h" | 20 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| 20 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" | 21 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" |
| 21 #include "services/ui/public/interfaces/window_tree.mojom.h" | 22 #include "services/ui/public/interfaces/window_tree.mojom.h" |
| 22 #include "ui/aura/client/default_capture_client.h" | 23 #include "ui/aura/client/default_capture_client.h" |
| 23 #include "ui/aura/client/window_tree_client.h" | 24 #include "ui/aura/client/window_tree_client.h" |
| 24 #include "ui/aura/env.h" | 25 #include "ui/aura/env.h" |
| 25 #include "ui/aura/layout_manager.h" | 26 #include "ui/aura/layout_manager.h" |
| 26 #include "ui/aura/mus/mus_util.h" | 27 #include "ui/aura/mus/mus_util.h" |
| 27 #include "ui/aura/window.h" | 28 #include "ui/aura/window.h" |
| 28 #include "ui/aura/window_property.h" | 29 #include "ui/aura/window_property.h" |
| 29 #include "ui/base/hit_test.h" | 30 #include "ui/base/hit_test.h" |
| 31 #include "ui/base/view_prop.h" |
| 30 #include "ui/display/display.h" | 32 #include "ui/display/display.h" |
| 31 #include "ui/display/screen.h" | 33 #include "ui/display/screen.h" |
| 32 #include "ui/events/event.h" | 34 #include "ui/events/event.h" |
| 33 #include "ui/gfx/canvas.h" | 35 #include "ui/gfx/canvas.h" |
| 34 #include "ui/gfx/path.h" | 36 #include "ui/gfx/path.h" |
| 35 #include "ui/native_theme/native_theme_aura.h" | 37 #include "ui/native_theme/native_theme_aura.h" |
| 36 #include "ui/platform_window/platform_window_delegate.h" | 38 #include "ui/platform_window/platform_window_delegate.h" |
| 37 #include "ui/views/mus/surface_context_factory.h" | 39 #include "ui/views/mus/surface_context_factory.h" |
| 38 #include "ui/views/mus/window_manager_constants_converters.h" | 40 #include "ui/views/mus/window_manager_constants_converters.h" |
| 39 #include "ui/views/mus/window_manager_frame_values.h" | 41 #include "ui/views/mus/window_manager_frame_values.h" |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 aura::Window* aura_window_; | 499 aura::Window* aura_window_; |
| 498 ui::Window* mus_window_; | 500 ui::Window* mus_window_; |
| 499 | 501 |
| 500 DISALLOW_COPY_AND_ASSIGN(MusCaptureClient); | 502 DISALLOW_COPY_AND_ASSIGN(MusCaptureClient); |
| 501 }; | 503 }; |
| 502 | 504 |
| 503 //////////////////////////////////////////////////////////////////////////////// | 505 //////////////////////////////////////////////////////////////////////////////// |
| 504 // NativeWidgetMus, public: | 506 // NativeWidgetMus, public: |
| 505 | 507 |
| 506 NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate, | 508 NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate, |
| 509 shell::Connector* connector, |
| 507 ui::Window* window, | 510 ui::Window* window, |
| 508 ui::mojom::SurfaceType surface_type) | 511 ui::mojom::SurfaceType surface_type) |
| 509 : window_(window), | 512 : window_(window), |
| 510 last_cursor_(ui::mojom::Cursor::CURSOR_NULL), | 513 last_cursor_(ui::mojom::Cursor::CURSOR_NULL), |
| 511 native_widget_delegate_(delegate), | 514 native_widget_delegate_(delegate), |
| 512 surface_type_(surface_type), | 515 surface_type_(surface_type), |
| 513 show_state_before_fullscreen_(ui::mojom::ShowState::DEFAULT), | 516 show_state_before_fullscreen_(ui::mojom::ShowState::DEFAULT), |
| 514 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 517 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
| 515 content_(new aura::Window(this)), | 518 content_(new aura::Window(this)), |
| 516 close_widget_factory_(this) { | 519 close_widget_factory_(this) { |
| 517 window_->set_input_event_handler(this); | 520 window_->set_input_event_handler(this); |
| 518 mus_window_observer_.reset(new MusWindowObserver(this)); | 521 mus_window_observer_.reset(new MusWindowObserver(this)); |
| 519 | 522 |
| 520 // TODO(fsamuel): Figure out lifetime of |window_|. | 523 // TODO(fsamuel): Figure out lifetime of |window_|. |
| 521 aura::SetMusWindow(content_, window_); | 524 aura::SetMusWindow(content_, window_); |
| 522 window->SetLocalProperty(kNativeWidgetMusKey, this); | 525 window->SetLocalProperty(kNativeWidgetMusKey, this); |
| 523 | 526 |
| 524 // WindowTreeHost creates the compositor using the ContextFactory from | 527 // WindowTreeHost creates the compositor using the ContextFactory from |
| 525 // aura::Env. Install |context_factory_| there so that |context_factory_| is | 528 // aura::Env. Install |context_factory_| there so that |context_factory_| is |
| 526 // picked up. | 529 // picked up. |
| 527 ui::ContextFactory* default_context_factory = | 530 ui::ContextFactory* default_context_factory = |
| 528 aura::Env::GetInstance()->context_factory(); | 531 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; |
| 529 if (!default_context_factory) { | 536 if (!default_context_factory) { |
| 530 context_factory_.reset(new SurfaceContextFactory(window_, surface_type_)); | 537 context_factory_.reset( |
| 538 new SurfaceContextFactory(connector, window_, surface_type_)); |
| 531 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); | 539 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; |
| 532 } | 543 } |
| 533 | 544 |
| 534 window_tree_host_.reset(new WindowTreeHostMus(this, window_)); | 545 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 |
| 535 aura::Env::GetInstance()->set_context_factory(default_context_factory); | 555 aura::Env::GetInstance()->set_context_factory(default_context_factory); |
| 536 } | 556 } |
| 537 | 557 |
| 538 NativeWidgetMus::~NativeWidgetMus() { | 558 NativeWidgetMus::~NativeWidgetMus() { |
| 539 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) { | 559 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) { |
| 540 DCHECK(!window_); | 560 DCHECK(!window_); |
| 541 delete native_widget_delegate_; | 561 delete native_widget_delegate_; |
| 542 } else { | 562 } else { |
| 543 if (window_) | 563 if (window_) |
| 544 window_->set_input_event_handler(nullptr); | 564 window_->set_input_event_handler(nullptr); |
| (...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1417 | 1437 |
| 1418 gfx::Path mask_path; | 1438 gfx::Path mask_path; |
| 1419 native_widget_delegate_->GetHitTestMask(&mask_path); | 1439 native_widget_delegate_->GetHitTestMask(&mask_path); |
| 1420 // TODO(jamescook): Use the full path for the mask. | 1440 // TODO(jamescook): Use the full path for the mask. |
| 1421 gfx::Rect mask_rect = | 1441 gfx::Rect mask_rect = |
| 1422 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); | 1442 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); |
| 1423 window_->SetHitTestMask(mask_rect); | 1443 window_->SetHitTestMask(mask_rect); |
| 1424 } | 1444 } |
| 1425 | 1445 |
| 1426 } // namespace views | 1446 } // namespace views |
| OLD | NEW |