From 6e49d8444e932ab1c46f72f25443d8866f6c8e9e Mon Sep 17 00:00:00 2001
From: Michal Klocek <michal.klocek@qt.io>
Date: Thu, 22 Mar 2018 15:56:45 +0100
Subject: [PATCH] Split GLSurfaceWGLQt

Refactor GLSurfaceWGLQt to speparte file.
This class is not used by ozone, however is keept
in ozone subdirecotry with other surface classes.

Change-Id: I161582546b597912bc4c1c75ebbc0c1763aebed5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
---
 src/core/core_chromium.pri           |  2 +
 src/core/gl_surface_qt.cpp           | 74 +---------------------
 src/core/ozone/gl_surface_wgl_qt.cpp | 92 ++++++++++++++++++++++++++++
 src/core/ozone/gl_surface_wgl_qt.h   | 74 ++++++++++++++++++++++
 4 files changed, 171 insertions(+), 71 deletions(-)
 create mode 100644 src/core/ozone/gl_surface_wgl_qt.cpp
 create mode 100644 src/core/ozone/gl_surface_wgl_qt.h

diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri
index bec272c79..84866c6cf 100644
--- a/src/core/core_chromium.pri
+++ b/src/core/core_chromium.pri
@@ -83,6 +83,7 @@ SOURCES = \
         ozone/gl_ozone_qt.cpp \
         ozone/gl_surface_egl_qt.cpp \
         ozone/gl_surface_glx_qt.cpp \
+        ozone/gl_surface_wgl_qt.cpp \
         ozone/ozone_platform_qt.cpp \
         ozone/platform_window_qt.cpp \
         ozone/surface_factory_qt.cpp \
@@ -168,6 +169,7 @@ HEADERS = \
         ozone/gl_ozone_qt.h \
         ozone/gl_surface_egl_qt.h \
         ozone/gl_surface_glx_qt.h \
+        ozone/gl_surface_wgl_qt.h \
         ozone/ozone_platform_qt.h \
         ozone/platform_window_qt.h \
         ozone/surface_factory_qt.h \
diff --git a/src/core/gl_surface_qt.cpp b/src/core/gl_surface_qt.cpp
index 54f220f8d..b41ce1d29 100644
--- a/src/core/gl_surface_qt.cpp
+++ b/src/core/gl_surface_qt.cpp
@@ -60,7 +60,7 @@
 #include "ui/gl/init/gl_factory.h"
 
 #if defined(OS_WIN)
-#include "ui/gl/gl_surface_wgl.h"
+#include "ozone/gl_surface_wgl_qt.h"
 #include "ui/gl/gl_context_wgl.h"
 #include "ui/gl/vsync_provider_win.h"
 #endif
@@ -85,74 +85,6 @@ GLSurfaceQt::~GLSurfaceQt()
 {
 }
 
-#if defined(OS_WIN)
-
-class GLSurfaceQtWGL: public GLSurfaceQt {
-public:
-    explicit GLSurfaceQtWGL(const gfx::Size& size);
-
-    static bool InitializeOneOff();
-
-    bool Initialize(GLSurfaceFormat format) override;
-    void Destroy() override;
-    void *GetHandle() override;
-    void *GetDisplay() override;
-    void *GetConfig() override;
-
-protected:
-    ~GLSurfaceQtWGL();
-
-private:
-    scoped_refptr<PbufferGLSurfaceWGL> m_surfaceBuffer;
-    DISALLOW_COPY_AND_ASSIGN(GLSurfaceQtWGL);
-};
-
-GLSurfaceQtWGL::GLSurfaceQtWGL(const gfx::Size& size)
-    : GLSurfaceQt(size),
-      m_surfaceBuffer(0)
-{
-}
-
-GLSurfaceQtWGL::~GLSurfaceQtWGL()
-{
-    Destroy();
-}
-
-bool GLSurfaceQtWGL::InitializeOneOff()
-{
-    return GLSurfaceWGL::InitializeOneOff();
-}
-
-bool GLSurfaceQtWGL::Initialize(GLSurfaceFormat format)
-{
-    m_surfaceBuffer = new PbufferGLSurfaceWGL(m_size);
-    m_format = format;
-
-    return m_surfaceBuffer->Initialize(format);
-}
-
-void GLSurfaceQtWGL::Destroy()
-{
-    m_surfaceBuffer = 0;
-}
-
-void *GLSurfaceQtWGL::GetHandle()
-{
-    return m_surfaceBuffer->GetHandle();
-}
-
-void *GLSurfaceQtWGL::GetDisplay()
-{
-    return m_surfaceBuffer->GetDisplay();
-}
-
-void *GLSurfaceQtWGL::GetConfig()
-{
-    return m_surfaceBuffer->GetConfig();
-}
-
-#endif // defined(OS_WIN)
-
 GLSurfaceQt::GLSurfaceQt()
 {
 }
