From d2b9c003f87e34ca599d3264a9af371e435ad0f8 Mon Sep 17 00:00:00 2001
From: Andras Becsi <andras.becsi@theqtcompany.com>
Date: Wed, 11 Feb 2015 18:37:38 +0100
Subject: [PATCH] Fix the build on eLinux
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Update ozone layer to the new snapshot, update the
embedded_linux.pri configuration, fix the GLSurfaceQt
build on non-x11 linux and update embedded command line
switches for the 40.0.2214-based chromium snapshot.

This patch also updates the snapshot sha1 to include
required chromium changes.

Change-Id: I7f9446fa1b67a0af7baee564acff41ae33ff1a94
Reviewed-by: Michael Brüning <michael.bruning@theqtcompany.com>
---
 src/3rdparty                       |  2 +-
 src/core/config/embedded_linux.pri |  3 +
 src/core/gl_surface_qt.cpp         |  9 ++-
 src/core/ozone_platform_eglfs.cpp  | 95 ++++++++++++++++++++++++++++--
 src/core/ozone_platform_eglfs.h    | 28 +++++----
 src/core/qtwebengine_extras.gypi   |  3 -
 src/core/surface_factory_qt.cpp    |  4 +-
 src/core/surface_factory_qt.h      |  7 +--
 src/core/web_engine_context.cpp    |  8 +--
 9 files changed, 125 insertions(+), 34 deletions(-)

diff --git a/src/3rdparty b/src/3rdparty
index a43649f5f..888ff83e0 160000
--- a/src/3rdparty
+++ b/src/3rdparty
@@ -1 +1 @@
-Subproject commit a43649f5fb0cd4b284b2b02a010a397e1ff48f8f
+Subproject commit 888ff83e022e24a7f150116c9e5049847a091d30
diff --git a/src/core/config/embedded_linux.pri b/src/core/config/embedded_linux.pri
index 773bf0be1..a0d640c18 100644
--- a/src/core/config/embedded_linux.pri
+++ b/src/core/config/embedded_linux.pri
@@ -2,6 +2,7 @@ GYP_ARGS += "-D qt_os=\"embedded_linux\" -I config/embedded_linux.gypi"
 
 GYP_CONFIG += \
     build_ffmpegsumo=1 \
+    clang=0 \
     configuration_policy=0 \
     desktop_linux=0 \
     disable_nacl=1 \
@@ -23,6 +24,7 @@ GYP_CONFIG += \
     enable_themes=0 \
     enable_webrtc=0 \
     gtest_target_type=none \
+    host_clang=0 \
     notifications=0 \
     ozone_platform_dri=0 \
     ozone_platform_test=0 \
@@ -40,6 +42,7 @@ GYP_CONFIG += \
     use_gio=0 \
     use_gnome_keyring=0 \
     use_kerberos=0 \
+    use_libpci=0 \
     use_openssl=1 \
     use_ozone=1 \
     use_pango=0 \
