diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri index 213eb0e8944c4e1d58401c9a71a8304e29db01d1..d33aa9677e91a646711c66e9e1c8a6c9b3987709 100644 --- a/src/core/core_chromium.pri +++ b/src/core/core_chromium.pri @@ -80,7 +80,10 @@ SOURCES = \ net/url_request_custom_job_proxy.cpp \ net/url_request_qrc_job_qt.cpp \ net/webui_controller_factory_qt.cpp \ - ozone_platform_qt.cpp \ + ozone/gl_ozone_qt.cpp \ + ozone/ozone_platform_qt.cpp \ + ozone/platform_window_qt.cpp \ + ozone/surface_factory_qt.cpp \ permission_manager_qt.cpp \ process_main.cpp \ quota_permission_context_qt.cpp \ @@ -99,7 +102,6 @@ SOURCES = \ renderer_host/web_channel_ipc_transport_host.cpp \ resource_bundle_qt.cpp \ resource_context_qt.cpp \ - surface_factory_qt.cpp \ type_conversion.cpp \ user_script.cpp \ visited_links_manager_qt.cpp \ @@ -161,7 +163,10 @@ HEADERS = \ net/url_request_custom_job_proxy.h \ net/url_request_qrc_job_qt.h \ net/webui_controller_factory_qt.h \ - ozone_platform_qt.h \ + ozone/gl_ozone_qt.h \ + ozone/ozone_platform_qt.h \ + ozone/platform_window_qt.h \ + ozone/surface_factory_qt.h \ permission_controller.h \ permission_manager_qt.h \ process_main.h \ @@ -184,7 +189,6 @@ HEADERS = \ renderer_host/user_resource_controller_host.h \ renderer_host/web_channel_ipc_transport_host.h \ resource_context_qt.h \ - surface_factory_qt.h \ type_conversion.h \ user_script.h \ visited_links_manager_qt.h \ diff --git a/src/core/surface_factory_qt.cpp b/src/core/ozone/gl_ozone_qt.cpp similarity index 79% rename from src/core/surface_factory_qt.cpp rename to src/core/ozone/gl_ozone_qt.cpp index f1eaf966714979eca8bea1e0ee34be6c6b47420d..81d5ccfa91ecda94d7fe7a1db4b4405f443d5c94 100644 --- a/src/core/surface_factory_qt.cpp +++ b/src/core/ozone/gl_ozone_qt.cpp @@ -37,23 +37,18 @@ ** ****************************************************************************/ -#include "surface_factory_qt.h" - -#include "gl_context_qt.h" -#include "type_conversion.h" +#if defined(USE_OZONE) #include "base/files/file_path.h" #include "base/native_library.h" +#include "gl_context_qt.h" +#include "ozone/gl_ozone_qt.h" #include "ui/gl/gl_context_egl.h" #include "ui/gl/gl_implementation.h" #include "ui/gl/gl_surface.h" -#include "ui/gl/init/gl_initializer.h" #include "ui/gl/init/gl_factory.h" -#include "ui/ozone/common/gl_ozone_egl.h" - -#include <QGuiApplication> +#include "ui/gl/init/gl_initializer.h" -#if defined(USE_OZONE) #include <EGL/egl.h> #include <dlfcn.h> @@ -65,26 +60,6 @@ Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context(); namespace QtWebEngineCore { -class GLOzoneQt : public ui::GLOzoneEGL { -public: - scoped_refptr<gl::GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget /*window*/) override - { - return nullptr; - } - scoped_refptr<gl::GLSurface> CreateOffscreenGLSurface(const gfx::Size& /*size*/) override - { - return nullptr; - } - -protected: - // Returns native platform display handle. This is used to obtain the EGL - // display connection for the native display. - intptr_t GetNativeDisplay() override; - - // Sets up GL bindings for the native surface. - bool LoadGLES2Bindings(gl::GLImplementation implementation) override; -}; - base::NativeLibrary LoadLibrary(const base::FilePath& filename) { base::NativeLibraryLoadError error; base::NativeLibrary library = base::LoadNativeLibrary(filename, &error); @@ -138,19 +113,6 @@ intptr_t GLOzoneQt::GetNativeDisplay() return reinterpret_cast<intptr_t>(EGL_DEFAULT_DISPLAY); } -std::vector<gl::GLImplementation> SurfaceFactoryQt::GetAllowedGLImplementations() -{ - std::vector<gl::GLImplementation> impls; - impls.push_back(gl::kGLImplementationEGLGLES2); - return impls; -} - -ui::GLOzone* SurfaceFactoryQt::GetGLOzone(gl::GLImplementation implementation) -{ - return new GLOzoneQt(); -} - } // namespace QtWebEngineCore #endif // defined(USE_OZONE) - diff --git a/src/core/ozone/gl_ozone_qt.h b/src/core/ozone/gl_ozone_qt.h new file mode 100644 index 0000000000000000000000000000000000000000..8af87974894c317f036dafb2367e550ba56b7633 --- /dev/null +++ b/src/core/ozone/gl_ozone_qt.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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 GL_OZONE_QT +#define GL_OZONE_QT + +#if defined(USE_OZONE) + +#include "ui/ozone/common/gl_ozone_egl.h" + +namespace QtWebEngineCore { + +class GLOzoneQt : public ui::GLOzoneEGL { +public: + scoped_refptr<gl::GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget /*window*/) override + { + return nullptr; + } + scoped_refptr<gl::GLSurface> CreateOffscreenGLSurface(const gfx::Size& /*size*/) override + { + return nullptr; + } + +protected: + // Returns native platform display handle. This is used to obtain the EGL + // display connection for the native display. + intptr_t GetNativeDisplay() override; + + // Sets up GL bindings for the native surface. + bool LoadGLES2Bindings(gl::GLImplementation implementation) override; +}; + +} // namespace QtWebEngineCore + +#endif // defined(USE_OZONE) + +#endif // GL_OZONE_QT diff --git a/src/core/ozone_platform_qt.cpp b/src/core/ozone/ozone_platform_qt.cpp similarity index 68% rename from src/core/ozone_platform_qt.cpp rename to src/core/ozone/ozone_platform_qt.cpp index cf44fa45695d4fc00a267716eedf1b92263890ba..8bb5007ef2b6a99c04b2311957903ce3f2c20a16 100644 --- a/src/core/ozone_platform_qt.cpp +++ b/src/core/ozone/ozone_platform_qt.cpp @@ -37,108 +37,25 @@ ** ****************************************************************************/ -#include "ozone_platform_qt.h" +#include "ozone/ozone_platform_qt.h" #if defined(USE_OZONE) - -#include "base/bind.h" -#include "base/memory/ptr_util.h" +#include "ozone/surface_factory_qt.h" +#include "ozone/platform_window_qt.h" #include "ui/display/types/native_display_delegate.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/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/platform_window/platform_window.h" +#include "ui/ozone/public/ozone_platform.h" #include "ui/platform_window/platform_window_delegate.h" - -#include "surface_factory_qt.h" +#include "ui/platform_window/platform_window.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; - void PrepareForShutdown() 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; -} - -void PlatformWindowQt::PrepareForShutdown() -{ -} - - class OzonePlatformQt : public OzonePlatform { public: OzonePlatformQt(); diff --git a/src/core/ozone_platform_qt.h b/src/core/ozone/ozone_platform_qt.h similarity index 93% rename from src/core/ozone_platform_qt.h rename to src/core/ozone/ozone_platform_qt.h index 8b92b817d697ac1535440f62f9eb939c2371addb..dee66beb342cd436facc52c63af6675cb4adc547 100644 --- a/src/core/ozone_platform_qt.h +++ b/src/core/ozone/ozone_platform_qt.h @@ -37,8 +37,8 @@ ** ****************************************************************************/ -#ifndef UI_OZONE_PLATFORM_EGLFS_OZONE_PLATFORM_QT_H_ -#define UI_OZONE_PLATFORM_EGLFS_OZONE_PLATFORM_QT_H_ +#ifndef OZONE_PLATFORM_QT_H +#define OZONE_PLATFORM_QT_H #if defined(USE_OZONE) @@ -52,4 +52,4 @@ OzonePlatform* CreateOzonePlatformQt(); } // namespace ui #endif // defined(USE_OZONE) -#endif // UI_OZONE_PLATFORM_EGLFS_OZONE_PLATFORM_QT_H_ +#endif // OZONE_PLATFORM_QT_H diff --git a/src/core/ozone/platform_window_qt.cpp b/src/core/ozone/platform_window_qt.cpp new file mode 100644 index 0000000000000000000000000000000000000000..757c042f0c7abf7a7baaf03105d3174fa5777263 --- /dev/null +++ b/src/core/ozone/platform_window_qt.cpp @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#if defined(USE_OZONE) + +#include "base/bind.h" +#include "ozone/platform_window_qt.h" +#include "ui/events/ozone/events_ozone.h" +#include "ui/events/platform/platform_event_source.h" +#include "ui/platform_window/platform_window_delegate.h" + +namespace ui { + +PlatformWindowQt::PlatformWindowQt(PlatformWindowDelegate* delegate, const gfx::Rect& bounds) + : delegate_(delegate) + , bounds_(bounds) +{ + ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); +} + +PlatformWindowQt::~PlatformWindowQt() +{ + ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); +} + +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; +} + +void PlatformWindowQt::PrepareForShutdown() +{ +} + +} // namespace ui + +#endif // defined(USE_OZONE) diff --git a/src/core/ozone/platform_window_qt.h b/src/core/ozone/platform_window_qt.h new file mode 100644 index 0000000000000000000000000000000000000000..d250964322a4558a43d1d971dacba346b79e5442 --- /dev/null +++ b/src/core/ozone/platform_window_qt.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2018 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 PLATFORM_WINDOW_QT_H +#define PLATFORM_WINDOW_QT_H + +#if defined(USE_OZONE) + +#include "ui/events/platform/platform_event_dispatcher.h" +#include "ui/gfx/geometry/point.h" +#include "ui/gfx/geometry/rect.h" +#include "ui/platform_window/platform_window.h" + +namespace ui { + +class PlatformWindowDelegate; + +class PlatformWindowQt : public PlatformWindow, public PlatformEventDispatcher +{ +public: + PlatformWindowQt(PlatformWindowDelegate* delegate, const gfx::Rect& bounds); + ~PlatformWindowQt() override; + // 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; + void PrepareForShutdown() override; + +private: + PlatformWindowDelegate* delegate_; + gfx::Rect bounds_; + + DISALLOW_COPY_AND_ASSIGN(PlatformWindowQt); +}; + +} + +#endif // defined(USE_OZONE) +#endif //PLATFORM_WINDOW_QT_H diff --git a/src/core/ozone/surface_factory_qt.cpp b/src/core/ozone/surface_factory_qt.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b1db44f656a06f65eea2ec9ce755767789387143 --- /dev/null +++ b/src/core/ozone/surface_factory_qt.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#if defined(USE_OZONE) + +#include "ozone/gl_ozone_qt.h" +#include "ozone/surface_factory_qt.h" +#include "ui/gl/gl_surface.h" +namespace QtWebEngineCore { + +std::vector<gl::GLImplementation> SurfaceFactoryQt::GetAllowedGLImplementations() +{ + std::vector<gl::GLImplementation> impls; + impls.push_back(gl::kGLImplementationEGLGLES2); + return impls; +} + +ui::GLOzone* SurfaceFactoryQt::GetGLOzone(gl::GLImplementation implementation) +{ + return new GLOzoneQt(); +} + +} // namespace QtWebEngineCore +#endif // defined(USE_OZONE) + diff --git a/src/core/surface_factory_qt.h b/src/core/ozone/surface_factory_qt.h similarity index 100% rename from src/core/surface_factory_qt.h rename to src/core/ozone/surface_factory_qt.h diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 7154859df8181722b4b8dfd6584074544577346e..56410ecd4c23ad45c4d042a32595cc0379442fa0 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -91,7 +91,7 @@ #include "media_capture_devices_dispatcher.h" #include "net/webui_controller_factory_qt.h" #include "type_conversion.h" -#include "surface_factory_qt.h" +#include "ozone/surface_factory_qt.h" #include "web_engine_library_info.h" #include <QFileInfo>