summaryrefslogtreecommitdiffstats
path: root/ui/ozone
diff options
context:
space:
mode:
authorspang@chromium.org <spang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-16 23:27:06 +0000
committerspang@chromium.org <spang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-16 23:27:06 +0000
commit6fa58150d06d0bbd3fa74f7f04ebe7e911b16dff (patch)
treef768a6ef55e2e066319c2d5cc28058aa8f84b1a7 /ui/ozone
parentf0324ee10c73d7f79eb45f097cb8ab08494ecd11 (diff)
downloadchromium_src-6fa58150d06d0bbd3fa74f7f04ebe7e911b16dff.zip
chromium_src-6fa58150d06d0bbd3fa74f7f04ebe7e911b16dff.tar.gz
chromium_src-6fa58150d06d0bbd3fa74f7f04ebe7e911b16dff.tar.bz2
ozone: Port WindowTreeHostOzone on top of PlatformWindow
Most of the WindowTreeHost functionality is actually implemented by the platform window, so there's not much in WindowTreeHostOzone aside from forwarding calls to and from the platform part. Should be no functional change for in-tree platforms. To accomplish that, this adds a transitional class PlatformWindowCompat that implements PlatformWindow functions as WindowTreeHostOzone did before. As a followup, we'll convert each platform to use the new PlatformWindow natively & then remove PlatformWindowCompat. BUG=392280 TEST=built with chromeos==1 use_ozone==1 & ran all platforms. NOTRY=true TBR=ben@chromium.org Review URL: https://codereview.chromium.org/375053002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283573 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/ozone')
-rw-r--r--ui/ozone/DEPS1
-rw-r--r--ui/ozone/common/window/platform_window_compat.cc79
-rw-r--r--ui/ozone/common/window/platform_window_compat.h59
-rw-r--r--ui/ozone/ozone.gyp2
-rw-r--r--ui/ozone/platform/caca/ozone_platform_caca.cc7
-rw-r--r--ui/ozone/platform/dri/ozone_platform_dri.cc7
-rw-r--r--ui/ozone/platform/dri/ozone_platform_gbm.cc7
-rw-r--r--ui/ozone/platform/egltest/ozone_platform_egltest.cc7
-rw-r--r--ui/ozone/platform/test/ozone_platform_test.cc7
-rw-r--r--ui/ozone/public/ozone_platform.h9
10 files changed, 185 insertions, 0 deletions
diff --git a/ui/ozone/DEPS b/ui/ozone/DEPS
index 8f39e9e..b4ed3b00 100644
--- a/ui/ozone/DEPS
+++ b/ui/ozone/DEPS
@@ -5,4 +5,5 @@ include_rules = [
"+ui/events",
"+ui/gfx",
"+ui/base/cursor",
+ "+ui/platform_window",
]
diff --git a/ui/ozone/common/window/platform_window_compat.cc b/ui/ozone/common/window/platform_window_compat.cc
new file mode 100644
index 0000000..5703680
--- /dev/null
+++ b/ui/ozone/common/window/platform_window_compat.cc
@@ -0,0 +1,79 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/ozone/common/window/platform_window_compat.h"
+
+#include "ui/events/event.h"
+#include "ui/events/platform/platform_event_source.h"
+#include "ui/ozone/public/cursor_factory_ozone.h"
+#include "ui/ozone/public/event_factory_ozone.h"
+#include "ui/ozone/public/surface_factory_ozone.h"
+#include "ui/platform_window/platform_window_delegate.h"
+
+namespace ui {
+
+PlatformWindowCompat::PlatformWindowCompat(PlatformWindowDelegate* delegate,
+ const gfx::Rect& bounds)
+ : delegate_(delegate), bounds_(bounds) {
+ widget_ = SurfaceFactoryOzone::GetInstance()->GetAcceleratedWidget();
+ delegate_->OnAcceleratedWidgetAvailable(widget_);
+ ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
+}
+
+PlatformWindowCompat::~PlatformWindowCompat() {
+ ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
+}
+
+bool PlatformWindowCompat::CanDispatchEvent(const ui::PlatformEvent& ne) {
+ CHECK(ne);
+ ui::Event* event = static_cast<ui::Event*>(ne);
+ if (event->IsMouseEvent() || event->IsScrollEvent())
+ return ui::CursorFactoryOzone::GetInstance()->GetCursorWindow() == widget_;
+
+ return true;
+}
+
+uint32_t PlatformWindowCompat::DispatchEvent(const ui::PlatformEvent& ne) {
+ ui::Event* event = static_cast<ui::Event*>(ne);
+ delegate_->DispatchEvent(event);
+ return ui::POST_DISPATCH_STOP_PROPAGATION;
+}
+
+gfx::Rect PlatformWindowCompat::GetBounds() {
+ return bounds_;
+}
+
+void PlatformWindowCompat::SetBounds(const gfx::Rect& bounds) {
+ bounds_ = bounds;
+ delegate_->OnBoundsChanged(bounds);
+}
+
+void PlatformWindowCompat::Show() {
+}
+
+void PlatformWindowCompat::Hide() {
+}
+
+void PlatformWindowCompat::Close() {
+}
+
+void PlatformWindowCompat::SetCapture() {
+}
+
+void PlatformWindowCompat::ReleaseCapture() {
+}
+
+void PlatformWindowCompat::ToggleFullscreen() {
+}
+
+void PlatformWindowCompat::Maximize() {
+}
+
+void PlatformWindowCompat::Minimize() {
+}
+
+void PlatformWindowCompat::Restore() {
+}
+
+} // namespace ui
diff --git a/ui/ozone/common/window/platform_window_compat.h b/ui/ozone/common/window/platform_window_compat.h
new file mode 100644
index 0000000..503a2de
--- /dev/null
+++ b/ui/ozone/common/window/platform_window_compat.h
@@ -0,0 +1,59 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_OZONE_COMMON_WINDOW_PLATFORM_WINDOW_COMPAT_H_
+#define UI_OZONE_COMMON_WINDOW_PLATFORM_WINDOW_COMPAT_H_
+
+#include "ui/base/cursor/cursor.h"
+#include "ui/events/platform/platform_event_dispatcher.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/native_widget_types.h"
+#include "ui/ozone/ozone_export.h"
+#include "ui/platform_window/platform_window.h"
+
+namespace gfx {
+class Point;
+class Rect;
+}
+
+namespace ui {
+
+class PlatformWindowDelegate;
+
+// This is just transitional code. Will be removed shortly.
+class OZONE_EXPORT PlatformWindowCompat : public PlatformWindow,
+ public ui::PlatformEventDispatcher {
+ public:
+ PlatformWindowCompat(PlatformWindowDelegate* delegate,
+ const gfx::Rect& bounds);
+ virtual ~PlatformWindowCompat();
+
+ // ui::PlatformEventDispatcher:
+ virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE;
+ virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE;
+
+ // PlatformWindow:
+ virtual gfx::Rect GetBounds() OVERRIDE;
+ virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
+ virtual void Show() OVERRIDE;
+ virtual void Hide() OVERRIDE;
+ virtual void Close() OVERRIDE;
+ virtual void SetCapture() OVERRIDE;
+ virtual void ReleaseCapture() OVERRIDE;
+ virtual void ToggleFullscreen() OVERRIDE;
+ virtual void Maximize() OVERRIDE;
+ virtual void Minimize() OVERRIDE;
+ virtual void Restore() OVERRIDE;
+
+ private:
+ PlatformWindowDelegate* delegate_;
+ gfx::AcceleratedWidget widget_;
+ gfx::Rect bounds_;
+
+ DISALLOW_COPY_AND_ASSIGN(PlatformWindowCompat);
+};
+
+} // namespace ui
+
+#endif // UI_OZONE_COMMON_WINDOW_PLATFORM_WINDOW_COMPAT_H_
diff --git a/ui/ozone/ozone.gyp b/ui/ozone/ozone.gyp
index 39b1100..9e9828f 100644
--- a/ui/ozone/ozone.gyp
+++ b/ui/ozone/ozone.gyp
@@ -100,6 +100,8 @@
'common/gpu/ozone_gpu_message_params.cc',
'common/gpu/ozone_gpu_message_params.h',
'common/gpu/ozone_gpu_messages.h',
+ 'common/window/platform_window_compat.cc',
+ 'common/window/platform_window_compat.h',
'public/ozone_platform.cc',
'public/ozone_platform.h',
'public/ozone_switches.cc',
diff --git a/ui/ozone/platform/caca/ozone_platform_caca.cc b/ui/ozone/platform/caca/ozone_platform_caca.cc
index 1146856..36b6414 100644
--- a/ui/ozone/platform/caca/ozone_platform_caca.cc
+++ b/ui/ozone/platform/caca/ozone_platform_caca.cc
@@ -4,6 +4,7 @@
#include "ui/ozone/platform/caca/ozone_platform_caca.h"
+#include "ui/ozone/common/window/platform_window_compat.h"
#include "ui/ozone/platform/caca/caca_connection.h"
#include "ui/ozone/platform/caca/caca_event_factory.h"
#include "ui/ozone/platform/caca/caca_surface_factory.h"
@@ -40,6 +41,12 @@ class OzonePlatformCaca : public OzonePlatform {
virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() OVERRIDE {
return NULL; // no GPU support
}
+ virtual scoped_ptr<PlatformWindow> CreatePlatformWindow(
+ PlatformWindowDelegate* delegate,
+ const gfx::Rect& bounds) OVERRIDE {
+ return make_scoped_ptr<PlatformWindow>(
+ new PlatformWindowCompat(delegate, bounds));
+ }
#if defined(OS_CHROMEOS)
virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate()
diff --git a/ui/ozone/platform/dri/ozone_platform_dri.cc b/ui/ozone/platform/dri/ozone_platform_dri.cc
index bb4c9a3..b369a6d 100644
--- a/ui/ozone/platform/dri/ozone_platform_dri.cc
+++ b/ui/ozone/platform/dri/ozone_platform_dri.cc
@@ -8,6 +8,7 @@
#include "ui/events/ozone/device/device_manager.h"
#include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
#include "ui/events/ozone/evdev/event_factory_evdev.h"
+#include "ui/ozone/common/window/platform_window_compat.h"
#include "ui/ozone/platform/dri/cursor_factory_evdev_dri.h"
#include "ui/ozone/platform/dri/dri_surface.h"
#include "ui/ozone/platform/dri/dri_surface_factory.h"
@@ -77,6 +78,12 @@ class OzonePlatformDri : public OzonePlatform {
virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() OVERRIDE {
return NULL; // no GPU support
}
+ virtual scoped_ptr<PlatformWindow> CreatePlatformWindow(
+ PlatformWindowDelegate* delegate,
+ const gfx::Rect& bounds) OVERRIDE {
+ return make_scoped_ptr<PlatformWindow>(
+ new PlatformWindowCompat(delegate, bounds));
+ }
#if defined(OS_CHROMEOS)
virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate()
OVERRIDE {
diff --git a/ui/ozone/platform/dri/ozone_platform_gbm.cc b/ui/ozone/platform/dri/ozone_platform_gbm.cc
index 34939db..f043996 100644
--- a/ui/ozone/platform/dri/ozone_platform_gbm.cc
+++ b/ui/ozone/platform/dri/ozone_platform_gbm.cc
@@ -11,6 +11,7 @@
#include "base/at_exit.h"
#include "ui/events/ozone/device/device_manager.h"
#include "ui/events/ozone/evdev/event_factory_evdev.h"
+#include "ui/ozone/common/window/platform_window_compat.h"
#include "ui/ozone/platform/dri/cursor_factory_evdev_dri.h"
#include "ui/ozone/platform/dri/dri_wrapper.h"
#include "ui/ozone/platform/dri/gbm_buffer.h"
@@ -107,6 +108,12 @@ class OzonePlatformGbm : public OzonePlatform {
virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() OVERRIDE {
return gpu_platform_support_host_.get();
}
+ virtual scoped_ptr<PlatformWindow> CreatePlatformWindow(
+ PlatformWindowDelegate* delegate,
+ const gfx::Rect& bounds) OVERRIDE {
+ return make_scoped_ptr<PlatformWindow>(
+ new PlatformWindowCompat(delegate, bounds));
+ }
#if defined(OS_CHROMEOS)
virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate()
OVERRIDE {
diff --git a/ui/ozone/platform/egltest/ozone_platform_egltest.cc b/ui/ozone/platform/egltest/ozone_platform_egltest.cc
index ebea5d0..dc34d73 100644
--- a/ui/ozone/platform/egltest/ozone_platform_egltest.cc
+++ b/ui/ozone/platform/egltest/ozone_platform_egltest.cc
@@ -12,6 +12,7 @@
#include "ui/events/ozone/device/device_manager.h"
#include "ui/events/ozone/evdev/event_factory_evdev.h"
#include "ui/gfx/vsync_provider.h"
+#include "ui/ozone/common/window/platform_window_compat.h"
#include "ui/ozone/public/cursor_factory_ozone.h"
#include "ui/ozone/public/gpu_platform_support.h"
#include "ui/ozone/public/gpu_platform_support_host.h"
@@ -260,6 +261,12 @@ class OzonePlatformEgltest : public OzonePlatform {
virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() OVERRIDE {
return gpu_platform_support_host_.get();
}
+ virtual scoped_ptr<PlatformWindow> CreatePlatformWindow(
+ PlatformWindowDelegate* delegate,
+ const gfx::Rect& bounds) OVERRIDE {
+ return make_scoped_ptr<PlatformWindow>(
+ new PlatformWindowCompat(delegate, bounds));
+ }
#if defined(OS_CHROMEOS)
virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate()
diff --git a/ui/ozone/platform/test/ozone_platform_test.cc b/ui/ozone/platform/test/ozone_platform_test.cc
index 2473e37..3f42d1f 100644
--- a/ui/ozone/platform/test/ozone_platform_test.cc
+++ b/ui/ozone/platform/test/ozone_platform_test.cc
@@ -8,6 +8,7 @@
#include "base/files/file_path.h"
#include "ui/events/ozone/device/device_manager.h"
#include "ui/events/ozone/evdev/event_factory_evdev.h"
+#include "ui/ozone/common/window/platform_window_compat.h"
#include "ui/ozone/platform/test/file_surface_factory.h"
#include "ui/ozone/platform/test/test_cursor_factory.h"
#include "ui/ozone/public/gpu_platform_support.h"
@@ -48,6 +49,12 @@ class OzonePlatformTest : public OzonePlatform {
virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() OVERRIDE {
return gpu_platform_support_host_.get();
}
+ virtual scoped_ptr<PlatformWindow> CreatePlatformWindow(
+ PlatformWindowDelegate* delegate,
+ const gfx::Rect& bounds) OVERRIDE {
+ return make_scoped_ptr<PlatformWindow>(
+ new PlatformWindowCompat(delegate, bounds));
+ }
#if defined(OS_CHROMEOS)
virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate()
diff --git a/ui/ozone/public/ozone_platform.h b/ui/ozone/public/ozone_platform.h
index 9716016..8620bf5 100644
--- a/ui/ozone/public/ozone_platform.h
+++ b/ui/ozone/public/ozone_platform.h
@@ -8,6 +8,10 @@
#include "base/memory/scoped_ptr.h"
#include "ui/ozone/ozone_export.h"
+namespace gfx {
+class Rect;
+}
+
namespace ui {
class CursorFactoryOzone;
@@ -17,6 +21,8 @@ class SurfaceFactoryOzone;
class TouchscreenDeviceManager;
class GpuPlatformSupport;
class GpuPlatformSupportHost;
+class PlatformWindow;
+class PlatformWindowDelegate;
// Base class for Ozone platform implementations.
//
@@ -54,6 +60,9 @@ class OZONE_EXPORT OzonePlatform {
virtual ui::CursorFactoryOzone* GetCursorFactoryOzone() = 0;
virtual ui::GpuPlatformSupport* GetGpuPlatformSupport() = 0;
virtual ui::GpuPlatformSupportHost* GetGpuPlatformSupportHost() = 0;
+ virtual scoped_ptr<PlatformWindow> CreatePlatformWindow(
+ PlatformWindowDelegate* delegate,
+ const gfx::Rect& bounds) = 0;
#if defined(OS_CHROMEOS)
virtual scoped_ptr<ui::NativeDisplayDelegate>
CreateNativeDisplayDelegate() = 0;