diff --git a/src/core/gl_surface_qt.cpp b/src/core/gl_surface_qt.cpp
index ad07ce047..85b78cc0e 100644
--- a/src/core/gl_surface_qt.cpp
+++ b/src/core/gl_surface_qt.cpp
@@ -69,6 +69,12 @@ extern "C" {
 #include "ui/gl/gl_context_wgl.h"
 #endif
 
+// From ANGLE's egl/eglext.h.
+#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle
+#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1
+#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200
+#endif
+
 using ui::GetLastEGLErrorString;
 
 namespace gfx {
@@ -357,12 +363,13 @@ bool GLSurface::InitializeOneOffInternal()
     if (GetGLImplementation() == kGLImplementationEGLGLES2)
         return GLSurfaceQtEGL::InitializeOneOff();
 
-    if (GetGLImplementation() == kGLImplementationDesktopGL)
+    if (GetGLImplementation() == kGLImplementationDesktopGL) {
 #if defined(USE_X11)
         return GLSurfaceQtGLX::InitializeOneOff();
 #elif defined(OS_WIN)
         return GLSurfaceQtWGL::InitializeOneOff();
 #endif
+    }
 
     return false;
 }
diff --git a/src/core/ozone_platform_eglfs.cpp b/src/core/ozone_platform_eglfs.cpp
index bf5db4e3f..f646ac2a6 100644
--- a/src/core/ozone_platform_eglfs.cpp
+++ b/src/core/ozone_platform_eglfs.cpp
@@ -38,12 +38,19 @@
 
 #if defined(USE_OZONE)
 
+#include "base/bind.h"
 #include "media/ozone/media_ozone_platform.h"
 #include "ui/events/ozone/device/device_manager.h"
-#include "ui/ozone/ozone_platform.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/public/ozone_platform.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"
+#include "ui/platform_window/platform_window.h"
+#include "ui/platform_window/platform_window_delegate.h"
 
 
 namespace media {
@@ -56,6 +63,73 @@ MediaOzonePlatform* CreateMediaOzonePlatformEglfs() {
 
 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 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 { }
+
+    // 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() {}
@@ -64,10 +138,6 @@ ui::SurfaceFactoryOzone* OzonePlatformEglfs::GetSurfaceFactoryOzone() {
   return surface_factory_ozone_.get();
 }
 
-ui::EventFactoryOzone* OzonePlatformEglfs::GetEventFactoryOzone() {
-  return event_factory_ozone_.get();
-}
-
 ui::CursorFactoryOzone* OzonePlatformEglfs::GetCursorFactoryOzone() {
   return cursor_factory_ozone_.get();
 }
@@ -80,6 +150,21 @@ GpuPlatformSupportHost* OzonePlatformEglfs::GetGpuPlatformSupportHost() {
   return gpu_platform_support_host_.get();
 }
 
+scoped_ptr<PlatformWindow> OzonePlatformEglfs::CreatePlatformWindow(
+      PlatformWindowDelegate* delegate,
+      const gfx::Rect& bounds)
+{
+    return make_scoped_ptr<PlatformWindow>(
+        new EglfsWindow(delegate,
+                          event_factory_ozone_.get(),
+                          bounds));
+}
+
+scoped_ptr<ui::NativeDisplayDelegate> OzonePlatformEglfs::CreateNativeDisplayDelegate()
+{
+    return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone());
+}
+
 OzonePlatform* CreateOzonePlatformEglfs() { return new OzonePlatformEglfs; }
 
 void OzonePlatformEglfs::InitializeUI() {
diff --git a/src/core/ozone_platform_eglfs.h b/src/core/ozone_platform_eglfs.h
index 07b9bf441..2371bb1e8 100644
--- a/src/core/ozone_platform_eglfs.h
+++ b/src/core/ozone_platform_eglfs.h
@@ -39,32 +39,38 @@
 
 #if defined(USE_OZONE)
 
-#include "ui/events/ozone/evdev/event_factory_evdev.h"
-#include "ui/ozone/ozone_platform.h"
+#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::EventFactoryOzone* GetEventFactoryOzone() OVERRIDE;
-  virtual ui::CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE;
-  virtual GpuPlatformSupport* GetGpuPlatformSupport() OVERRIDE;
-  virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() OVERRIDE;
-  virtual void InitializeUI() OVERRIDE;
-  virtual void InitializeGPU() OVERRIDE;
+  virtual ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override;
+  virtual ui::CursorFactoryOzone* GetCursorFactoryOzone() override;
+  virtual GpuPlatformSupport* GetGpuPlatformSupport() override;
+  virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() override;
+  virtual scoped_ptr<PlatformWindow> CreatePlatformWindow(
+      PlatformWindowDelegate* delegate,
+      const gfx::Rect& bounds) override;
+  virtual scoped_ptr<ui::NativeDisplayDelegate> CreateNativeDisplayDelegate() override;
 
  private:
+  virtual void InitializeUI() override;
+  virtual void InitializeGPU() override;
   scoped_ptr<DeviceManager> device_manager_;
 
   scoped_ptr<SurfaceFactoryQt> surface_factory_ozone_;
-  scoped_ptr<ui::CursorFactoryOzone> cursor_factory_ozone_;
-  scoped_ptr<ui::EventFactoryEvdev> event_factory_ozone_;
+  scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_;
+  scoped_ptr<EventFactoryEvdev> event_factory_ozone_;
 
   scoped_ptr<GpuPlatformSupport> gpu_platform_support_;
   scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_;
diff --git a/src/core/qtwebengine_extras.gypi b/src/core/qtwebengine_extras.gypi
index b0e9bc697..c128f289a 100644
--- a/src/core/qtwebengine_extras.gypi
+++ b/src/core/qtwebengine_extras.gypi
@@ -86,9 +86,6 @@
             'EGL_API_FB=1',
             'LINUX=1',
         ],
-        'defines!': [
-            'OPENSSLDIR="/etc/ssl"',
-        ],
         'target_conditions': [
           ['_type=="shared_library"', {
             'ldflags': [
diff --git a/src/core/surface_factory_qt.cpp b/src/core/surface_factory_qt.cpp
index cfa63a651..14e46b946 100644
--- a/src/core/surface_factory_qt.cpp
+++ b/src/core/surface_factory_qt.cpp
@@ -97,7 +97,7 @@ bool SurfaceFactoryQt::LoadEGLGLES2Bindings(AddGLLibraryCallback add_gl_library,
     gfx::AddGLNativeLibrary(eglLibrary);
     gfx::AddGLNativeLibrary(gles2Library);
     return true;
-#endif
+#endif // defined(OS_ANDROID)
 }
 
 intptr_t SurfaceFactoryQt::GetNativeDisplay()
@@ -110,5 +110,5 @@ intptr_t SurfaceFactoryQt::GetNativeDisplay()
     return reinterpret_cast<intptr_t>(EGL_DEFAULT_DISPLAY);
 }
 
-#endif
+#endif // defined(USE_OZONE) || defined(OS_ANDROID)
 
diff --git a/src/core/surface_factory_qt.h b/src/core/surface_factory_qt.h
index ec70d79b1..bd4eba3c9 100644
--- a/src/core/surface_factory_qt.h
+++ b/src/core/surface_factory_qt.h
@@ -48,14 +48,9 @@ class SurfaceFactoryQt
 {
     virtual bool LoadEGLGLES2Bindings(AddGLLibraryCallback add_gl_library, SetGLGetProcAddressProcCallback set_gl_get_proc_address) Q_DECL_OVERRIDE;
     virtual intptr_t GetNativeDisplay() Q_DECL_OVERRIDE;
-    virtual ui::SurfaceFactoryOzone::HardwareState InitializeHardware() Q_DECL_OVERRIDE { return ui::SurfaceFactoryOzone::INITIALIZED; }
-    virtual void ShutdownHardware() Q_DECL_OVERRIDE {}
-    virtual gfx::AcceleratedWidget GetAcceleratedWidget() Q_DECL_OVERRIDE { return 0; }
-    virtual gfx::AcceleratedWidget RealizeAcceleratedWidget(gfx::AcceleratedWidget w) Q_DECL_OVERRIDE { return 0; }
-    virtual bool AttemptToResizeAcceleratedWidget(gfx::AcceleratedWidget w, const gfx::Rect& bounds) Q_DECL_OVERRIDE { return false; }
 };
 
-#endif
+#endif // defined(USE_OZONE) || defined(OS_ANDROID)
 
 #endif // SURFACE_FACTORY_QT
 
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index eb8f8b01d..2e6abd697 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -195,16 +195,13 @@ WebEngineContext::WebEngineContext()
     parsedCommandLine->AppendSwitch(switches::kInProcessGPU);
 
 #if defined(QTWEBENGINE_MOBILE_SWITCHES)
-    // Inspired from the Android port's default switches
+    // Inspired by the Android port's default switches
     parsedCommandLine->AppendSwitch(switches::kEnableOverlayScrollbar);
-    parsedCommandLine->AppendSwitch(switches::kEnableGestureTapHighlight);
     parsedCommandLine->AppendSwitch(switches::kEnablePinch);
     parsedCommandLine->AppendSwitch(switches::kEnableViewport);
     parsedCommandLine->AppendSwitch(switches::kEnableViewportMeta);
-    parsedCommandLine->AppendSwitch(switches::kEnableSmoothScrolling);
+    parsedCommandLine->AppendSwitch(switches::kMainFrameResizesAreOrientationChanges);
     parsedCommandLine->AppendSwitch(switches::kDisableAcceleratedVideoDecode);
-    parsedCommandLine->AppendSwitch(switches::kEnableAcceleratedOverflowScroll);
-    parsedCommandLine->AppendSwitch(switches::kEnableCompositingForFixedPosition);
     parsedCommandLine->AppendSwitch(switches::kDisableGpuShaderDiskCache);
     parsedCommandLine->AppendSwitch(switches::kDisable2dCanvasAntialiasing);
     parsedCommandLine->AppendSwitch(switches::kEnableImplSidePainting);
@@ -217,6 +214,7 @@ WebEngineContext::WebEngineContext()
     // On eAndroid we use this to get the native display
     // from Qt in GLSurfaceEGL::InitializeOneOff.
     m_surfaceFactory.reset(new SurfaceFactoryQt());
+    parsedCommandLine->AppendSwitch(switches::kDisableOverscrollEdgeEffect);
 #endif
 
     GLContextHelper::initialize();
-- 
GitLab