@@ -219,7 +151,7 @@ bool InitializeGLOneOffPlatform()
 
     if (GetGLImplementation() == kGLImplementationDesktopGL) {
 #if defined(OS_WIN)
-        return GLSurfaceQtWGL::InitializeOneOff();
+        return GLSurfaceWGLQt::InitializeOneOff();
 #elif defined(USE_X11)
         if (GLSurfaceGLXQt::InitializeOneOff())
             return true;
@@ -247,7 +179,7 @@ CreateOffscreenGLSurfaceWithFormat(const gfx::Size& size, GLSurfaceFormat format
     case kGLImplementationDesktopGLCoreProfile:
     case kGLImplementationDesktopGL: {
 #if defined(OS_WIN)
-        surface = new GLSurfaceQtWGL(size);
+        surface = new GLSurfaceWGLQt(size);
         if (surface->Initialize(format))
             return surface;
         break;
diff --git a/src/core/ozone/gl_surface_wgl_qt.cpp b/src/core/ozone/gl_surface_wgl_qt.cpp
new file mode 100644
index 000000000..7c9e87b86
--- /dev/null
+++ b/src/core/ozone/gl_surface_wgl_qt.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#if defined(OS_WIN)
+
+#include "gl_surface_wgl_qt.h"
+#include "ui/gl/gl_surface_wgl.h"
+
+namespace gl {
+
+GLSurfaceWGLQt::GLSurfaceWGLQt(const gfx::Size& size)
+    : GLSurfaceQt(size),
+      m_surfaceBuffer(nullptr)
+{
+}
+
+GLSurfaceWGLQt::~GLSurfaceWGLQt()
+{
+    Destroy();
+}
+
+bool GLSurfaceWGLQt::InitializeOneOff()
+{
+    return GLSurfaceWGL::InitializeOneOff();
+}
+
+bool GLSurfaceWGLQt::Initialize(GLSurfaceFormat format)
+{
+    m_surfaceBuffer = new PbufferGLSurfaceWGL(m_size);
+    m_format = format;
+    return m_surfaceBuffer->Initialize(format);
+}
+
+void GLSurfaceWGLQt::Destroy()
+{
+    m_surfaceBuffer = nullptr;
+}
+
+void *GLSurfaceWGLQt::GetHandle()
+{
+    return m_surfaceBuffer->GetHandle();
+}
+
+void *GLSurfaceWGLQt::GetDisplay()
+{
+    return m_surfaceBuffer->GetDisplay();
+}
+
+void *GLSurfaceWGLQt::GetConfig()
+{
+    return m_surfaceBuffer->GetConfig();
+}
+
+} //namespace gl
+
+#endif // defined(OS_WIN)
diff --git a/src/core/ozone/gl_surface_wgl_qt.h b/src/core/ozone/gl_surface_wgl_qt.h
new file mode 100644
index 000000000..2b562b61b
--- /dev/null
+++ b/src/core/ozone/gl_surface_wgl_qt.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** 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 GL_SURFACE_WGL_QT_H
+#define GL_SURFACE_WGL_QT_H
+
+#include "gl_surface_qt.h"
+
+#if defined(OS_WIN)
+
+namespace gl {
+
+class PbufferGLSurfaceWGL;
+
+class GLSurfaceWGLQt: public GLSurfaceQt {
+public:
+    explicit GLSurfaceWGLQt(const gfx::Size& size);
+
+    static bool InitializeOneOff();
+
+    bool Initialize(GLSurfaceFormat format) override;
+    void Destroy() override;
+    void *GetHandle() override;
+    void *GetDisplay() override;
+    void *GetConfig() override;
+
+protected:
+    ~GLSurfaceWGLQt();
+
+private:
+    scoped_refptr<PbufferGLSurfaceWGL> m_surfaceBuffer;
+    DISALLOW_COPY_AND_ASSIGN(GLSurfaceWGLQt);
+};
+
+}
+#endif // defined(OS_WIN)
+#endif // GL_SURFACE_WGL_QT_H
+
-- 
GitLab