Index: ui/views/mus/window_tree_host_mus.cc |
diff --git a/ui/views/mus/window_tree_host_mus.cc b/ui/views/mus/window_tree_host_mus.cc |
index e360eb05b46ba0ed6769758e0e49a248ecd6b3d9..7aacf283586aadaefb9785852351cc9b82bd53d6 100644 |
--- a/ui/views/mus/window_tree_host_mus.cc |
+++ b/ui/views/mus/window_tree_host_mus.cc |
@@ -5,15 +5,21 @@ |
#include "ui/views/mus/window_tree_host_mus.h" |
#include "base/memory/ptr_util.h" |
+#include "components/bitmap_uploader/bitmap_uploader.h" |
#include "ui/aura/window.h" |
#include "ui/aura/window_event_dispatcher.h" |
+#include "ui/base/view_prop.h" |
#include "ui/events/event.h" |
+#include "ui/platform_window/stub/stub_window.h" |
#include "ui/views/mus/input_method_mus.h" |
#include "ui/views/mus/native_widget_mus.h" |
-#include "ui/views/mus/platform_window_mus.h" |
namespace views { |
+namespace { |
+static uint32_t accelerated_widget_count = 1; |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// WindowTreeHostMus, public: |
@@ -21,8 +27,35 @@ WindowTreeHostMus::WindowTreeHostMus(shell::Connector* connector, |
NativeWidgetMus* native_widget, |
mus::Window* window) |
: native_widget_(native_widget) { |
- SetPlatformWindow( |
- base::WrapUnique(new PlatformWindowMus(this, connector, window))); |
+ // We need accelerated widget numbers to be different for each |
+ // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t |
+ // has this property. |
+#if defined(OS_WIN) || defined(OS_ANDROID) |
+ gfx::AcceleratedWidget accelerated_widget = |
+ reinterpret_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); |
+#else |
+ gfx::AcceleratedWidget accelerated_widget = |
+ static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); |
+#endif |
+ |
+ // TODO(markdittmer): StubWindow will call |OnAcceleratedWidgetAvailable| with |
+ // device pixel ratio = 1. Really, this ratio should be consistent with that |
+ // of |window|. |
+ SetPlatformWindow(base::WrapUnique( |
+ new ui::StubWindow(this, accelerated_widget))); |
+ |
+ // If no connector was passed, then it's entirely possible that mojo has not |
+ // been initialized and BitmapUploader will not work. This occurs, for |
+ // example, in some unit test contexts. |
+ if (connector) { |
+ bitmap_uploader_.reset(new bitmap_uploader::BitmapUploader(window)); |
+ bitmap_uploader_->Init(connector); |
+ prop_.reset(new ui::ViewProp( |
+ accelerated_widget, |
+ bitmap_uploader::kBitmapUploaderForAcceleratedWidget, |
+ bitmap_uploader_.get())); |
+ } |
+ |
// The location of events is already transformed, and there is no way to |
// correctly determine the reverse transform. So, don't attempt to transform |
// event locations, else the root location is wrong. |
@@ -39,11 +72,6 @@ WindowTreeHostMus::~WindowTreeHostMus() { |
DestroyDispatcher(); |
} |
-PlatformWindowMus* WindowTreeHostMus::platform_window() { |
- return static_cast<PlatformWindowMus*>( |
- WindowTreeHostPlatform::platform_window()); |
-} |
- |
void WindowTreeHostMus::DispatchEvent(ui::Event* event) { |
if (event->IsKeyEvent() && GetInputMethod()) { |
GetInputMethod()->DispatchKeyEvent(event->AsKeyEvent()); |