From 7965546fbe0b654ddad7418edb27a7c94c802019 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 20 Mar 2017 13:13:03 +0100 Subject: Cleanup ozone platform Rename the platform to make it clear it is not just for eglfs. Fixes formating, and also removes parts unnecessary for us that original ozone platforms doesn't use anymore either. Change-Id: I04e5792e2ced2580ae0cbfe208b4e594af60a09a Reviewed-by: Michal Klocek --- src/core/config/embedded_linux.pri | 2 +- src/core/core_generator.pro | 4 +- src/core/ozone_platform_eglfs.cpp | 195 ------------------------------ src/core/ozone_platform_eglfs.h | 93 --------------- src/core/ozone_platform_qt.cpp | 236 +++++++++++++++++++++++++++++++++++++ src/core/ozone_platform_qt.h | 55 +++++++++ 6 files changed, 294 insertions(+), 291 deletions(-) delete mode 100644 src/core/ozone_platform_eglfs.cpp delete mode 100644 src/core/ozone_platform_eglfs.h create mode 100644 src/core/ozone_platform_qt.cpp create mode 100644 src/core/ozone_platform_qt.h diff --git a/src/core/config/embedded_linux.pri b/src/core/config/embedded_linux.pri index f9b8a35d5..11ed3e310 100644 --- a/src/core/config/embedded_linux.pri +++ b/src/core/config/embedded_linux.pri @@ -13,7 +13,7 @@ use?(gn) { ozone_auto_platforms=false \ ozone_platform_headless=true \ ozone_platform_external=true \ - ozone_platform=\"eglfs\" \ + ozone_platform=\"qt\" \ toolkit_views=false use?(icecc) { diff --git a/src/core/core_generator.pro b/src/core/core_generator.pro index c99e10ef8..9c109146f 100644 --- a/src/core/core_generator.pro +++ b/src/core/core_generator.pro @@ -84,7 +84,7 @@ SOURCES = \ media_capture_devices_dispatcher.cpp \ native_web_keyboard_event_qt.cpp \ network_delegate_qt.cpp \ - ozone_platform_eglfs.cpp \ + ozone_platform_qt.cpp \ permission_manager_qt.cpp \ process_main.cpp \ proxy_config_service_qt.cpp \ @@ -159,7 +159,7 @@ HEADERS = \ javascript_dialog_manager_qt.h \ media_capture_devices_dispatcher.h \ network_delegate_qt.h \ - ozone_platform_eglfs.h \ + ozone_platform_qt.h \ permission_manager_qt.h \ process_main.h \ proxy_config_service_qt.h \ diff --git a/src/core/ozone_platform_eglfs.cpp b/src/core/ozone_platform_eglfs.cpp deleted file mode 100644 index e6e1ab5e2..000000000 --- a/src/core/ozone_platform_eglfs.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "ozone_platform_eglfs.h" - -#if defined(USE_OZONE) - -#include "base/bind.h" -#include "base/memory/ptr_util.h" -#include "ui/events/ozone/device/device_manager.h" -#include "ui/events/ozone/evdev/event_factory_evdev.h" -#include "ui/events/ozone/events_ozone.h" -#include "ui/events/platform/platform_event_dispatcher.h" -#include "ui/ozone/common/native_display_delegate_ozone.h" -#include "ui/ozone/common/stub_client_native_pixmap_factory.h" -#include "ui/ozone/common/stub_overlay_manager.h" -#include "ui/ozone/public/ozone_platform.h" -#include "ui/ozone/public/cursor_factory_ozone.h" -#include "ui/ozone/public/gpu_platform_support_host.h" -#include "ui/platform_window/platform_window.h" -#include "ui/platform_window/platform_window_delegate.h" - -namespace ui { - -namespace { -class EglfsWindow : public PlatformWindow, public PlatformEventDispatcher { -public: - EglfsWindow(PlatformWindowDelegate* delegate, - EventFactoryEvdev* event_factory, - const gfx::Rect& bounds) - : delegate_(delegate) - , event_factory_(event_factory) - , bounds_(bounds) - { - ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); - } - - ~EglfsWindow() override - { - ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); - } - - // PlatformWindow: - gfx::Rect GetBounds() override; - void SetBounds(const gfx::Rect& bounds) override; - void Show() override { } - void Hide() override { } - void Close() override { } - void SetTitle(const base::string16&) override { } - void SetCapture() override { } - void ReleaseCapture() override { } - void ToggleFullscreen() override { } - void Maximize() override { } - void Minimize() override { } - void Restore() override { } - void SetCursor(PlatformCursor) override { } - void MoveCursorTo(const gfx::Point&) override { } - void ConfineCursorToBounds(const gfx::Rect&) override { } - PlatformImeController* GetPlatformImeController() override { return nullptr; } - // PlatformEventDispatcher: - bool CanDispatchEvent(const PlatformEvent& event) override; - uint32_t DispatchEvent(const PlatformEvent& event) override; - -private: - PlatformWindowDelegate* delegate_; - EventFactoryEvdev* event_factory_; - gfx::Rect bounds_; - - DISALLOW_COPY_AND_ASSIGN(EglfsWindow); -}; - -gfx::Rect EglfsWindow::GetBounds() { - return bounds_; -} - -void EglfsWindow::SetBounds(const gfx::Rect& bounds) { - bounds_ = bounds; - delegate_->OnBoundsChanged(bounds); -} - -bool EglfsWindow::CanDispatchEvent(const ui::PlatformEvent& ne) { - return true; -} - -uint32_t EglfsWindow::DispatchEvent(const ui::PlatformEvent& native_event) { - DispatchEventFromNativeUiEvent( - native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent, - base::Unretained(delegate_))); - - return ui::POST_DISPATCH_STOP_PROPAGATION; -} -} // namespace - -OzonePlatformEglfs::OzonePlatformEglfs() {} - -OzonePlatformEglfs::~OzonePlatformEglfs() {} - -ui::SurfaceFactoryOzone* OzonePlatformEglfs::GetSurfaceFactoryOzone() { - return surface_factory_ozone_.get(); -} - -ui::CursorFactoryOzone* OzonePlatformEglfs::GetCursorFactoryOzone() { - return cursor_factory_ozone_.get(); -} - -GpuPlatformSupportHost* OzonePlatformEglfs::GetGpuPlatformSupportHost() { - return gpu_platform_support_host_.get(); -} - -std::unique_ptr OzonePlatformEglfs::CreatePlatformWindow( - PlatformWindowDelegate* delegate, - const gfx::Rect& bounds) -{ - return base::WrapUnique( - new EglfsWindow(delegate, - event_factory_ozone_.get(), - bounds)); -} - -ui::InputController* OzonePlatformEglfs::GetInputController() { - return input_controller_.get(); -} - -std::unique_ptr OzonePlatformEglfs::CreateSystemInputInjector() { - return nullptr; // no input injection support. -} - -ui::OverlayManagerOzone* OzonePlatformEglfs::GetOverlayManager() { - return overlay_manager_.get(); -} - -std::unique_ptr OzonePlatformEglfs::CreateNativeDisplayDelegate() -{ - return base::WrapUnique(new NativeDisplayDelegateOzone()); -} - -OzonePlatform* CreateOzonePlatformEglfs() { return new OzonePlatformEglfs; } - -ClientNativePixmapFactory* CreateClientNativePixmapFactoryEglfs() { - return CreateStubClientNativePixmapFactory(); -} - -void OzonePlatformEglfs::InitializeUI() { - overlay_manager_.reset(new StubOverlayManager()); - device_manager_ = CreateDeviceManager(); - cursor_factory_ozone_.reset(new CursorFactoryOzone()); - event_factory_ozone_.reset(new EventFactoryEvdev(NULL, device_manager_.get(), NULL)); - gpu_platform_support_host_.reset(ui::CreateStubGpuPlatformSupportHost()); - input_controller_ = CreateStubInputController(); -} - -void OzonePlatformEglfs::InitializeGPU() { - surface_factory_ozone_.reset(new QtWebEngineCore::SurfaceFactoryQt()); -} - -} // namespace ui - -#endif - diff --git a/src/core/ozone_platform_eglfs.h b/src/core/ozone_platform_eglfs.h deleted file mode 100644 index c319b1e5c..000000000 --- a/src/core/ozone_platform_eglfs.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef UI_OZONE_PLATFORM_EGLFS_OZONE_PLATFORM_EGLFS_H_ -#define UI_OZONE_PLATFORM_EGLFS_OZONE_PLATFORM_EGLFS_H_ - -#if defined(USE_OZONE) - -#include "ui/ozone/public/ozone_platform.h" - -#include "surface_factory_qt.h" - -namespace ui { - -class DeviceManager; -class EventFactoryEvdev; -class CursorFactoryOzone; - -class OzonePlatformEglfs : public OzonePlatform { - public: - OzonePlatformEglfs(); - virtual ~OzonePlatformEglfs(); - - virtual ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override; - virtual ui::CursorFactoryOzone* GetCursorFactoryOzone() override; - virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() override; - virtual std::unique_ptr CreatePlatformWindow( - PlatformWindowDelegate* delegate, - const gfx::Rect& bounds) override; - virtual std::unique_ptr CreateNativeDisplayDelegate() override; - virtual ui::InputController* GetInputController() override; - virtual std::unique_ptr CreateSystemInputInjector() override; - virtual ui::OverlayManagerOzone* GetOverlayManager() override; - - private: - virtual void InitializeUI() override; - virtual void InitializeGPU() override; - std::unique_ptr device_manager_; - - std::unique_ptr surface_factory_ozone_; - std::unique_ptr cursor_factory_ozone_; - std::unique_ptr event_factory_ozone_; - - std::unique_ptr gpu_platform_support_host_; - std::unique_ptr input_controller_; - std::unique_ptr overlay_manager_; - - DISALLOW_COPY_AND_ASSIGN(OzonePlatformEglfs); -}; - -// Constructor hook for use in ozone_platform_list.cc -OzonePlatform* CreateOzonePlatformEglfs(); - -} // namespace ui - -#endif // defined(USE_OZONE) -#endif // UI_OZONE_PLATFORM_EGLFS_OZONE_PLATFORM_EGLFS_H_ diff --git a/src/core/ozone_platform_qt.cpp b/src/core/ozone_platform_qt.cpp new file mode 100644 index 000000000..54626f0aa --- /dev/null +++ b/src/core/ozone_platform_qt.cpp @@ -0,0 +1,236 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "ozone_platform_qt.h" + +#if defined(USE_OZONE) + +#include "base/bind.h" +#include "base/memory/ptr_util.h" +#include "ui/events/ozone/events_ozone.h" +#include "ui/events/platform/platform_event_dispatcher.h" +#include "ui/events/platform/platform_event_source.h" +#include "ui/ozone/common/native_display_delegate_ozone.h" +#include "ui/ozone/common/stub_client_native_pixmap_factory.h" +#include "ui/ozone/common/stub_overlay_manager.h" +#include "ui/ozone/public/ozone_platform.h" +#include "ui/ozone/public/cursor_factory_ozone.h" +#include "ui/ozone/public/gpu_platform_support_host.h" +#include "ui/ozone/public/input_controller.h" +#include "ui/ozone/public/system_input_injector.h" +#include "ui/platform_window/platform_window.h" +#include "ui/platform_window/platform_window_delegate.h" + +#include "surface_factory_qt.h" + +namespace ui { + +namespace { + +class PlatformWindowQt : public PlatformWindow, public PlatformEventDispatcher +{ +public: + PlatformWindowQt(PlatformWindowDelegate* delegate, + const gfx::Rect& bounds) + : delegate_(delegate) + , bounds_(bounds) + { + ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); + } + + ~PlatformWindowQt() override + { + ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); + } + + // PlatformWindow: + gfx::Rect GetBounds() override; + void SetBounds(const gfx::Rect& bounds) override; + void Show() override { } + void Hide() override { } + void Close() override { } + void SetTitle(const base::string16&) override { } + void SetCapture() override { } + void ReleaseCapture() override { } + void ToggleFullscreen() override { } + void Maximize() override { } + void Minimize() override { } + void Restore() override { } + void SetCursor(PlatformCursor) override { } + void MoveCursorTo(const gfx::Point&) override { } + void ConfineCursorToBounds(const gfx::Rect&) override { } + PlatformImeController* GetPlatformImeController() override { return nullptr; } + // PlatformEventDispatcher: + bool CanDispatchEvent(const PlatformEvent& event) override; + uint32_t DispatchEvent(const PlatformEvent& event) override; + +private: + PlatformWindowDelegate* delegate_; + gfx::Rect bounds_; + + DISALLOW_COPY_AND_ASSIGN(PlatformWindowQt); +}; + +gfx::Rect PlatformWindowQt::GetBounds() +{ + return bounds_; +} + +void PlatformWindowQt::SetBounds(const gfx::Rect& bounds) +{ + if (bounds == bounds_) + return; + bounds_ = bounds; + delegate_->OnBoundsChanged(bounds); +} + +bool PlatformWindowQt::CanDispatchEvent(const ui::PlatformEvent& /*ne*/) +{ + return true; +} + +uint32_t PlatformWindowQt::DispatchEvent(const ui::PlatformEvent& native_event) +{ + DispatchEventFromNativeUiEvent( + native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent, + base::Unretained(delegate_))); + + return ui::POST_DISPATCH_STOP_PROPAGATION; +} + +class OzonePlatformQt : public OzonePlatform { +public: + OzonePlatformQt(); + ~OzonePlatformQt() override; + + ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override; + ui::CursorFactoryOzone* GetCursorFactoryOzone() override; + GpuPlatformSupportHost* GetGpuPlatformSupportHost() override; + std::unique_ptr CreatePlatformWindow(PlatformWindowDelegate* delegate, const gfx::Rect& bounds) override; + std::unique_ptr CreateNativeDisplayDelegate() override; + ui::InputController* GetInputController() override; + std::unique_ptr CreateSystemInputInjector() override; + ui::OverlayManagerOzone* GetOverlayManager() override; + +private: + void InitializeUI() override; + void InitializeGPU() override; + + std::unique_ptr surface_factory_ozone_; + std::unique_ptr cursor_factory_ozone_; + + std::unique_ptr gpu_platform_support_host_; + std::unique_ptr input_controller_; + std::unique_ptr overlay_manager_; + + DISALLOW_COPY_AND_ASSIGN(OzonePlatformQt); +}; + + +OzonePlatformQt::OzonePlatformQt() {} + +OzonePlatformQt::~OzonePlatformQt() {} + +ui::SurfaceFactoryOzone* OzonePlatformQt::GetSurfaceFactoryOzone() +{ + return surface_factory_ozone_.get(); +} + +ui::CursorFactoryOzone* OzonePlatformQt::GetCursorFactoryOzone() +{ + return cursor_factory_ozone_.get(); +} + +GpuPlatformSupportHost* OzonePlatformQt::GetGpuPlatformSupportHost() +{ + return gpu_platform_support_host_.get(); +} + +std::unique_ptr OzonePlatformQt::CreatePlatformWindow(PlatformWindowDelegate* delegate, const gfx::Rect& bounds) +{ + return base::WrapUnique(new PlatformWindowQt(delegate, bounds)); +} + +ui::InputController* OzonePlatformQt::GetInputController() +{ + return input_controller_.get(); +} + +std::unique_ptr OzonePlatformQt::CreateSystemInputInjector() +{ + return nullptr; // no input injection support. +} + +ui::OverlayManagerOzone* OzonePlatformQt::GetOverlayManager() +{ + return overlay_manager_.get(); +} + +std::unique_ptr OzonePlatformQt::CreateNativeDisplayDelegate() +{ + return base::WrapUnique(new NativeDisplayDelegateOzone()); +} + +void OzonePlatformQt::InitializeUI() +{ + overlay_manager_.reset(new StubOverlayManager()); + cursor_factory_ozone_.reset(new CursorFactoryOzone()); + gpu_platform_support_host_.reset(ui::CreateStubGpuPlatformSupportHost()); + input_controller_ = CreateStubInputController(); +} + +void OzonePlatformQt::InitializeGPU() +{ + surface_factory_ozone_.reset(new QtWebEngineCore::SurfaceFactoryQt()); +} + +} // namespace + + +OzonePlatform* CreateOzonePlatformQt() { return new OzonePlatformQt; } + +ClientNativePixmapFactory* CreateClientNativePixmapFactoryQt() +{ + return CreateStubClientNativePixmapFactory(); +} + +} // namespace ui + +#endif + diff --git a/src/core/ozone_platform_qt.h b/src/core/ozone_platform_qt.h new file mode 100644 index 000000000..8b92b817d --- /dev/null +++ b/src/core/ozone_platform_qt.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef UI_OZONE_PLATFORM_EGLFS_OZONE_PLATFORM_QT_H_ +#define UI_OZONE_PLATFORM_EGLFS_OZONE_PLATFORM_QT_H_ + +#if defined(USE_OZONE) + +#include "ui/ozone/public/ozone_platform.h" + +namespace ui { + +// Constructor hook for use in ozone_platform_list.cc +OzonePlatform* CreateOzonePlatformQt(); + +} // namespace ui + +#endif // defined(USE_OZONE) +#endif // UI_OZONE_PLATFORM_EGLFS_OZONE_PLATFORM_QT_H_ -- cgit v1.2.3