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/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
11 #include "components/bitmap_uploader/bitmap_uploader.h" | 11 #include "components/bitmap_uploader/bitmap_uploader.h" |
| 12 #include "services/ui/common/gpu_service.h" |
12 #include "services/ui/public/cpp/property_type_converters.h" | 13 #include "services/ui/public/cpp/property_type_converters.h" |
13 #include "services/ui/public/cpp/window.h" | 14 #include "services/ui/public/cpp/window.h" |
14 #include "services/ui/public/cpp/window_observer.h" | 15 #include "services/ui/public/cpp/window_observer.h" |
15 #include "services/ui/public/cpp/window_property.h" | 16 #include "services/ui/public/cpp/window_property.h" |
16 #include "services/ui/public/cpp/window_tree_client.h" | 17 #include "services/ui/public/cpp/window_tree_client.h" |
17 #include "services/ui/public/interfaces/cursor.mojom.h" | 18 #include "services/ui/public/interfaces/cursor.mojom.h" |
18 #include "services/ui/public/interfaces/window_manager.mojom.h" | 19 #include "services/ui/public/interfaces/window_manager.mojom.h" |
19 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" | 20 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" |
20 #include "services/ui/public/interfaces/window_tree.mojom.h" | 21 #include "services/ui/public/interfaces/window_tree.mojom.h" |
21 #include "ui/aura/client/default_capture_client.h" | 22 #include "ui/aura/client/default_capture_client.h" |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 ui::ContextFactory* default_context_factory = | 522 ui::ContextFactory* default_context_factory = |
522 aura::Env::GetInstance()->context_factory(); | 523 aura::Env::GetInstance()->context_factory(); |
523 // For Chrome, we need the GpuProcessTransportFactory so that renderer and | 524 // For Chrome, we need the GpuProcessTransportFactory so that renderer and |
524 // browser pixels are composited into a single backing SoftwareOutputDeviceMus | 525 // browser pixels are composited into a single backing SoftwareOutputDeviceMus |
525 // (which also requires the BitmapUploader). | 526 // (which also requires the BitmapUploader). |
526 bool needs_bitmap_uploader = false; | 527 bool needs_bitmap_uploader = false; |
527 if (!default_context_factory) { | 528 if (!default_context_factory) { |
528 context_factory_.reset( | 529 context_factory_.reset( |
529 new SurfaceContextFactory(connector, window_, surface_type_)); | 530 new SurfaceContextFactory(connector, window_, surface_type_)); |
530 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); | 531 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); |
531 } else { | 532 } else if (!ui::GpuService::UseChromeGpuCommandBuffer()) { |
| 533 // Only use the BitmapUploader when the mojo command buffer is being used. |
532 needs_bitmap_uploader = true; | 534 needs_bitmap_uploader = true; |
533 } | 535 } |
534 | 536 |
535 window_tree_host_.reset(new WindowTreeHostMus(this, window_)); | 537 window_tree_host_.reset(new WindowTreeHostMus(this, window_)); |
536 if (needs_bitmap_uploader) { | 538 if (needs_bitmap_uploader) { |
537 bitmap_uploader_.reset(new bitmap_uploader::BitmapUploader(window)); | 539 bitmap_uploader_.reset(new bitmap_uploader::BitmapUploader(window)); |
538 bitmap_uploader_->Init(connector); | 540 bitmap_uploader_->Init(connector); |
539 prop_.reset( | 541 prop_ = base::MakeUnique<ui::ViewProp>( |
540 new ui::ViewProp(window_tree_host_->GetAcceleratedWidget(), | 542 window_tree_host_->GetAcceleratedWidget(), |
541 bitmap_uploader::kBitmapUploaderForAcceleratedWidget, | 543 bitmap_uploader::kBitmapUploaderForAcceleratedWidget, |
542 bitmap_uploader_.get())); | 544 bitmap_uploader_.get()); |
543 } | 545 } |
544 | 546 |
545 aura::Env::GetInstance()->set_context_factory(default_context_factory); | 547 aura::Env::GetInstance()->set_context_factory(default_context_factory); |
546 } | 548 } |
547 | 549 |
548 NativeWidgetMus::~NativeWidgetMus() { | 550 NativeWidgetMus::~NativeWidgetMus() { |
549 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) { | 551 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) { |
550 DCHECK(!window_); | 552 DCHECK(!window_); |
551 delete native_widget_delegate_; | 553 delete native_widget_delegate_; |
552 } else { | 554 } else { |
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 | 1403 |
1402 gfx::Path mask_path; | 1404 gfx::Path mask_path; |
1403 native_widget_delegate_->GetHitTestMask(&mask_path); | 1405 native_widget_delegate_->GetHitTestMask(&mask_path); |
1404 // TODO(jamescook): Use the full path for the mask. | 1406 // TODO(jamescook): Use the full path for the mask. |
1405 gfx::Rect mask_rect = | 1407 gfx::Rect mask_rect = |
1406 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); | 1408 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); |
1407 window_->SetHitTestMask(mask_rect); | 1409 window_->SetHitTestMask(mask_rect); |
1408 } | 1410 } |
1409 | 1411 |
1410 } // namespace views | 1412 } // namespace views |
OLD | NEW |