| 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/platform_window_mus.h" | 5 #include "ui/views/mus/platform_window_mus.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "components/bitmap_uploader/bitmap_uploader.h" | 8 #include "components/bitmap_uploader/bitmap_uploader.h" |
| 9 #include "components/mus/public/cpp/property_type_converters.h" | 9 #include "components/mus/public/cpp/property_type_converters.h" |
| 10 #include "components/mus/public/cpp/window_property.h" | 10 #include "components/mus/public/cpp/window_property.h" |
| 11 #include "components/mus/public/interfaces/window_manager.mojom.h" | 11 #include "components/mus/public/interfaces/window_manager.mojom.h" |
| 12 #include "mojo/converters/input_events/input_events_type_converters.h" | 12 #include "mojo/converters/input_events/input_events_type_converters.h" |
| 13 #include "ui/base/view_prop.h" | 13 #include "ui/base/view_prop.h" |
| 14 #include "ui/platform_window/platform_window_delegate.h" | 14 #include "ui/platform_window/platform_window_delegate.h" |
| 15 #include "ui/views/mus/window_manager_connection.h" | 15 #include "ui/views/mus/window_manager_connection.h" |
| 16 | 16 |
| 17 namespace views { | 17 namespace views { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 static uint32_t accelerated_widget_count = 1; | 20 static uint32_t accelerated_widget_count = 1; |
| 21 | 21 |
| 22 } // namespace | 22 } // namespace |
| 23 | 23 |
| 24 PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate, | 24 PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate, |
| 25 mojo::Shell* shell, | 25 mojo::Connector* connector, |
| 26 mus::Window* mus_window) | 26 mus::Window* mus_window) |
| 27 : delegate_(delegate), | 27 : delegate_(delegate), |
| 28 mus_window_(mus_window), | 28 mus_window_(mus_window), |
| 29 show_state_(mus::mojom::ShowState::RESTORED), | 29 show_state_(mus::mojom::ShowState::RESTORED), |
| 30 last_cursor_(mus::mojom::Cursor::CURSOR_NULL), | 30 last_cursor_(mus::mojom::Cursor::CURSOR_NULL), |
| 31 mus_window_destroyed_(false) { | 31 mus_window_destroyed_(false) { |
| 32 DCHECK(delegate_); | 32 DCHECK(delegate_); |
| 33 DCHECK(mus_window_); | 33 DCHECK(mus_window_); |
| 34 mus_window_->AddObserver(this); | 34 mus_window_->AddObserver(this); |
| 35 mus_window_->set_input_event_handler(this); | 35 mus_window_->set_input_event_handler(this); |
| 36 | 36 |
| 37 // We need accelerated widget numbers to be different for each | 37 // We need accelerated widget numbers to be different for each |
| 38 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t | 38 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t |
| 39 // has this property. | 39 // has this property. |
| 40 #if defined(OS_WIN) || defined(OS_ANDROID) | 40 #if defined(OS_WIN) || defined(OS_ANDROID) |
| 41 gfx::AcceleratedWidget accelerated_widget = | 41 gfx::AcceleratedWidget accelerated_widget = |
| 42 reinterpret_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); | 42 reinterpret_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); |
| 43 #else | 43 #else |
| 44 gfx::AcceleratedWidget accelerated_widget = | 44 gfx::AcceleratedWidget accelerated_widget = |
| 45 static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); | 45 static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); |
| 46 #endif | 46 #endif |
| 47 delegate_->OnAcceleratedWidgetAvailable( | 47 delegate_->OnAcceleratedWidgetAvailable( |
| 48 accelerated_widget, mus_window_->viewport_metrics().device_pixel_ratio); | 48 accelerated_widget, mus_window_->viewport_metrics().device_pixel_ratio); |
| 49 | 49 |
| 50 bitmap_uploader_.reset(new bitmap_uploader::BitmapUploader(mus_window_)); | 50 bitmap_uploader_.reset(new bitmap_uploader::BitmapUploader(mus_window_)); |
| 51 bitmap_uploader_->Init(shell); | 51 bitmap_uploader_->Init(connector); |
| 52 prop_.reset(new ui::ViewProp( | 52 prop_.reset(new ui::ViewProp( |
| 53 accelerated_widget, bitmap_uploader::kBitmapUploaderForAcceleratedWidget, | 53 accelerated_widget, bitmap_uploader::kBitmapUploaderForAcceleratedWidget, |
| 54 bitmap_uploader_.get())); | 54 bitmap_uploader_.get())); |
| 55 } | 55 } |
| 56 | 56 |
| 57 PlatformWindowMus::~PlatformWindowMus() { | 57 PlatformWindowMus::~PlatformWindowMus() { |
| 58 if (!mus_window_) | 58 if (!mus_window_) |
| 59 return; | 59 return; |
| 60 mus_window_->RemoveObserver(this); | 60 mus_window_->RemoveObserver(this); |
| 61 mus_window_->set_input_event_handler(nullptr); | 61 mus_window_->set_input_event_handler(nullptr); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 // It's possible dispatching the event will spin a nested message loop. Ack | 227 // It's possible dispatching the event will spin a nested message loop. Ack |
| 228 // the callback now, otherwise we appear unresponsive for the life of the | 228 // the callback now, otherwise we appear unresponsive for the life of the |
| 229 // nested message loop. | 229 // nested message loop. |
| 230 (*ack_callback)->Run(); | 230 (*ack_callback)->Run(); |
| 231 ack_callback->reset(); | 231 ack_callback->reset(); |
| 232 scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event>>()); | 232 scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event>>()); |
| 233 delegate_->DispatchEvent(ui_event.get()); | 233 delegate_->DispatchEvent(ui_event.get()); |
| 234 } | 234 } |
| 235 | 235 |
| 236 } // namespace views | 236 } // namespace views |
| OLD | NEW |