Commit 68dcc38c authored by sadrul's avatar sadrul Committed by Commit bot

views/mus: Make PlatformWindowMus be responsible for setting-up the BitmapUploader.

Doing this allows using PlatformWindowMus and have it paint correctly without
needing to create a WindowTreeHostMus too.

BUG=none

Review URL: https://codereview.chromium.org/1634103002

Cr-Commit-Position: refs/heads/master@{#371540}
parent 81aa4e8f
...@@ -5,10 +5,12 @@ ...@@ -5,10 +5,12 @@
#include "ui/views/mus/platform_window_mus.h" #include "ui/views/mus/platform_window_mus.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/bitmap_uploader/bitmap_uploader.h"
#include "components/mus/public/cpp/property_type_converters.h" #include "components/mus/public/cpp/property_type_converters.h"
#include "components/mus/public/cpp/window_property.h" #include "components/mus/public/cpp/window_property.h"
#include "components/mus/public/interfaces/window_manager.mojom.h" #include "components/mus/public/interfaces/window_manager.mojom.h"
#include "mojo/converters/input_events/input_events_type_converters.h" #include "mojo/converters/input_events/input_events_type_converters.h"
#include "ui/base/view_prop.h"
#include "ui/platform_window/platform_window_delegate.h" #include "ui/platform_window/platform_window_delegate.h"
#include "ui/views/mus/window_manager_connection.h" #include "ui/views/mus/window_manager_connection.h"
...@@ -20,6 +22,7 @@ static uint32_t accelerated_widget_count = 1; ...@@ -20,6 +22,7 @@ static uint32_t accelerated_widget_count = 1;
} // namespace } // namespace
PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate, PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate,
mojo::Shell* shell,
mus::Window* mus_window) mus::Window* mus_window)
: delegate_(delegate), : delegate_(delegate),
mus_window_(mus_window), mus_window_(mus_window),
...@@ -36,14 +39,20 @@ PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate, ...@@ -36,14 +39,20 @@ PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate,
// window and fit in the smallest sizeof(AcceleratedWidget) uint32_t // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t
// has this property. // has this property.
#if defined(OS_WIN) || defined(OS_ANDROID) #if defined(OS_WIN) || defined(OS_ANDROID)
delegate_->OnAcceleratedWidgetAvailable( gfx::AcceleratedWidget accelerated_widget =
reinterpret_cast<gfx::AcceleratedWidget>(accelerated_widget_count++), reinterpret_cast<gfx::AcceleratedWidget>(accelerated_widget_count++);
mus_window_->viewport_metrics().device_pixel_ratio);
#else #else
delegate_->OnAcceleratedWidgetAvailable( gfx::AcceleratedWidget accelerated_widget =
static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++), static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++);
mus_window_->viewport_metrics().device_pixel_ratio);
#endif #endif
delegate_->OnAcceleratedWidgetAvailable(
accelerated_widget, mus_window_->viewport_metrics().device_pixel_ratio);
bitmap_uploader_.reset(new bitmap_uploader::BitmapUploader(mus_window_));
bitmap_uploader_->Init(shell);
prop_.reset(new ui::ViewProp(
accelerated_widget, bitmap_uploader::kBitmapUploaderForAcceleratedWidget,
bitmap_uploader_.get()));
} }
PlatformWindowMus::~PlatformWindowMus() { PlatformWindowMus::~PlatformWindowMus() {
......
...@@ -16,6 +16,18 @@ ...@@ -16,6 +16,18 @@
#include "ui/platform_window/platform_window.h" #include "ui/platform_window/platform_window.h"
#include "ui/views/mus/mus_export.h" #include "ui/views/mus/mus_export.h"
namespace bitmap_uploader {
class BitmapUploader;
}
namespace mojo {
class Shell;
}
namespace ui {
class ViewProp;
}
namespace views { namespace views {
class VIEWS_MUS_EXPORT PlatformWindowMus class VIEWS_MUS_EXPORT PlatformWindowMus
...@@ -24,6 +36,7 @@ class VIEWS_MUS_EXPORT PlatformWindowMus ...@@ -24,6 +36,7 @@ class VIEWS_MUS_EXPORT PlatformWindowMus
public NON_EXPORTED_BASE(mus::InputEventHandler) { public NON_EXPORTED_BASE(mus::InputEventHandler) {
public: public:
PlatformWindowMus(ui::PlatformWindowDelegate* delegate, PlatformWindowMus(ui::PlatformWindowDelegate* delegate,
mojo::Shell* shell,
mus::Window* mus_window); mus::Window* mus_window);
~PlatformWindowMus() override; ~PlatformWindowMus() override;
...@@ -82,6 +95,8 @@ class VIEWS_MUS_EXPORT PlatformWindowMus ...@@ -82,6 +95,8 @@ class VIEWS_MUS_EXPORT PlatformWindowMus
// True if OnWindowDestroyed() has been received. // True if OnWindowDestroyed() has been received.
bool mus_window_destroyed_; bool mus_window_destroyed_;
scoped_ptr<bitmap_uploader::BitmapUploader> bitmap_uploader_;
scoped_ptr<ui::ViewProp> prop_;
#ifndef NDEBUG #ifndef NDEBUG
scoped_ptr<base::WeakPtrFactory<PlatformWindowMus>> weak_factory_; scoped_ptr<base::WeakPtrFactory<PlatformWindowMus>> weak_factory_;
#endif #endif
......
...@@ -4,11 +4,8 @@ ...@@ -4,11 +4,8 @@
#include "ui/views/mus/window_tree_host_mus.h" #include "ui/views/mus/window_tree_host_mus.h"
#include "components/bitmap_uploader/bitmap_uploader.h"
#include "mojo/shell/public/interfaces/shell.mojom.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h" #include "ui/aura/window_event_dispatcher.h"
#include "ui/base/view_prop.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/views/mus/input_method_mus.h" #include "ui/views/mus/input_method_mus.h"
#include "ui/views/mus/native_widget_mus.h" #include "ui/views/mus/native_widget_mus.h"
...@@ -25,7 +22,8 @@ WindowTreeHostMus::WindowTreeHostMus(mojo::Shell* shell, ...@@ -25,7 +22,8 @@ WindowTreeHostMus::WindowTreeHostMus(mojo::Shell* shell,
mus::mojom::SurfaceType surface_type) mus::mojom::SurfaceType surface_type)
: native_widget_(native_widget), : native_widget_(native_widget),
show_state_(ui::PLATFORM_WINDOW_STATE_UNKNOWN) { show_state_(ui::PLATFORM_WINDOW_STATE_UNKNOWN) {
SetPlatformWindow(make_scoped_ptr(new PlatformWindowMus(this, window))); SetPlatformWindow(
make_scoped_ptr(new PlatformWindowMus(this, shell, window)));
// The location of events is already transformed, and there is no way to // The location of events is already transformed, and there is no way to
// correctly determine the reverse transform. So, don't attempt to transform // correctly determine the reverse transform. So, don't attempt to transform
// event locations, else the root location is wrong. // event locations, else the root location is wrong.
...@@ -33,13 +31,6 @@ WindowTreeHostMus::WindowTreeHostMus(mojo::Shell* shell, ...@@ -33,13 +31,6 @@ WindowTreeHostMus::WindowTreeHostMus(mojo::Shell* shell,
dispatcher()->set_transform_events(false); dispatcher()->set_transform_events(false);
compositor()->SetHostHasTransparentBackground(true); compositor()->SetHostHasTransparentBackground(true);
bitmap_uploader_.reset(new bitmap_uploader::BitmapUploader(window));
bitmap_uploader_->Init(shell);
prop_.reset(
new ui::ViewProp(GetAcceleratedWidget(),
bitmap_uploader::kBitmapUploaderForAcceleratedWidget,
bitmap_uploader_.get()));
input_method_.reset(new InputMethodMUS(this, window)); input_method_.reset(new InputMethodMUS(this, window));
SetSharedInputMethod(input_method_.get()); SetSharedInputMethod(input_method_.get());
} }
......
...@@ -12,10 +12,6 @@ ...@@ -12,10 +12,6 @@
class SkBitmap; class SkBitmap;
namespace bitmap_uploader {
class BitmapUploader;
}
namespace mojo { namespace mojo {
class Shell; class Shell;
} }
...@@ -24,11 +20,6 @@ namespace mus { ...@@ -24,11 +20,6 @@ namespace mus {
class Window; class Window;
} }
namespace ui {
class Compositor;
class ViewProp;
}
namespace views { namespace views {
class InputMethodMUS; class InputMethodMUS;
...@@ -44,9 +35,6 @@ class VIEWS_MUS_EXPORT WindowTreeHostMus : public aura::WindowTreeHostPlatform { ...@@ -44,9 +35,6 @@ class VIEWS_MUS_EXPORT WindowTreeHostMus : public aura::WindowTreeHostPlatform {
~WindowTreeHostMus() override; ~WindowTreeHostMus() override;
PlatformWindowMus* platform_window(); PlatformWindowMus* platform_window();
bitmap_uploader::BitmapUploader* bitmap_uploader() {
return bitmap_uploader_.get();
}
ui::PlatformWindowState show_state() const { return show_state_; } ui::PlatformWindowState show_state() const { return show_state_; }
private: private:
...@@ -60,8 +48,6 @@ class VIEWS_MUS_EXPORT WindowTreeHostMus : public aura::WindowTreeHostPlatform { ...@@ -60,8 +48,6 @@ class VIEWS_MUS_EXPORT WindowTreeHostMus : public aura::WindowTreeHostPlatform {
NativeWidgetMus* native_widget_; NativeWidgetMus* native_widget_;
scoped_ptr<InputMethodMUS> input_method_; scoped_ptr<InputMethodMUS> input_method_;
ui::PlatformWindowState show_state_; ui::PlatformWindowState show_state_;
scoped_ptr<bitmap_uploader::BitmapUploader> bitmap_uploader_;
scoped_ptr<ui::ViewProp> prop_;
DISALLOW_COPY_AND_ASSIGN(WindowTreeHostMus); DISALLOW_COPY_AND_ASSIGN(WindowTreeHostMus);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment