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

Side by Side Diff: ui/views/mus/native_widget_mus.cc

Issue 2196503003: Revert of services/ui: Revert CLs that broke Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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/views/mus/native_widget_mus.h ('k') | ui/views/mus/surface_binding.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 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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 aura::Window* aura_window_; 497 aura::Window* aura_window_;
500 ui::Window* mus_window_; 498 ui::Window* mus_window_;
501 499
502 DISALLOW_COPY_AND_ASSIGN(MusCaptureClient); 500 DISALLOW_COPY_AND_ASSIGN(MusCaptureClient);
503 }; 501 };
504 502
505 //////////////////////////////////////////////////////////////////////////////// 503 ////////////////////////////////////////////////////////////////////////////////
506 // NativeWidgetMus, public: 504 // NativeWidgetMus, public:
507 505
508 NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate, 506 NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate,
509 shell::Connector* connector,
510 ui::Window* window, 507 ui::Window* window,
511 ui::mojom::SurfaceType surface_type) 508 ui::mojom::SurfaceType surface_type)
512 : window_(window), 509 : window_(window),
513 last_cursor_(ui::mojom::Cursor::CURSOR_NULL), 510 last_cursor_(ui::mojom::Cursor::CURSOR_NULL),
514 native_widget_delegate_(delegate), 511 native_widget_delegate_(delegate),
515 surface_type_(surface_type), 512 surface_type_(surface_type),
516 show_state_before_fullscreen_(ui::mojom::ShowState::DEFAULT), 513 show_state_before_fullscreen_(ui::mojom::ShowState::DEFAULT),
517 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), 514 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
518 content_(new aura::Window(this)), 515 content_(new aura::Window(this)),
519 close_widget_factory_(this) { 516 close_widget_factory_(this) {
520 window_->set_input_event_handler(this); 517 window_->set_input_event_handler(this);
521 mus_window_observer_.reset(new MusWindowObserver(this)); 518 mus_window_observer_.reset(new MusWindowObserver(this));
522 519
523 // TODO(fsamuel): Figure out lifetime of |window_|. 520 // TODO(fsamuel): Figure out lifetime of |window_|.
524 aura::SetMusWindow(content_, window_); 521 aura::SetMusWindow(content_, window_);
525 window->SetLocalProperty(kNativeWidgetMusKey, this); 522 window->SetLocalProperty(kNativeWidgetMusKey, this);
526 523
527 // WindowTreeHost creates the compositor using the ContextFactory from 524 // WindowTreeHost creates the compositor using the ContextFactory from
528 // aura::Env. Install |context_factory_| there so that |context_factory_| is 525 // aura::Env. Install |context_factory_| there so that |context_factory_| is
529 // picked up. 526 // picked up.
530 ui::ContextFactory* default_context_factory = 527 ui::ContextFactory* default_context_factory =
531 aura::Env::GetInstance()->context_factory(); 528 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) { 529 if (!default_context_factory) {
537 context_factory_.reset( 530 context_factory_.reset(new SurfaceContextFactory(window_, surface_type_));
538 new SurfaceContextFactory(connector, window_, surface_type_));
539 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); 531 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 } 532 }
544 533
545 window_tree_host_.reset(new WindowTreeHostMus(this, window_)); 534 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); 535 aura::Env::GetInstance()->set_context_factory(default_context_factory);
556 } 536 }
557 537
558 NativeWidgetMus::~NativeWidgetMus() { 538 NativeWidgetMus::~NativeWidgetMus() {
559 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) { 539 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) {
560 DCHECK(!window_); 540 DCHECK(!window_);
561 delete native_widget_delegate_; 541 delete native_widget_delegate_;
562 } else { 542 } else {
563 if (window_) 543 if (window_)
564 window_->set_input_event_handler(nullptr); 544 window_->set_input_event_handler(nullptr);
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
1437 1417
1438 gfx::Path mask_path; 1418 gfx::Path mask_path;
1439 native_widget_delegate_->GetHitTestMask(&mask_path); 1419 native_widget_delegate_->GetHitTestMask(&mask_path);
1440 // TODO(jamescook): Use the full path for the mask. 1420 // TODO(jamescook): Use the full path for the mask.
1441 gfx::Rect mask_rect = 1421 gfx::Rect mask_rect =
1442 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); 1422 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds()));
1443 window_->SetHitTestMask(mask_rect); 1423 window_->SetHitTestMask(mask_rect);
1444 } 1424 }
1445 1425
1446 } // namespace views 1426 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/native_widget_mus.h ('k') | ui/views/mus/surface_binding.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698