diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-11-01 18:22:21 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-11-01 19:03:09 +0100 |
commit | 3d0d0afe573d1c568f1f5c0eba647eff993dcb81 (patch) | |
tree | 4c05b09f478233f3156c7f4c1a5cb0fb5ee2a597 /src/core | |
parent | 30aa9c7bf0f1eceda8516fd5de87dc8e2cff1758 (diff) | |
parent | 399d77a38ff52d33dc871a5b221db253308b7436 (diff) |
Merge branch '5.9' into 5.10
Conflicts:
.qmake.conf
src/core/core_module.pro
src/core/delegated_frame_node.cpp
src/core/surface_factory_qt.cpp
src/webenginewidgets/api/qwebengineprofile.cpp
tests/auto/widgets/widgets.pro
Change-Id: I92f3ef4eee779afef6c5381a7aa8b551417c1b17
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/api/core_api.pro | 8 | ||||
-rw-r--r-- | src/core/content_main_delegate_qt.cpp | 34 | ||||
-rw-r--r-- | src/core/core_module.pro | 4 | ||||
-rw-r--r-- | src/core/delegated_frame_node.cpp | 45 | ||||
-rw-r--r-- | src/core/delegated_frame_node.h | 3 | ||||
-rw-r--r-- | src/core/surface_factory_qt.cpp | 30 | ||||
-rw-r--r-- | src/core/type_conversion.h | 5 |
7 files changed, 107 insertions, 22 deletions
diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro index 05166536e..270595378 100644 --- a/src/core/api/core_api.pro +++ b/src/core/api/core_api.pro @@ -55,3 +55,11 @@ unix:!isEmpty(QMAKE_LFLAGS_VERSION_SCRIPT):!static { SOURCES += qtbug-60565.cpp \ qtbug-61521.cpp } + +msvc { + # Create a list of object files that can be used as response file for the linker. + # This is done to simulate -whole-archive on MSVC. + QMAKE_POST_LINK = \ + "if exist $(DESTDIR_TARGET).objects del $(DESTDIR_TARGET).objects$$escape_expand(\\n\\t)" \ + "for %%a in ($(OBJECTS)) do echo $$shell_quote($$shell_path($$OUT_PWD))\\%%a >> $(DESTDIR_TARGET).objects" +} diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp index 720db77bf..359e0b3d9 100644 --- a/src/core/content_main_delegate_qt.cpp +++ b/src/core/content_main_delegate_qt.cpp @@ -40,19 +40,23 @@ #include "content_main_delegate_qt.h" #include "base/command_line.h" +#include <base/i18n/rtl.h> #include "base/logging.h" #include "base/path_service.h" #include "base/strings/string_number_conversions.h" +#include <chrome/grit/generated_resources.h> #include "content/public/common/content_paths.h" #include "content/public/common/content_switches.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/ui_base_paths.h" #include "ui/base/resource/resource_bundle.h" +#include <ui/base/webui/jstemplate_builder.h> #include "net/grit/net_resources.h" #include "net/base/net_module.h" #include "content_client_qt.h" #include "renderer/content_renderer_client_qt.h" +#include "type_conversion.h" #include "web_engine_library_info.h" #if defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX)) @@ -63,12 +67,38 @@ #include "ui/base/ui_base_switches.h" #endif +#include <QtCore/qcoreapplication.h> + namespace QtWebEngineCore { +// The logic of this function is based on chrome/common/net/net_resource_provider.cc +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE.Chromium file. +static std::string constructDirHeaderHTML() +{ + base::DictionaryValue dict; + dict.SetString("header", l10n_util::GetStringUTF16(IDS_DIRECTORY_LISTING_HEADER)); + dict.SetString("parentDirText", l10n_util::GetStringUTF16(IDS_DIRECTORY_LISTING_PARENT)); + dict.SetString("headerName", l10n_util::GetStringUTF16(IDS_DIRECTORY_LISTING_NAME)); + dict.SetString("headerSize", l10n_util::GetStringUTF16(IDS_DIRECTORY_LISTING_SIZE)); + dict.SetString("headerDateModified", + l10n_util::GetStringUTF16(IDS_DIRECTORY_LISTING_DATE_MODIFIED)); + dict.SetString("language", l10n_util::GetLanguage(base::i18n::GetConfiguredLocale())); + dict.SetString("listingParsingErrorBoxText", + l10n_util::GetStringFUTF16(IDS_DIRECTORY_LISTING_PARSING_ERROR_BOX_TEXT, + toString16(QCoreApplication::applicationName()))); + dict.SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr"); + std::string html = webui::GetI18nTemplateHtml( + ui::ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_DIR_HEADER_HTML), + &dict); + return html; +} + static base::StringPiece PlatformResourceProvider(int key) { if (key == IDR_DIR_HEADER_HTML) { - base::StringPiece html_data = ui::ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_DIR_HEADER_HTML); - return html_data; + static std::string html_data = constructDirHeaderHTML(); + return base::StringPiece(html_data); } return base::StringPiece(); } diff --git a/src/core/core_module.pro b/src/core/core_module.pro index 55b20cda2..78bb8baee 100644 --- a/src/core/core_module.pro +++ b/src/core/core_module.pro @@ -61,7 +61,9 @@ osx { QMAKE_LFLAGS_DEBUG -= /DEBUG QMAKE_LFLAGS_DEBUG += /DEBUG:FASTLINK } - QMAKE_LFLAGS += /WHOLEARCHIVE:$${api_library_path}$${QMAKE_DIR_SEP}$${api_library_name}.lib + # Simulate -whole-archive by passing the list of object files that belong to the public + # API library as response file to the linker. + QMAKE_LFLAGS += @$${api_library_path}$${QMAKE_DIR_SEP}$${api_library_name}.lib.objects } else { LIBS_PRIVATE += -Wl,-whole-archive -l$$api_library_name -Wl,-no-whole-archive } diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp index d0d840ecb..d6ee87950 100644 --- a/src/core/delegated_frame_node.cpp +++ b/src/core/delegated_frame_node.cpp @@ -849,8 +849,8 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, // countering the scale of devicePixel-scaled tiles when rendering them // to the final surface. QMatrix4x4 matrix; - matrix.scale(1 / m_chromiumCompositorData->frameDevicePixelRatio, - 1 / m_chromiumCompositorData->frameDevicePixelRatio); + const float devicePixelRatio = m_chromiumCompositorData->frameDevicePixelRatio; + matrix.scale(1 / devicePixelRatio, 1 / devicePixelRatio); if (QSGTransformNode::matrix() != matrix) setMatrix(matrix); @@ -872,11 +872,19 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, frameData->resource_list.clear(); QScopedPointer<DelegatedNodeTreeHandler> nodeHandler; + const QSizeF viewportSizeInPt = apiDelegate->screenRect().size(); + const QSize viewportSize = (viewportSizeInPt * devicePixelRatio).toSize(); + // We first compare if the render passes from the previous frame data are structurally // equivalent to the render passes in the current frame data. If they are, we are going // to reuse the old nodes. Otherwise, we will delete the old nodes and build a new tree. - cc::CompositorFrame *previousFrameData = &m_chromiumCompositorData->previousFrameData; - const bool buildNewTree = !areRenderPassStructuresEqual(frameData, previousFrameData) || m_sceneGraphNodes.empty(); + // + // Additionally, because we clip (i.e. don't build scene graph nodes for) quads outside + // of the visible area, we also have to rebuild the tree whenever the window is resized. + const bool buildNewTree = + !areRenderPassStructuresEqual(frameData, &m_chromiumCompositorData->previousFrameData) || + m_sceneGraphNodes.empty() || + viewportSize != m_previousViewportSize; m_chromiumCompositorData->previousFrameData = cc::CompositorFrame(); SGObjects previousSGObjects; @@ -904,10 +912,7 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, // All RenderPasses except the last one are rendered to an FBO. cc::RenderPass *rootRenderPass = frameData->render_pass_list.back().get(); - QRectF screenRectQt = apiDelegate->screenRect(); - gfx::Size thisSize(int(screenRectQt.width() * m_chromiumCompositorData->frameDevicePixelRatio), - int(screenRectQt.height() * m_chromiumCompositorData->frameDevicePixelRatio)); - + gfx::Rect viewportRect(toGfx(viewportSize)); for (unsigned i = 0; i < frameData->render_pass_list.size(); ++i) { cc::RenderPass *pass = frameData->render_pass_list.at(i).get(); @@ -939,12 +944,14 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, scissorRect = pass->output_rect; } else { renderPassParent = this; - scissorRect = gfx::Rect(thisSize); + scissorRect = viewportRect; scissorRect += rootRenderPass->output_rect.OffsetFromOrigin(); } - if (scissorRect.IsEmpty()) + if (scissorRect.IsEmpty()) { + holdResources(pass, resourceCandidates); continue; + } QSGNode *renderPassChain = nullptr; if (buildNewTree) @@ -967,8 +974,10 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, if (quadState->is_clipped) targetRect.Intersect(quadState->clip_rect); targetRect.Intersect(scissorRect); - if (targetRect.IsEmpty()) + if (targetRect.IsEmpty()) { + holdResources(quad, resourceCandidates); continue; + } if (quadState->sorting_context_id != currentSortingContextId) { flushPolygons(&polygonQueue, renderPassChain, @@ -1007,6 +1016,8 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, ResourceHolderIterator end = resourceCandidates.constEnd(); for (ResourceHolderIterator it = resourceCandidates.constBegin(); it != end ; ++it) resourcesToRelease->push_back((*it)->returnResource()); + + m_previousViewportSize = viewportSize; } void DelegatedFrameNode::flushPolygons( @@ -1224,6 +1235,18 @@ ResourceHolder *DelegatedFrameNode::findAndHoldResource(unsigned resourceId, QHa return resource.data(); } +void DelegatedFrameNode::holdResources(const cc::DrawQuad *quad, QHash<unsigned, QSharedPointer<ResourceHolder> > &candidates) +{ + for (auto resource : quad->resources) + findAndHoldResource(resource, candidates); +} + +void DelegatedFrameNode::holdResources(const cc::RenderPass *pass, QHash<unsigned, QSharedPointer<ResourceHolder> > &candidates) +{ + for (const auto &quad : pass->quad_list) + holdResources(quad, candidates); +} + QSGTexture *DelegatedFrameNode::initAndHoldTexture(ResourceHolder *resource, bool quadIsAllOpaque, RenderWidgetHostViewQtDelegate *apiDelegate) { // QSGTextures must be destroyed in the scene graph thread as part of the QSGNode tree, diff --git a/src/core/delegated_frame_node.h b/src/core/delegated_frame_node.h index b83f4682a..c627cdf95 100644 --- a/src/core/delegated_frame_node.h +++ b/src/core/delegated_frame_node.h @@ -126,6 +126,8 @@ private: static void fenceAndUnlockQt(DelegatedFrameNode *frameNode); ResourceHolder *findAndHoldResource(unsigned resourceId, QHash<unsigned, QSharedPointer<ResourceHolder> > &candidates); + void holdResources(const cc::DrawQuad *quad, QHash<unsigned, QSharedPointer<ResourceHolder> > &candidates); + void holdResources(const cc::RenderPass *pass, QHash<unsigned, QSharedPointer<ResourceHolder> > &candidates); QSGTexture *initAndHoldTexture(ResourceHolder *resource, bool quadIsAllOpaque, RenderWidgetHostViewQtDelegate *apiDelegate = 0); QExplicitlySharedDataPointer<ChromiumCompositorData> m_chromiumCompositorData; @@ -143,6 +145,7 @@ private: bool m_contextShared; QScopedPointer<QOffscreenSurface> m_offsurface; #endif + QSize m_previousViewportSize; }; } // namespace QtWebEngineCore diff --git a/src/core/surface_factory_qt.cpp b/src/core/surface_factory_qt.cpp index d0741506a..c976e8b04 100644 --- a/src/core/surface_factory_qt.cpp +++ b/src/core/surface_factory_qt.cpp @@ -56,7 +56,13 @@ #if defined(USE_OZONE) #include <EGL/egl.h> -#include <dlfcn.h> + +#ifndef QT_LIBDIR_EGL +#define QT_LIBDIR_EGL "/usr/lib" +#endif +#ifndef QT_LIBDIR_GLES2 +#define QT_LIBDIR_GLES2 QT_LIBDIR_EGL +#endif namespace QtWebEngineCore { @@ -92,21 +98,29 @@ base::NativeLibrary LoadLibrary(const base::FilePath& filename) { bool GLOzoneQt::LoadGLES2Bindings(gl::GLImplementation /*implementation*/) { - base::NativeLibrary eglgles2Library = dlopen(NULL, RTLD_LAZY); - if (!eglgles2Library) { - LOG(ERROR) << "Failed to open EGL/GLES2 context " << dlerror(); + base::FilePath libEGLPath = QtWebEngineCore::toFilePath(QT_LIBDIR_EGL); + libEGLPath = libEGLPath.Append("libEGL.so.1"); + base::NativeLibrary eglLibrary = LoadLibrary(libEGLPath); + if (!eglLibrary) + return false; + + base::FilePath libGLES2Path = QtWebEngineCore::toFilePath(QT_LIBDIR_GLES2); + libGLES2Path = libGLES2Path.Append("libGLESv2.so.2"); + base::NativeLibrary gles2Library = LoadLibrary(libGLES2Path); + if (!gles2Library) return false; - } - gl::GLGetProcAddressProc get_proc_address = reinterpret_cast<gl::GLGetProcAddressProc>(base::GetFunctionPointerFromNativeLibrary(eglgles2Library, "eglGetProcAddress")); + gl::GLGetProcAddressProc get_proc_address = reinterpret_cast<gl::GLGetProcAddressProc>(base::GetFunctionPointerFromNativeLibrary(eglLibrary, "eglGetProcAddress")); if (!get_proc_address) { LOG(ERROR) << "eglGetProcAddress not found."; - base::UnloadNativeLibrary(eglgles2Library); + base::UnloadNativeLibrary(eglLibrary); + base::UnloadNativeLibrary(gles2Library); return false; } gl::SetGLGetProcAddressProc(get_proc_address); - gl::AddGLNativeLibrary(eglgles2Library); + gl::AddGLNativeLibrary(eglLibrary); + gl::AddGLNativeLibrary(gles2Library); return true; } diff --git a/src/core/type_conversion.h b/src/core/type_conversion.h index d9ba735bd..eb7c9d48b 100644 --- a/src/core/type_conversion.h +++ b/src/core/type_conversion.h @@ -142,6 +142,11 @@ inline QRectF toQt(const gfx::RectF &rect) return QRectF(rect.x(), rect.y(), rect.width(), rect.height()); } +inline gfx::Size toGfx(const QSize &size) +{ + return gfx::Size(size.width(), size.height()); +} + inline QSize toQt(const gfx::Size &size) { return QSize(size.width(), size.height()); |