From dee6ffb0eb3b133d38f09a2f7dd915aee8c289e7 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 11 Apr 2017 09:50:38 +0200 Subject: Graphics adaptations for Chromium 58 Change-Id: I66262ce7943bd5ba98defff5e4a33063b2ed0353 Reviewed-by: Peter Varga --- src/core/delegated_frame_node.cpp | 22 +++++--------------- src/core/delegated_frame_node.h | 1 - src/core/gl_context_qt.cpp | 11 +++++----- src/core/gl_context_qt.h | 5 +++-- src/core/gl_surface_qt.cpp | 6 +++++- src/core/qtwebengine_sources.gni | 2 +- src/core/surface_factory_qt.cpp | 42 +++++++++++++++++++++++++++++++++++++-- src/core/surface_factory_qt.h | 7 +++---- 8 files changed, 62 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp index d3b7733a5..9a4d1ba91 100644 --- a/src/core/delegated_frame_node.cpp +++ b/src/core/delegated_frame_node.cpp @@ -1129,27 +1129,15 @@ void DelegatedFrameNode::fetchAndSyncMailboxes(QList &mailboxe QMutexLocker lock(&m_mutex); gpu::SyncPointManager *syncPointManager = sync_point_manager(); - if (!m_syncPointClient) - m_syncPointClient = syncPointManager->CreateSyncPointClientWaiter(); base::MessageLoop *gpuMessageLoop = gpu_message_loop(); Q_ASSERT(m_numPendingSyncPoints == 0); m_numPendingSyncPoints = mailboxesToFetch.count(); - auto it = mailboxesToFetch.constBegin(); - auto end = mailboxesToFetch.constEnd(); - for (; it != end; ++it) { - MailboxTexture *mailboxTexture = *it; + for (MailboxTexture *mailboxTexture : qAsConst(mailboxesToFetch)) { gpu::SyncToken &syncToken = mailboxTexture->mailboxHolder().sync_token; - if (syncToken.HasData()) { - scoped_refptr release_state = - syncPointManager->GetSyncPointClientState(syncToken.namespace_id(), syncToken.command_buffer_id()); - if (release_state && !release_state->IsFenceSyncReleased(syncToken.release_count())) { - m_syncPointClient->WaitOutOfOrderNonThreadSafe( - release_state.get(), syncToken.release_count(), - gpuMessageLoop->task_runner(), base::Bind(&DelegatedFrameNode::pullTexture, this, mailboxTexture)); - continue; - } - } - gpuMessageLoop->task_runner()->PostTask(FROM_HERE, base::Bind(&DelegatedFrameNode::pullTexture, this, mailboxTexture)); + const auto task = base::Bind(&DelegatedFrameNode::pullTexture, this, mailboxTexture); + if (syncPointManager->WaitOutOfOrderNonThreadSafe(syncToken, gpuMessageLoop->task_runner(), task)) + continue; + gpuMessageLoop->task_runner()->PostTask(FROM_HERE, task); } m_mailboxesFetchedWaitCond.wait(&m_mutex); diff --git a/src/core/delegated_frame_node.h b/src/core/delegated_frame_node.h index 0c826663a..b2b87a2f8 100644 --- a/src/core/delegated_frame_node.h +++ b/src/core/delegated_frame_node.h @@ -103,7 +103,6 @@ private: QWaitCondition m_mailboxesFetchedWaitCond; QMutex m_mutex; QList m_textureFences; - std::unique_ptr m_syncPointClient; #if defined(USE_X11) bool m_contextShared; QScopedPointer m_offsurface; diff --git a/src/core/gl_context_qt.cpp b/src/core/gl_context_qt.cpp index 8f812a9cb..cd82b1069 100644 --- a/src/core/gl_context_qt.cpp +++ b/src/core/gl_context_qt.cpp @@ -93,21 +93,20 @@ void GLContextHelper::destroy() contextHelper = 0; } -bool GLContextHelper::initializeContextOnBrowserThread(gl::GLContext* context, gl::GLSurface* surface) +bool GLContextHelper::initializeContextOnBrowserThread(gl::GLContext* context, gl::GLSurface* surface, gl::GLContextAttribs attribs) { - gl::GLContextAttribs attribs; - attribs.gpu_preference = gl::PreferDiscreteGpu; return context->Initialize(surface, attribs); } -bool GLContextHelper::initializeContext(gl::GLContext* context, gl::GLSurface* surface) +bool GLContextHelper::initializeContext(gl::GLContext* context, gl::GLSurface* surface, gl::GLContextAttribs attribs) { bool ret = false; Qt::ConnectionType connType = (QThread::currentThread() == qApp->thread()) ? Qt::DirectConnection : Qt::BlockingQueuedConnection; QMetaObject::invokeMethod(contextHelper, "initializeContextOnBrowserThread", connType, Q_RETURN_ARG(bool, ret), Q_ARG(gl::GLContext*, context), - Q_ARG(gl::GLSurface*, surface)); + Q_ARG(gl::GLSurface*, surface), + Q_ARG(gl::GLContextAttribs, attribs)); return ret; } @@ -171,7 +170,7 @@ scoped_refptr CreateGLContext(GLShareGroup* share_group, scoped_refptr context = new GLContextEGL(share_group); #endif - if (!GLContextHelper::initializeContext(context.get(), compatible_surface)) + if (!GLContextHelper::initializeContext(context.get(), compatible_surface, attribs)) return NULL; return context; diff --git a/src/core/gl_context_qt.h b/src/core/gl_context_qt.h index 47cd7dc7f..9c8a43a0a 100644 --- a/src/core/gl_context_qt.h +++ b/src/core/gl_context_qt.h @@ -41,6 +41,7 @@ #define GL_GL_CONTEXT_QT_H_ #include +#include "ui/gl/gl_context.h" namespace gl { class GLContext; @@ -54,7 +55,7 @@ class GLContextHelper : public QObject { public: static void initialize(); static void destroy(); - static bool initializeContext(gl::GLContext* context, gl::GLSurface* surface); + static bool initializeContext(gl::GLContext* context, gl::GLSurface* surface, gl::GLContextAttribs attribs); static void* getEGLConfig(); static void* getXConfig(); @@ -63,7 +64,7 @@ public: static void* getNativeDisplay(); private: - Q_INVOKABLE bool initializeContextOnBrowserThread(gl::GLContext* context, gl::GLSurface* surface); + Q_INVOKABLE bool initializeContextOnBrowserThread(gl::GLContext* context, gl::GLSurface* surface, gl::GLContextAttribs attribs); static GLContextHelper* contextHelper; }; diff --git a/src/core/gl_surface_qt.cpp b/src/core/gl_surface_qt.cpp index a09196220..e0672f14f 100644 --- a/src/core/gl_surface_qt.cpp +++ b/src/core/gl_surface_qt.cpp @@ -441,6 +441,11 @@ bool GLSurfaceEGL::HasEGLExtension(const char* name) return ExtensionsContain(GetEGLExtensions(), name); } +bool GLSurfaceEGL::InitializeOneOff(EGLNativeDisplayType /*native_display*/) +{ + return GLSurfaceQtEGL::InitializeOneOff(); +} + GLSurfaceQt::GLSurfaceQt(const gfx::Size& size) : m_size(size) { @@ -463,7 +468,6 @@ GLSurfaceQtEGL::GLSurfaceQtEGL(const gfx::Size& size) bool GLSurfaceQtEGL::Initialize(GLSurfaceFormat format) { - Q_UNUSED(format); Q_ASSERT(!m_surfaceBuffer); m_format = format; diff --git a/src/core/qtwebengine_sources.gni b/src/core/qtwebengine_sources.gni index e1bedff54..785c252cb 100644 --- a/src/core/qtwebengine_sources.gni +++ b/src/core/qtwebengine_sources.gni @@ -1,4 +1,5 @@ import("//build/config/features.gni") +import("//build/config/ui.gni") import("//components/spellcheck/spellcheck_build_features.gni") import("//pdf/features.gni") import("//ppapi/features/features.gni") @@ -106,6 +107,5 @@ source_set("qtwebengine_sources") { "//components/printing/renderer", ] } - } diff --git a/src/core/surface_factory_qt.cpp b/src/core/surface_factory_qt.cpp index 36c05ec5d..9e72885c3 100644 --- a/src/core/surface_factory_qt.cpp +++ b/src/core/surface_factory_qt.cpp @@ -44,7 +44,12 @@ #include "base/files/file_path.h" #include "base/native_library.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 @@ -61,6 +66,27 @@ namespace QtWebEngineCore { +class GLOzoneQt : public ui::GLOzoneEGL { +public: + scoped_refptr CreateViewGLSurface(gfx::AcceleratedWidget /*window*/) override + { + return nullptr; + } + scoped_refptr 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() override; + +}; + base::NativeLibrary LoadLibrary(const base::FilePath& filename) { base::NativeLibraryLoadError error; base::NativeLibrary library = base::LoadNativeLibrary(filename, &error); @@ -71,7 +97,7 @@ base::NativeLibrary LoadLibrary(const base::FilePath& filename) { return library; } -bool SurfaceFactoryQt::LoadEGLGLES2Bindings() +bool GLOzoneQt::LoadGLES2Bindings() { base::FilePath libEGLPath = QtWebEngineCore::toFilePath(QT_LIBDIR_EGL); libEGLPath = libEGLPath.Append("libEGL.so.1"); @@ -99,7 +125,7 @@ bool SurfaceFactoryQt::LoadEGLGLES2Bindings() return true; } -intptr_t SurfaceFactoryQt::GetNativeDisplay() +intptr_t GLOzoneQt::GetNativeDisplay() { static void *display = GLContextHelper::getNativeDisplay(); @@ -109,6 +135,18 @@ intptr_t SurfaceFactoryQt::GetNativeDisplay() return reinterpret_cast(EGL_DEFAULT_DISPLAY); } +std::vector SurfaceFactoryQt::GetAllowedGLImplementations() +{ + std::vector 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/surface_factory_qt.h index 76b6dc6ed..b7991829c 100644 --- a/src/core/surface_factory_qt.h +++ b/src/core/surface_factory_qt.h @@ -46,11 +46,10 @@ namespace QtWebEngineCore { -class SurfaceFactoryQt - : public ui::SurfaceFactoryOzone +class SurfaceFactoryQt : public ui::SurfaceFactoryOzone { - bool LoadEGLGLES2Bindings() override; - intptr_t GetNativeDisplay() override; + std::vector GetAllowedGLImplementations() override; + ui::GLOzone* GetGLOzone(gl::GLImplementation implementation) override; }; } // namespace QtWebEngineCore -- cgit v1.2.3