Commit eb63642a authored by spang@chromium.org's avatar spang@chromium.org

ozone: Port NativeViewportOzone on top of PlatformWindow

This mirrors a similar change to WindowTreeHostOzone.

BUG=392280
TEST=built with chromeos==1 use_ozone==1 & ran with egltest

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283758 0039d316-1c4b-4281-b951-d872f2087c98
parent a46492b0
...@@ -9,90 +9,80 @@ ...@@ -9,90 +9,80 @@
#include "ui/events/platform/platform_event_source.h" #include "ui/events/platform/platform_event_source.h"
#include "ui/ozone/public/cursor_factory_ozone.h" #include "ui/ozone/public/cursor_factory_ozone.h"
#include "ui/ozone/public/event_factory_ozone.h" #include "ui/ozone/public/event_factory_ozone.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/surface_factory_ozone.h" #include "ui/ozone/public/surface_factory_ozone.h"
#include "ui/platform_window/platform_window.h"
#include "ui/platform_window/platform_window_delegate.h"
namespace mojo { namespace mojo {
namespace services { namespace services {
bool override_redirect = false; // TODO(spang): Deduplicate with NativeViewportX11.. but there's a hack
// in there that prevents this.
class NativeViewportOzone : public NativeViewport, class NativeViewportOzone : public NativeViewport,
public ui::PlatformEventDispatcher { public ui::PlatformWindowDelegate {
public: public:
NativeViewportOzone(NativeViewportDelegate* delegate) explicit NativeViewportOzone(NativeViewportDelegate* delegate)
: delegate_(delegate), : delegate_(delegate) {
widget_(gfx::kNullAcceleratedWidget) { ui::OzonePlatform::InitializeForUI();
ui::SurfaceFactoryOzone* surface_factory =
ui::SurfaceFactoryOzone::GetInstance();
widget_ = surface_factory->GetAcceleratedWidget();
// TODO(sky): need to enable this.
// ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
} }
virtual ~NativeViewportOzone() { virtual ~NativeViewportOzone() {
// TODO(sky): need to enable this. // Destroy the platform-window while |this| is still alive.
// ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher( platform_window_.reset();
// this);
} }
private: private:
// Overridden from NativeViewport: // Overridden from NativeViewport:
virtual void Init(const gfx::Rect& bounds) OVERRIDE { virtual void Init(const gfx::Rect& bounds) OVERRIDE {
NOTIMPLEMENTED(); platform_window_ =
bounds_ = bounds; ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds);
delegate_->OnAcceleratedWidgetAvailable(widget_);
} }
virtual void Show() OVERRIDE { virtual void Show() OVERRIDE { platform_window_->Show(); }
NOTIMPLEMENTED();
}
virtual void Hide() OVERRIDE { virtual void Hide() OVERRIDE { platform_window_->Hide(); }
NOTIMPLEMENTED();
}
virtual void Close() OVERRIDE { virtual void Close() OVERRIDE { platform_window_->Close(); }
delegate_->OnDestroyed();
}
virtual gfx::Size GetSize() OVERRIDE { virtual gfx::Size GetSize() OVERRIDE {
return bounds_.size(); return platform_window_->GetBounds().size();
} }
virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE { virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE {
bounds_ = bounds; platform_window_->SetBounds(bounds);
NOTIMPLEMENTED();
} }
virtual void SetCapture() OVERRIDE { virtual void SetCapture() OVERRIDE { platform_window_->SetCapture(); }
NOTIMPLEMENTED();
} virtual void ReleaseCapture() OVERRIDE { platform_window_->ReleaseCapture(); }
virtual void ReleaseCapture() OVERRIDE { // ui::PlatformWindowDelegate:
NOTIMPLEMENTED(); virtual void OnBoundsChanged(const gfx::Rect& new_bounds) OVERRIDE {
delegate_->OnBoundsChanged(new_bounds);
} }
// ui::PlatformEventDispatcher: virtual void OnDamageRect(const gfx::Rect& damaged_region) OVERRIDE {}
virtual bool CanDispatchEvent(const ui::PlatformEvent& ne) OVERRIDE {
CHECK(ne);
ui::Event* event = static_cast<ui::Event*>(ne);
if (event->IsMouseEvent() || event->IsScrollEvent()) {
return ui::CursorFactoryOzone::GetInstance()->GetCursorWindow() ==
widget_;
}
return true; virtual void DispatchEvent(ui::Event* event) OVERRIDE {
delegate_->OnEvent(event);
} }
virtual uint32_t DispatchEvent(const ui::PlatformEvent& ne) OVERRIDE { virtual void OnCloseRequest() OVERRIDE { platform_window_->Close(); }
ui::Event* event = static_cast<ui::Event*>(ne);
delegate_->OnEvent(event); virtual void OnClosed() OVERRIDE { delegate_->OnDestroyed(); }
return ui::POST_DISPATCH_STOP_PROPAGATION;
virtual void OnWindowStateChanged(ui::PlatformWindowState state) OVERRIDE {}
virtual void OnLostCapture() OVERRIDE {}
virtual void OnAcceleratedWidgetAvailable(
gfx::AcceleratedWidget widget) OVERRIDE {
delegate_->OnAcceleratedWidgetAvailable(widget);
} }
scoped_ptr<ui::PlatformWindow> platform_window_;
NativeViewportDelegate* delegate_; NativeViewportDelegate* delegate_;
gfx::AcceleratedWidget widget_;
gfx::Rect bounds_;
DISALLOW_COPY_AND_ASSIGN(NativeViewportOzone); DISALLOW_COPY_AND_ASSIGN(NativeViewportOzone);
}; };
......
...@@ -282,7 +282,9 @@ class OzonePlatformEgltest : public OzonePlatform { ...@@ -282,7 +282,9 @@ class OzonePlatformEgltest : public OzonePlatform {
virtual void InitializeUI() OVERRIDE { virtual void InitializeUI() OVERRIDE {
device_manager_ = CreateDeviceManager(); device_manager_ = CreateDeviceManager();
surface_factory_ozone_.reset(new SurfaceFactoryEgltest(&eglplatform_shim_)); if (!surface_factory_ozone_)
surface_factory_ozone_.reset(
new SurfaceFactoryEgltest(&eglplatform_shim_));
event_factory_ozone_.reset( event_factory_ozone_.reset(
new EventFactoryEvdev(NULL, device_manager_.get())); new EventFactoryEvdev(NULL, device_manager_.get()));
cursor_factory_ozone_.reset(new CursorFactoryOzone()); cursor_factory_ozone_.reset(new CursorFactoryOzone());
...@@ -290,7 +292,9 @@ class OzonePlatformEgltest : public OzonePlatform { ...@@ -290,7 +292,9 @@ class OzonePlatformEgltest : public OzonePlatform {
} }
virtual void InitializeGPU() OVERRIDE { virtual void InitializeGPU() OVERRIDE {
surface_factory_ozone_.reset(new SurfaceFactoryEgltest(&eglplatform_shim_)); if (!surface_factory_ozone_)
surface_factory_ozone_.reset(
new SurfaceFactoryEgltest(&eglplatform_shim_));
gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); gpu_platform_support_.reset(CreateStubGpuPlatformSupport());
} }
......
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