summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2017-01-27 08:36:56 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2017-02-02 12:31:42 +0000
commit6b406688a4020916ba2966e6e5252d9c1385970f (patch)
tree65af619b76adb44fee03f2e496a2e4dc5c455dd8
parent46167faa61861b01a0e4e8e774da9febc3c2956e (diff)
Imported WebKit commit bdab88b903fe1a254c80af20161183976670cd3b
Change-Id: Idc1156f4a64df4e7d89e90d4e03451f004c8ae6d Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
-rw-r--r--Source/CMakeLists.txt2
-rw-r--r--Source/ThirdParty/ANGLE/src/libANGLE/Platform.cpp6
-rw-r--r--Source/WTF/wtf/Compiler.h5
-rw-r--r--Source/WTF/wtf/Platform.h5
-rw-r--r--Source/WTF/wtf/cf/RunLoopCF.cpp129
-rw-r--r--Source/WTF/wtf/cf/TypeCastsCF.h75
-rw-r--r--Source/WTF/wtf/text/cf/AtomicStringImplCF.cpp56
-rw-r--r--Source/WTF/wtf/text/cf/StringCF.cpp64
-rw-r--r--Source/WTF/wtf/text/cf/StringImplCF.cpp157
-rw-r--r--Source/WTF/wtf/text/cf/StringViewCF.cpp46
-rw-r--r--Source/WebCore/CMakeLists.txt6
-rw-r--r--Source/WebCore/PlatformQt.cmake32
-rw-r--r--Source/WebCore/html/HTMLCanvasElement.cpp16
-rw-r--r--Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp4
-rw-r--r--Source/WebCore/platform/FileSystem.h1
-rw-r--r--Source/WebCore/platform/cf/SharedBufferCF.cpp202
-rw-r--r--Source/WebCore/platform/graphics/ANGLEWebKitBridge.h5
-rw-r--r--Source/WebCore/platform/graphics/GraphicsContext.cpp2
-rw-r--r--Source/WebCore/platform/graphics/GraphicsContext3D.h31
-rw-r--r--Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp39
-rw-r--r--Source/WebCore/platform/graphics/ImageBuffer.cpp2
-rw-r--r--Source/WebCore/platform/graphics/ImageBuffer.h12
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp3
-rw-r--r--Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp80
-rw-r--r--Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h10
-rw-r--r--Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp7
-rw-r--r--Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp4
-rw-r--r--Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp162
-rw-r--r--Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp21
-rw-r--r--Source/WebCore/platform/graphics/opengl/TemporaryOpenGLSetting.cpp13
-rw-r--r--Source/WebCore/platform/graphics/opengl/TemporaryOpenGLSetting.h14
-rw-r--r--Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp282
-rw-r--r--Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp16
-rw-r--r--Source/WebCore/platform/graphics/qt/ImageBufferDataQt.cpp538
-rw-r--r--Source/WebCore/platform/graphics/qt/ImageBufferDataQt.h47
-rw-r--r--Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp130
-rw-r--r--Source/WebCore/platform/graphics/qt/OpenGLShimsQt.h206
-rw-r--r--Source/WebCore/platform/graphics/qt/OpenGLShimsQtVAO.h (renamed from Source/WebCore/platform/graphics/gpu/qt/DrawingBufferQt.cpp)41
-rw-r--r--Source/WebCore/platform/graphics/qt/QFramebufferPaintDevice.cpp69
-rw-r--r--Source/WebCore/platform/graphics/qt/QFramebufferPaintDevice.h56
-rw-r--r--Source/WebCore/platform/graphics/qt/StillImageQt.h6
-rw-r--r--Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp16
-rw-r--r--Source/WebCore/platform/graphics/texmap/BitmapTextureImageBuffer.cpp88
-rw-r--r--Source/WebCore/platform/graphics/texmap/BitmapTextureImageBuffer.h60
-rw-r--r--Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp18
-rw-r--r--Source/WebCore/platform/graphics/texmap/BitmapTexturePool.h3
-rw-r--r--Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp3
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapper.cpp8
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapper.h7
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp3
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp125
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h59
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp3
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp9
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h1
-rw-r--r--Source/WebCore/platform/qt/FileSystemQt.cpp6
-rw-r--r--Source/WebCore/platform/qt/QWebPageClient.h2
-rw-r--r--Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp14
-rw-r--r--Source/WebKit/qt/Api/qwebfullscreenrequest.cpp2
-rw-r--r--Source/WebKit/qt/Api/qwebsettings.cpp17
-rw-r--r--Source/WebKit/qt/Api/qwebsettings.h1
-rw-r--r--Source/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp3
-rw-r--r--Source/WebKit/qt/WebCoreSupport/TextureMapperLayerClientQt.cpp23
-rw-r--r--Source/WebKit/qt/WidgetApi/qwebpage.cpp3
-rw-r--r--Source/WebKit/qt/WidgetSupport/PageClientQt.cpp50
-rw-r--r--Source/WebKit/qt/WidgetSupport/PageClientQt.h1
-rw-r--r--Source/WebKit/qt/tests/CMakeLists.txt21
-rw-r--r--Source/WebKit/qt/tests/hybridPixmap/tst_hybridPixmap.qrc (renamed from Source/WebKit/qt/tests/hybridPixmap/resources.qrc)0
-rw-r--r--Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp23
-rw-r--r--Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp23
-rw-r--r--Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp2
-rw-r--r--Source/cmake/OptionsQt.cmake67
-rw-r--r--Source/cmake/WebKitFeatures.cmake1
-rw-r--r--Tools/QtTestBrowser/launcherwindow.cpp61
-rw-r--r--Tools/QtTestBrowser/launcherwindow.h9
-rw-r--r--Tools/QtTestBrowser/qttestbrowser.cpp13
-rw-r--r--Tools/Scripts/webkitperl/FeatureList.pm6
-rw-r--r--Tools/qmake/mkspecs/features/functions.prf13
-rw-r--r--Tools/qmake/projects/run_cmake.pro4
-rwxr-xr-xTools/qt/convert-prl-libs-to-cmake.pl39
-rw-r--r--Tools/qt/jhbuild-qt-5.4.modules59
-rw-r--r--Tools/qt/jhbuild.modules28
-rw-r--r--Tools/qt/jhbuildrc6
-rwxr-xr-xTools/qt/make-snapshot.pl22
-rw-r--r--Tools/qt/manifest.txt5
-rw-r--r--Tools/qt/patches/qtbase-5.4-fontconfig-fix.patch (renamed from Tools/qt/patches/qt-5.4-fontconfig-fix.patch)12
86 files changed, 3078 insertions, 463 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 719c62125..9d9483ecc 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -11,7 +11,7 @@ add_subdirectory(JavaScriptCore)
add_subdirectory(WebCore)
-if (WIN32 AND ENABLE_GRAPHICS_CONTEXT_3D)
+if (${PORT} STREQUAL "Win" AND ENABLE_GRAPHICS_CONTEXT_3D)
add_subdirectory(ThirdParty/ANGLE)
endif ()
diff --git a/Source/ThirdParty/ANGLE/src/libANGLE/Platform.cpp b/Source/ThirdParty/ANGLE/src/libANGLE/Platform.cpp
index ab75bbba5..8687b9ed9 100644
--- a/Source/ThirdParty/ANGLE/src/libANGLE/Platform.cpp
+++ b/Source/ThirdParty/ANGLE/src/libANGLE/Platform.cpp
@@ -16,20 +16,20 @@ angle::Platform *currentPlatform = nullptr;
}
// static
-ANGLE_EXPORT angle::Platform *ANGLEPlatformCurrent()
+angle::Platform *ANGLEPlatformCurrent()
{
return currentPlatform;
}
// static
-ANGLE_EXPORT void ANGLEPlatformInitialize(angle::Platform *platformImpl)
+void ANGLEPlatformInitialize(angle::Platform *platformImpl)
{
ASSERT(platformImpl != nullptr);
currentPlatform = platformImpl;
}
// static
-ANGLE_EXPORT void ANGLEPlatformShutdown()
+void ANGLEPlatformShutdown()
{
currentPlatform = nullptr;
}
diff --git a/Source/WTF/wtf/Compiler.h b/Source/WTF/wtf/Compiler.h
index eca3d6451..c2b808283 100644
--- a/Source/WTF/wtf/Compiler.h
+++ b/Source/WTF/wtf/Compiler.h
@@ -101,6 +101,11 @@
#if defined(_MSC_VER)
#define WTF_COMPILER_MSVC 1
+
+#if _MSC_VER >= 1900
+#define WTF_COMPILER_SUPPORTS_CXX_REFERENCE_QUALIFIED_FUNCTIONS 1
+#endif
+
#endif
#if defined(_MSC_VER) && _MSC_VER < 1800
diff --git a/Source/WTF/wtf/Platform.h b/Source/WTF/wtf/Platform.h
index 9ae58ef48..d42efbdec 100644
--- a/Source/WTF/wtf/Platform.h
+++ b/Source/WTF/wtf/Platform.h
@@ -940,11 +940,6 @@
#define USE_TEXTURE_MAPPER_GL 1
#endif
-/* Compositing on the UI-process in WebKit2 */
-#if USE(3D_GRAPHICS) && PLATFORM(QT)
-#define USE_COORDINATED_GRAPHICS 1
-#endif
-
#if PLATFORM(COCOA)
#define USE_PROTECTION_SPACE_AUTH_CALLBACK 1
#endif
diff --git a/Source/WTF/wtf/cf/RunLoopCF.cpp b/Source/WTF/wtf/cf/RunLoopCF.cpp
new file mode 100644
index 000000000..7e840dd52
--- /dev/null
+++ b/Source/WTF/wtf/cf/RunLoopCF.cpp
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2010, 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "RunLoop.h"
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <dispatch/dispatch.h>
+#include <wtf/AutodrainedPool.h>
+
+namespace WTF {
+
+void RunLoop::performWork(void* context)
+{
+ AutodrainedPool pool;
+ static_cast<RunLoop*>(context)->performWork();
+}
+
+RunLoop::RunLoop()
+ : m_runLoop(CFRunLoopGetCurrent())
+ , m_nestingLevel(0)
+{
+ CFRunLoopSourceContext context = { 0, this, 0, 0, 0, 0, 0, 0, 0, performWork };
+ m_runLoopSource = adoptCF(CFRunLoopSourceCreate(kCFAllocatorDefault, 0, &context));
+ CFRunLoopAddSource(m_runLoop.get(), m_runLoopSource.get(), kCFRunLoopCommonModes);
+}
+
+RunLoop::~RunLoop()
+{
+ CFRunLoopSourceInvalidate(m_runLoopSource.get());
+}
+
+void RunLoop::runForDuration(double duration)
+{
+ CFRunLoopRunInMode(kCFRunLoopDefaultMode, duration, true);
+}
+
+void RunLoop::wakeUp()
+{
+ CFRunLoopSourceSignal(m_runLoopSource.get());
+ CFRunLoopWakeUp(m_runLoop.get());
+}
+
+void RunLoop::run()
+{
+ current().m_nestingLevel++;
+
+ {
+ AutodrainedPool pool;
+ CFRunLoopRun();
+ }
+
+ current().m_nestingLevel--;
+}
+
+void RunLoop::stop()
+{
+ ASSERT(m_runLoop == CFRunLoopGetCurrent());
+ CFRunLoopStop(m_runLoop.get());
+}
+
+// RunLoop::Timer
+
+void RunLoop::TimerBase::timerFired(CFRunLoopTimerRef, void* context)
+{
+ TimerBase* timer = static_cast<TimerBase*>(context);
+
+ AutodrainedPool pool;
+ timer->fired();
+}
+
+RunLoop::TimerBase::TimerBase(RunLoop& runLoop)
+ : m_runLoop(runLoop)
+{
+}
+
+RunLoop::TimerBase::~TimerBase()
+{
+ stop();
+}
+
+void RunLoop::TimerBase::start(double nextFireInterval, bool repeat)
+{
+ if (m_timer)
+ stop();
+
+ CFRunLoopTimerContext context = { 0, this, 0, 0, 0 };
+ CFTimeInterval repeatInterval = repeat ? nextFireInterval : 0;
+ m_timer = adoptCF(CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + nextFireInterval, repeatInterval, 0, 0, timerFired, &context));
+ CFRunLoopAddTimer(m_runLoop.m_runLoop.get(), m_timer.get(), kCFRunLoopCommonModes);
+}
+
+void RunLoop::TimerBase::stop()
+{
+ if (!m_timer)
+ return;
+
+ CFRunLoopTimerInvalidate(m_timer.get());
+ m_timer = nullptr;
+}
+
+bool RunLoop::TimerBase::isActive() const
+{
+ return m_timer && CFRunLoopTimerIsValid(m_timer.get());
+}
+
+} // namespace WTF
diff --git a/Source/WTF/wtf/cf/TypeCastsCF.h b/Source/WTF/wtf/cf/TypeCastsCF.h
new file mode 100644
index 000000000..d525894ac
--- /dev/null
+++ b/Source/WTF/wtf/cf/TypeCastsCF.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TypeCastsCF_h
+#define TypeCastsCF_h
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <wtf/Assertions.h>
+
+namespace WTF {
+
+template <typename> struct CFTypeTrait;
+
+#define DECLARE_CF_TYPE_TRAIT(ClassName) \
+template <> \
+struct CFTypeTrait<ClassName##Ref> { \
+ static inline CFTypeID typeID() { return ClassName##GetTypeID(); } \
+};
+
+DECLARE_CF_TYPE_TRAIT(CFArray);
+DECLARE_CF_TYPE_TRAIT(CFBoolean);
+DECLARE_CF_TYPE_TRAIT(CFData);
+DECLARE_CF_TYPE_TRAIT(CFDictionary);
+DECLARE_CF_TYPE_TRAIT(CFNumber);
+DECLARE_CF_TYPE_TRAIT(CFString);
+
+#undef DECLARE_CF_TYPE_TRAIT
+
+template<typename T> T dynamic_cf_cast(CFTypeRef object)
+{
+ if (!object)
+ return nullptr;
+
+ if (CFGetTypeID(object) != CFTypeTrait<T>::typeID())
+ return nullptr;
+
+ return static_cast<T>(object);
+}
+
+template<typename T> T checked_cf_cast(CFTypeRef object)
+{
+ auto result = dynamic_cf_cast<T>(object);
+ ASSERT_WITH_SECURITY_IMPLICATION(result);
+
+ return result;
+}
+
+} // namespace WTF
+
+using WTF::checked_cf_cast;
+using WTF::dynamic_cf_cast;
+
+#endif // TypeCastsCF_h
diff --git a/Source/WTF/wtf/text/cf/AtomicStringImplCF.cpp b/Source/WTF/wtf/text/cf/AtomicStringImplCF.cpp
new file mode 100644
index 000000000..4a3f15dae
--- /dev/null
+++ b/Source/WTF/wtf/text/cf/AtomicStringImplCF.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include <wtf/text/AtomicStringImpl.h>
+
+#if USE(CF)
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <wtf/text/CString.h>
+
+namespace WTF {
+
+RefPtr<AtomicStringImpl> AtomicStringImpl::add(CFStringRef string)
+{
+ if (!string)
+ return nullptr;
+
+ CFIndex length = CFStringGetLength(string);
+
+ if (const LChar* ptr = reinterpret_cast<const LChar*>(CFStringGetCStringPtr(string, kCFStringEncodingISOLatin1)))
+ return add(ptr, length);
+
+ if (const UniChar* ptr = CFStringGetCharactersPtr(string))
+ return add(reinterpret_cast<const UChar*>(ptr), length);
+
+ Vector<UniChar, 1024> ucharBuffer(length);
+ CFStringGetCharacters(string, CFRangeMake(0, length), ucharBuffer.data());
+ return add(reinterpret_cast<const UChar*>(ucharBuffer.data()), length);
+}
+
+} // namespace WTF
+
+#endif // USE(CF)
diff --git a/Source/WTF/wtf/text/cf/StringCF.cpp b/Source/WTF/wtf/text/cf/StringCF.cpp
new file mode 100644
index 000000000..10ebc0c65
--- /dev/null
+++ b/Source/WTF/wtf/text/cf/StringCF.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2006, 2012 Apple Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include <wtf/text/WTFString.h>
+
+#if USE(CF)
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <wtf/RetainPtr.h>
+
+namespace WTF {
+
+String::String(CFStringRef str)
+{
+ if (!str)
+ return;
+
+ CFIndex size = CFStringGetLength(str);
+ if (size == 0)
+ m_impl = StringImpl::empty();
+ else {
+ Vector<LChar, 1024> lcharBuffer(size);
+ CFIndex usedBufLen;
+ CFIndex convertedsize = CFStringGetBytes(str, CFRangeMake(0, size), kCFStringEncodingISOLatin1, 0, false, lcharBuffer.data(), size, &usedBufLen);
+ if ((convertedsize == size) && (usedBufLen == size)) {
+ m_impl = StringImpl::create(lcharBuffer.data(), size);
+ return;
+ }
+
+ Vector<UChar, 1024> buffer(size);
+ CFStringGetCharacters(str, CFRangeMake(0, size), (UniChar*)buffer.data());
+ m_impl = StringImpl::create(buffer.data(), size);
+ }
+}
+
+RetainPtr<CFStringRef> String::createCFString() const
+{
+ if (!m_impl)
+ return CFSTR("");
+
+ return m_impl->createCFString();
+}
+
+}
+
+#endif // USE(CF)
diff --git a/Source/WTF/wtf/text/cf/StringImplCF.cpp b/Source/WTF/wtf/text/cf/StringImplCF.cpp
new file mode 100644
index 000000000..7bad9a7d1
--- /dev/null
+++ b/Source/WTF/wtf/text/cf/StringImplCF.cpp
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2006, 2009, 2012 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include <wtf/text/StringImpl.h>
+
+#if USE(CF)
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <wtf/MainThread.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/Threading.h>
+
+namespace WTF {
+
+namespace StringWrapperCFAllocator {
+
+ static StringImpl* currentString;
+
+ static const void* retain(const void* info)
+ {
+ return info;
+ }
+
+ NO_RETURN_DUE_TO_ASSERT
+ static void release(const void*)
+ {
+ ASSERT_NOT_REACHED();
+ }
+
+ static CFStringRef copyDescription(const void*)
+ {
+ return CFSTR("WTF::String-based allocator");
+ }
+
+ static void* allocate(CFIndex size, CFOptionFlags, void*)
+ {
+ StringImpl* underlyingString = 0;
+ if (isMainThread()) {
+ underlyingString = currentString;
+ if (underlyingString) {
+ currentString = 0;
+ underlyingString->ref(); // Balanced by call to deref in deallocate below.
+ }
+ }
+ StringImpl** header = static_cast<StringImpl**>(fastMalloc(sizeof(StringImpl*) + size));
+ *header = underlyingString;
+ return header + 1;
+ }
+
+ static void* reallocate(void* pointer, CFIndex newSize, CFOptionFlags, void*)
+ {
+ size_t newAllocationSize = sizeof(StringImpl*) + newSize;
+ StringImpl** header = static_cast<StringImpl**>(pointer) - 1;
+ ASSERT(!*header);
+ header = static_cast<StringImpl**>(fastRealloc(header, newAllocationSize));
+ return header + 1;
+ }
+
+ static void deallocate(void* pointer, void*)
+ {
+ StringImpl** header = static_cast<StringImpl**>(pointer) - 1;
+ StringImpl* underlyingString = *header;
+ if (!underlyingString)
+ fastFree(header);
+ else {
+ if (isMainThread()) {
+ underlyingString->deref(); // Balanced by call to ref in allocate above.
+ fastFree(header);
+ return;
+ }
+
+ callOnMainThread([header] {
+ StringImpl* underlyingString = *header;
+ ASSERT(underlyingString);
+ underlyingString->deref(); // Balanced by call to ref in allocate above.
+ fastFree(header);
+ });
+ }
+ }
+
+ static CFIndex preferredSize(CFIndex size, CFOptionFlags, void*)
+ {
+ // FIXME: If FastMalloc provided a "good size" callback, we'd want to use it here.
+ // Note that this optimization would help performance for strings created with the
+ // allocator that are mutable, and those typically are only created by callers who
+ // make a new string using the old string's allocator, such as some of the call
+ // sites in CFURL.
+ return size;
+ }
+
+ static CFAllocatorRef create()
+ {
+ CFAllocatorContext context = { 0, 0, retain, release, copyDescription, allocate, reallocate, deallocate, preferredSize };
+ return CFAllocatorCreate(0, &context);
+ }
+
+ static CFAllocatorRef allocator()
+ {
+ static CFAllocatorRef allocator = create();
+ return allocator;
+ }
+
+}
+
+RetainPtr<CFStringRef> StringImpl::createCFString()
+{
+ if (!m_length || !isMainThread()) {
+ if (is8Bit())
+ return adoptCF(CFStringCreateWithBytes(0, reinterpret_cast<const UInt8*>(characters8()), m_length, kCFStringEncodingISOLatin1, false));
+ return adoptCF(CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(characters16()), m_length));
+ }
+ CFAllocatorRef allocator = StringWrapperCFAllocator::allocator();
+
+ // Put pointer to the StringImpl in a global so the allocator can store it with the CFString.
+ ASSERT(!StringWrapperCFAllocator::currentString);
+ StringWrapperCFAllocator::currentString = this;
+
+ CFStringRef string;
+ if (is8Bit())
+ string = CFStringCreateWithBytesNoCopy(allocator, reinterpret_cast<const UInt8*>(characters8()), m_length, kCFStringEncodingISOLatin1, false, kCFAllocatorNull);
+ else
+ string = CFStringCreateWithCharactersNoCopy(allocator, reinterpret_cast<const UniChar*>(characters16()), m_length, kCFAllocatorNull);
+ // CoreFoundation might not have to allocate anything, we clear currentString in case we did not execute allocate().
+ StringWrapperCFAllocator::currentString = 0;
+
+ return adoptCF(string);
+}
+
+// On StringImpl creation we could check if the allocator is the StringWrapperCFAllocator.
+// If it is, then we could find the original StringImpl and just return that. But to
+// do that we'd have to compute the offset from CFStringRef to the allocated block;
+// the CFStringRef is *not* at the start of an allocated block. Testing shows 1000x
+// more calls to createCFString than calls to the create functions with the appropriate
+// allocator, so it's probably not urgent optimize that case.
+
+}
+
+#endif // USE(CF)
diff --git a/Source/WTF/wtf/text/cf/StringViewCF.cpp b/Source/WTF/wtf/text/cf/StringViewCF.cpp
new file mode 100644
index 000000000..a3736fda4
--- /dev/null
+++ b/Source/WTF/wtf/text/cf/StringViewCF.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include <wtf/text/StringView.h>
+
+#if USE(CF)
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <wtf/RetainPtr.h>
+
+namespace WTF {
+
+RetainPtr<CFStringRef> StringView::createCFStringWithoutCopying() const
+{
+ if (is8Bit())
+ return adoptCF(CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, characters8(), length(), kCFStringEncodingISOLatin1, false, kCFAllocatorNull));
+
+ return adoptCF(CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, reinterpret_cast<const UniChar*>(characters16()), length(), kCFAllocatorNull));
+}
+
+}
+
+#endif // USE(CF)
diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt
index 51791ac6d..7d0ad0433 100644
--- a/Source/WebCore/CMakeLists.txt
+++ b/Source/WebCore/CMakeLists.txt
@@ -3790,7 +3790,7 @@ if (WebCoreTestSupport_OUTPUT_NAME)
endif ()
endif ()
-if (ENABLE_GRAPHICS_CONTEXT_3D AND NOT WIN32)
+if (ENABLE_GRAPHICS_CONTEXT_3D AND NOT ${PORT} STREQUAL "Win")
add_library(ANGLESupport STATIC ${ANGLESupport_SOURCES})
set_target_properties(ANGLESupport PROPERTIES FOLDER "WebCore")
@@ -3806,6 +3806,10 @@ if (ENABLE_GRAPHICS_CONTEXT_3D AND NOT WIN32)
list(APPEND WebCore_LIBRARIES ANGLESupport)
WEBKIT_SET_EXTRA_COMPILER_FLAGS(ANGLESupport IGNORECXX_WARNINGS)
QT_ADD_EXTRA_WEBKIT_TARGET_EXPORT(ANGLESupport)
+
+ if (WIN32)
+ ADD_TARGET_PROPERTIES(ANGLESupport COMPILE_DEFINITIONS ANGLE_WEBKIT_WIN=1)
+ endif ()
endif ()
target_link_libraries(WebCore ${WebCore_LIBRARIES})
diff --git a/Source/WebCore/PlatformQt.cmake b/Source/WebCore/PlatformQt.cmake
index 3b9e36bef..26883021a 100644
--- a/Source/WebCore/PlatformQt.cmake
+++ b/Source/WebCore/PlatformQt.cmake
@@ -65,7 +65,8 @@ list(APPEND WebCore_SOURCES
platform/graphics/ImageSource.cpp
platform/graphics/WOFFFileFormat.cpp
- platform/graphics/gpu/qt/DrawingBufferQt.cpp
+ platform/graphics/texmap/BitmapTextureImageBuffer.cpp
+ platform/graphics/texmap/TextureMapperImageBuffer.cpp
platform/graphics/qt/ColorQt.cpp
platform/graphics/qt/FloatPointQt.cpp
@@ -80,12 +81,14 @@ list(APPEND WebCore_SOURCES
platform/graphics/qt/GradientQt.cpp
platform/graphics/qt/GraphicsContextQt.cpp
platform/graphics/qt/IconQt.cpp
+ platform/graphics/qt/ImageBufferDataQt.cpp
platform/graphics/qt/ImageBufferQt.cpp
platform/graphics/qt/ImageDecoderQt.cpp
platform/graphics/qt/ImageQt.cpp
platform/graphics/qt/IntPointQt.cpp
platform/graphics/qt/IntRectQt.cpp
platform/graphics/qt/IntSizeQt.cpp
+ platform/graphics/qt/QFramebufferPaintDevice.cpp
platform/graphics/qt/PathQt.cpp
platform/graphics/qt/PatternQt.cpp
platform/graphics/qt/StillImageQt.cpp
@@ -149,6 +152,14 @@ list(APPEND WebCore_SOURCES
platform/text/qt/TextBreakIteratorInternalICUQt.cpp
)
+if (COMPILER_IS_GCC_OR_CLANG)
+ set_source_files_properties(
+ platform/graphics/qt/ImageBufferDataQt.cpp
+ PROPERTIES
+ COMPILE_FLAGS -frtti
+ )
+endif ()
+
if (ENABLE_DEVICE_ORIENTATION)
list(APPEND WebCore_SOURCES
platform/qt/DeviceMotionClientQt.cpp
@@ -251,8 +262,6 @@ endif ()
if (ENABLE_OPENGL)
list(APPEND WebCore_SOURCES
- platform/graphics/OpenGLShims.cpp
-
platform/graphics/opengl/Extensions3DOpenGLCommon.cpp
platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
platform/graphics/opengl/TemporaryOpenGLSetting.cpp
@@ -263,23 +272,16 @@ if (ENABLE_OPENGL)
platform/graphics/opengl/Extensions3DOpenGLES.cpp
platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp
)
- elseif (${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL GL)
+ list(APPEND WebCore_LIBRARIES
+ ${Qt5Gui_EGL_LIBRARIES}
+ ${Qt5Gui_OPENGL_LIBRARIES}
+ )
+ else ()
list(APPEND WebCore_SOURCES
platform/graphics/opengl/Extensions3DOpenGL.cpp
platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
)
- else ()
- message(FATAL_ERROR "Unsupported Qt OpenGL implementation ${Qt5Gui_OPENGL_IMPLEMENTATION}")
endif ()
-
- list(APPEND WebCore_SYSTEM_INCLUDE_DIRECTORIES
- ${Qt5Gui_EGL_INCLUDE_DIRS}
- ${Qt5Gui_OPENGL_INCLUDE_DIRS}
- )
- list(APPEND WebCore_LIBRARIES
- ${Qt5Gui_EGL_LIBRARIES}
- ${Qt5Gui_OPENGL_LIBRARIES}
- )
endif ()
if (USE_GLIB)
diff --git a/Source/WebCore/html/HTMLCanvasElement.cpp b/Source/WebCore/html/HTMLCanvasElement.cpp
index e88911b7a..8ea5b0381 100644
--- a/Source/WebCore/html/HTMLCanvasElement.cpp
+++ b/Source/WebCore/html/HTMLCanvasElement.cpp
@@ -52,6 +52,10 @@
#include <runtime/JSCInlines.h>
#include <runtime/JSLock.h>
+#if PLATFORM(QT)
+#include "QWebPageClient.h"
+#endif
+
#if ENABLE(WEBGL)
#include "WebGLContextAttributes.h"
#include "WebGLRenderingContextBase.h"
@@ -667,7 +671,17 @@ void HTMLCanvasElement::createImageBuffer() const
RenderingMode renderingMode = shouldAccelerate(bufferSize) ? Accelerated : Unaccelerated;
- setImageBuffer(ImageBuffer::create(size(), renderingMode));
+#if PLATFORM(QT) && ENABLE(ACCELERATED_2D_CANVAS)
+ if (renderingMode == Accelerated) {
+ QWebPageClient* client = document().page()->chrome().platformPageClient();
+ // The WebKit2 Chrome does not have a pageclient.
+ QOpenGLContext* context = client ? client->openGLContextIfAvailable() : 0;
+ setImageBuffer(ImageBuffer::createCompatibleBuffer(size(), 1.0f, ColorSpaceDeviceRGB, context));
+ } else
+#endif
+ {
+ setImageBuffer(ImageBuffer::create(size(), renderingMode));
+ }
if (!m_imageBuffer)
return;
m_imageBuffer->context().setShadowsIgnoreTransforms(true);
diff --git a/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp b/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
index bb84d9723..352f42163 100644
--- a/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
+++ b/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
@@ -94,6 +94,10 @@
#include <wtf/text/CString.h>
#include <wtf/text/StringBuilder.h>
+#if PLATFORM(QT)
+#undef emit
+#endif
+
namespace WebCore {
const double secondsBetweenRestoreAttempts = 1.0;
diff --git a/Source/WebCore/platform/FileSystem.h b/Source/WebCore/platform/FileSystem.h
index f3844b8df..2c46e4da0 100644
--- a/Source/WebCore/platform/FileSystem.h
+++ b/Source/WebCore/platform/FileSystem.h
@@ -178,6 +178,7 @@ bool excludeFromBackup(const String&); // Returns true if successful.
WEBCORE_EXPORT Vector<String> listDirectory(const String& path, const String& filter = String());
WEBCORE_EXPORT CString fileSystemRepresentation(const String&);
+String stringFromFileSystemRepresentation(const char*);
inline bool isHandleValid(const PlatformFileHandle& handle) { return handle != invalidPlatformFileHandle; }
diff --git a/Source/WebCore/platform/cf/SharedBufferCF.cpp b/Source/WebCore/platform/cf/SharedBufferCF.cpp
new file mode 100644
index 000000000..21af320d9
--- /dev/null
+++ b/Source/WebCore/platform/cf/SharedBufferCF.cpp
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2008, 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "config.h"
+#include "SharedBuffer.h"
+
+#include <wtf/OSAllocator.h>
+#include <wtf/cf/TypeCastsCF.h>
+
+namespace WebCore {
+
+SharedBuffer::SharedBuffer(CFDataRef cfData)
+ : m_buffer(adoptRef(new DataBuffer))
+ , m_cfData(cfData)
+ , m_vnodeToken(VNodeTracker::singleton().token())
+{
+}
+
+// Using Foundation allows for an even more efficient implementation of this function,
+// so only use this version for non-Foundation.
+#if !USE(FOUNDATION)
+RetainPtr<CFDataRef> SharedBuffer::createCFData()
+{
+ if (m_cfData)
+ return m_cfData;
+
+ // Internal data in SharedBuffer can be segmented. We need to get the contiguous buffer.
+ const Vector<char>& contiguousBuffer = buffer();
+ return adoptCF(CFDataCreate(0, reinterpret_cast<const UInt8*>(contiguousBuffer.data()), contiguousBuffer.size()));
+}
+#endif
+
+PassRefPtr<SharedBuffer> SharedBuffer::wrapCFData(CFDataRef data)
+{
+ return adoptRef(new SharedBuffer(data));
+}
+
+bool SharedBuffer::hasPlatformData() const
+{
+ return m_cfData;
+}
+
+const char* SharedBuffer::platformData() const
+{
+ return reinterpret_cast<const char*>(CFDataGetBytePtr(m_cfData.get()));
+}
+
+unsigned SharedBuffer::platformDataSize() const
+{
+ return CFDataGetLength(m_cfData.get());
+}
+
+void SharedBuffer::hintMemoryNotNeededSoon()
+{
+ if (!hasPlatformData())
+ return;
+ OSAllocator::hintMemoryNotNeededSoon(const_cast<char*>(platformData()), platformDataSize());
+}
+
+void SharedBuffer::maybeTransferPlatformData()
+{
+ if (!m_cfData)
+ return;
+
+ ASSERT(!m_size);
+
+ // Hang on to the m_cfData pointer in a local pointer as append() will re-enter maybeTransferPlatformData()
+ // and we need to make sure to early return when it does.
+ RetainPtr<CFDataRef> cfData = adoptCF(m_cfData.leakRef());
+
+ append(reinterpret_cast<const char*>(CFDataGetBytePtr(cfData.get())), CFDataGetLength(cfData.get()));
+}
+
+void SharedBuffer::clearPlatformData()
+{
+ m_cfData = 0;
+}
+
+bool SharedBuffer::tryReplaceContentsWithPlatformBuffer(SharedBuffer& newContents)
+{
+ if (!newContents.m_cfData)
+ return false;
+
+ clear();
+ m_cfData = newContents.m_cfData;
+ return true;
+}
+
+bool SharedBuffer::maybeAppendPlatformData(SharedBuffer* newContents)
+{
+ if (size() || !newContents->m_cfData)
+ return false;
+ m_cfData = newContents->m_cfData;
+ return true;
+}
+
+#if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
+PassRefPtr<SharedBuffer> SharedBuffer::wrapCFDataArray(CFArrayRef cfDataArray)
+{
+ return adoptRef(new SharedBuffer(cfDataArray));
+}
+
+SharedBuffer::SharedBuffer(CFArrayRef cfDataArray)
+ : m_buffer(adoptRef(new DataBuffer))
+ , m_cfData(nullptr)
+{
+ CFIndex dataArrayCount = CFArrayGetCount(cfDataArray);
+ for (CFIndex index = 0; index < dataArrayCount; ++index)
+ append(checked_cf_cast<CFDataRef>(CFArrayGetValueAtIndex(cfDataArray, index)));
+}
+
+void SharedBuffer::append(CFDataRef data)
+{
+ ASSERT(data);
+ m_dataArray.append(data);
+ m_size += CFDataGetLength(data);
+}
+
+void SharedBuffer::copyBufferAndClear(char* destination, unsigned bytesToCopy) const
+{
+ if (m_dataArray.isEmpty())
+ return;
+
+ CFIndex bytesLeft = bytesToCopy;
+ for (auto& cfData : m_dataArray) {
+ CFIndex dataLen = CFDataGetLength(cfData.get());
+ ASSERT(bytesLeft >= dataLen);
+ memcpy(destination, CFDataGetBytePtr(cfData.get()), dataLen);
+ destination += dataLen;
+ bytesLeft -= dataLen;
+ }
+ m_dataArray.clear();
+}
+
+unsigned SharedBuffer::copySomeDataFromDataArray(const char*& someData, unsigned position) const
+{
+ unsigned totalOffset = 0;
+ for (auto& cfData : m_dataArray) {
+ unsigned dataLen = static_cast<unsigned>(CFDataGetLength(cfData.get()));
+ ASSERT(totalOffset <= position);
+ unsigned localOffset = position - totalOffset;
+ if (localOffset < dataLen) {
+ someData = reinterpret_cast<const char *>(CFDataGetBytePtr(cfData.get())) + localOffset;
+ return dataLen - localOffset;
+ }
+ totalOffset += dataLen;
+ }
+ return 0;
+}
+
+const char *SharedBuffer::singleDataArrayBuffer() const
+{
+ // If we had previously copied data into m_buffer in copyDataArrayAndClear() or some other
+ // function, then we can't return a pointer to the CFDataRef buffer.
+ if (m_buffer->data.size())
+ return 0;
+
+ if (m_dataArray.size() != 1)
+ return 0;
+
+ return reinterpret_cast<const char*>(CFDataGetBytePtr(m_dataArray.at(0).get()));
+}
+
+bool SharedBuffer::maybeAppendDataArray(SharedBuffer* data)
+{
+ if (m_buffer->data.size() || m_cfData || !data->m_dataArray.size())
+ return false;
+#if !ASSERT_DISABLED
+ unsigned originalSize = size();
+#endif
+ for (auto& cfData : data->m_dataArray)
+ append(cfData.get());
+ ASSERT(size() == originalSize + data->size());
+ return true;
+}
+#endif
+
+}
diff --git a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h
index 50684426a..dc5082a45 100644
--- a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h
+++ b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h
@@ -38,6 +38,11 @@
#include "OpenGLESShims.h"
#elif PLATFORM(QT)
#include <qopengl.h>
+
+#ifndef GL_SAMPLER_2D_RECT_ARB
+#define GL_SAMPLER_2D_RECT_ARB 0x8B63
+#endif
+
#elif PLATFORM(GTK) || PLATFORM(EFL)
#if USE(OPENGL_ES_2)
#include <GLES2/gl2.h>
diff --git a/Source/WebCore/platform/graphics/GraphicsContext.cpp b/Source/WebCore/platform/graphics/GraphicsContext.cpp
index 4dfef933f..b4c6f46c4 100644
--- a/Source/WebCore/platform/graphics/GraphicsContext.cpp
+++ b/Source/WebCore/platform/graphics/GraphicsContext.cpp
@@ -993,7 +993,7 @@ void GraphicsContext::setPlatformShouldSmoothFonts(bool)
}
#endif
-#if !USE(CG) && !USE(CAIRO)
+#if !USE(CG) && !USE(CAIRO) && !PLATFORM(QT)
bool GraphicsContext::isAcceleratedContext() const
{
return false;
diff --git a/Source/WebCore/platform/graphics/GraphicsContext3D.h b/Source/WebCore/platform/graphics/GraphicsContext3D.h
index 940394e3b..e7d7f9a7f 100644
--- a/Source/WebCore/platform/graphics/GraphicsContext3D.h
+++ b/Source/WebCore/platform/graphics/GraphicsContext3D.h
@@ -65,6 +65,7 @@ QT_BEGIN_NAMESPACE
class QPainter;
class QRect;
class QOpenGLContext;
+class QOpenGLExtensions;
class QSurface;
QT_END_NAMESPACE
#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN_CAIRO)
@@ -95,14 +96,9 @@ const Platform3DObject NullPlatform3DObject = 0;
namespace WebCore {
class Extensions3D;
-#if USE(OPENGL_ES_2)
+class Extensions3DOpenGLCommon;
class Extensions3DOpenGLES;
-#else
class Extensions3DOpenGL;
-#endif
-#if PLATFORM(QT)
-class Extensions3DQt;
-#endif
class HostWindow;
class Image;
class ImageBuffer;
@@ -690,7 +686,7 @@ public:
ALREADY_SIGNALED = 0x911A,
TIMEOUT_EXPIRED = 0x911B,
CONDITION_SATISFIED = 0x911C,
-#if PLATFORM(WIN)
+#if OS(WINDOWS)
WAIT_FAILED_WIN = 0x911D,
#else
WAIT_FAILED = 0x911D,
@@ -1417,17 +1413,15 @@ private:
String mappedSymbolName(Platform3DObject shaders[2], size_t count, const String& name);
String originalSymbolName(Platform3DObject program, ANGLEShaderSymbolType, const String& name);
+#if !PLATFORM(QT)
ANGLEWebKitBridge m_compiler;
+#endif
std::unique_ptr<ShaderNameHash> nameHashMapForShaders;
-#if (PLATFORM(QT) && defined(QT_OPENGL_ES_2)) || ((PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN)) && USE(OPENGL_ES_2))
- friend class Extensions3DOpenGLES;
- std::unique_ptr<Extensions3DOpenGLES> m_extensions;
-#else
+ std::unique_ptr<Extensions3DOpenGLCommon> m_extensions;
friend class Extensions3DOpenGL;
- std::unique_ptr<Extensions3DOpenGL> m_extensions;
-#endif
+ friend class Extensions3DOpenGLES;
friend class Extensions3DOpenGLCommon;
Attributes m_attrs;
@@ -1470,9 +1464,18 @@ private:
// Errors raised by synthesizeGLError().
ListHashSet<GC3Denum> m_syntheticErrors;
+#if PLATFORM(QT)
+ QOpenGLExtensions* m_functions;
+#endif
+
friend class GraphicsContext3DPrivate;
std::unique_ptr<GraphicsContext3DPrivate> m_private;
-
+
+#if PLATFORM(QT)
+ // Must be initialized after m_private so that isGLES2Compliant works
+ ANGLEWebKitBridge m_compiler;
+#endif
+
WebGLRenderingContextBase* m_webglContext;
};
diff --git a/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp b/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp
index 15cd4df00..aeaefbca0 100644
--- a/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp
+++ b/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp
@@ -121,6 +121,45 @@ void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper& textureMapper
m_context->markLayerComposited();
+ // FIXME: We do not support mask for the moment with TextureMapperImageBuffer.
+ if (textureMapper->accelerationMode() != TextureMapper::OpenGLMode) {
+ GraphicsContext* context = textureMapper->graphicsContext();
+ context->save();
+ context->platformContext()->setGlobalAlpha(opacity);
+
+ const int height = m_context->m_currentHeight;
+ const int width = m_context->m_currentWidth;
+ int totalBytes = width * height * 4;
+
+ auto pixels = std::make_unique<unsigned char[]>(totalBytes);
+ if (!pixels)
+ return;
+
+ // OpenGL keeps the pixels stored bottom up, so we need to flip the image here.
+ context->translate(0, height);
+ context->scale(FloatSize(1, -1));
+
+ context->concatCTM(matrix.toAffineTransform());
+
+ m_context->readRenderingResults(pixels.get(), totalBytes);
+
+ // Premultiply alpha.
+ for (int i = 0; i < totalBytes; i += 4)
+ if (pixels[i + 3] != 255) {
+ pixels[i + 0] = min(255, pixels[i + 0] * pixels[i + 3] / 255);
+ pixels[i + 1] = min(255, pixels[i + 1] * pixels[i + 3] / 255);
+ pixels[i + 2] = min(255, pixels[i + 2] * pixels[i + 3] / 255);
+ }
+
+ RefPtr<cairo_surface_t> imageSurface = adoptRef(cairo_image_surface_create_for_data(
+ const_cast<unsigned char*>(pixels.get()), CAIRO_FORMAT_ARGB32, width, height, width * 4));
+
+ context->platformContext()->drawSurfaceToContext(imageSurface.get(), targetRect, IntRect(0, 0, width, height), context);
+
+ context->restore();
+ return;
+ }
+
#if USE(TEXTURE_MAPPER_GL)
if (m_context->m_attrs.antialias && m_context->m_state.boundFBO == m_context->m_multisampleFBO) {
GLContext* previousActiveContext = GLContext::getCurrent();
diff --git a/Source/WebCore/platform/graphics/ImageBuffer.cpp b/Source/WebCore/platform/graphics/ImageBuffer.cpp
index 2ace73c28..d3c3ae644 100644
--- a/Source/WebCore/platform/graphics/ImageBuffer.cpp
+++ b/Source/WebCore/platform/graphics/ImageBuffer.cpp
@@ -153,10 +153,12 @@ void ImageBuffer::convertToLuminanceMask()
}
#if !USE(CAIRO)
+#if !PLATFORM(QT)
PlatformLayer* ImageBuffer::platformLayer() const
{
return 0;
}
+#endif
bool ImageBuffer::copyToPlatformTexture(GraphicsContext3D&, GC3Denum, Platform3DObject, GC3Denum, bool, bool)
{
diff --git a/Source/WebCore/platform/graphics/ImageBuffer.h b/Source/WebCore/platform/graphics/ImageBuffer.h
index 04f9ef93a..6f48d3db9 100644
--- a/Source/WebCore/platform/graphics/ImageBuffer.h
+++ b/Source/WebCore/platform/graphics/ImageBuffer.h
@@ -40,6 +40,12 @@
#include <wtf/PassRefPtr.h>
#include <wtf/Vector.h>
+#if PLATFORM(QT)
+QT_BEGIN_NAMESPACE
+class QOpenGLContext;
+QT_END_NAMESPACE
+#endif
+
namespace WebCore {
class FloatRect;
@@ -80,6 +86,9 @@ public:
}
static std::unique_ptr<ImageBuffer> createCompatibleBuffer(const FloatSize&, float resolutionScale, ColorSpace, const GraphicsContext&, bool hasAlpha);
+#if PLATFORM(QT) && ENABLE(ACCELERATED_2D_CANVAS)
+ static std::unique_ptr<ImageBuffer> createCompatibleBuffer(const IntSize&, float resolutionScale, ColorSpace, QOpenGLContext*);
+#endif
WEBCORE_EXPORT ~ImageBuffer();
@@ -164,6 +173,9 @@ private:
// This constructor will place its success into the given out-variable
// so that create() knows when it should return failure.
WEBCORE_EXPORT ImageBuffer(const FloatSize&, float resolutionScale, ColorSpace, RenderingMode, bool& success);
+#if PLATFORM(QT) && ENABLE(ACCELERATED_2D_CANVAS)
+ ImageBuffer(const IntSize&, float resolutionScale, ColorSpace, QOpenGLContext*, bool& success);
+#endif
};
#if USE(CG)
diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
index 310a02247..428f432e6 100644
--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
@@ -625,6 +625,9 @@ void MediaPlayerPrivateGStreamerBase::paint(GraphicsContext& context, const Floa
#if USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
void MediaPlayerPrivateGStreamerBase::paintToTextureMapper(TextureMapper& textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity)
{
+ if (textureMapper.accelerationMode() != TextureMapper::OpenGLMode)
+ return;
+
if (!m_player->visible())
return;
diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp
index a0bc40357..51d5db650 100644
--- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp
+++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp
@@ -36,7 +36,14 @@
#include <OpenGLES/ES2/glext.h>
#elif PLATFORM(MAC)
#include <OpenGL/gl.h>
-#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(QT) || PLATFORM(WIN)
+#elif PLATFORM(QT)
+#define FUNCTIONS m_context->m_functions
+#include "OpenGLShimsQt.h"
+#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
+#define VAO_FUNCTIONS m_vaoFunctions
+#include "OpenGLShimsQtVAO.h"
+#endif
+#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN)
#include "OpenGLShims.h"
#endif
@@ -44,15 +51,25 @@
#include "GraphicsContext3DIOS.h"
#endif
+// Note this implementation serves a double role for Qt where it also handles OpenGLES.
+
namespace WebCore {
Extensions3DOpenGL::Extensions3DOpenGL(GraphicsContext3D* context)
: Extensions3DOpenGLCommon(context)
{
+#if PLATFORM(QT) && QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
+ context->makeContextCurrent();
+ m_vaoFunctions = new QOpenGLVertexArrayObjectHelper(context->platformGraphicsContext3D());
+#endif
}
Extensions3DOpenGL::~Extensions3DOpenGL()
{
+#if PLATFORM(QT) && QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
+ delete m_vaoFunctions;
+ m_vaoFunctions = 0;
+#endif
}
@@ -119,6 +136,8 @@ GC3Dboolean Extensions3DOpenGL::isVertexArrayOES(Platform3DObject array)
#elif defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
return glIsVertexArrayAPPLE(array);
#endif
+
+ m_context->synthesizeGLError(GL_INVALID_OPERATION);
return GL_FALSE;
}
@@ -157,6 +176,23 @@ bool Extensions3DOpenGL::supportsExtension(const String& name)
{
// GL_ANGLE_framebuffer_blit and GL_ANGLE_framebuffer_multisample are "fake". They are implemented using other
// extensions. In particular GL_EXT_framebuffer_blit and GL_EXT_framebuffer_multisample/GL_APPLE_framebuffer_multisample.
+#if PLATFORM(QT)
+ m_context->makeContextCurrent();
+
+ if (name == "GL_ANGLE_framebuffer_blit" || name == "GL_EXT_framebuffer_blit")
+ return m_context->m_functions->hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit);
+ if (name == "GL_ANGLE_framebuffer_multisample" || name == "GL_EXT_framebuffer_multisample")
+ return m_context->m_functions->hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample);
+
+ if (name == "GL_OES_texture_npot" || name == "GL_ARB_texture_non_power_of_two")
+ return m_context->m_functions->hasOpenGLFeature(QOpenGLFunctions::NPOTTextures);
+ if (name == "GL_OES_packed_depth_stencil" || name == "GL_EXT_packed_depth_stencil")
+ return m_context->m_functions->hasOpenGLExtension(QOpenGLExtensions::PackedDepthStencil);
+
+ // FIXME: We don't have the robustness methods from Extensions3DOpenGLES.
+ if (name == "GL_EXT_robustness")
+ return false;
+#else
if (name == "GL_ANGLE_framebuffer_blit")
return m_availableExtensions.contains("GL_EXT_framebuffer_blit");
if (name == "GL_ANGLE_framebuffer_multisample")
@@ -165,6 +201,7 @@ bool Extensions3DOpenGL::supportsExtension(const String& name)
#else
return m_availableExtensions.contains("GL_EXT_framebuffer_multisample");
#endif
+#endif // !PLATFORM(QT)
if (name == "GL_ANGLE_instanced_arrays") {
return (m_availableExtensions.contains("GL_ARB_instanced_arrays") || m_availableExtensions.contains("GL_EXT_instanced_arrays"))
@@ -185,6 +222,10 @@ bool Extensions3DOpenGL::supportsExtension(const String& name)
return m_availableExtensions.contains("GL_EXT_frag_depth");
#endif
+#if PLATFORM(QT)
+ if (!m_context->isGLES2Compliant()) {
+#endif
+
// Desktop GL always supports GL_OES_rgb8_rgba8.
if (name == "GL_OES_rgb8_rgba8")
return true;
@@ -194,17 +235,27 @@ bool Extensions3DOpenGL::supportsExtension(const String& name)
if (name == "GL_OES_texture_float" || name == "GL_OES_texture_half_float" || name == "GL_OES_texture_float_linear" || name == "GL_OES_texture_half_float_linear")
return m_availableExtensions.contains("GL_ARB_texture_float") || m_availableExtensions.contains("GL_OES_texture_float");
+#if PLATFORM(QT)
+ }
+#endif
+
// GL_OES_vertex_array_object
if (name == "GL_OES_vertex_array_object") {
-#if (PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL))
+#if (PLATFORM(GTK) || PLATFORM(EFL))
return m_availableExtensions.contains("GL_ARB_vertex_array_object");
#elif PLATFORM(IOS)
return m_availableExtensions.contains("GL_OES_vertex_array_object");
+#elif PLATFORM(QT)
+ return isVertexArrayObjectSupported();
#else
return m_availableExtensions.contains("GL_APPLE_vertex_array_object");
#endif
}
+#if PLATFORM(QT)
+ if (!m_context->isGLES2Compliant()) {
+#endif
+
// Desktop GL always supports the standard derivative functions
if (name == "GL_OES_standard_derivatives")
return true;
@@ -212,6 +263,10 @@ bool Extensions3DOpenGL::supportsExtension(const String& name)
// Desktop GL always supports UNSIGNED_INT indices
if (name == "GL_OES_element_index_uint")
return true;
+
+#if PLATFORM(QT)
+ }
+#endif
if (name == "GL_EXT_shader_texture_lod")
return m_availableExtensions.contains("GL_EXT_shader_texture_lod");
@@ -222,7 +277,7 @@ bool Extensions3DOpenGL::supportsExtension(const String& name)
if (name == "GL_EXT_draw_buffers") {
#if PLATFORM(IOS)
return m_availableExtensions.contains(name);
-#elif PLATFORM(MAC) || PLATFORM(GTK)
+#elif PLATFORM(MAC) || PLATFORM(GTK) || (PLATFORM(QT) && QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
return m_availableExtensions.contains("GL_ARB_draw_buffers");
#else
// FIXME: implement support for other platforms.
@@ -243,7 +298,7 @@ void Extensions3DOpenGL::drawBuffersEXT(GC3Dsizei n, const GC3Denum* bufs)
// FIXME: implement support for other platforms.
#if PLATFORM(MAC)
::glDrawBuffersARB(n, bufs);
-#elif PLATFORM(GTK)
+#elif PLATFORM(GTK) || (PLATFORM(QT) && QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
::glDrawBuffers(n, bufs);
#else
UNUSED_PARAM(n);
@@ -254,7 +309,7 @@ void Extensions3DOpenGL::drawBuffersEXT(GC3Dsizei n, const GC3Denum* bufs)
void Extensions3DOpenGL::drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount)
{
m_context->makeContextCurrent();
-#if PLATFORM(GTK)
+#if PLATFORM(GTK) || (PLATFORM(QT) && QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
::glDrawArraysInstanced(mode, first, count, primcount);
#elif PLATFORM(COCOA)
::glDrawArraysInstancedARB(mode, first, count, primcount);
@@ -269,7 +324,7 @@ void Extensions3DOpenGL::drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Ds
void Extensions3DOpenGL::drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, GC3Dsizei primcount)
{
m_context->makeContextCurrent();
-#if PLATFORM(GTK)
+#if PLATFORM(GTK) || (PLATFORM(QT) && QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
::glDrawElementsInstanced(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)), primcount);
#elif PLATFORM(COCOA)
::glDrawElementsInstancedARB(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)), primcount);
@@ -285,7 +340,7 @@ void Extensions3DOpenGL::drawElementsInstanced(GC3Denum mode, GC3Dsizei count, G
void Extensions3DOpenGL::vertexAttribDivisor(GC3Duint index, GC3Duint divisor)
{
m_context->makeContextCurrent();
-#if PLATFORM(GTK)
+#if PLATFORM(GTK) || (PLATFORM(QT) && QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
::glVertexAttribDivisor(index, divisor);
#elif PLATFORM(COCOA)
::glVertexAttribDivisorARB(index, divisor);
@@ -300,12 +355,21 @@ String Extensions3DOpenGL::getExtensions()
return String(reinterpret_cast<const char*>(::glGetString(GL_EXTENSIONS)));
}
-#if (PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(WIN) || PLATFORM(IOS))
+#if (PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN) || PLATFORM(IOS))
bool Extensions3DOpenGL::isVertexArrayObjectSupported()
{
static const bool supportsVertexArrayObject = supports("GL_OES_vertex_array_object");
return supportsVertexArrayObject;
}
+#elif PLATFORM(QT)
+bool Extensions3DOpenGL::isVertexArrayObjectSupported()
+{
+#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
+ return m_vaoFunctions && m_vaoFunctions->isValid();
+#else
+ return false;
+#endif
+}
#endif
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h
index 2938110c5..fd3512fa2 100644
--- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h
+++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h
@@ -32,6 +32,12 @@
#include <wtf/HashSet.h>
#include <wtf/text/StringHash.h>
+#if PLATFORM(QT)
+QT_BEGIN_NAMESPACE
+class QOpenGLVertexArrayObjectHelper;
+QT_END_NAMESPACE
+#endif
+
namespace WebCore {
class Extensions3DOpenGL : public Extensions3DOpenGLCommon {
@@ -65,6 +71,10 @@ protected:
private:
bool isVertexArrayObjectSupported();
#endif
+
+#if PLATFORM(QT) && QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
+ QOpenGLVertexArrayObjectHelper *m_vaoFunctions;
+#endif
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp
index 93e8cfd8f..62430006b 100644
--- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp
+++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp
@@ -35,13 +35,16 @@
#if PLATFORM(IOS)
#include <OpenGLES/ES2/glext.h>
#else
-#if USE(OPENGL_ES_2)
+#if PLATFORM(QT)
+#define FUNCTIONS m_context->m_functions
+#include "OpenGLShimsQt.h"
+#elif USE(OPENGL_ES_2)
#include "OpenGLESShims.h"
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#elif PLATFORM(MAC)
#include <OpenGL/gl.h>
-#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(QT) || PLATFORM(WIN)
+#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN)
#include "OpenGLShims.h"
#endif
#endif
diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp
index 9199cb84e..27dc6bd5f 100644
--- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp
+++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp
@@ -195,10 +195,14 @@ void Extensions3DOpenGLES::setEXTContextLostCallback(std::unique_ptr<GraphicsCon
void Extensions3DOpenGLES::readnPixelsEXT(int x, int y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, GC3Dsizei bufSize, void *data)
{
if (m_glReadnPixelsEXT) {
+#if PLATFORM(QT)
+ m_context->flush();
+#else
m_context->makeContextCurrent();
// FIXME: remove the two glFlush calls when the driver bug is fixed, i.e.,
// all previous rendering calls should be done before reading pixels.
::glFlush();
+#endif
// FIXME: If non-BlackBerry platforms use this, they will need to implement
// their anti-aliasing code here.
diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
index e1e244985..85da831cc 100644
--- a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
+++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
@@ -1,6 +1,9 @@
/*
* Copyright (C) 2010, 2013 Apple Inc. All rights reserved.
* Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2012 ChangSeok Oh <shivamidow@gmail.com>
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ * Copyright (C) 2014 Digia Plc. and/or its subsidiary(-ies).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -21,11 +24,13 @@
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
+// Note this implementation serves a double role for Qt where it also handles OpenGLES.
+
#if ENABLE(GRAPHICS_CONTEXT_3D)
#include "GraphicsContext3D.h"
@@ -55,16 +60,66 @@
#define GL_RGB32F_ARB 0x8815
#elif PLATFORM(MAC)
#include <OpenGL/gl.h>
-#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(QT) || PLATFORM(WIN)
+#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN)
#include "OpenGLShims.h"
#endif
+#if PLATFORM(QT)
+
+#define FUNCTIONS m_functions
+#include "OpenGLShimsQt.h"
+#include <QOpenGLContext>
+
+#define scopedScissor(c, s) scopedScissor(m_functions, c, s)
+#define scopedDither(c, s) scopedDither(m_functions, c, s)
+#define scopedDepth(c, s) scopedDepth(m_functions, c, s)
+#define scopedStencil(c, s) scopedStencil(m_functions, c, s)
+
+#ifndef GL_BGRA
+#define GL_BGRA 0x80E1
+#endif
+
+#ifndef GL_READ_FRAMEBUFFER
+#define GL_READ_FRAMEBUFFER 0x8CA8
+#endif
+
+#ifndef GL_DRAW_FRAMEBUFFER
+#define GL_DRAW_FRAMEBUFFER 0x8CA9
+#endif
+
+#ifndef GL_MAX_VARYING_FLOATS
+#define GL_MAX_VARYING_FLOATS 0x8B4B
+#endif
+
+#ifndef GL_ALPHA16F_ARB
+#define GL_ALPHA16F_ARB 0x881C
+#endif
+
+#ifndef GL_LUMINANCE16F_ARB
+#define GL_LUMINANCE16F_ARB 0x881E
+#endif
+
+#ifndef GL_LUMINANCE_ALPHA16F_ARB
+#define GL_LUMINANCE_ALPHA16F_ARB 0x881F
+#endif
+
+#ifndef GL_HALF_FLOAT_OES
+#define GL_HALF_FLOAT_OES 0x8D61
+#endif
+
+#endif
+
namespace WebCore {
void GraphicsContext3D::releaseShaderCompiler()
{
makeContextCurrent();
+#if PLATFORM(QT)
+ ASSERT(m_private);
+ m_functions->glReleaseShaderCompiler();
+#else
notImplemented();
+#endif
}
void GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary(int x, int y, int width, int height, unsigned char* pixels)
@@ -93,13 +148,41 @@ void GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary(int x, int y, int
for (int i = 0; i < totalBytes; i += 4)
std::swap(pixels[i], pixels[i + 2]);
#endif
- } else
+ } else {
+#if PLATFORM(QT)
+ ASSERT(m_private);
+ bool readBGRA = !isGLES2Compliant() || platformGraphicsContext3D()->hasExtension("GL_EXT_read_format_bgra");
+
+ if (readBGRA)
+ glReadPixels(x, y, width, height, GL_BGRA, GL_UNSIGNED_BYTE, pixels);
+ else
+ glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+ int totalBytes = width * height * 4;
+ if (!readBGRA) {
+ for (int i = 0; i < totalBytes; i += 4)
+ std::swap(pixels[i], pixels[i + 2]); // Convert to BGRA.
+ }
+#else
::glReadPixels(x, y, width, height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pixels);
+#endif
+ }
}
void GraphicsContext3D::validateAttributes()
{
+#if PLATFORM(QT)
+ if (isGLES2Compliant())
+ validateDepthStencil("GL_OES_packed_depth_stencil");
+ else
+ validateDepthStencil("GL_EXT_packed_depth_stencil");
+
+ if (m_attrs.antialias && isGLES2Compliant()) {
+ if (!m_functions->hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample) || !m_functions->hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit))
+ m_attrs.antialias = false;
+ }
+#else
validateDepthStencil("GL_EXT_packed_depth_stencil");
+#endif
}
bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
@@ -107,13 +190,17 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
const int width = size.width();
const int height = size.height();
GLuint colorFormat, internalDepthStencilFormat = 0;
+ GLuint pixelDataType = 0;
if (m_attrs.alpha) {
- m_internalColorFormat = GL_RGBA8;
+ m_internalColorFormat = isGLES2Compliant() ? GL_RGBA : GL_RGBA8;
colorFormat = GL_RGBA;
+ pixelDataType = GL_UNSIGNED_BYTE;
} else {
- m_internalColorFormat = GL_RGB8;
+ m_internalColorFormat = isGLES2Compliant() ? GL_RGB : GL_RGB8;
colorFormat = GL_RGB;
+ pixelDataType = isGLES2Compliant() ? GL_UNSIGNED_SHORT_5_6_5 : GL_UNSIGNED_BYTE;
}
+
if (m_attrs.stencil || m_attrs.depth) {
// We don't allow the logic where stencil is required and depth is not.
// See GraphicsContext3D::validateAttributes.
@@ -131,7 +218,7 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
}
// Resize multisample FBO.
- if (m_attrs.antialias) {
+ if (m_attrs.antialias && !isGLES2Compliant()) {
GLint maxSampleCount;
::glGetIntegerv(GL_MAX_SAMPLES_EXT, &maxSampleCount);
GLint sampleCount = std::min(8, maxSampleCount);
@@ -169,12 +256,12 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
setRenderbufferStorageFromDrawable(m_currentWidth, m_currentHeight);
#else
::glBindTexture(GL_TEXTURE_2D, m_texture);
- ::glTexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
+ ::glTexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, pixelDataType, 0);
::glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_texture, 0);
if (m_compositorTexture) {
::glBindTexture(GL_TEXTURE_2D, m_compositorTexture);
- ::glTexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
+ ::glTexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, pixelDataType, 0);
::glBindTexture(GL_TEXTURE_2D, 0);
#if USE(COORDINATED_GRAPHICS_THREADED)
::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_compositorFBO);
@@ -188,7 +275,7 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
attachDepthAndStencilBufferIfNeeded(internalDepthStencilFormat, width, height);
bool mustRestoreFBO = true;
- if (m_attrs.antialias) {
+ if (m_attrs.antialias && !isGLES2Compliant()) {
::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
if (m_state.boundFBO == m_multisampleFBO)
mustRestoreFBO = false;
@@ -203,6 +290,10 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
void GraphicsContext3D::attachDepthAndStencilBufferIfNeeded(GLuint internalDepthStencilFormat, int width, int height)
{
if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth)) {
+#if PLATFORM(QT)
+ bool supportPackedDepthStencilBuffer = internalDepthStencilFormat == GL_DEPTH24_STENCIL8_EXT;
+ if (supportPackedDepthStencilBuffer || !isGLES2Compliant()) {
+#endif
::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
::glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, internalDepthStencilFormat, width, height);
if (m_attrs.stencil)
@@ -210,6 +301,21 @@ void GraphicsContext3D::attachDepthAndStencilBufferIfNeeded(GLuint internalDepth
if (m_attrs.depth)
::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
+#if PLATFORM(QT)
+ } else {
+ if (m_attrs.stencil) {
+ ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_stencilBuffer);
+ ::glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_STENCIL_INDEX8, width, height);
+ ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_stencilBuffer);
+ }
+ if (m_attrs.depth) {
+ ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_depthBuffer);
+ ::glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16, width, height);
+ ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthBuffer);
+ }
+ ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
+ }
+#endif
}
if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) {
@@ -220,6 +326,18 @@ void GraphicsContext3D::attachDepthAndStencilBufferIfNeeded(GLuint internalDepth
void GraphicsContext3D::resolveMultisamplingIfNecessary(const IntRect& rect)
{
+#if PLATFORM(QT)
+ Q_ASSERT(m_private);
+ if (!m_attrs.antialias)
+ return;
+
+ // QTFIXME: Probably not needed, iOS uses following code successfully
+ if (isGLES2Compliant()) {
+ notImplemented();
+ return;
+ }
+#endif
+
TemporaryOpenGLSetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE);
TemporaryOpenGLSetting scopedDither(GL_DITHER, GL_FALSE);
TemporaryOpenGLSetting scopedDepth(GL_DEPTH_TEST, GL_FALSE);
@@ -249,6 +367,9 @@ void GraphicsContext3D::renderbufferStorage(GC3Denum target, GC3Denum internalfo
{
makeContextCurrent();
#if !PLATFORM(IOS)
+#if PLATFORM(QT)
+ if (!isGLES2Compliant()) {
+#endif
switch (internalformat) {
case DEPTH_STENCIL:
internalformat = GL_DEPTH24_STENCIL8_EXT;
@@ -264,6 +385,9 @@ void GraphicsContext3D::renderbufferStorage(GC3Denum target, GC3Denum internalfo
internalformat = GL_RGB;
break;
}
+#if PLATFORM(QT)
+ }
+#endif
#endif
::glRenderbufferStorageEXT(target, internalformat, width, height);
}
@@ -275,6 +399,12 @@ void GraphicsContext3D::getIntegerv(GC3Denum pname, GC3Dint* value)
// whereas GLES2 return the number of vectors (each vector has 4 components).
// Therefore, the value returned by desktop GL needs to be divided by 4.
makeContextCurrent();
+#if PLATFORM(QT)
+ if (isGLES2Compliant()) {
+ ::glGetIntegerv(pname, value);
+ return;
+ }
+#endif
switch (pname) {
#if !PLATFORM(IOS)
case MAX_FRAGMENT_UNIFORM_VECTORS:
@@ -307,12 +437,19 @@ void GraphicsContext3D::getIntegerv(GC3Denum pname, GC3Dint* value)
void GraphicsContext3D::getShaderPrecisionFormat(GC3Denum shaderType, GC3Denum precisionType, GC3Dint* range, GC3Dint* precision)
{
+#if !PLATFORM(QT)
UNUSED_PARAM(shaderType);
+#endif
ASSERT(range);
ASSERT(precision);
makeContextCurrent();
+#if PLATFORM(QT)
+ m_functions->glGetShaderPrecisionFormat(shaderType, precisionType, range, precision);
+ return;
+#endif
+
switch (precisionType) {
case GraphicsContext3D::LOW_INT:
case GraphicsContext3D::MEDIUM_INT:
@@ -346,6 +483,9 @@ bool GraphicsContext3D::texImage2D(GC3Denum target, GC3Dint level, GC3Denum inte
GC3Denum openGLFormat = format;
GC3Denum openGLInternalFormat = internalformat;
#if !PLATFORM(IOS)
+#if PLATFORM(QT)
+ if (!isGLES2Compliant()) {
+#endif
if (type == GL_FLOAT) {
if (format == GL_RGBA)
openGLInternalFormat = GL_RGBA32F_ARB;
@@ -370,6 +510,9 @@ bool GraphicsContext3D::texImage2D(GC3Denum target, GC3Dint level, GC3Denum inte
openGLFormat = GL_RGBA;
else if (format == Extensions3D::SRGB_EXT)
openGLFormat = GL_RGB;
+#if PLATFORM(QT)
+ }
+#endif
#endif
texImage2DDirect(target, level, openGLInternalFormat, width, height, border, openGLFormat, type, pixels);
return true;
@@ -404,6 +547,7 @@ Extensions3D* GraphicsContext3D::getExtensions()
void GraphicsContext3D::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data)
{
+ ASSERT(m_private);
// FIXME: remove the two glFlush calls when the driver bug is fixed, i.e.,
// all previous rendering calls should be done before reading pixels.
makeContextCurrent();
diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
index f1509fb5f..03460cf2c 100644
--- a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
+++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
@@ -67,11 +67,20 @@
#define GL_RGBA32F_ARB 0x8814
#define GL_RGB32F_ARB 0x8815
#else
-#if USE(OPENGL_ES_2)
+#if PLATFORM(QT)
+#define FUNCTIONS m_functions
+#include "OpenGLShimsQt.h"
+
+#define glGetError(...) m_functions->glGetError(__VA_ARGS__)
+#define glIsEnabled(...) m_functions->glIsEnabled(__VA_ARGS__)
+
+#define scopedScissor(c, s) scopedScissor(m_functions, c, s)
+#define scopedDither(c, s) scopedDither(m_functions, c, s)
+#elif USE(OPENGL_ES_2)
#include "OpenGLESShims.h"
#elif PLATFORM(MAC)
#include <OpenGL/gl.h>
-#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(QT) || PLATFORM(WIN)
+#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN)
#include "OpenGLShims.h"
#endif
#endif
@@ -403,7 +412,7 @@ bool GraphicsContext3D::checkVaryingsPacking(Platform3DObject vertexShader, Plat
}
GC3Dint maxVaryingVectors = 0;
-#if !PLATFORM(IOS) && !((PLATFORM(WIN) || PLATFORM(GTK)) && USE(OPENGL_ES_2))
+#if !PLATFORM(IOS) && !((PLATFORM(WIN) || PLATFORM(GTK) || PLATFORM(QT)) && USE(OPENGL_ES_2))
GC3Dint maxVaryingFloats = 0;
::glGetIntegerv(GL_MAX_VARYING_FLOATS, &maxVaryingFloats);
maxVaryingVectors = maxVaryingFloats / 4;
@@ -1012,7 +1021,7 @@ GC3Denum GraphicsContext3D::getError()
}
makeContextCurrent();
- return ::glGetError();
+ return glGetError();
}
String GraphicsContext3D::getString(GC3Denum name)
@@ -1039,7 +1048,7 @@ GC3Dboolean GraphicsContext3D::isBuffer(Platform3DObject buffer)
GC3Dboolean GraphicsContext3D::isEnabled(GC3Denum cap)
{
makeContextCurrent();
- return ::glIsEnabled(cap);
+ return glIsEnabled(cap);
}
GC3Dboolean GraphicsContext3D::isFramebuffer(Platform3DObject framebuffer)
@@ -1382,6 +1391,7 @@ void GraphicsContext3D::viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsize
::glViewport(x, y, width, height);
}
+#if !PLATFORM(QT) || ENABLE(WEBGL2)
Platform3DObject GraphicsContext3D::createVertexArray()
{
makeContextCurrent();
@@ -1432,6 +1442,7 @@ void GraphicsContext3D::bindVertexArray(Platform3DObject array)
UNUSED_PARAM(array);
#endif
}
+#endif
void GraphicsContext3D::getBooleanv(GC3Denum pname, GC3Dboolean* value)
{
diff --git a/Source/WebCore/platform/graphics/opengl/TemporaryOpenGLSetting.cpp b/Source/WebCore/platform/graphics/opengl/TemporaryOpenGLSetting.cpp
index b948c3a15..c502a0c3b 100644
--- a/Source/WebCore/platform/graphics/opengl/TemporaryOpenGLSetting.cpp
+++ b/Source/WebCore/platform/graphics/opengl/TemporaryOpenGLSetting.cpp
@@ -39,16 +39,25 @@
#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN)
#include "OpenGLShims.h"
#elif PLATFORM(QT)
-#include <qopengl.h>
+#define FUNCTIONS m_functions
+#include "OpenGLShimsQt.h"
+#define glIsEnabled(...) m_functions->glIsEnabled(__VA_ARGS__)
#endif
namespace WebCore {
+#if PLATFORM(QT)
+TemporaryOpenGLSetting::TemporaryOpenGLSetting(QOpenGLExtensions* functions, GC3Denum capability, GC3Denum scopedState)
+#else
TemporaryOpenGLSetting::TemporaryOpenGLSetting(GLenum capability, GLenum scopedState)
+#endif
: m_capability(capability)
, m_scopedState(scopedState)
+#if PLATFORM(QT)
+ , m_functions(functions)
+#endif
{
- m_originalState = ::glIsEnabled(m_capability);
+ m_originalState = glIsEnabled(m_capability);
if (m_originalState == m_scopedState)
return;
diff --git a/Source/WebCore/platform/graphics/opengl/TemporaryOpenGLSetting.h b/Source/WebCore/platform/graphics/opengl/TemporaryOpenGLSetting.h
index 833f8b6be..736b57fa1 100644
--- a/Source/WebCore/platform/graphics/opengl/TemporaryOpenGLSetting.h
+++ b/Source/WebCore/platform/graphics/opengl/TemporaryOpenGLSetting.h
@@ -31,6 +31,12 @@
#include <wtf/Noncopyable.h>
+#if PLATFORM(QT)
+QT_BEGIN_NAMESPACE
+class QOpenGLExtensions;
+QT_END_NAMESPACE
+#endif
+
namespace WebCore {
// TemporaryOpenGLSetting<> is useful for temporarily disabling (or enabling) a particular OpenGL
@@ -43,13 +49,21 @@ namespace WebCore {
class TemporaryOpenGLSetting {
WTF_MAKE_NONCOPYABLE(TemporaryOpenGLSetting);
public:
+#if PLATFORM(QT)
+ TemporaryOpenGLSetting(QOpenGLExtensions*, GC3Denum capability, GC3Denum scopedState);
+#else
TemporaryOpenGLSetting(GC3Denum capability, GC3Denum scopedState);
+#endif
~TemporaryOpenGLSetting();
private:
const GC3Denum m_capability;
const GC3Denum m_scopedState;
GC3Denum m_originalState;
+
+#if PLATFORM(QT)
+ QOpenGLExtensions* m_functions { nullptr };
+#endif
};
}
diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
index a0b76cc88..7f2f07b60 100644
--- a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
@@ -19,13 +19,7 @@
#include "config.h"
#include "GraphicsContext3D.h"
-#if ENABLE(GRAPHICS_CONTEXT_3D)
-
-#if USE(OPENGL_ES_2)
-#include "Extensions3DOpenGLES.h"
-#else
-#include "Extensions3DOpenGL.h"
-#endif
+#include "Extensions3DOpenGLCommon.h"
#include "GraphicsContext.h"
#include "GraphicsSurface.h"
#include "HostWindow.h"
@@ -33,32 +27,51 @@
#include "ImageData.h"
#include "NativeImageQt.h"
#include "NotImplemented.h"
-#include "OpenGLShims.h"
#include "QWebPageClient.h"
#include "SharedBuffer.h"
#include "TextureMapperPlatformLayer.h"
+#include <QOffscreenSurface>
+#include <private/qopenglextensions_p.h>
#include <qpa/qplatformpixmap.h>
#include <wtf/text/CString.h>
-#include <QOffscreenSurface>
-
#if USE(TEXTURE_MAPPER_GL)
#include <texmap/TextureMapperGL.h>
#endif
+#if ENABLE(GRAPHICS_CONTEXT_3D)
+
+QT_BEGIN_NAMESPACE
+extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize&, bool alpha_format, bool include_alpha);
+QT_END_NAMESPACE
+
namespace WebCore {
#if !defined(GLchar)
typedef char GLchar;
#endif
-#if !defined(GL_DEPTH24_STENCIL8)
-#define GL_DEPTH24_STENCIL8 0x88F0
+#ifndef GL_VERTEX_PROGRAM_POINT_SIZE
+#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
#endif
-class GraphicsContext3DPrivate final
- : public TextureMapperPlatformLayer
-{
+#ifndef GL_POINT_SPRITE
+#define GL_POINT_SPRITE 0x8861
+#endif
+
+#ifndef GL_DEPTH24_STENCIL8
+#define GL_DEPTH24_STENCIL8 0x88F0
+#endif
+
+#ifndef GL_READ_FRAMEBUFFER
+#define GL_READ_FRAMEBUFFER 0x8CA8
+#endif
+
+#ifndef GL_DRAW_FRAMEBUFFER
+#define GL_DRAW_FRAMEBUFFER 0x8CA9
+#endif
+
+class GraphicsContext3DPrivate final : public TextureMapperPlatformLayer, public QOpenGLExtensions {
public:
GraphicsContext3DPrivate(GraphicsContext3D*, HostWindow*, GraphicsContext3D::RenderStyle);
~GraphicsContext3DPrivate();
@@ -71,13 +84,16 @@ public:
#endif
QRectF boundingRect() const;
- void blitMultisampleFramebuffer() const;
- void blitMultisampleFramebufferAndRestoreContext() const;
+ void blitMultisampleFramebuffer();
+ void blitMultisampleFramebufferAndRestoreContext();
bool makeCurrentIfNeeded() const;
void createOffscreenBuffers();
void initializeANGLE();
void createGraphicsSurfaces(const IntSize&);
+ bool isOpenGLES() const;
+ bool isValid() const;
+
GraphicsContext3D* m_context;
HostWindow* m_hostWindow;
PlatformGraphicsSurface3D m_surface;
@@ -87,10 +103,43 @@ public:
GraphicsSurface::Flags m_surfaceFlags;
RefPtr<GraphicsSurface> m_graphicsSurface;
#endif
+
+ // Register as a child of a Qt context to make the necessary when it may be destroyed before the GraphicsContext3D instance
+ class QtContextWatcher : public QObject {
+ public:
+ QtContextWatcher(QObject* ctx, GraphicsContext3DPrivate* watcher)
+ : QObject(ctx), m_watcher(watcher) { }
+ ~QtContextWatcher() { m_watcher->m_platformContext = 0; m_watcher->m_platformContextWatcher = 0; }
+
+ private:
+ GraphicsContext3DPrivate* m_watcher;
+ };
+ QtContextWatcher* m_platformContextWatcher;
};
+bool GraphicsContext3DPrivate::isOpenGLES() const
+{
+ if (m_platformContext)
+ return m_platformContext->isOpenGLES();
+#if USE(OPENGL_ES_2)
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool GraphicsContext3DPrivate::isValid() const
+{
+ if (!m_platformContext || !m_platformContext->isValid())
+ return false;
+ return m_platformContext->isOpenGLES() || m_platformContext->format().majorVersion() >= 2;
+}
+
bool GraphicsContext3D::isGLES2Compliant() const
{
+ if (m_private)
+ return m_private->isOpenGLES();
+ ASSERT_NOT_REACHED();
#if USE(OPENGL_ES_2)
return true;
#else
@@ -104,17 +153,23 @@ GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, H
, m_surface(0)
, m_platformContext(0)
, m_surfaceOwner(0)
+ , m_platformContextWatcher(0)
{
if (renderStyle == GraphicsContext3D::RenderToCurrentGLContext) {
m_platformContext = QOpenGLContext::currentContext();
if (m_platformContext)
m_surface = m_platformContext->surface();
+
+ // Watcher needed to invalidate the GL context if destroyed before this instance
+ m_platformContextWatcher = new QtContextWatcher(m_platformContext, this);
+
+ initializeOpenGLFunctions();
return;
}
QOpenGLContext* shareContext = 0;
- if (hostWindow && hostWindow->platformPageClient() && hostWindow->platformPageClient()->makeOpenGLContextCurrentIfAvailable())
- shareContext = QOpenGLContext::currentContext();
+ if (hostWindow && hostWindow->platformPageClient())
+ shareContext = hostWindow->platformPageClient()->openGLContextIfAvailable();
QOffscreenSurface* surface = new QOffscreenSurface;
surface->create();
@@ -125,15 +180,18 @@ GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, H
if (shareContext)
m_platformContext->setShareContext(shareContext);
- if (!m_platformContext->create())
+ if (!m_platformContext->create()) {
+ delete m_platformContext;
+ m_platformContext = 0;
return;
+ }
makeCurrentIfNeeded();
+ initializeOpenGLFunctions();
#if USE(GRAPHICS_SURFACE)
IntSize surfaceSize(m_context->m_currentWidth, m_context->m_currentHeight);
- m_surfaceFlags = GraphicsSurface::SupportsTextureTarget
- | GraphicsSurface::SupportsSharing;
+ m_surfaceFlags = GraphicsSurface::SupportsTextureTarget | GraphicsSurface::SupportsSharing;
if (!surfaceSize.isEmpty())
m_graphicsSurface = GraphicsSurface::create(surfaceSize, m_surfaceFlags, m_platformContext);
@@ -145,31 +203,31 @@ void GraphicsContext3DPrivate::createOffscreenBuffers()
glGenFramebuffers(/* count */ 1, &m_context->m_fbo);
glGenTextures(1, &m_context->m_texture);
- glBindTexture(GraphicsContext3D::TEXTURE_2D, m_context->m_texture);
- glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
- glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
- glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
- glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
- glBindTexture(GraphicsContext3D::TEXTURE_2D, 0);
+ glBindTexture(GL_TEXTURE_2D, m_context->m_texture);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glBindTexture(GL_TEXTURE_2D, 0);
// Create a multisample FBO.
if (m_context->m_attrs.antialias) {
glGenFramebuffers(1, &m_context->m_multisampleFBO);
- glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_multisampleFBO);
+ glBindFramebuffer(GL_FRAMEBUFFER, m_context->m_multisampleFBO);
m_context->m_state.boundFBO = m_context->m_multisampleFBO;
glGenRenderbuffers(1, &m_context->m_multisampleColorBuffer);
if (m_context->m_attrs.stencil || m_context->m_attrs.depth)
glGenRenderbuffers(1, &m_context->m_multisampleDepthStencilBuffer);
} else {
// Bind canvas FBO.
- glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER, m_context->m_fbo);
m_context->m_state.boundFBO = m_context->m_fbo;
-#if USE(OPENGL_ES_2)
- if (m_context->m_attrs.depth)
- glGenRenderbuffers(1, &m_context->m_depthBuffer);
- if (m_context->m_attrs.stencil)
- glGenRenderbuffers(1, &m_context->m_stencilBuffer);
-#endif
+ if (isOpenGLES()) {
+ if (m_context->m_attrs.depth)
+ glGenRenderbuffers(1, &m_context->m_depthBuffer);
+ if (m_context->m_attrs.stencil)
+ glGenRenderbuffers(1, &m_context->m_stencilBuffer);
+ }
if (m_context->m_attrs.stencil || m_context->m_attrs.depth)
glGenRenderbuffers(1, &m_context->m_depthStencilBuffer);
}
@@ -206,11 +264,9 @@ GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
{
delete m_surfaceOwner;
m_surfaceOwner = 0;
-}
-static inline quint32 swapBgrToRgb(quint32 pixel)
-{
- return (((pixel << 16) | (pixel >> 16)) & 0x00ff00ff) | (pixel & 0xff00ff00);
+ delete m_platformContextWatcher;
+ m_platformContextWatcher = 0;
}
void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper& textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity)
@@ -218,34 +274,15 @@ void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper& textureMapper
m_context->markLayerComposited();
blitMultisampleFramebufferAndRestoreContext();
- // FIXME: For now we have OpenGLMode only
-// if (textureMapper->accelerationMode() == TextureMapper::OpenGLMode) {
+ if (textureMapper.accelerationMode() == TextureMapper::OpenGLMode) {
TextureMapperGL& texmapGL = static_cast<TextureMapperGL&>(textureMapper);
-#if USE(GRAPHICS_SURFACE)
- ASSERT(m_graphicsSurface);
- // CGL only provides us the context, but not the view the context is currently bound to.
- // To make sure the context is bound the the right surface we have to do a makeCurrent through QOpenGL again.
- // FIXME: Remove this code as soon as GraphicsSurfaceMac makes use of NSOpenGL.
- QOpenGLContext* currentContext = QOpenGLContext::currentContext();
- QSurface* currentSurface = currentContext->surface();
- makeCurrentIfNeeded();
-
- m_graphicsSurface->copyFromTexture(m_context->m_texture, IntRect(0, 0, m_context->m_currentWidth, m_context->m_currentHeight));
-
- // CGL only provides us the context, but not the view the context is currently bound to.
- // To make sure the context is bound the the right surface we have to do a makeCurrent through QOpenGL again.
- // FIXME: Remove this code as soon as GraphicsSurfaceMac makes use of NSOpenGL.
- currentContext->makeCurrent(currentSurface);
-
- m_graphicsSurface->paintToTextureMapper(texmapGL, targetRect, matrix, opacity);
-#else
TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (m_context->m_attrs.alpha ? TextureMapperGL::ShouldBlend : 0);
IntSize textureSize(m_context->m_currentWidth, m_context->m_currentHeight);
texmapGL.drawTexture(m_context->m_texture, flags, textureSize, targetRect, matrix, opacity);
-#endif
return;
-// }
+ }
+ // Alternatively read pixels to a memory buffer.
GraphicsContext* context = textureMapper.graphicsContext();
QPainter* painter = context->platformContext();
painter->save();
@@ -255,36 +292,13 @@ void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper& textureMapper
const int height = m_context->m_currentHeight;
const int width = m_context->m_currentWidth;
- // Alternatively read pixels to a memory buffer.
- QImage offscreenImage(width, height, QImage::Format_ARGB32);
- quint32* imagePixels = reinterpret_cast<quint32*>(offscreenImage.bits());
-
+ painter->beginNativePainting();
makeCurrentIfNeeded();
- glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_fbo);
- glReadPixels(/* x */ 0, /* y */ 0, width, height, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, imagePixels);
- glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_state.boundFBO);
-
- // OpenGL gives us ABGR on 32 bits, and with the origin at the bottom left
- // We need RGB32 or ARGB32_PM, with the origin at the top left.
- quint32* pixelsSrc = imagePixels;
- const int halfHeight = height / 2;
- for (int row = 0; row < halfHeight; ++row) {
- const int targetIdx = (height - 1 - row) * width;
- quint32* pixelsDst = imagePixels + targetIdx;
- for (int column = 0; column < width; ++column) {
- quint32 tempPixel = *pixelsSrc;
- *pixelsSrc = swapBgrToRgb(*pixelsDst);
- *pixelsDst = swapBgrToRgb(tempPixel);
- ++pixelsSrc;
- ++pixelsDst;
- }
- }
- if (static_cast<int>(height) % 2) {
- for (int column = 0; column < width; ++column) {
- *pixelsSrc = swapBgrToRgb(*pixelsSrc);
- ++pixelsSrc;
- }
- }
+ glBindFramebuffer(GL_FRAMEBUFFER, m_context->m_fbo);
+ QImage offscreenImage = qt_gl_read_framebuffer(QSize(width, height), true, true);
+ glBindFramebuffer(GL_FRAMEBUFFER, m_context->m_state.boundFBO);
+
+ painter->endNativePainting();
painter->drawImage(targetRect, offscreenImage);
painter->restore();
@@ -318,19 +332,21 @@ QRectF GraphicsContext3DPrivate::boundingRect() const
return QRectF(QPointF(0, 0), QSizeF(m_context->m_currentWidth, m_context->m_currentHeight));
}
-void GraphicsContext3DPrivate::blitMultisampleFramebuffer() const
+void GraphicsContext3DPrivate::blitMultisampleFramebuffer()
{
if (!m_context->m_attrs.antialias)
return;
-#if !USE(OPENGL_ES_2)
- glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, m_context->m_multisampleFBO);
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, m_context->m_fbo);
- glBlitFramebuffer(0, 0, m_context->m_currentWidth, m_context->m_currentHeight, 0, 0, m_context->m_currentWidth, m_context->m_currentHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
-#endif
- glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_state.boundFBO);
+
+ if (!isOpenGLES()) {
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, m_context->m_multisampleFBO);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_context->m_fbo);
+ glBlitFramebuffer(0, 0, m_context->m_currentWidth, m_context->m_currentHeight, 0, 0, m_context->m_currentWidth, m_context->m_currentHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
+ }
+
+ glBindFramebuffer(GL_FRAMEBUFFER, m_context->m_state.boundFBO);
}
-void GraphicsContext3DPrivate::blitMultisampleFramebufferAndRestoreContext() const
+void GraphicsContext3DPrivate::blitMultisampleFramebufferAndRestoreContext()
{
const QOpenGLContext* currentContext = QOpenGLContext::currentContext();
QSurface* currentSurface = 0;
@@ -352,6 +368,8 @@ void GraphicsContext3DPrivate::blitMultisampleFramebufferAndRestoreContext() con
bool GraphicsContext3DPrivate::makeCurrentIfNeeded() const
{
+ if (!m_platformContext)
+ return false;
const QOpenGLContext* currentContext = QOpenGLContext::currentContext();
if (currentContext == m_platformContext)
return true;
@@ -382,39 +400,34 @@ PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri
GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
: m_currentWidth(0)
, m_currentHeight(0)
- , m_compiler(isGLES2Compliant() ? SH_ESSL_OUTPUT : SH_GLSL_OUTPUT)
, m_attrs(attrs)
, m_renderStyle(renderStyle)
, m_texture(0)
, m_compositorTexture(0)
, m_fbo(0)
-#if USE(OPENGL_ES_2)
, m_depthBuffer(0)
, m_stencilBuffer(0)
-#endif
, m_depthStencilBuffer(0)
, m_layerComposited(false)
, m_internalColorFormat(0)
, m_multisampleFBO(0)
, m_multisampleDepthStencilBuffer(0)
, m_multisampleColorBuffer(0)
+ , m_functions(0)
, m_private(std::make_unique<GraphicsContext3DPrivate>(this, hostWindow, renderStyle))
+ , m_compiler(isGLES2Compliant() ? SH_ESSL_OUTPUT : SH_GLSL_OUTPUT)
+ , m_webglContext(nullptr)
{
- validateAttributes();
-
if (!m_private->m_surface || !m_private->m_platformContext) {
LOG_ERROR("GraphicsContext3D: GL context creation failed.");
m_private = nullptr;
return;
}
- static bool initialized = false;
- static bool success = true;
- if (!initialized) {
- success = initializeOpenGLShims();
- initialized = true;
- }
- if (!success) {
+ m_functions = m_private.get();
+ validateAttributes();
+
+ if (!m_private->isValid()) {
m_private = nullptr;
return;
}
@@ -424,13 +437,13 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
m_private->initializeANGLE();
-#if !USE(OPENGL_ES_2)
- glEnable(GL_POINT_SPRITE);
- glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
-#endif
+ if (!isGLES2Compliant()) {
+ m_functions->glEnable(GL_POINT_SPRITE);
+ m_functions->glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
+ }
if (renderStyle != RenderToCurrentGLContext)
- glClearColor(0.0, 0.0, 0.0, 0.0);
+ m_functions->glClearColor(0.0, 0.0, 0.0, 0.0);
}
GraphicsContext3D::~GraphicsContext3D()
@@ -439,23 +452,26 @@ GraphicsContext3D::~GraphicsContext3D()
if (!m_private)
return;
- makeContextCurrent();
- glDeleteTextures(1, &m_texture);
- glDeleteFramebuffers(1, &m_fbo);
- if (m_attrs.antialias) {
- glDeleteRenderbuffers(1, &m_multisampleColorBuffer);
- glDeleteFramebuffers(1, &m_multisampleFBO);
- if (m_attrs.stencil || m_attrs.depth)
- glDeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer);
- } else if (m_attrs.stencil || m_attrs.depth) {
-#if USE(OPENGL_ES_2)
- if (m_attrs.depth)
- glDeleteRenderbuffers(1, &m_depthBuffer);
- if (m_attrs.stencil)
- glDeleteRenderbuffers(1, &m_stencilBuffer);
-#endif
- glDeleteRenderbuffers(1, &m_depthStencilBuffer);
+ if (makeContextCurrent()) {
+ m_functions->glDeleteTextures(1, &m_texture);
+ m_functions->glDeleteFramebuffers(1, &m_fbo);
+ if (m_attrs.antialias) {
+ m_functions->glDeleteRenderbuffers(1, &m_multisampleColorBuffer);
+ m_functions->glDeleteFramebuffers(1, &m_multisampleFBO);
+ if (m_attrs.stencil || m_attrs.depth)
+ m_functions->glDeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer);
+ } else if (m_attrs.stencil || m_attrs.depth) {
+ if (isGLES2Compliant()) {
+ if (m_attrs.depth)
+ m_functions->glDeleteRenderbuffers(1, &m_depthBuffer);
+ if (m_attrs.stencil)
+ m_functions->glDeleteRenderbuffers(1, &m_stencilBuffer);
+ }
+ m_functions->glDeleteRenderbuffers(1, &m_depthStencilBuffer);
+ }
}
+
+ m_functions = 0;
}
PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D()
@@ -475,7 +491,7 @@ PlatformLayer* GraphicsContext3D::platformLayer() const
bool GraphicsContext3D::makeContextCurrent()
{
- if (!m_private || m_renderStyle == RenderToCurrentGLContext)
+ if (!m_private)
return false;
return m_private->makeCurrentIfNeeded();
}
diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
index d1ab885d9..00bcb8532 100644
--- a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
@@ -49,6 +49,7 @@
#include "FloatConversion.h"
#include "Font.h"
#include "ImageBuffer.h"
+#include "ImageBufferDataQt.h"
#include "NotImplemented.h"
#include "Path.h"
#include "Pattern.h"
@@ -959,15 +960,8 @@ void GraphicsContext::clipToImageBuffer(ImageBuffer& buffer, const FloatRect& de
if (paintingDisabled())
return;
- RefPtr<Image> image = buffer.copyImage(DontCopyBackingStore);
- QPixmap* nativeImage = image->nativeImageForCurrentFrame();
- if (!nativeImage)
- return;
-
IntRect rect = enclosingIntRect(destRect);
- QPixmap alphaMask = *nativeImage;
-
- pushTransparencyLayerInternal(rect, 1.0, alphaMask);
+ buffer.m_data.m_impl->clip(*this, rect);
}
void drawFocusRingForPath(QPainter* p, const QPainterPath& path, const Color& color, bool antiAliasing)
@@ -1553,7 +1547,7 @@ void GraphicsContext::setCTM(const AffineTransform& transform)
m_data->p()->setWorldTransform(transform);
}
-#if ENABLE(3D_RENDERING)
+#if ENABLE(3D_TRANSFORMS)
TransformationMatrix GraphicsContext::get3DTransform() const
{
if (paintingDisabled())
@@ -1757,6 +1751,10 @@ void GraphicsContext::takeOwnershipOfPlatformContext()
m_data->takeOwnershipOfPlatformContext();
}
+bool GraphicsContext::isAcceleratedContext() const
+{
+ return (platformContext()->paintEngine()->type() == QPaintEngine::OpenGL2);
}
+}
// vim: ts=4 sw=4 et
diff --git a/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.cpp b/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.cpp
new file mode 100644
index 000000000..b277fd421
--- /dev/null
+++ b/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.cpp
@@ -0,0 +1,538 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ * Copyright (C) 2008 Holger Hans Peter Freyther
+ * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
+ * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
+ * Copyright (C) 2014 Digia Plc. and/or its subsidiary(-ies)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ImageBuffer.h"
+
+#include "GraphicsContext.h"
+#include "GraphicsSurface.h"
+#include "ImageData.h"
+#include "IntRect.h"
+#include "StillImageQt.h"
+
+#include <QImage>
+#include <QPaintEngine>
+#include <QPainter>
+#include <QPixmap>
+
+#if ENABLE(ACCELERATED_2D_CANVAS)
+#include "QFramebufferPaintDevice.h"
+#include "TextureMapper.h"
+#include "TextureMapperGL.h"
+#include "TextureMapperPlatformLayer.h"
+#include <QOffscreenSurface>
+#include <QOpenGLContext>
+#include <QOpenGLFramebufferObject>
+#include <QOpenGLPaintDevice>
+#include <QThreadStorage>
+#include <private/qopenglpaintengine_p.h>
+#endif
+
+namespace WebCore {
+
+#if ENABLE(ACCELERATED_2D_CANVAS)
+
+class QOpenGLContextThreadStorage {
+public:
+ QOpenGLContext* context()
+ {
+ QOpenGLContext*& context = storage.localData();
+ if (!context) {
+ context = new QOpenGLContext;
+ context->create();
+ }
+ return context;
+ }
+
+private:
+ QThreadStorage<QOpenGLContext*> storage;
+};
+
+Q_GLOBAL_STATIC(QOpenGLContextThreadStorage, imagebuffer_opengl_context)
+
+// The owner of the surface needs to be separate from QFramebufferPaintDevice, since the surface
+// must already be current with the QFramebufferObject constructor is called.
+class ImageBufferContext {
+public:
+ ImageBufferContext(QOpenGLContext* sharedContext)
+ : m_ownSurface(0)
+ {
+ if (sharedContext)
+ m_format = sharedContext->format();
+
+ m_context = sharedContext ? sharedContext : imagebuffer_opengl_context->context();
+
+ m_surface = m_context->surface();
+ }
+ ~ImageBufferContext()
+ {
+ if (QOpenGLContext::currentContext() == m_context && m_context->surface() == m_ownSurface)
+ m_context->doneCurrent();
+ delete m_ownSurface;
+ }
+ void createSurfaceIfNeeded()
+ {
+ if (m_surface)
+ return;
+
+ m_ownSurface = new QOffscreenSurface;
+ m_ownSurface->setFormat(m_format);
+ m_ownSurface->create();
+
+ m_surface = m_ownSurface;
+ }
+ void makeCurrentIfNeeded()
+ {
+ if (QOpenGLContext::currentContext() != m_context) {
+ createSurfaceIfNeeded();
+
+ m_context->makeCurrent(m_surface);
+ }
+ }
+ QOpenGLContext* context() { return m_context; }
+
+private:
+ QSurface* m_surface;
+ QOffscreenSurface* m_ownSurface;
+ QOpenGLContext* m_context;
+ QSurfaceFormat m_format;
+};
+
+// ---------------------- ImageBufferDataPrivateAccelerated
+
+struct ImageBufferDataPrivateAccelerated final : public TextureMapperPlatformLayer, public ImageBufferDataPrivate {
+ ImageBufferDataPrivateAccelerated(const IntSize&, QOpenGLContext* sharedContext);
+ virtual ~ImageBufferDataPrivateAccelerated();
+
+ QPaintDevice* paintDevice() final { return m_paintDevice; }
+ QImage toQImage() const final;
+ RefPtr<Image> image() const final;
+ RefPtr<Image> copyImage() const final;
+ RefPtr<Image> takeImage() final;
+ bool isAccelerated() const final { return true; }
+ PlatformLayer* platformLayer() final { return this; }
+
+ void invalidateState() const;
+ void draw(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect,
+ CompositeOperator, BlendMode, bool ownContext) final;
+ void drawPattern(GraphicsContext& destContext, const FloatRect& srcRect, const AffineTransform& patternTransform,
+ const FloatPoint& phase, const FloatSize& spacing, CompositeOperator,
+ const FloatRect& destRect, BlendMode, bool ownContext) final;
+ void clip(GraphicsContext&, const IntRect& floatRect) const final;
+ void platformTransformColorSpace(const Vector<int>& lookUpTable) final;
+
+ // TextureMapperPlatformLayer:
+ void paintToTextureMapper(TextureMapper&, const FloatRect&, const TransformationMatrix& modelViewMatrix = TransformationMatrix(), float opacity = 1.0) final;
+#if USE(GRAPHICS_SURFACE)
+ IntSize platformLayerSize() const final;
+ uint32_t copyToGraphicsSurface() final;
+ GraphicsSurfaceToken graphicsSurfaceToken() const final;
+ RefPtr<GraphicsSurface> m_graphicsSurface;
+#endif
+private:
+ QFramebufferPaintDevice* m_paintDevice;
+ ImageBufferContext* m_context;
+};
+
+ImageBufferDataPrivateAccelerated::ImageBufferDataPrivateAccelerated(const IntSize& size, QOpenGLContext* sharedContext)
+{
+ m_context = new ImageBufferContext(sharedContext);
+ m_context->makeCurrentIfNeeded();
+
+ m_paintDevice = new QFramebufferPaintDevice(size);
+}
+
+ImageBufferDataPrivateAccelerated::~ImageBufferDataPrivateAccelerated()
+{
+ if (client())
+ client()->platformLayerWillBeDestroyed();
+ delete m_paintDevice;
+ delete m_context;
+}
+
+QImage ImageBufferDataPrivateAccelerated::toQImage() const
+{
+ invalidateState();
+ return m_paintDevice->toImage();
+}
+
+RefPtr<Image> ImageBufferDataPrivateAccelerated::image() const
+{
+ return copyImage();
+}
+
+RefPtr<Image> ImageBufferDataPrivateAccelerated::copyImage() const
+{
+ return StillImage::create(QPixmap::fromImage(toQImage()));
+}
+
+RefPtr<Image> ImageBufferDataPrivateAccelerated::takeImage()
+{
+ return StillImage::create(QPixmap::fromImage(toQImage()));
+}
+
+void ImageBufferDataPrivateAccelerated::invalidateState() const
+{
+ // This will flush pending QPainter operations and force ensureActiveTarget() to be called on the next paint.
+ QOpenGL2PaintEngineEx* acceleratedPaintEngine = static_cast<QOpenGL2PaintEngineEx*>(m_paintDevice->paintEngine());
+ acceleratedPaintEngine->invalidateState();
+}
+
+void ImageBufferDataPrivateAccelerated::draw(GraphicsContext& destContext, const FloatRect& destRect,
+ const FloatRect& srcRect, CompositeOperator op, BlendMode blendMode, bool /*ownContext*/)
+{
+ if (destContext.isAcceleratedContext()) {
+ invalidateState();
+
+ // If accelerated compositing is disabled, this may be the painter of the QGLWidget, which is a QGL2PaintEngineEx.
+ QOpenGL2PaintEngineEx* acceleratedPaintEngine = dynamic_cast<QOpenGL2PaintEngineEx*>(destContext.platformContext()->paintEngine()); // toQOpenGL2PaintEngineEx(destContext.platformContext()->paintEngine());
+ if (acceleratedPaintEngine) {
+ QPaintDevice* targetPaintDevice = acceleratedPaintEngine->paintDevice();
+
+ QRect rect(QPoint(), m_paintDevice->size());
+
+ // drawTexture's rendering is flipped relative to QtWebKit's convention, so we need to compensate
+ FloatRect srcRectFlipped = m_paintDevice->paintFlipped()
+ ? FloatRect(srcRect.x(), srcRect.maxY(), srcRect.width(), -srcRect.height())
+ : FloatRect(srcRect.x(), rect.height() - srcRect.maxY(), srcRect.width(), srcRect.height());
+
+ // Using the same texture as source and target of a rendering operation is undefined in OpenGL,
+ // so if that's the case we need to use a temporary intermediate buffer.
+ if (m_paintDevice == targetPaintDevice) {
+ m_context->makeCurrentIfNeeded();
+
+ QFramebufferPaintDevice device(rect.size(), QOpenGLFramebufferObject::NoAttachment, false);
+
+ // We disable flipping in order to do a pure blit into the intermediate buffer
+ device.setPaintFlipped(false);
+
+ QPainter painter(&device);
+ QOpenGL2PaintEngineEx* pe = static_cast<QOpenGL2PaintEngineEx*>(painter.paintEngine());
+ pe->drawTexture(rect, m_paintDevice->texture(), rect.size(), rect);
+ painter.end();
+
+ acceleratedPaintEngine->drawTexture(destRect, device.texture(), rect.size(), srcRectFlipped);
+ } else {
+ acceleratedPaintEngine->drawTexture(destRect, m_paintDevice->texture(), rect.size(), srcRectFlipped);
+ }
+
+ return;
+ }
+ }
+ RefPtr<Image> image = StillImage::create(QPixmap::fromImage(toQImage()));
+ destContext.drawImage(*image, destRect, srcRect, ImagePaintingOptions(op, blendMode, DoNotRespectImageOrientation));
+}
+
+
+void ImageBufferDataPrivateAccelerated::drawPattern(GraphicsContext& destContext, const FloatRect& srcRect, const AffineTransform& patternTransform,
+ const FloatPoint& phase, const FloatSize& spacing, CompositeOperator op, const FloatRect& destRect, BlendMode blendMode, bool /*ownContext*/)
+{
+ RefPtr<Image> image = StillImage::create(QPixmap::fromImage(toQImage()));
+ image->drawPattern(destContext, srcRect, patternTransform, phase, spacing, op, destRect, blendMode);
+}
+
+void ImageBufferDataPrivateAccelerated::clip(GraphicsContext& context, const IntRect& rect) const
+{
+ QPixmap alphaMask = QPixmap::fromImage(toQImage());
+ context.pushTransparencyLayerInternal(rect, 1.0, alphaMask);
+}
+
+void ImageBufferDataPrivateAccelerated::platformTransformColorSpace(const Vector<int>& lookUpTable)
+{
+ QPainter* painter = paintDevice()->paintEngine()->painter();
+
+ QImage image = toQImage().convertToFormat(QImage::Format_ARGB32);
+ ASSERT(!image.isNull());
+
+ uchar* bits = image.bits();
+ const int bytesPerLine = image.bytesPerLine();
+
+ for (int y = 0; y < image.height(); ++y) {
+ quint32* scanLine = reinterpret_cast_ptr<quint32*>(bits + y * bytesPerLine);
+ for (int x = 0; x < image.width(); ++x) {
+ QRgb& pixel = scanLine[x];
+ pixel = qRgba(lookUpTable[qRed(pixel)],
+ lookUpTable[qGreen(pixel)],
+ lookUpTable[qBlue(pixel)],
+ qAlpha(pixel));
+ }
+ }
+
+ painter->save();
+ painter->resetTransform();
+ painter->setOpacity(1.0);
+ painter->setClipping(false);
+ painter->setCompositionMode(QPainter::CompositionMode_Source);
+ painter->drawImage(QPoint(0, 0), image);
+ painter->restore();
+}
+
+void ImageBufferDataPrivateAccelerated::paintToTextureMapper(TextureMapper& textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity)
+{
+ bool canRenderDirectly = false;
+ if (textureMapper.accelerationMode() == TextureMapper::OpenGLMode) {
+ if (QOpenGLContext::areSharing(m_context->context(),
+ static_cast<TextureMapperGL&>(textureMapper).graphicsContext3D()->platformGraphicsContext3D()))
+ {
+ canRenderDirectly = true;
+ }
+ }
+
+ if (!canRenderDirectly) {
+ QImage image = toQImage();
+ TransformationMatrix oldTransform = textureMapper.graphicsContext()->get3DTransform();
+ textureMapper.graphicsContext()->concat3DTransform(matrix);
+ textureMapper.graphicsContext()->platformContext()->drawImage(targetRect, image);
+ textureMapper.graphicsContext()->set3DTransform(oldTransform);
+ return;
+ }
+
+ invalidateState();
+#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
+ static_cast<TextureMapperGL&>(textureMapper).drawTexture(m_paintDevice->texture(), TextureMapperGL::ShouldBlend, m_paintDevice->size(), targetRect, matrix, opacity);
+#else
+ static_cast<TextureMapperGL&>(textureMapper).drawTexture(m_paintDevice->texture(), TextureMapperGL::ShouldBlend | TextureMapperGL::ShouldFlipTexture, m_paintDevice->size(), targetRect, matrix, opacity);
+#endif
+}
+
+#if USE(GRAPHICS_SURFACE)
+IntSize ImageBufferDataPrivateAccelerated::platformLayerSize() const
+{
+ return m_paintDevice->size();
+}
+
+uint32_t ImageBufferDataPrivateAccelerated::copyToGraphicsSurface()
+{
+ if (!m_graphicsSurface) {
+ GraphicsSurface::Flags flags = GraphicsSurface::SupportsAlpha | GraphicsSurface::SupportsTextureTarget | GraphicsSurface::SupportsSharing;
+ m_graphicsSurface = GraphicsSurface::create(m_paintDevice->size(), flags);
+ }
+
+ invalidateState();
+
+ m_graphicsSurface->copyFromTexture(m_paintDevice->texture(), IntRect(IntPoint(), m_paintDevice->size()));
+ return m_graphicsSurface->swapBuffers();
+}
+
+GraphicsSurfaceToken ImageBufferDataPrivateAccelerated::graphicsSurfaceToken() const
+{
+ return m_graphicsSurface->exportToken();
+}
+#endif // USE(GRAPHICS_SURFACE)
+
+#endif // ENABLE(ACCELERATED_2D_CANVAS)
+
+// ---------------------- ImageBufferDataPrivateUnaccelerated
+
+struct ImageBufferDataPrivateUnaccelerated final : public ImageBufferDataPrivate {
+ ImageBufferDataPrivateUnaccelerated(const IntSize&);
+ QPaintDevice* paintDevice() final { return m_pixmap.isNull() ? 0 : &m_pixmap; }
+ QImage toQImage() const final;
+ RefPtr<Image> image() const final;
+ RefPtr<Image> copyImage() const final;
+ RefPtr<Image> takeImage() final;
+ bool isAccelerated() const final { return false; }
+ PlatformLayer* platformLayer() final { return 0; }
+ void draw(GraphicsContext& destContext, const FloatRect& destRect,
+ const FloatRect& srcRect, CompositeOperator, BlendMode, bool ownContext) final;
+ void drawPattern(GraphicsContext& destContext, const FloatRect& srcRect, const AffineTransform& patternTransform,
+ const FloatPoint& phase, const FloatSize& spacing, CompositeOperator,
+ const FloatRect& destRect, BlendMode, bool ownContext) final;
+ void clip(GraphicsContext&, const IntRect& floatRect) const final;
+ void platformTransformColorSpace(const Vector<int>& lookUpTable) final;
+
+ QPixmap m_pixmap;
+ RefPtr<Image> m_image;
+};
+
+ImageBufferDataPrivateUnaccelerated::ImageBufferDataPrivateUnaccelerated(const IntSize& size)
+ : m_pixmap(size)
+ , m_image(StillImage::createForRendering(&m_pixmap))
+{
+ m_pixmap.fill(QColor(Qt::transparent));
+}
+
+QImage ImageBufferDataPrivateUnaccelerated::toQImage() const
+{
+ QPaintEngine* paintEngine = m_pixmap.paintEngine();
+ if (!paintEngine || paintEngine->type() != QPaintEngine::Raster)
+ return m_pixmap.toImage();
+
+ // QRasterPixmapData::toImage() will deep-copy the backing QImage if there's an active QPainter on it.
+ // For performance reasons, we don't want that here, so we temporarily redirect the paint engine.
+ QPaintDevice* currentPaintDevice = paintEngine->paintDevice();
+ paintEngine->setPaintDevice(0);
+ QImage image = m_pixmap.toImage();
+ paintEngine->setPaintDevice(currentPaintDevice);
+ return image;
+}
+
+RefPtr<Image> ImageBufferDataPrivateUnaccelerated::image() const
+{
+ return StillImage::createForRendering(&m_pixmap);
+}
+
+RefPtr<Image> ImageBufferDataPrivateUnaccelerated::copyImage() const
+{
+ return StillImage::create(m_pixmap);
+}
+
+RefPtr<Image> ImageBufferDataPrivateUnaccelerated::takeImage()
+{
+ return StillImage::create(WTFMove(m_pixmap));
+}
+
+void ImageBufferDataPrivateUnaccelerated::draw(GraphicsContext& destContext, const FloatRect& destRect,
+ const FloatRect& srcRect, CompositeOperator op, BlendMode blendMode, bool ownContext)
+{
+ if (ownContext) {
+ // We're drawing into our own buffer. In order for this to work, we need to copy the source buffer first.
+ RefPtr<Image> copy = copyImage();
+ destContext.drawImage(*copy, destRect, srcRect, ImagePaintingOptions(op, blendMode, ImageOrientationDescription()));
+ } else
+ destContext.drawImage(*m_image, destRect, srcRect, ImagePaintingOptions(op, blendMode, ImageOrientationDescription()));
+}
+
+void ImageBufferDataPrivateUnaccelerated::drawPattern(GraphicsContext& destContext, const FloatRect& srcRect, const AffineTransform& patternTransform,
+ const FloatPoint& phase, const FloatSize& spacing, CompositeOperator op,
+ const FloatRect& destRect, BlendMode blendMode, bool ownContext)
+{
+ if (ownContext) {
+ // We're drawing into our own buffer. In order for this to work, we need to copy the source buffer first.
+ RefPtr<Image> copy = copyImage();
+ copy->drawPattern(destContext, srcRect, patternTransform, phase, spacing, op, destRect, blendMode);
+ } else
+ m_image->drawPattern(destContext, srcRect, patternTransform, phase, spacing, op, destRect, blendMode);
+}
+
+void ImageBufferDataPrivateUnaccelerated::clip(GraphicsContext& context, const IntRect& rect) const
+{
+ QPixmap* nativeImage = m_image->nativeImageForCurrentFrame();
+ if (!nativeImage)
+ return;
+
+ QPixmap alphaMask = *nativeImage;
+ context.pushTransparencyLayerInternal(rect, 1.0, alphaMask);
+}
+
+void ImageBufferDataPrivateUnaccelerated::platformTransformColorSpace(const Vector<int>& lookUpTable)
+{
+ QPainter* painter = paintDevice()->paintEngine()->painter();
+
+ bool isPainting = painter->isActive();
+ if (isPainting)
+ painter->end();
+
+ QImage image = toQImage().convertToFormat(QImage::Format_ARGB32);
+ ASSERT(!image.isNull());
+
+ uchar* bits = image.bits();
+ const int bytesPerLine = image.bytesPerLine();
+
+ for (int y = 0; y < m_pixmap.height(); ++y) {
+ quint32* scanLine = reinterpret_cast_ptr<quint32*>(bits + y * bytesPerLine);
+ for (int x = 0; x < m_pixmap.width(); ++x) {
+ QRgb& pixel = scanLine[x];
+ pixel = qRgba(lookUpTable[qRed(pixel)],
+ lookUpTable[qGreen(pixel)],
+ lookUpTable[qBlue(pixel)],
+ qAlpha(pixel));
+ }
+ }
+
+ m_pixmap = QPixmap::fromImage(image);
+
+ if (isPainting)
+ painter->begin(&m_pixmap);
+}
+
+// ---------------------- ImageBufferData
+
+ImageBufferData::ImageBufferData(const IntSize& size)
+{
+ m_painter = new QPainter;
+
+ m_impl = new ImageBufferDataPrivateUnaccelerated(size);
+
+ if (!m_impl->paintDevice())
+ return;
+ if (!m_painter->begin(m_impl->paintDevice()))
+ return;
+
+ initPainter();
+}
+
+#if ENABLE(ACCELERATED_2D_CANVAS)
+ImageBufferData::ImageBufferData(const IntSize& size, QOpenGLContext* compatibleContext)
+{
+ m_painter = new QPainter;
+
+ m_impl = new ImageBufferDataPrivateAccelerated(size, compatibleContext);
+
+ if (!m_impl->paintDevice())
+ return;
+ if (!m_painter->begin(m_impl->paintDevice()))
+ return;
+
+ initPainter();
+}
+#endif
+
+ImageBufferData::~ImageBufferData()
+{
+#if ENABLE(ACCELERATED_2D_CANVAS)
+ if (m_impl->isAccelerated())
+ static_cast<QFramebufferPaintDevice*>(m_impl->paintDevice())->ensureActiveTarget();
+#endif
+ m_painter->end();
+ delete m_painter;
+ delete m_impl;
+}
+
+void ImageBufferData::initPainter()
+{
+ m_painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
+
+ // Since ImageBuffer is used mainly for Canvas, explicitly initialize
+ // its painter's pen and brush with the corresponding canvas defaults
+ // NOTE: keep in sync with CanvasRenderingContext2D::State
+ QPen pen = m_painter->pen();
+ pen.setColor(Qt::black);
+ pen.setWidth(1);
+ pen.setCapStyle(Qt::FlatCap);
+ pen.setJoinStyle(Qt::SvgMiterJoin);
+ pen.setMiterLimit(10);
+ m_painter->setPen(pen);
+ QBrush brush = m_painter->brush();
+ brush.setColor(Qt::black);
+ m_painter->setBrush(brush);
+ m_painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
+}
+
+}
diff --git a/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.h b/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.h
index abd51a584..2ead943ca 100644
--- a/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.h
+++ b/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.h
@@ -23,10 +23,20 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef ImageBufferDataQt_h
+#define ImageBufferDataQt_h
+
#include "Image.h"
+#include "PlatformLayer.h"
+
+#include <QImage>
+#include <QPaintDevice>
#include <QPainter>
-#include <QPixmap>
+
+#if ENABLE(ACCELERATED_2D_CANVAS)
+#include <QOpenGLContext>
+#endif
#include <wtf/RefPtr.h>
@@ -34,16 +44,39 @@ namespace WebCore {
class IntSize;
+struct ImageBufferDataPrivate {
+ virtual ~ImageBufferDataPrivate() { }
+ virtual QPaintDevice* paintDevice() = 0;
+ virtual QImage toQImage() const = 0;
+ virtual RefPtr<Image> image() const = 0;
+ virtual RefPtr<Image> copyImage() const = 0;
+ virtual RefPtr<Image> takeImage() = 0;
+ virtual bool isAccelerated() const = 0;
+ virtual PlatformLayer* platformLayer() = 0;
+ virtual void draw(GraphicsContext& destContext, const FloatRect& destRect,
+ const FloatRect& srcRect, CompositeOperator, BlendMode,
+ bool ownContext) = 0;
+ virtual void drawPattern(GraphicsContext& destContext, const FloatRect& srcRect, const AffineTransform& patternTransform,
+ const FloatPoint& phase, const FloatSize& spacing, CompositeOperator,
+ const FloatRect& destRect, BlendMode, bool ownContext) = 0;
+ virtual void clip(GraphicsContext&, const IntRect& floatRect) const = 0;
+ virtual void platformTransformColorSpace(const Vector<int>& lookUpTable) = 0;
+};
+
class ImageBufferData {
public:
ImageBufferData(const IntSize&);
-
- QImage toQImage() const;
-
- QPixmap m_pixmap;
- std::unique_ptr<QPainter> m_painter;
- RefPtr<Image> m_image;
+#if ENABLE(ACCELERATED_2D_CANVAS)
+ ImageBufferData(const IntSize&, QOpenGLContext*);
+#endif
+ ~ImageBufferData();
+ QPainter* m_painter;
std::unique_ptr<GraphicsContext> m_context;
+ ImageBufferDataPrivate* m_impl;
+protected:
+ void initPainter();
};
} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp b/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
index b0990b3ee..885c43f92 100644
--- a/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
@@ -3,6 +3,7 @@
* Copyright (C) 2008 Holger Hans Peter Freyther
* Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
* Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
+ * Copyright (C) 2014 Digia Plc. and/or its subsidiary(-ies)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -41,7 +42,6 @@
#include <wtf/text/WTFString.h>
#include <QBuffer>
-#include <QColor>
#include <QImage>
#include <QImageWriter>
#include <QPainter>
@@ -50,53 +50,21 @@
namespace WebCore {
-ImageBufferData::ImageBufferData(const IntSize& size)
- : m_pixmap(size)
+#if ENABLE(ACCELERATED_2D_CANVAS)
+ImageBuffer::ImageBuffer(const IntSize& size, float /* resolutionScale */, ColorSpace, QOpenGLContext* compatibleContext, bool& success)
+ : m_data(size, compatibleContext)
+ , m_size(size)
+ , m_logicalSize(size)
{
- if (m_pixmap.isNull())
- return;
-
- m_pixmap.fill(QColor(Qt::transparent));
-
- m_painter = std::make_unique<QPainter>();
-
- if (!m_painter->begin(&m_pixmap))
+ success = m_data.m_painter && m_data.m_painter->isActive();
+ if (!success)
return;
- // Since ImageBuffer is used mainly for Canvas, explicitly initialize
- // its painter's pen and brush with the corresponding canvas defaults
- // NOTE: keep in sync with CanvasRenderingContext2D::State
- QPen pen = m_painter->pen();
- pen.setColor(Qt::black);
- pen.setWidth(1);
- pen.setCapStyle(Qt::FlatCap);
- pen.setJoinStyle(Qt::SvgMiterJoin);
- pen.setMiterLimit(10);
- m_painter->setPen(pen);
- QBrush brush = m_painter->brush();
- brush.setColor(Qt::black);
- m_painter->setBrush(brush);
- m_painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
-
- m_image = StillImage::createForRendering(&m_pixmap);
-}
-
-QImage ImageBufferData::toQImage() const
-{
- QPaintEngine* paintEngine = m_pixmap.paintEngine();
- if (!paintEngine || paintEngine->type() != QPaintEngine::Raster)
- return m_pixmap.toImage();
-
- // QRasterPixmapData::toImage() will deep-copy the backing QImage if there's an active QPainter on it.
- // For performance reasons, we don't want that here, so we temporarily redirect the paint engine.
- QPaintDevice* currentPaintDevice = paintEngine->paintDevice();
- paintEngine->setPaintDevice(0);
- QImage image = m_pixmap.toImage();
- paintEngine->setPaintDevice(currentPaintDevice);
- return image;
+ m_data.m_context = std::make_unique<GraphicsContext>(m_data.m_painter);
}
+#endif
-ImageBuffer::ImageBuffer(const FloatSize& size, float /* resolutionScale */, ColorSpace, RenderingMode, bool& success)
+ImageBuffer::ImageBuffer(const FloatSize& size, float /* resolutionScale */, ColorSpace, RenderingMode /*renderingMode*/, bool& success)
: m_data(IntSize(size))
, m_size(size)
, m_logicalSize(size)
@@ -105,13 +73,24 @@ ImageBuffer::ImageBuffer(const FloatSize& size, float /* resolutionScale */, Col
if (!success)
return;
- m_data.m_context = std::make_unique<GraphicsContext>(m_data.m_painter.get());
+ m_data.m_context = std::make_unique<GraphicsContext>(m_data.m_painter);
}
ImageBuffer::~ImageBuffer()
{
}
+#if ENABLE(ACCELERATED_2D_CANVAS)
+std::unique_ptr<ImageBuffer> ImageBuffer::createCompatibleBuffer(const IntSize& size, float resolutionScale, ColorSpace colorSpace, QOpenGLContext* context)
+{
+ bool success = false;
+ std::unique_ptr<ImageBuffer> buf(new ImageBuffer(size, resolutionScale, colorSpace, context, success));
+ if (!success)
+ return nullptr;
+ return buf;
+}
+#endif
+
GraphicsContext& ImageBuffer::context() const
{
ASSERT(m_data.m_painter->isActive());
@@ -122,14 +101,14 @@ GraphicsContext& ImageBuffer::context() const
RefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBehavior) const
{
if (copyBehavior == CopyBackingStore)
- return StillImage::create(m_data.m_pixmap);
+ return m_data.m_impl->copyImage();
- return StillImage::createForRendering(&m_data.m_pixmap);
+ return m_data.m_impl->image();
}
-RefPtr<Image> ImageBuffer::sinkIntoImage(std::unique_ptr<ImageBuffer> imageBuffer, ScaleBehavior scaleBehavior)
+RefPtr<Image> ImageBuffer::sinkIntoImage(std::unique_ptr<ImageBuffer> imageBuffer, ScaleBehavior)
{
- return StillImage::create(WTFMove(imageBuffer->m_data.m_pixmap));
+ return imageBuffer->m_data.m_impl->takeImage();
}
BackingStoreCopy ImageBuffer::fastCopyImageMode()
@@ -145,52 +124,18 @@ void ImageBuffer::drawConsuming(std::unique_ptr<ImageBuffer> imageBuffer, Graphi
void ImageBuffer::draw(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect,
CompositeOperator op, BlendMode blendMode)
{
- if (&destContext == &context()) {
- // We're drawing into our own buffer. In order for this to work, we need to copy the source buffer first.
- RefPtr<Image> copy = copyImage(CopyBackingStore);
- destContext.drawImage(*copy, destRect, srcRect, ImagePaintingOptions(op, blendMode, ImageOrientationDescription()));
- } else
- destContext.drawImage(*m_data.m_image, destRect, srcRect, ImagePaintingOptions(op, blendMode, ImageOrientationDescription()));
+ m_data.m_impl->draw(destContext, destRect, srcRect, op, blendMode, &destContext == &context());
}
void ImageBuffer::drawPattern(GraphicsContext& destContext, const FloatRect& srcRect, const AffineTransform& patternTransform,
const FloatPoint& phase, const FloatSize& spacing, CompositeOperator op, const FloatRect& destRect, BlendMode blendMode)
{
- if (&destContext == &context()) {
- // We're drawing into our own buffer. In order for this to work, we need to copy the source buffer first.
- RefPtr<Image> copy = copyImage(CopyBackingStore);
- copy->drawPattern(destContext, srcRect, patternTransform, phase, spacing, op, destRect, blendMode);
- } else
- m_data.m_image->drawPattern(destContext, srcRect, patternTransform, phase, spacing, op, destRect, blendMode);
+ m_data.m_impl->drawPattern(destContext, srcRect, patternTransform, phase, spacing, op, destRect, blendMode, &destContext == &context());
}
void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
{
- bool isPainting = m_data.m_painter->isActive();
- if (isPainting)
- m_data.m_painter->end();
-
- QImage image = m_data.toQImage().convertToFormat(QImage::Format_ARGB32);
- ASSERT(!image.isNull());
-
- uchar* bits = image.bits();
- const int bytesPerLine = image.bytesPerLine();
-
- for (int y = 0; y < m_size.height(); ++y) {
- quint32* scanLine = reinterpret_cast_ptr<quint32*>(bits + y * bytesPerLine);
- for (int x = 0; x < m_size.width(); ++x) {
- QRgb& pixel = scanLine[x];
- pixel = qRgba(lookUpTable[qRed(pixel)],
- lookUpTable[qGreen(pixel)],
- lookUpTable[qBlue(pixel)],
- qAlpha(pixel));
- }
- }
-
- m_data.m_pixmap = QPixmap::fromImage(image);
-
- if (isPainting)
- m_data.m_painter->begin(&m_data.m_pixmap);
+ m_data.m_impl->platformTransformColorSpace(lookUpTable);
}
template <Multiply multiplied>
@@ -207,10 +152,11 @@ PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, const ImageBuffe
if (rect.x() < 0 || rect.y() < 0 || rect.maxX() > size.width() || rect.maxY() > size.height())
image.fill(0);
- // Let drawPixmap deal with the conversion.
+ // Let drawImage deal with the conversion.
+ // FIXME: This is inefficient for accelerated ImageBuffers when only part of the imageData is read.
QPainter painter(&image);
painter.setCompositionMode(QPainter::CompositionMode_Source);
- painter.drawPixmap(QPoint(0, 0), imageData.m_pixmap, rect);
+ painter.drawImage(QPoint(0, 0), imageData.m_impl->toQImage(), rect);
painter.end();
return result.release();
@@ -233,7 +179,7 @@ void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, c
bool isPainting = m_data.m_painter->isActive();
if (!isPainting)
- m_data.m_painter->begin(&m_data.m_pixmap);
+ m_data.m_painter->begin(m_data.m_impl->paintDevice());
else {
m_data.m_painter->save();
@@ -281,11 +227,17 @@ String ImageBuffer::toDataURL(const String& mimeType, const double* quality, Coo
// gif, jpeg..., xpm) so skip the image/ to get the Qt image format used to encode
// the m_pixmap image.
+ RefPtr<Image> image = copyImage(DontCopyBackingStore);
QByteArray data;
- if (!encodeImage(m_data.m_pixmap, mimeType.substring(sizeof "image"), quality, data))
+ if (!encodeImage(*image->nativeImageForCurrentFrame(), mimeType.substring(sizeof "image"), quality, data))
return "data:,";
return "data:" + mimeType + ";base64," + data.toBase64().data();
}
+PlatformLayer* ImageBuffer::platformLayer() const
+{
+ return m_data.m_impl->platformLayer();
+}
+
}
diff --git a/Source/WebCore/platform/graphics/qt/OpenGLShimsQt.h b/Source/WebCore/platform/graphics/qt/OpenGLShimsQt.h
new file mode 100644
index 000000000..827d8f6b2
--- /dev/null
+++ b/Source/WebCore/platform/graphics/qt/OpenGLShimsQt.h
@@ -0,0 +1,206 @@
+/*
+ * Copyright (C) 2017 Konstantin Tokarev <annulen@yandex.ru>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <private/qopenglextensions_p.h>
+
+#ifndef FUNCTIONS
+#error You must define FUNCTIONS macro before including this header
+#endif
+
+namespace OpenGLShimsQt {
+ALWAYS_INLINE static void doNothing() { }
+}
+
+#define LOOKUP_GL_FUNCTION(f, ...) OpenGLShimsQt::doNothing(), FUNCTIONS->f(__VA_ARGS__)
+
+// Extra items
+#define glBindTexture(...) LOOKUP_GL_FUNCTION(glBindTexture, __VA_ARGS__)
+#define glBlendFunc(...) LOOKUP_GL_FUNCTION(glBlendFunc, __VA_ARGS__)
+#define glClear(...) LOOKUP_GL_FUNCTION(glClear, __VA_ARGS__)
+#define glClearColor(...) LOOKUP_GL_FUNCTION(glClearColor, __VA_ARGS__)
+#define glClearDepth(...) LOOKUP_GL_FUNCTION(glClearDepthf, __VA_ARGS__)
+#define glClearStencil(...) LOOKUP_GL_FUNCTION(glClearStencil, __VA_ARGS__)
+#define glColorMask(...) LOOKUP_GL_FUNCTION(glColorMask, __VA_ARGS__)
+#define glCopyTexImage2D(...) LOOKUP_GL_FUNCTION(glCopyTexImage2D, __VA_ARGS__)
+#define glCopyTexSubImage2D(...) LOOKUP_GL_FUNCTION(glCopyTexSubImage2D, __VA_ARGS__)
+#define glCullFace(...) LOOKUP_GL_FUNCTION(glCullFace, __VA_ARGS__)
+#define glDeleteTextures(...) LOOKUP_GL_FUNCTION(glDeleteTextures, __VA_ARGS__)
+#define glDepthFunc(...) LOOKUP_GL_FUNCTION(glDepthFunc, __VA_ARGS__)
+#define glDepthMask(...) LOOKUP_GL_FUNCTION(glDepthMask, __VA_ARGS__)
+#define glDepthRange(...) LOOKUP_GL_FUNCTION(glDepthRangef, __VA_ARGS__)
+#define glDisable(...) LOOKUP_GL_FUNCTION(glDisable, __VA_ARGS__)
+#define glDrawArrays(...) LOOKUP_GL_FUNCTION(glDrawArrays, __VA_ARGS__)
+#define glDrawElements(...) LOOKUP_GL_FUNCTION(glDrawElements, __VA_ARGS__)
+#define glEnable(...) LOOKUP_GL_FUNCTION(glEnable, __VA_ARGS__)
+#define glFinish(...) LOOKUP_GL_FUNCTION(glFinish, __VA_ARGS__)
+#define glFlush(...) LOOKUP_GL_FUNCTION(glFlush, __VA_ARGS__)
+#define glFrontFace(...) LOOKUP_GL_FUNCTION(glFrontFace, __VA_ARGS__)
+#define glGenTextures(...) LOOKUP_GL_FUNCTION(glGenTextures, __VA_ARGS__)
+#define glGetBooleanv(...) LOOKUP_GL_FUNCTION(glGetBooleanv, __VA_ARGS__)
+#define glGetFloatv(...) LOOKUP_GL_FUNCTION(glGetFloatv, __VA_ARGS__)
+#define glGetIntegerv(...) LOOKUP_GL_FUNCTION(glGetIntegerv, __VA_ARGS__)
+#define glGetString(...) LOOKUP_GL_FUNCTION(glGetString, __VA_ARGS__)
+#define glGetTexParameterfv(...) LOOKUP_GL_FUNCTION(glGetTexParameterfv, __VA_ARGS__)
+#define glGetTexParameteriv(...) LOOKUP_GL_FUNCTION(glGetTexParameteriv, __VA_ARGS__)
+#define glHint(...) LOOKUP_GL_FUNCTION(glHint, __VA_ARGS__)
+#define glIsTexture(...) LOOKUP_GL_FUNCTION(glIsTexture, __VA_ARGS__)
+#define glLineWidth(...) LOOKUP_GL_FUNCTION(glLineWidth, __VA_ARGS__)
+#define glPixelStorei(...) LOOKUP_GL_FUNCTION(glPixelStorei, __VA_ARGS__)
+#define glPolygonOffset(...) LOOKUP_GL_FUNCTION(glPolygonOffset, __VA_ARGS__)
+#define glReadPixels(...) LOOKUP_GL_FUNCTION(glReadPixels, __VA_ARGS__)
+#define glScissor(...) LOOKUP_GL_FUNCTION(glScissor, __VA_ARGS__)
+#define glStencilFunc(...) LOOKUP_GL_FUNCTION(glStencilFunc, __VA_ARGS__)
+#define glStencilMask(...) LOOKUP_GL_FUNCTION(glStencilMask, __VA_ARGS__)
+#define glStencilOp(...) LOOKUP_GL_FUNCTION(glStencilOp, __VA_ARGS__)
+#define glTexImage2D(...) LOOKUP_GL_FUNCTION(glTexImage2D, __VA_ARGS__)
+#define glTexParameterf(...) LOOKUP_GL_FUNCTION(glTexParameterf, __VA_ARGS__)
+#define glTexParameteri(...) LOOKUP_GL_FUNCTION(glTexParameteri, __VA_ARGS__)
+#define glTexSubImage2D(...) LOOKUP_GL_FUNCTION(glTexSubImage2D, __VA_ARGS__)
+#define glViewport(...) LOOKUP_GL_FUNCTION(glViewport, __VA_ARGS__)
+
+// Keep in sync with OpenGLShims.h
+
+#define glActiveTexture(...) LOOKUP_GL_FUNCTION(glActiveTexture, __VA_ARGS__)
+#define glAttachShader(...) LOOKUP_GL_FUNCTION(glAttachShader, __VA_ARGS__)
+#define glBindAttribLocation(...) LOOKUP_GL_FUNCTION(glBindAttribLocation, __VA_ARGS__)
+#define glBindBuffer(...) LOOKUP_GL_FUNCTION(glBindBuffer, __VA_ARGS__)
+#define glBindFramebufferEXT glBindFramebuffer
+#define glBindFramebuffer(...) LOOKUP_GL_FUNCTION(glBindFramebuffer, __VA_ARGS__)
+#define glBindRenderbufferEXT glBindRenderbuffer
+#define glBindRenderbuffer(...) LOOKUP_GL_FUNCTION(glBindRenderbuffer, __VA_ARGS__)
+#define glBlendColor(...) LOOKUP_GL_FUNCTION(glBlendColor, __VA_ARGS__)
+#define glBlendEquation(...) LOOKUP_GL_FUNCTION(glBlendEquation, __VA_ARGS__)
+#define glBlendEquationSeparate(...) LOOKUP_GL_FUNCTION(glBlendEquationSeparate, __VA_ARGS__)
+#define glBlendFuncSeparate(...) LOOKUP_GL_FUNCTION(glBlendFuncSeparate, __VA_ARGS__)
+#define glBlitFramebufferEXT glBlitFramebuffer
+#define glBlitFramebuffer(...) LOOKUP_GL_FUNCTION(glBlitFramebuffer, __VA_ARGS__)
+#define glBufferData(...) LOOKUP_GL_FUNCTION(glBufferData, __VA_ARGS__)
+#define glBufferSubData(...) LOOKUP_GL_FUNCTION(glBufferSubData, __VA_ARGS__)
+#define glCheckFramebufferStatusEXT glCheckFramebufferStatus
+#define glCheckFramebufferStatus(...) LOOKUP_GL_FUNCTION(glCheckFramebufferStatus, __VA_ARGS__)
+#define glCompileShader(...) LOOKUP_GL_FUNCTION(glCompileShader, __VA_ARGS__)
+#define glCompressedTexImage2D(...) LOOKUP_GL_FUNCTION(glCompressedTexImage2D, __VA_ARGS__)
+#define glCompressedTexSubImage2D(...) LOOKUP_GL_FUNCTION(glCompressedTexSubImage2D, __VA_ARGS__)
+#define glCreateProgram(...) LOOKUP_GL_FUNCTION(glCreateProgram, __VA_ARGS__)
+#define glCreateShader(...) LOOKUP_GL_FUNCTION(glCreateShader, __VA_ARGS__)
+#define glDeleteBuffers(...) LOOKUP_GL_FUNCTION(glDeleteBuffers, __VA_ARGS__)
+#define glDeleteFramebuffersEXT glDeleteFramebuffers
+#define glDeleteFramebuffers(...) LOOKUP_GL_FUNCTION(glDeleteFramebuffers, __VA_ARGS__)
+#define glDeleteProgram(...) LOOKUP_GL_FUNCTION(glDeleteProgram, __VA_ARGS__)
+#define glDeleteRenderbuffersEXT glDeleteRenderbuffers
+#define glDeleteRenderbuffers(...) LOOKUP_GL_FUNCTION(glDeleteRenderbuffers, __VA_ARGS__)
+#define glDeleteShader(...) LOOKUP_GL_FUNCTION(glDeleteShader, __VA_ARGS__)
+#define glDetachShader(...) LOOKUP_GL_FUNCTION(glDetachShader, __VA_ARGS__)
+#define glDisableVertexAttribArray(...) LOOKUP_GL_FUNCTION(glDisableVertexAttribArray, __VA_ARGS__)
+#define glDrawArraysInstancedEXT glDrawArraysInstanced
+#define glDrawArraysInstanced(...) LOOKUP_GL_FUNCTION(glDrawArraysInstanced, __VA_ARGS__)
+#define glDrawBuffersEXT glDrawBuffers
+#define glDrawBuffers(...) LOOKUP_GL_FUNCTION(glDrawBuffers, __VA_ARGS__)
+#define glDrawElementsInstancedEXT glDrawElementsInstanced
+#define glDrawElementsInstanced(...) LOOKUP_GL_FUNCTION(glDrawElementsInstanced, __VA_ARGS__)
+#define glEnableVertexAttribArray(...) LOOKUP_GL_FUNCTION(glEnableVertexAttribArray, __VA_ARGS__)
+#define glFramebufferRenderbufferEXT glFramebufferRenderbuffer
+#define glFramebufferRenderbuffer(...) LOOKUP_GL_FUNCTION(glFramebufferRenderbuffer, __VA_ARGS__)
+#define glFramebufferTexture2DEXT glFramebufferTexture2D
+#define glFramebufferTexture2D(...) LOOKUP_GL_FUNCTION(glFramebufferTexture2D, __VA_ARGS__)
+#define glGenBuffers(...) LOOKUP_GL_FUNCTION(glGenBuffers, __VA_ARGS__)
+#define glGenerateMipmapEXT glGenerateMipmap
+#define glGenerateMipmap(...) LOOKUP_GL_FUNCTION(glGenerateMipmap, __VA_ARGS__)
+#define glGenFramebuffersEXT glGenFramebuffers
+#define glGenFramebuffers(...) LOOKUP_GL_FUNCTION(glGenFramebuffers, __VA_ARGS__)
+#define glGenRenderbuffersEXT glGenRenderbuffers
+#define glGenRenderbuffers(...) LOOKUP_GL_FUNCTION(glGenRenderbuffers, __VA_ARGS__)
+#define glGetActiveAttrib(...) LOOKUP_GL_FUNCTION(glGetActiveAttrib, __VA_ARGS__)
+#define glGetActiveUniform(...) LOOKUP_GL_FUNCTION(glGetActiveUniform, __VA_ARGS__)
+#define glGetAttachedShaders(...) LOOKUP_GL_FUNCTION(glGetAttachedShaders, __VA_ARGS__)
+#define glGetAttribLocation(...) LOOKUP_GL_FUNCTION(glGetAttribLocation, __VA_ARGS__)
+#define glGetBufferParameterivEXT glGetBufferParameteriv
+#define glGetBufferParameteriv(...) LOOKUP_GL_FUNCTION(glGetBufferParameteriv, __VA_ARGS__)
+#define glGetFramebufferAttachmentParameterivEXT glGetFramebufferAttachmentParameteriv
+#define glGetFramebufferAttachmentParameteriv(...) LOOKUP_GL_FUNCTION(glGetFramebufferAttachmentParameteriv, __VA_ARGS__)
+#define glGetProgramInfoLog(...) LOOKUP_GL_FUNCTION(glGetProgramInfoLog, __VA_ARGS__)
+#define glGetProgramiv(...) LOOKUP_GL_FUNCTION(glGetProgramiv, __VA_ARGS__)
+#define glGetRenderbufferParameterivEXT glGetRenderbufferParameteriv
+#define glGetRenderbufferParameteriv(...) LOOKUP_GL_FUNCTION(glGetRenderbufferParameteriv, __VA_ARGS__)
+#define glGetShaderInfoLog(...) LOOKUP_GL_FUNCTION(glGetShaderInfoLog, __VA_ARGS__)
+#define glGetShaderiv(...) LOOKUP_GL_FUNCTION(glGetShaderiv, __VA_ARGS__)
+#define glGetShaderSource(...) LOOKUP_GL_FUNCTION(glGetShaderSource, __VA_ARGS__)
+#define glGetUniformfv(...) LOOKUP_GL_FUNCTION(glGetUniformfv, __VA_ARGS__)
+#define glGetUniformiv(...) LOOKUP_GL_FUNCTION(glGetUniformiv, __VA_ARGS__)
+#define glGetUniformLocation(...) LOOKUP_GL_FUNCTION(glGetUniformLocation, __VA_ARGS__)
+#define glGetVertexAttribfv(...) LOOKUP_GL_FUNCTION(glGetVertexAttribfv, __VA_ARGS__)
+#define glGetVertexAttribiv(...) LOOKUP_GL_FUNCTION(glGetVertexAttribiv, __VA_ARGS__)
+#define glGetVertexAttribPointerv(...) LOOKUP_GL_FUNCTION(glGetVertexAttribPointerv, __VA_ARGS__)
+#define glIsBuffer(...) LOOKUP_GL_FUNCTION(glIsBuffer, __VA_ARGS__)
+#define glIsFramebufferEXT glIsFramebuffer
+#define glIsFramebuffer(...) LOOKUP_GL_FUNCTION(glIsFramebuffer, __VA_ARGS__)
+#define glIsProgram(...) LOOKUP_GL_FUNCTION(glIsProgram, __VA_ARGS__)
+#define glIsRenderbufferEXT glIsRenderbuffer
+#define glIsRenderbuffer(...) LOOKUP_GL_FUNCTION(glIsRenderbuffer, __VA_ARGS__)
+#define glIsShader(...) LOOKUP_GL_FUNCTION(glIsShader, __VA_ARGS__)
+#define glLinkProgram(...) LOOKUP_GL_FUNCTION(glLinkProgram, __VA_ARGS__)
+#define glRenderbufferStorageEXT glRenderbufferStorage
+#define glRenderbufferStorage(...) LOOKUP_GL_FUNCTION(glRenderbufferStorage, __VA_ARGS__)
+#define glRenderbufferStorageMultisampleEXT glRenderbufferStorageMultisample
+#define glRenderbufferStorageMultisample(...) LOOKUP_GL_FUNCTION(glRenderbufferStorageMultisample, __VA_ARGS__)
+#define glSampleCoverage(...) LOOKUP_GL_FUNCTION(glSampleCoverage, __VA_ARGS__)
+#define glShaderSource(...) LOOKUP_GL_FUNCTION(glShaderSource, __VA_ARGS__)
+#define glStencilFuncSeparate(...) LOOKUP_GL_FUNCTION(glStencilFuncSeparate, __VA_ARGS__)
+#define glStencilMaskSeparate(...) LOOKUP_GL_FUNCTION(glStencilMaskSeparate, __VA_ARGS__)
+#define glStencilOpSeparate(...) LOOKUP_GL_FUNCTION(glStencilOpSeparate, __VA_ARGS__)
+#define glUniform1f(...) LOOKUP_GL_FUNCTION(glUniform1f, __VA_ARGS__)
+#define glUniform1fv(...) LOOKUP_GL_FUNCTION(glUniform1fv, __VA_ARGS__)
+#define glUniform1i(...) LOOKUP_GL_FUNCTION(glUniform1i, __VA_ARGS__)
+#define glUniform1iv(...) LOOKUP_GL_FUNCTION(glUniform1iv, __VA_ARGS__)
+#define glUniform2f(...) LOOKUP_GL_FUNCTION(glUniform2f, __VA_ARGS__)
+#define glUniform2fv(...) LOOKUP_GL_FUNCTION(glUniform2fv, __VA_ARGS__)
+#define glUniform2i(...) LOOKUP_GL_FUNCTION(glUniform2i, __VA_ARGS__)
+#define glUniform2iv(...) LOOKUP_GL_FUNCTION(glUniform2iv, __VA_ARGS__)
+#define glUniform3f(...) LOOKUP_GL_FUNCTION(glUniform3f, __VA_ARGS__)
+#define glUniform3fv(...) LOOKUP_GL_FUNCTION(glUniform3fv, __VA_ARGS__)
+#define glUniform3i(...) LOOKUP_GL_FUNCTION(glUniform3i, __VA_ARGS__)
+#define glUniform3iv(...) LOOKUP_GL_FUNCTION(glUniform3iv, __VA_ARGS__)
+#define glUniform4f(...) LOOKUP_GL_FUNCTION(glUniform4f, __VA_ARGS__)
+#define glUniform4fv(...) LOOKUP_GL_FUNCTION(glUniform4fv, __VA_ARGS__)
+#define glUniform4i(...) LOOKUP_GL_FUNCTION(glUniform4i, __VA_ARGS__)
+#define glUniform4iv(...) LOOKUP_GL_FUNCTION(glUniform4iv, __VA_ARGS__)
+#define glUniformMatrix2fv(...) LOOKUP_GL_FUNCTION(glUniformMatrix2fv, __VA_ARGS__)
+#define glUniformMatrix3fv(...) LOOKUP_GL_FUNCTION(glUniformMatrix3fv, __VA_ARGS__)
+#define glUniformMatrix4fv(...) LOOKUP_GL_FUNCTION(glUniformMatrix4fv, __VA_ARGS__)
+#define glUseProgram(...) LOOKUP_GL_FUNCTION(glUseProgram, __VA_ARGS__)
+#define glValidateProgram(...) LOOKUP_GL_FUNCTION(glValidateProgram, __VA_ARGS__)
+#define glVertexAttrib1f(...) LOOKUP_GL_FUNCTION(glVertexAttrib1f, __VA_ARGS__)
+#define glVertexAttrib1fv(...) LOOKUP_GL_FUNCTION(glVertexAttrib1fv, __VA_ARGS__)
+#define glVertexAttrib2f(...) LOOKUP_GL_FUNCTION(glVertexAttrib2f, __VA_ARGS__)
+#define glVertexAttrib2fv(...) LOOKUP_GL_FUNCTION(glVertexAttrib2fv, __VA_ARGS__)
+#define glVertexAttrib3f(...) LOOKUP_GL_FUNCTION(glVertexAttrib3f, __VA_ARGS__)
+#define glVertexAttrib3fv(...) LOOKUP_GL_FUNCTION(glVertexAttrib3fv, __VA_ARGS__)
+#define glVertexAttrib4f(...) LOOKUP_GL_FUNCTION(glVertexAttrib4f, __VA_ARGS__)
+#define glVertexAttrib4fv(...) LOOKUP_GL_FUNCTION(glVertexAttrib4fv, __VA_ARGS__)
+#define glVertexAttribDivisorEXT glVertexAttribDivisor
+#define glVertexAttribDivisor(...) LOOKUP_GL_FUNCTION(glVertexAttribDivisor, __VA_ARGS__)
+#define glVertexAttribPointer(...) LOOKUP_GL_FUNCTION(glVertexAttribPointer, __VA_ARGS__)
diff --git a/Source/WebCore/platform/graphics/gpu/qt/DrawingBufferQt.cpp b/Source/WebCore/platform/graphics/qt/OpenGLShimsQtVAO.h
index 47cb4b95b..36b3aec69 100644
--- a/Source/WebCore/platform/graphics/gpu/qt/DrawingBufferQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/OpenGLShimsQtVAO.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Andrew Wason (rectalogic@rectalogic.com)
+ * Copyright (C) 2017 Konstantin Tokarev <annulen@yandex.ru>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -13,40 +13,31 @@
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
+#pragma once
-#if USE(3D_GRAPHICS)
+#include <private/qopenglvertexarrayobject_p.h>
-#include "DrawingBuffer.h"
-
-namespace WebCore {
-
-#if USE(ACCELERATED_COMPOSITING)
-PlatformLayer* DrawingBuffer::platformLayer()
-{
- return 0;
-}
-
-unsigned DrawingBuffer::frontColorBuffer() const
-{
- return colorBuffer();
-}
-
-void DrawingBuffer::paintCompositedResultsToCanvas(ImageBuffer*)
-{
-}
+#ifndef VAO_FUNCTIONS
+#error You must define VAO_FUNCTIONS macro before including this header
#endif
-}
-
+#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
+#define LOOKUP_VAO_FUNCTION(f, ...) VAO_FUNCTIONS->f(__VA_ARGS__)
+#else
+#define LOOKUP_VAO_FUNCTION(f, ...)
#endif
+
+#define glGenVertexArrays(...) LOOKUP_VAO_FUNCTION(glGenVertexArrays, __VA_ARGS__)
+#define glDeleteVertexArrays(...) LOOKUP_VAO_FUNCTION(glDeleteVertexArrays, __VA_ARGS__)
+#define glIsVertexArray(...) LOOKUP_VAO_FUNCTION(glIsVertexArray, __VA_ARGS__)
+#define glBindVertexArray(...) LOOKUP_VAO_FUNCTION(glBindVertexArray, __VA_ARGS__)
diff --git a/Source/WebCore/platform/graphics/qt/QFramebufferPaintDevice.cpp b/Source/WebCore/platform/graphics/qt/QFramebufferPaintDevice.cpp
new file mode 100644
index 000000000..7c29d95e6
--- /dev/null
+++ b/Source/WebCore/platform/graphics/qt/QFramebufferPaintDevice.cpp
@@ -0,0 +1,69 @@
+/*
+ Copyright (C) 2014 Digia Plc. and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "QFramebufferPaintDevice.h"
+
+#include <QOpenGLFunctions>
+
+QFramebufferPaintDevice::QFramebufferPaintDevice(const QSize& size,
+ QOpenGLFramebufferObject::Attachment attachment, bool clearOnInit)
+ : QOpenGLPaintDevice(size)
+ , m_framebufferObject(size, attachment)
+{
+ m_surface = QOpenGLContext::currentContext()->surface();
+#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
+ setPaintFlipped(true);
+#endif
+ if (clearOnInit) {
+ m_framebufferObject.bind();
+
+ context()->functions()->glClearColor(0, 0, 0, 0);
+ context()->functions()->glClear(GL_COLOR_BUFFER_BIT);
+ }
+}
+
+void QFramebufferPaintDevice::ensureActiveTarget()
+{
+ if (QOpenGLContext::currentContext() != context())
+ context()->makeCurrent(m_surface);
+
+ m_framebufferObject.bind();
+}
+
+QImage QFramebufferPaintDevice::toImage() const
+{
+ QOpenGLContext* currentContext = QOpenGLContext::currentContext();
+ QSurface* currentSurface = currentContext ? currentContext->surface() : 0;
+
+ context()->makeCurrent(m_surface);
+
+#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
+ QImage image = m_framebufferObject.toImage(false);
+#else
+ QImage image = m_framebufferObject.toImage();
+#endif
+
+ if (currentContext)
+ currentContext->makeCurrent(currentSurface);
+ else
+ context()->doneCurrent();
+
+ return image;
+}
diff --git a/Source/WebCore/platform/graphics/qt/QFramebufferPaintDevice.h b/Source/WebCore/platform/graphics/qt/QFramebufferPaintDevice.h
new file mode 100644
index 000000000..14562acb2
--- /dev/null
+++ b/Source/WebCore/platform/graphics/qt/QFramebufferPaintDevice.h
@@ -0,0 +1,56 @@
+/*
+ Copyright (C) 2014 Digia Plc. and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef QFramebufferPaintDevice_h
+#define QFramebufferPaintDevice_h
+
+#include <QImage>
+#include <QOpenGLFramebufferObject>
+#include <QOpenGLPaintDevice>
+#include <QSurface>
+
+class QFramebufferPaintDevice : public QOpenGLPaintDevice {
+public:
+ QFramebufferPaintDevice(const QSize&,
+ QOpenGLFramebufferObject::Attachment = QOpenGLFramebufferObject::CombinedDepthStencil,
+ bool clearOnInit = true);
+
+ // QOpenGLPaintDevice:
+ virtual void ensureActiveTarget() Q_DECL_OVERRIDE;
+
+ bool isValid() const { return m_framebufferObject.isValid(); }
+ GLuint handle() const { return m_framebufferObject.handle(); }
+ GLuint texture() const { return m_framebufferObject.texture(); }
+ QImage toImage() const;
+
+ bool bind() { return m_framebufferObject.bind(); }
+ bool release() { return m_framebufferObject.release(); }
+ QSize size() const { return m_framebufferObject.size(); }
+
+ QOpenGLFramebufferObject* framebufferObject() { return &m_framebufferObject; }
+ const QOpenGLFramebufferObject* framebufferObject() const { return &m_framebufferObject; }
+
+ static bool isSupported() { return QOpenGLFramebufferObject::hasOpenGLFramebufferObjects(); }
+
+private:
+ QOpenGLFramebufferObject m_framebufferObject;
+ QSurface* m_surface;
+};
+
+#endif
diff --git a/Source/WebCore/platform/graphics/qt/StillImageQt.h b/Source/WebCore/platform/graphics/qt/StillImageQt.h
index e35e56609..b9079727e 100644
--- a/Source/WebCore/platform/graphics/qt/StillImageQt.h
+++ b/Source/WebCore/platform/graphics/qt/StillImageQt.h
@@ -34,17 +34,17 @@ namespace WebCore {
class StillImage final : public Image {
public:
- static PassRefPtr<StillImage> create(const QPixmap& pixmap)
+ static RefPtr<StillImage> create(const QPixmap& pixmap)
{
return adoptRef(new StillImage(pixmap));
}
- static PassRefPtr<StillImage> createForRendering(const QPixmap* pixmap)
+ static RefPtr<StillImage> createForRendering(const QPixmap* pixmap)
{
return adoptRef(new StillImage(pixmap));
}
- static PassRefPtr<StillImage> create(QPixmap&& pixmap)
+ static RefPtr<StillImage> create(QPixmap&& pixmap)
{
return adoptRef(new StillImage(WTFMove(pixmap)));
}
diff --git a/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp b/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp
index 3d7037c2f..59c763b51 100644
--- a/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp
+++ b/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp
@@ -37,6 +37,10 @@
#include <wtf/RefCounted.h>
#include <wtf/TemporaryChange.h>
+#if PLATFORM(QT)
+#include <QPaintEngine>
+#endif
+
#if USE(CAIRO)
#include "CairoUtilities.h"
#include "RefPtrCairo.h"
@@ -200,7 +204,17 @@ void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, co
imageData = reinterpret_cast<const char*>(cairo_image_surface_get_data(surface));
bytesPerLine = cairo_image_surface_get_stride(surface);
#elif PLATFORM(QT)
- QImage qImage = frameImage->toImage();
+ QImage qImage;
+ QPaintEngine* paintEngine = frameImage->paintEngine();
+ if (paintEngine && paintEngine->type() == QPaintEngine::Raster) {
+ // QRasterPixmapData::toImage() will deep-copy the backing QImage if there's an active QPainter on it.
+ // For performance reasons, we don't want that here, so we temporarily redirect the paint engine.
+ QPaintDevice* currentPaintDevice = paintEngine->paintDevice();
+ paintEngine->setPaintDevice(0);
+ qImage = frameImage->toImage();
+ paintEngine->setPaintDevice(currentPaintDevice);
+ } else
+ qImage = frameImage->toImage();
imageData = reinterpret_cast<const char*>(qImage.constBits());
bytesPerLine = qImage.bytesPerLine();
#endif
diff --git a/Source/WebCore/platform/graphics/texmap/BitmapTextureImageBuffer.cpp b/Source/WebCore/platform/graphics/texmap/BitmapTextureImageBuffer.cpp
new file mode 100644
index 000000000..ee677c2a2
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/BitmapTextureImageBuffer.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "BitmapTextureImageBuffer.h"
+
+#include "GraphicsLayer.h"
+
+#if PLATFORM(QT)
+#include "GraphicsContext.h"
+#include "NativeImageQt.h"
+#endif
+
+namespace WebCore {
+
+void BitmapTextureImageBuffer::updateContents(const void* data, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine, UpdateContentsFlag)
+{
+#if PLATFORM(QT)
+ QImage image(reinterpret_cast<const uchar*>(data), targetRect.width(), targetRect.height(), bytesPerLine, NativeImageQt::defaultFormatForAlphaEnabledImages());
+
+ QPainter* painter = m_image->context().platformContext();
+ painter->save();
+ painter->setCompositionMode(QPainter::CompositionMode_Source);
+ painter->drawImage(targetRect, image, IntRect(sourceOffset, targetRect.size()));
+ painter->restore();
+#elif PLATFORM(CAIRO)
+ RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(static_cast<unsigned char*>(data()),
+ CAIRO_FORMAT_ARGB32, targetRect.width(), targetRect.height(), bytesPerLine));
+ m_image->context()->platformContext()->drawSurfaceToContext(surface.get(), targetRect,
+ IntRect(sourceOffset, targetRect.size()), m_image->context());
+#else
+ UNUSED_PARAM(data);
+ UNUSED_PARAM(targetRect);
+ UNUSED_PARAM(sourceOffset);
+ UNUSED_PARAM(bytesPerLine);
+#endif
+}
+
+void BitmapTextureImageBuffer::updateContents(TextureMapper&, GraphicsLayer* sourceLayer, const IntRect& targetRect, const IntPoint& sourceOffset, UpdateContentsFlag, float scale)
+{
+ // QTFIXME: Handle scale, like BitmapTexture::updateContents
+ GraphicsContext& context = m_image->context();
+
+ context.clearRect(targetRect);
+
+ IntRect sourceRect(targetRect);
+ sourceRect.setLocation(sourceOffset);
+ context.save();
+ context.clip(targetRect);
+ context.translate(targetRect.x() - sourceOffset.x(), targetRect.y() - sourceOffset.y());
+ sourceLayer->paintGraphicsLayerContents(context, sourceRect);
+ context.restore();
+}
+
+void BitmapTextureImageBuffer::didReset()
+{
+ m_image = ImageBuffer::create(contentSize(), Unaccelerated);
+}
+
+void BitmapTextureImageBuffer::updateContents(Image* image, const IntRect& targetRect, const IntPoint& offset, UpdateContentsFlag)
+{
+ m_image->context().drawImage(*image, targetRect, IntRect(offset, targetRect.size()), CompositeCopy);
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/texmap/BitmapTextureImageBuffer.h b/Source/WebCore/platform/graphics/texmap/BitmapTextureImageBuffer.h
new file mode 100644
index 000000000..6443ba737
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/BitmapTextureImageBuffer.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BitmapTextureImageBuffer_h
+#define BitmapTextureImageBuffer_h
+
+#include "BitmapTexture.h"
+#include "ImageBuffer.h"
+#include "IntRect.h"
+#include "IntSize.h"
+
+namespace WebCore {
+
+class GraphicsContext;
+
+class BitmapTextureImageBuffer final : public BitmapTexture {
+public:
+ static PassRefPtr<BitmapTexture> create() { return adoptRef(new BitmapTextureImageBuffer); }
+ IntSize size() const final { return m_image->internalSize(); }
+ void didReset() final;
+ bool isValid() const final { return m_image.get(); }
+ void updateContents(Image*, const IntRect&, const IntPoint&, UpdateContentsFlag) final;
+ void updateContents(TextureMapper&, GraphicsLayer*, const IntRect& target, const IntPoint& offset, UpdateContentsFlag, float scale) final;
+ void updateContents(const void*, const IntRect& target, const IntPoint& sourceOffset, int bytesPerLine, UpdateContentsFlag) final;
+ PassRefPtr<BitmapTexture> applyFilters(TextureMapper&, const FilterOperations&) final;
+
+ inline GraphicsContext* graphicsContext() { return m_image ? &m_image->context() : nullptr; }
+ ImageBuffer* image() const { return m_image.get(); }
+
+private:
+ BitmapTextureImageBuffer() { }
+ std::unique_ptr<ImageBuffer> m_image;
+};
+
+}
+
+#endif // BitmapTextureImageBuffer_h
diff --git a/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp b/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp
index 1b46f3752..f0e7f23e7 100644
--- a/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp
+++ b/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp
@@ -31,11 +31,23 @@
#include "BitmapTextureGL.h"
#endif
+#if PLATFORM(QT)
+#include "BitmapTextureImageBuffer.h"
+#endif
+
namespace WebCore {
static const double s_releaseUnusedSecondsTolerance = 3;
static const double s_releaseUnusedTexturesTimerInterval = 0.5;
+
+#if PLATFORM(QT)
+BitmapTexturePool::BitmapTexturePool()
+ : m_releaseUnusedTexturesTimer(*this, &BitmapTexturePool::releaseUnusedTexturesTimerFired)
+{
+}
+#endif
+
#if USE(TEXTURE_MAPPER_GL)
BitmapTexturePool::BitmapTexturePool(RefPtr<GraphicsContext3D>&& context3D)
: m_context3D(WTFMove(context3D))
@@ -104,10 +116,14 @@ void BitmapTexturePool::releaseUnusedTexturesTimerFired()
RefPtr<BitmapTexture> BitmapTexturePool::createTexture(const BitmapTexture::Flags flags)
{
+#if PLATFORM(QT)
+ if (!m_context3D)
+ return BitmapTextureImageBuffer::create();
+#endif
#if USE(TEXTURE_MAPPER_GL)
return adoptRef(new BitmapTextureGL(m_context3D, flags));
#else
- return nullptr;
+ return BitmapTextureImageBuffer::create();
#endif
}
diff --git a/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.h b/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.h
index 95ba249aa..bf577344b 100644
--- a/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.h
+++ b/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.h
@@ -44,6 +44,9 @@ class BitmapTexturePool {
WTF_MAKE_NONCOPYABLE(BitmapTexturePool);
WTF_MAKE_FAST_ALLOCATED;
public:
+#if PLATFORM(QT)
+ BitmapTexturePool();
+#endif
#if USE(TEXTURE_MAPPER_GL)
explicit BitmapTexturePool(RefPtr<GraphicsContext3D>&&);
#endif
diff --git a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
index 636be8751..812980a28 100644
--- a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
+++ b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
@@ -608,7 +608,8 @@ void GraphicsLayerTextureMapper::removeAnimation(const String& animationName)
bool GraphicsLayerTextureMapper::setFilters(const FilterOperations& filters)
{
TextureMapper* textureMapper = m_layer.textureMapper();
- if (!textureMapper)
+ // TextureMapperImageBuffer does not support CSS filters.
+ if (!textureMapper || textureMapper->accelerationMode() == TextureMapper::SoftwareMode)
return false;
notifyChange(FilterChange);
return GraphicsLayer::setFilters(filters);
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp
index b985c7b90..a458f8177 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp
@@ -23,6 +23,7 @@
#include "BitmapTexturePool.h"
#include "FilterOperations.h"
#include "GraphicsLayer.h"
+#include "TextureMapperImageBuffer.h"
#include "Timer.h"
#include <wtf/CurrentTime.h>
@@ -35,15 +36,18 @@ PassRefPtr<BitmapTexture> TextureMapper::acquireTextureFromPool(const IntSize& s
return selectedTexture.release();
}
-std::unique_ptr<TextureMapper> TextureMapper::create()
+std::unique_ptr<TextureMapper> TextureMapper::create(AccelerationMode mode)
{
+ if (mode == SoftwareMode)
+ return std::make_unique<TextureMapperImageBuffer>();
return platformCreateAccelerated();
}
-TextureMapper::TextureMapper()
+TextureMapper::TextureMapper(AccelerationMode accelerationMode)
: m_context(0)
, m_interpolationQuality(InterpolationDefault)
, m_textDrawingMode(TextModeFill)
+ , m_accelerationMode(accelerationMode)
, m_isMaskMode(false)
, m_wrapMode(StretchWrap)
{ }
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapper.h b/Source/WebCore/platform/graphics/texmap/TextureMapper.h
index bfe718e28..43d1db7a1 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapper.h
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapper.h
@@ -48,6 +48,7 @@ class FilterOperations;
class TextureMapper {
WTF_MAKE_FAST_ALLOCATED;
public:
+ enum AccelerationMode { SoftwareMode, OpenGLMode };
enum PaintFlag {
PaintingMirrored = 1 << 0,
};
@@ -59,9 +60,9 @@ public:
typedef unsigned PaintFlags;
- static std::unique_ptr<TextureMapper> create();
+ static std::unique_ptr<TextureMapper> create(AccelerationMode newMode = SoftwareMode);
- explicit TextureMapper();
+ explicit TextureMapper(AccelerationMode);
virtual ~TextureMapper();
enum ExposedEdges {
@@ -93,6 +94,7 @@ public:
InterpolationQuality imageInterpolationQuality() const { return m_interpolationQuality; }
TextDrawingModeFlags textDrawingMode() const { return m_textDrawingMode; }
+ AccelerationMode accelerationMode() const { return m_accelerationMode; }
virtual void beginPainting(PaintFlags = 0) { }
virtual void endPainting() { }
@@ -125,6 +127,7 @@ private:
#endif
InterpolationQuality m_interpolationQuality;
TextDrawingModeFlags m_textDrawingMode;
+ AccelerationMode m_accelerationMode;
bool m_isMaskMode;
TransformationMatrix m_patternTransform;
WrapMode m_wrapMode;
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
index 86f100262..25ed9dd7f 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
@@ -176,7 +176,8 @@ void TextureMapperGLData::initializeStencil()
}
TextureMapperGL::TextureMapperGL()
- : m_enableEdgeDistanceAntialiasing(false)
+ : TextureMapper(OpenGLMode)
+ , m_enableEdgeDistanceAntialiasing(false)
{
m_context3D = GraphicsContext3D::createForCurrentGLContext();
m_data = new TextureMapperGLData(m_context3D.get());
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp
new file mode 100644
index 000000000..0812b585d
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp
@@ -0,0 +1,125 @@
+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "TextureMapperImageBuffer.h"
+
+#include "BitmapTexturePool.h"
+#include "GraphicsLayer.h"
+#include "NotImplemented.h"
+
+#if USE(TEXTURE_MAPPER)
+namespace WebCore {
+
+static const int s_maximumAllowedImageBufferDimension = 4096;
+
+TextureMapperImageBuffer::TextureMapperImageBuffer()
+ : TextureMapper(SoftwareMode)
+{
+ m_texturePool = std::make_unique<BitmapTexturePool>();
+}
+
+IntSize TextureMapperImageBuffer::maxTextureSize() const
+{
+ return IntSize(s_maximumAllowedImageBufferDimension, s_maximumAllowedImageBufferDimension);
+}
+
+void TextureMapperImageBuffer::beginClip(const TransformationMatrix& matrix, const FloatRect& rect)
+{
+ GraphicsContext* context = currentContext();
+ if (!context)
+ return;
+#if ENABLE(3D_TRANSFORMS)
+ TransformationMatrix previousTransform = context->get3DTransform();
+#else
+ AffineTransform previousTransform = context->getCTM();
+#endif
+ context->save();
+
+#if ENABLE(3D_TRANSFORMS)
+ context->concat3DTransform(matrix);
+#else
+ context->concatCTM(matrix.toAffineTransform());
+#endif
+
+ context->clip(rect);
+
+#if ENABLE(3D_TRANSFORMS)
+ context->set3DTransform(previousTransform);
+#else
+ context->setCTM(previousTransform);
+#endif
+}
+
+void TextureMapperImageBuffer::drawTexture(const BitmapTexture& texture, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, unsigned /* exposedEdges */)
+{
+ GraphicsContext* context = currentContext();
+ if (!context)
+ return;
+
+ const BitmapTextureImageBuffer& textureImageBuffer = static_cast<const BitmapTextureImageBuffer&>(texture);
+ ImageBuffer* image = textureImageBuffer.image();
+ context->save();
+ context->setCompositeOperation(isInMaskMode() ? CompositeDestinationIn : CompositeSourceOver);
+ context->setAlpha(opacity);
+#if ENABLE(3D_TRANSFORMS)
+ context->concat3DTransform(matrix);
+#else
+ context->concatCTM(matrix.toAffineTransform());
+#endif
+ context->drawImageBuffer(*image, targetRect);
+ context->restore();
+}
+
+void TextureMapperImageBuffer::drawSolidColor(const FloatRect& rect, const TransformationMatrix& matrix, const Color& color)
+{
+ GraphicsContext* context = currentContext();
+ if (!context)
+ return;
+
+ context->save();
+ context->setCompositeOperation(isInMaskMode() ? CompositeDestinationIn : CompositeSourceOver);
+#if ENABLE(3D_TRANSFORMS)
+ context->concat3DTransform(matrix);
+#else
+ context->concatCTM(matrix.toAffineTransform());
+#endif
+
+ context->fillRect(rect, color);
+ context->restore();
+}
+
+void TextureMapperImageBuffer::drawBorder(const Color&, float /* borderWidth */, const FloatRect&, const TransformationMatrix&)
+{
+ notImplemented();
+}
+
+void TextureMapperImageBuffer::drawNumber(int /* number */, const Color&, const FloatPoint&, const TransformationMatrix&)
+{
+ notImplemented();
+}
+
+PassRefPtr<BitmapTexture> BitmapTextureImageBuffer::applyFilters(TextureMapper&, const FilterOperations&)
+{
+ ASSERT_NOT_REACHED();
+ return this;
+}
+
+}
+#endif
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h b/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h
new file mode 100644
index 000000000..234b8eeec
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h
@@ -0,0 +1,59 @@
+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef TextureMapperImageBuffer_h
+#define TextureMapperImageBuffer_h
+
+#include "BitmapTextureImageBuffer.h"
+#include "ImageBuffer.h"
+#include "TextureMapper.h"
+
+#if USE(TEXTURE_MAPPER)
+namespace WebCore {
+
+class TextureMapperImageBuffer final : public TextureMapper {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ TextureMapperImageBuffer();
+
+ // TextureMapper implementation
+ void drawBorder(const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) final;
+ void drawNumber(int number, const Color&, const FloatPoint&, const TransformationMatrix&) final;
+ void drawTexture(const BitmapTexture&, const FloatRect& targetRect, const TransformationMatrix&, float opacity, unsigned exposedEdges) final;
+ void drawSolidColor(const FloatRect&, const TransformationMatrix&, const Color&) final;
+ void beginClip(const TransformationMatrix&, const FloatRect&) final;
+ void bindSurface(BitmapTexture* surface) final { m_currentSurface = surface;}
+ void endClip() final { graphicsContext()->restore(); }
+ IntRect clipBounds() final { return currentContext()->clipBounds(); }
+ IntSize maxTextureSize() const final;
+ PassRefPtr<BitmapTexture> createTexture() final { return BitmapTextureImageBuffer::create(); }
+
+ inline GraphicsContext* currentContext()
+ {
+ return m_currentSurface ? static_cast<BitmapTextureImageBuffer*>(m_currentSurface.get())->graphicsContext() : graphicsContext();
+ }
+
+private:
+ RefPtr<BitmapTexture> m_currentSurface;
+};
+
+}
+#endif // USE(TEXTURE_MAPPER)
+
+#endif // TextureMapperImageBuffer_h
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp
index 4bfddfd6c..e2f15b3b8 100644
--- a/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp
@@ -58,6 +58,9 @@ CompositingCoordinator::CompositingCoordinator(Page* page, CompositingCoordinato
, m_lastAnimationServiceTime(0)
#endif
{
+ // This is a temporary way to enable this only in the GL case, until TextureMapperImageBuffer is removed.
+ // See https://bugs.webkit.org/show_bug.cgi?id=114869
+ CoordinatedGraphicsLayer::setShouldSupportContentsTiling(true);
}
CompositingCoordinator::~CompositingCoordinator()
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
index cb94a9652..7de531692 100644
--- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
@@ -376,9 +376,16 @@ void CoordinatedGraphicsLayer::setContentsTilePhase(const FloatSize& p)
didChangeLayerState();
}
+static bool s_shouldSupportContentsTiling = false;
+
+void CoordinatedGraphicsLayer::setShouldSupportContentsTiling(bool s)
+{
+ s_shouldSupportContentsTiling = s;
+}
+
bool GraphicsLayer::supportsContentsTiling()
{
- return true;
+ return s_shouldSupportContentsTiling;
}
void CoordinatedGraphicsLayer::setContentsNeedsDisplay()
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h
index 8a45c3565..1664cffe7 100644
--- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h
@@ -146,6 +146,7 @@ public:
void setNeedsVisibleRectAdjustment();
void purgeBackingStores();
+ static void setShouldSupportContentsTiling(bool);
CoordinatedGraphicsLayer* findFirstDescendantWithContentsRecursively();
private:
diff --git a/Source/WebCore/platform/qt/FileSystemQt.cpp b/Source/WebCore/platform/qt/FileSystemQt.cpp
index 363029406..167ff8354 100644
--- a/Source/WebCore/platform/qt/FileSystemQt.cpp
+++ b/Source/WebCore/platform/qt/FileSystemQt.cpp
@@ -147,6 +147,12 @@ CString fileSystemRepresentation(const String& path)
return path.utf8();
}
+String stringFromFileSystemRepresentation(const char* fileSystemRepresentation)
+{
+ // This needs to do the opposite of fileSystemRepresentation.
+ return String::fromUTF8(fileSystemRepresentation);
+}
+
String openTemporaryFile(const String& prefix, PlatformFileHandle& handle)
{
#ifndef QT_NO_TEMPORARYFILE
diff --git a/Source/WebCore/platform/qt/QWebPageClient.h b/Source/WebCore/platform/qt/QWebPageClient.h
index c9211044c..c37abff62 100644
--- a/Source/WebCore/platform/qt/QWebPageClient.h
+++ b/Source/WebCore/platform/qt/QWebPageClient.h
@@ -34,6 +34,7 @@
#include <QRect>
QT_BEGIN_NAMESPACE
+class QOpenGLContext;
class QStyle;
class QWindow;
QT_END_NAMESPACE
@@ -54,6 +55,7 @@ public:
virtual void setInputMethodEnabled(bool) = 0;
virtual bool inputMethodEnabled() const = 0;
virtual bool makeOpenGLContextCurrentIfAvailable() { return false; }
+ virtual QOpenGLContext* openGLContextIfAvailable() { return 0; }
virtual void setInputMethodHints(Qt::InputMethodHints) = 0;
virtual bool isViewVisible() = 0;
diff --git a/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp b/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp
index 16a540c91..92ce4685a 100644
--- a/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp
+++ b/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp
@@ -31,6 +31,8 @@
#include "FileSystem.h"
#include <hyphen.h>
+#include <limits>
+#include <stdlib.h>
#include <wtf/HashMap.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/TinyLRUCache.h>
@@ -62,8 +64,14 @@ static String extractLocaleFromDictionaryFilePath(const String& filePath)
static void scanDirectoryForDicionaries(const char* directoryPath, HashMap<AtomicString, Vector<String>>& availableLocales)
{
- for (const auto& filePath : listDirectory(directoryPath, "hyph_*.dic")) {
+ for (auto& filePath : listDirectory(directoryPath, "hyph_*.dic")) {
String locale = extractLocaleFromDictionaryFilePath(filePath).convertToASCIILowercase();
+
+ char normalizedPath[PATH_MAX];
+ if (!realpath(fileSystemRepresentation(filePath).data(), normalizedPath))
+ continue;
+
+ filePath = stringFromFileSystemRepresentation(normalizedPath);
availableLocales.add(locale, Vector<String>()).iterator->value.append(filePath);
String localeReplacingUnderscores = String(locale);
@@ -170,9 +178,9 @@ template<>
class TinyLRUCachePolicy<AtomicString, RefPtr<HyphenationDictionary>>
{
public:
- static TinyLRUCache<AtomicString, RefPtr<HyphenationDictionary>>& cache()
+ static TinyLRUCache<AtomicString, RefPtr<WebCore::HyphenationDictionary>, 32>& cache()
{
- static NeverDestroyed<TinyLRUCache<AtomicString, RefPtr<HyphenationDictionary>>> cache;
+ static NeverDestroyed<TinyLRUCache<AtomicString, RefPtr<WebCore::HyphenationDictionary>, 32>> cache;
return cache;
}
diff --git a/Source/WebKit/qt/Api/qwebfullscreenrequest.cpp b/Source/WebKit/qt/Api/qwebfullscreenrequest.cpp
index 56e14f6c8..14f20a63a 100644
--- a/Source/WebKit/qt/Api/qwebfullscreenrequest.cpp
+++ b/Source/WebKit/qt/Api/qwebfullscreenrequest.cpp
@@ -107,7 +107,7 @@ void QWebFullScreenRequest::reject()
bool QWebFullScreenRequest::toggleOn() const
{
- return d->toggleOn;
+ return d->toggleOn;
}
QUrl QWebFullScreenRequest::origin() const
diff --git a/Source/WebKit/qt/Api/qwebsettings.cpp b/Source/WebKit/qt/Api/qwebsettings.cpp
index 9adc662b7..ddd617a67 100644
--- a/Source/WebKit/qt/Api/qwebsettings.cpp
+++ b/Source/WebKit/qt/Api/qwebsettings.cpp
@@ -148,14 +148,18 @@ void QWebSettingsPrivate::apply()
settings->setDNSPrefetchingEnabled(value);
value = attributes.value(QWebSettings::JavascriptEnabled,
- global->attributes.value(QWebSettings::JavascriptEnabled));
+ global->attributes.value(QWebSettings::JavascriptEnabled));
settings->setScriptEnabled(value);
value = attributes.value(QWebSettings::AcceleratedCompositingEnabled,
global->attributes.value(QWebSettings::AcceleratedCompositingEnabled));
- // FIXME: Temporary disabled until AC is fully working
- // settings->setAcceleratedCompositingEnabled(value);
- settings->setAcceleratedCompositingEnabled(false);
+ settings->setAcceleratedCompositingEnabled(value);
+
+#if ENABLE(ACCELERATED_2D_CANVAS)
+ value = value && attributes.value(QWebSettings::Accelerated2dCanvasEnabled,
+ global->attributes.value(QWebSettings::Accelerated2dCanvasEnabled));
+ settings->setAccelerated2dCanvasEnabled(value);
+#endif
bool showDebugVisuals = qgetenv("WEBKIT_SHOW_COMPOSITING_DEBUG_VISUALS") == "1";
settings->setShowDebugBorders(showDebugVisuals);
@@ -300,8 +304,10 @@ void QWebSettingsPrivate::apply()
global->attributes.value(QWebSettings::SiteSpecificQuirksEnabled));
settings->setNeedsSiteSpecificQuirks(value);
+#if ENABLE(FULLSCREEN_API)
value = attributes.value(QWebSettings::FullScreenSupportEnabled, global->attributes.value(QWebSettings::FullScreenSupportEnabled));
settings->setFullScreenEnabled(value);
+#endif
settings->setUsesPageCache(WebCore::PageCache::singleton().maxSize());
} else {
@@ -515,6 +521,8 @@ QWebSettings* QWebSettings::globalSettings()
\value CaretBrowsingEnabled This setting enables caret browsing. It is disabled by default.
\value NotificationsEnabled Specifies whether support for the HTML 5 web notifications is enabled
or not. This is enabled by default.
+ \value Accelerated2dCanvasEnabled Specifies whether the HTML5 2D canvas should be a OpenGL framebuffer.
+ This makes many painting operations faster, but slows down pixel access. This is disabled by default.
\value WebSecurityEnabled Specifies whether browser should enforce same-origin policy for scripts downloaded
from remote servers. This setting is set to true by default. Note that setting this flag to false is
strongly discouraged as it makes the browser more prone to malicious code. This setting is intended
@@ -577,6 +585,7 @@ QWebSettings::QWebSettings()
d->attributes.insert(QWebSettings::ScrollAnimatorEnabled, false);
d->attributes.insert(QWebSettings::CaretBrowsingEnabled, false);
d->attributes.insert(QWebSettings::NotificationsEnabled, true);
+ d->attributes.insert(QWebSettings::Accelerated2dCanvasEnabled, false);
d->attributes.insert(QWebSettings::WebSecurityEnabled, true);
d->attributes.insert(QWebSettings::FullScreenSupportEnabled, true);
d->offlineStorageDefaultQuota = 5 * 1024 * 1024;
diff --git a/Source/WebKit/qt/Api/qwebsettings.h b/Source/WebKit/qt/Api/qwebsettings.h
index 11fae751f..a0b75533e 100644
--- a/Source/WebKit/qt/Api/qwebsettings.h
+++ b/Source/WebKit/qt/Api/qwebsettings.h
@@ -86,6 +86,7 @@ public:
CaretBrowsingEnabled,
NotificationsEnabled,
WebAudioEnabled,
+ Accelerated2dCanvasEnabled,
MediaSourceEnabled,
MediaEnabled,
WebSecurityEnabled,
diff --git a/Source/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
index 597ba95dd..29879a08a 100644
--- a/Source/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
@@ -226,7 +226,8 @@ void InspectorClientQt::detachRemoteFrontend()
void InspectorClientQt::closeFrontendWindow()
{
- m_frontendClient->closeWindow();
+ if (m_frontendClient)
+ m_frontendClient->closeWindow();
}
void InspectorClientQt::highlight()
diff --git a/Source/WebKit/qt/WebCoreSupport/TextureMapperLayerClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/TextureMapperLayerClientQt.cpp
index 2c6926c40..552fe6555 100644
--- a/Source/WebKit/qt/WebCoreSupport/TextureMapperLayerClientQt.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/TextureMapperLayerClientQt.cpp
@@ -70,9 +70,10 @@ void TextureMapperLayerClientQt::setRootGraphicsLayer(GraphicsLayer* layer)
m_rootGraphicsLayer->setDrawsContent(false);
m_rootGraphicsLayer->setMasksToBounds(false);
m_rootGraphicsLayer->setSize(IntSize(1, 1));
- if (!m_frame->pageAdapter->client->makeOpenGLContextCurrentIfAvailable())
- ASSERT_WITH_MESSAGE(false, "TextureMapper::SoftwareMode is not implemented");
- m_textureMapper = TextureMapper::create();
+ TextureMapper::AccelerationMode mode = TextureMapper::SoftwareMode;
+ if (m_frame->pageAdapter->client->makeOpenGLContextCurrentIfAvailable())
+ mode = TextureMapper::OpenGLMode;
+ m_textureMapper = TextureMapper::create(mode);
m_rootTextureMapperLayer->setTextureMapper(m_textureMapper.get());
syncRootLayer();
} else {
@@ -86,12 +87,13 @@ void TextureMapperLayerClientQt::syncLayers()
if (m_rootGraphicsLayer)
syncRootLayer();
- m_frame->frame->view()->flushCompositingStateIncludingSubframes();
+ bool didSync = m_frame->frame->view()->flushCompositingStateIncludingSubframes();
if (!m_rootGraphicsLayer)
return;
- downcast<GraphicsLayerTextureMapper>(*m_rootGraphicsLayer).updateBackingStoreIncludingSubLayers();
+ if (didSync)
+ downcast<GraphicsLayerTextureMapper>(*m_rootGraphicsLayer).updateBackingStoreIncludingSubLayers();
if (rootLayer()->descendantsOrSelfHaveRunningAnimations() && !m_syncTimer.isActive())
m_syncTimer.startOneShot(1.0 / 60.0);
@@ -115,7 +117,16 @@ void TextureMapperLayerClientQt::renderCompositedLayers(GraphicsContext& context
m_textureMapper->setTextDrawingMode(context.textDrawingMode());
QPainter* painter = context.platformContext();
- const QTransform transform = painter->worldTransform();
+ QTransform transform;
+ if (m_textureMapper->accelerationMode() == TextureMapper::OpenGLMode) {
+ // TextureMapperGL needs to duplicate the entire transform QPainter would do,
+ // including the transforms QPainter would normally do behind the scenes.
+ transform = painter->deviceTransform();
+ } else {
+ // TextureMapperImageBuffer needs a transform that can be used
+ // with QPainter::setWorldTransform.
+ transform = painter->worldTransform();
+ }
const TransformationMatrix matrix(
transform.m11(), transform.m12(), 0, transform.m13(),
transform.m21(), transform.m22(), 0, transform.m23(),
diff --git a/Source/WebKit/qt/WidgetApi/qwebpage.cpp b/Source/WebKit/qt/WidgetApi/qwebpage.cpp
index 80fbf5697..a1ea49d35 100644
--- a/Source/WebKit/qt/WidgetApi/qwebpage.cpp
+++ b/Source/WebKit/qt/WidgetApi/qwebpage.cpp
@@ -3075,7 +3075,8 @@ QWebPageAdapter *QWebPage::handle() const
*/
bool QWebPage::findText(const QString &subString, FindFlags options)
{
- return d->findText(subString, static_cast<QWebPageAdapter::FindFlag>(options.operator int()));
+ return d->findText(subString, static_cast<QWebPageAdapter::FindFlag>(
+ static_cast<FindFlags::Int>(options)));
}
/*!
diff --git a/Source/WebKit/qt/WidgetSupport/PageClientQt.cpp b/Source/WebKit/qt/WidgetSupport/PageClientQt.cpp
index 6ae5f12c4..7e5cb1fb7 100644
--- a/Source/WebKit/qt/WidgetSupport/PageClientQt.cpp
+++ b/Source/WebKit/qt/WidgetSupport/PageClientQt.cpp
@@ -33,6 +33,9 @@
#ifdef QT_OPENGL_LIB
#include <QGLWidget>
#endif
+#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
+#include <QOpenGLWidget>
+#endif
QWindow* QWebPageClient::ownerWindow() const
{
@@ -140,7 +143,7 @@ QStyle* PageClientQWidget::style() const
QRectF PageClientQWidget::windowRect() const
{
- return QRectF(view->window()->geometry());
+ return QRectF(view->window()->frameGeometry());
}
void PageClientQWidget::setWidgetVisible(Widget* widget, bool visible)
@@ -183,20 +186,53 @@ void PageClientQGraphicsWidget::repaintViewport()
bool PageClientQGraphicsWidget::makeOpenGLContextCurrentIfAvailable()
{
-#if USE(TEXTURE_MAPPER_GL) && defined(QT_OPENGL_LIB)
+#if USE(TEXTURE_MAPPER_GL)
QGraphicsView* graphicsView = firstGraphicsView();
if (graphicsView && graphicsView->viewport()) {
- QGLWidget* glWidget = qobject_cast<QGLWidget*>(graphicsView->viewport());
- if (glWidget) {
+ QWidget* widget = graphicsView->viewport();
+#if defined(QT_OPENGL_LIB)
+ if (widget->inherits("QGLWidget")) {
+ QGLWidget* glWidget = static_cast<QGLWidget*>(widget);
// The GL context belonging to the QGLWidget viewport must be current when TextureMapper is being created.
glWidget->makeCurrent();
return true;
}
+#endif
+#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
+ if (widget->inherits("QOpenGLWidget")) {
+ QOpenGLWidget* qoglWidget = static_cast<QOpenGLWidget*>(widget);
+ qoglWidget->makeCurrent();
+ return true;
+ }
+#endif
}
#endif
return false;
}
+QOpenGLContext* PageClientQGraphicsWidget::openGLContextIfAvailable()
+{
+#if USE(TEXTURE_MAPPER_GL)
+ QGraphicsView* graphicsView = firstGraphicsView();
+ if (graphicsView && graphicsView->viewport()) {
+ QWidget* widget = graphicsView->viewport();
+#if defined(QT_OPENGL_LIB)
+ if (widget->inherits("QGLWidget")) {
+ QGLWidget* glWidget = static_cast<QGLWidget*>(widget);
+ return glWidget->context()->contextHandle();
+ }
+#endif
+#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
+ if (widget->inherits("QOpenGLWidget")) {
+ QOpenGLWidget* qoglWidget = static_cast<QOpenGLWidget*>(widget);
+ return qoglWidget->context();
+ }
+#endif
+ }
+#endif
+ return 0;
+}
+
void PageClientQGraphicsWidget::setInputMethodEnabled(bool enable)
{
view->setFlag(QGraphicsItem::ItemAcceptsInputMethod, enable);
@@ -257,10 +293,9 @@ QRect PageClientQGraphicsWidget::geometryRelativeToOwnerWidget() const
QPoint PageClientQGraphicsWidget::mapToOwnerWindow(const QPoint& point) const
{
if (const QGraphicsView* graphicsView = firstGraphicsView()) {
- if (const QWidget *nativeParent = graphicsView->nativeParentWidget())
+ if (const QWidget* nativeParent = graphicsView->nativeParentWidget())
return graphicsView->mapTo(nativeParent, graphicsView->mapFromScene(view->mapToScene(point)));
- else
- return graphicsView->mapFromScene(view->mapToScene(point));
+ return graphicsView->mapFromScene(view->mapToScene(point));
}
return point;
}
@@ -316,4 +351,3 @@ bool PageClientQGraphicsWidget::isViewVisible()
#endif // QT_NO_GRAPHICSVIEW
} // namespace WebCore
-
diff --git a/Source/WebKit/qt/WidgetSupport/PageClientQt.h b/Source/WebKit/qt/WidgetSupport/PageClientQt.h
index 649882990..cb8c3c79f 100644
--- a/Source/WebKit/qt/WidgetSupport/PageClientQt.h
+++ b/Source/WebKit/qt/WidgetSupport/PageClientQt.h
@@ -168,6 +168,7 @@ public:
#endif
bool makeOpenGLContextCurrentIfAvailable() final;
+ QOpenGLContext* openGLContextIfAvailable() final;
QRectF windowRect() const final;
diff --git a/Source/WebKit/qt/tests/CMakeLists.txt b/Source/WebKit/qt/tests/CMakeLists.txt
index 8c96f4cbf..685896bfe 100644
--- a/Source/WebKit/qt/tests/CMakeLists.txt
+++ b/Source/WebKit/qt/tests/CMakeLists.txt
@@ -1,26 +1,23 @@
cmake_minimum_required(VERSION 2.8.12)
include_directories(
- "${CMAKE_BINARY_DIR}"
"${CMAKE_SOURCE_DIR}/Source"
"${DERIVED_SOURCES_DIR}/ForwardingHeaders"
- "${DERIVED_SOURCES_WEBKIT_DIR}"
- "${WEBCORE_DIR}"
- "${WEBCORE_DIR}/platform"
- "${WEBCORE_DIR}/platform/qt"
"${WEBKIT_DIR}/qt/Api"
"${WEBKIT_DIR}/qt/WidgetApi"
-
- "${JAVASCRIPTCORE_DIR}"
- "${WTF_DIR}"
)
include_directories(SYSTEM
${ICU_INCLUDE_DIRS}
+ ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
${Qt5Test_INCLUDE_DIRS}
)
+if (ENABLE_TEST_SUPPORT)
+ add_definitions(-DHAVE_QTTESTSUPPORT)
+endif ()
+
set(QtWK1ApiTests_LIBRARIES
${Qt5Gui_LIBRARIES}
${Qt5Network_LIBRARIES}
@@ -35,6 +32,7 @@ set(QtWK1ApiTests_RUNTIME_OUTPUT_DIRECTORY
)
set(QtWK1ApiTests
+ hybridPixmap
qgraphicswebview
qobjectbridge
qwebelement
@@ -42,18 +40,23 @@ set(QtWK1ApiTests
qwebhistory
qwebhistoryinterface
qwebinspector
+ qwebpage
qwebsecurityorigin
qwebview
)
+set(tst_hybridPixmap_SOURCES hybridPixmap/widget.cpp)
+qt5_wrap_ui(tst_hybridPixmap_SOURCES hybridPixmap/widget.ui)
+
if (ENABLE_API_TESTS)
foreach (testName ${QtWK1ApiTests})
- set(tst_${testName}_SOURCES ${testName}/tst_${testName}.cpp)
+ list(APPEND tst_${testName}_SOURCES ${testName}/tst_${testName}.cpp)
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${testName}/tst_${testName}.qrc")
qt5_add_resources(tst_${testName}_SOURCES ${testName}/tst_${testName}.qrc)
endif ()
add_executable(tst_${testName} ${tst_${testName}_SOURCES})
+ target_include_directories(tst_${testName} PRIVATE ${testName})
target_link_libraries(tst_${testName} ${QtWK1ApiTests_LIBRARIES})
set_target_properties(tst_${testName} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${QtWK1ApiTests_RUNTIME_OUTPUT_DIRECTORY})
diff --git a/Source/WebKit/qt/tests/hybridPixmap/resources.qrc b/Source/WebKit/qt/tests/hybridPixmap/tst_hybridPixmap.qrc
index 5fd47e32d..5fd47e32d 100644
--- a/Source/WebKit/qt/tests/hybridPixmap/resources.qrc
+++ b/Source/WebKit/qt/tests/hybridPixmap/tst_hybridPixmap.qrc
diff --git a/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
index 6e239f67d..bef98fee6 100644
--- a/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
+++ b/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
@@ -20,7 +20,6 @@
*/
#include "../util.h"
-#include "../WebCoreSupport/DumpRenderTreeSupportQt.h"
#include <QClipboard>
#include <QDir>
#include <QGraphicsWidget>
@@ -50,6 +49,10 @@
#include <qwebview.h>
#include <qimagewriter.h>
+#ifdef HAVE_QTTESTSUPPORT
+#include "../WebCoreSupport/DumpRenderTreeSupportQt.h"
+#endif
+
static void removeRecursive(const QString& dirname)
{
QDir dir(dirname);
@@ -110,7 +113,11 @@ public Q_SLOTS:
private Q_SLOTS:
void initTestCase();
void cleanupTestCase();
+
+#ifdef HAVE_QTTESTSUPPORT
void thirdPartyCookiePolicy();
+#endif
+
void contextMenuCopy();
void contextMenuPopulatedOnce();
void acceptNavigationRequest();
@@ -135,7 +142,11 @@ private Q_SLOTS:
void createViewlessPlugin_data();
void createViewlessPlugin();
void graphicsWidgetPlugin();
+
+#ifdef HAVE_QTTESTSUPPORT
void multiplePageGroupsAndLocalStorage();
+#endif
+
void cursorMovements();
void textSelection();
void textEditing();
@@ -143,7 +154,11 @@ private Q_SLOTS:
void frameAt();
void requestCache();
void loadCachedPage();
+
+#ifdef HAVE_QTTESTSUPPORT
void protectBindingsRuntimeObjectsFromCollector();
+#endif
+
void localURLSchemes();
void testOptionalJSObjects();
void testLocalStorageVisibility();
@@ -1089,6 +1104,7 @@ void tst_QWebPage::createViewlessPlugin()
}
+#ifdef HAVE_QTTESTSUPPORT
void tst_QWebPage::multiplePageGroupsAndLocalStorage()
{
QDir dir(tmpDirPath());
@@ -1130,6 +1146,7 @@ void tst_QWebPage::multiplePageGroupsAndLocalStorage()
dir.rmdir(QDir::toNativeSeparators("./path1"));
dir.rmdir(QDir::toNativeSeparators("./path2"));
}
+#endif
class CursorTrackedPage : public QWebPage
{
@@ -2449,6 +2466,7 @@ void tst_QWebPage::inputMethodsTextFormat()
delete view;
}
+#ifdef HAVE_QTTESTSUPPORT
void tst_QWebPage::protectBindingsRuntimeObjectsFromCollector()
{
QSignalSpy loadSpy(m_view, SIGNAL(loadFinished(bool)));
@@ -2470,6 +2488,7 @@ void tst_QWebPage::protectBindingsRuntimeObjectsFromCollector()
// don't crash!
newPage->mainFrame()->evaluateJavaScript("testme('bar')");
}
+#endif
void tst_QWebPage::localURLSchemes()
{
@@ -3133,6 +3152,7 @@ void tst_QWebPage::navigatorCookieEnabled()
QVERIFY(m_page->mainFrame()->evaluateJavaScript("navigator.cookieEnabled").toBool());
}
+#ifdef HAVE_QTTESTSUPPORT
void tst_QWebPage::thirdPartyCookiePolicy()
{
QWebSettings::globalSettings()->setThirdPartyCookiePolicy(QWebSettings::AlwaysBlockThirdPartyCookies);
@@ -3171,6 +3191,7 @@ void tst_QWebPage::thirdPartyCookiePolicy()
QVERIFY(!DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(m_page->handle(),
QUrl("http://anotherexample.co.uk"), QUrl("http://example.co.uk")));
}
+#endif
#ifdef Q_OS_MAC
void tst_QWebPage::macCopyUnicodeToClipboard()
diff --git a/Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp b/Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp
index 3824dda7b..f4db608d4 100644
--- a/Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp
+++ b/Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp
@@ -59,6 +59,7 @@ private Q_SLOTS:
void setPalette_data();
void setPalette();
#endif
+ void innerOuterRect();
};
// This will be called before the first test function is executed.
@@ -518,6 +519,28 @@ void tst_QWebView::renderingAfterMaxAndBack()
QCOMPARE(image3, reference3);
}
+void tst_QWebView::innerOuterRect()
+{
+ QUrl url = QUrl("data:text/html,<html><head></head>"
+ "<body bgcolor=red>"
+ "</body>"
+ "</html>");
+ QWebView view;
+ view.page()->mainFrame()->load(url);
+ QVERIFY(waitForSignal(&view, SIGNAL(loadFinished(bool))));
+ view.showMaximized();
+ const QRect frameGeometry = view.frameGeometry();
+ const QRect geometry = view.geometry();
+ QVariant outerWidth = view.page()->mainFrame()->evaluateJavaScript("window.outerWidth;");
+ QCOMPARE(outerWidth.toInt(), frameGeometry.width());
+ QVariant innerWidth = view.page()->mainFrame()->evaluateJavaScript("window.innerWidth;");
+ QCOMPARE(innerWidth.toInt(), geometry.width());
+ QVariant outerHeight = view.page()->mainFrame()->evaluateJavaScript("window.outerHeight;");
+ QCOMPARE(outerHeight.toInt(), frameGeometry.height());
+ QVariant innerHeight = view.page()->mainFrame()->evaluateJavaScript("window.innerHeight;");
+ QCOMPARE(innerHeight.toInt(), geometry.height());
+}
+
QTEST_MAIN(tst_QWebView)
#include "tst_qwebview.moc"
diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp b/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp
index 1b78fd8ef..e97a52733 100644
--- a/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp
+++ b/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp
@@ -72,7 +72,7 @@ CoordinatedGraphicsScene::~CoordinatedGraphicsScene()
void CoordinatedGraphicsScene::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity, const FloatRect& clipRect, const Color& backgroundColor, bool drawsBackground, const FloatPoint& contentPosition, TextureMapper::PaintFlags PaintFlags)
{
if (!m_textureMapper) {
- m_textureMapper = TextureMapper::create();
+ m_textureMapper = TextureMapper::create(TextureMapper::OpenGLMode);
static_cast<TextureMapperGL*>(m_textureMapper.get())->setEnableEdgeDistanceAntialiasing(true);
}
diff --git a/Source/cmake/OptionsQt.cmake b/Source/cmake/OptionsQt.cmake
index b46d92c3d..5c20e97d4 100644
--- a/Source/cmake/OptionsQt.cmake
+++ b/Source/cmake/OptionsQt.cmake
@@ -4,6 +4,26 @@ include(ECMQueryQmake)
set(ECM_MODULE_DIR ${CMAKE_MODULE_PATH})
+set(QT_CONAN_DIR "" CACHE PATH "Directory containing conanbuildinfo.cmake and conanfile.txt")
+if (QT_CONAN_DIR)
+ include("${QT_CONAN_DIR}/conanbuildinfo.cmake")
+ conan_basic_setup()
+
+ install(CODE "
+ set(_conan_imports_dest \${CMAKE_INSTALL_PREFIX})
+ if (DEFINED ENV{DESTDIR})
+ get_filename_component(_absolute_destdir \$ENV{DESTDIR} ABSOLUTE)
+ string(REGEX REPLACE \"^[A-z]:\" \"\" _conan_imports_dest \${CMAKE_INSTALL_PREFIX})
+ set(_conan_imports_dest \"\${_absolute_destdir}\${_conan_imports_dest}\")
+ endif ()
+
+ execute_process(
+ COMMAND conan imports -f \"${QT_CONAN_DIR}/conanfile.txt\" --dest \${_conan_imports_dest}
+ WORKING_DIRECTORY \"${QT_CONAN_DIR}\"
+ )
+ ")
+endif ()
+
set(STATIC_DEPENDENCIES_CMAKE_FILE "${CMAKE_BINARY_DIR}/QtStaticDependencies.cmake")
if (EXISTS ${STATIC_DEPENDENCIES_CMAKE_FILE})
file(REMOVE ${STATIC_DEPENDENCIES_CMAKE_FILE})
@@ -30,7 +50,7 @@ endmacro()
set(PROJECT_VERSION_MAJOR 5)
set(PROJECT_VERSION_MINOR 602)
-set(PROJECT_VERSION_MICRO 2)
+set(PROJECT_VERSION_MICRO 3)
set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_MICRO})
set(PROJECT_VERSION_STRING "${PROJECT_VERSION}")
@@ -87,7 +107,7 @@ WEBKIT_OPTION_DEFINE(USE_MEDIA_FOUNDATION "Use MediaFoundation implementation of
WEBKIT_OPTION_DEFINE(USE_QT_MULTIMEDIA "Use Qt Multimedia implementation of MediaPlayer" PUBLIC ${USE_QT_MULTIMEDIA_DEFAULT})
WEBKIT_OPTION_DEFINE(USE_WOFF2 "Include support of WOFF2 fonts format" PUBLIC ON)
WEBKIT_OPTION_DEFINE(ENABLE_INSPECTOR_UI "Include Inspector UI into resources" PUBLIC ON)
-WEBKIT_OPTION_DEFINE(ENABLE_OPENGL "Whether to use OpenGL." PUBLIC OFF)
+WEBKIT_OPTION_DEFINE(ENABLE_OPENGL "Whether to use OpenGL." PUBLIC ON)
WEBKIT_OPTION_DEFINE(ENABLE_PRINT_SUPPORT "Enable support for printing web pages" PUBLIC ON)
WEBKIT_OPTION_DEFINE(ENABLE_X11_TARGET "Whether to enable support for the X11 windowing target." PUBLIC ${ENABLE_X11_TARGET_DEFAULT})
@@ -98,6 +118,7 @@ option(USE_STATIC_RUNTIME "Use static runtime (MSVC only)" OFF)
# Public options shared with other WebKit ports. There must be strong reason
# to support changing the value of the option.
+WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCELERATED_2D_CANVAS PUBLIC ON)
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ALLINONE_BUILD PUBLIC ON)
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_API_TESTS PUBLIC ON)
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_GRID_LAYOUT PUBLIC ON)
@@ -127,6 +148,7 @@ WEBKIT_OPTION_DEFAULT_PORT_VALUE(USE_SYSTEM_MALLOC PUBLIC OFF)
# Private options shared with other WebKit ports. Add options here when
# we need a value different from the default defined in WebKitFeatures.cmake.
# Changing these options is completely unsupported.
+WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_3D_TRANSFORMS PRIVATE ON)
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_IMAGE_SET PRIVATE ON)
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_REGIONS PRIVATE ON)
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_SHAPES PRIVATE ON)
@@ -142,12 +164,18 @@ WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NOTIFICATIONS PRIVATE ON)
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_USERSELECT_ALL PRIVATE ON)
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIDEO_TRACK PRIVATE ON)
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_TIMING PRIVATE ON)
+WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBGL PRIVATE ON)
+
+WEBKIT_OPTION_CONFLICT(USE_GSTREAMER USE_QT_MULTIMEDIA)
-WEBKIT_OPTION_DEPEND(ENABLE_MEDIA_SOURCE ENABLE_VIDEO)
+WEBKIT_OPTION_DEPEND(ENABLE_3D_TRANSFORMS ENABLE_OPENGL)
+WEBKIT_OPTION_DEPEND(ENABLE_ACCELERATED_2D_CANVAS ENABLE_OPENGL)
+WEBKIT_OPTION_DEPEND(ENABLE_WEBGL ENABLE_OPENGL)
-# WebAudio is supported with GStreamer only
+# WebAudio and MediaSource are supported with GStreamer only
WEBKIT_OPTION_DEPEND(ENABLE_WEB_AUDIO USE_GSTREAMER)
WEBKIT_OPTION_DEPEND(ENABLE_LEGACY_WEB_AUDIO USE_GSTREAMER)
+WEBKIT_OPTION_DEPEND(ENABLE_MEDIA_SOURCE USE_GSTREAMER)
# While it's possible to have UI-less NPAPI plugins without X11, we don't support this case yet
if (UNIX AND NOT APPLE)
@@ -242,6 +270,7 @@ if (DEFINED ENV{SQLITE3SRCDIR})
endif ()
add_library(qtsqlite STATIC ${SQLITE_SOURCE_FILE})
target_compile_definitions(qtsqlite PUBLIC -DSQLITE_CORE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_COMPLETE)
+ WEBKIT_SET_EXTRA_COMPILER_FLAGS(qtsqlite)
set(SQLITE_LIBRARIES qtsqlite)
set(SQLITE_FOUND 1)
else ()
@@ -438,6 +467,16 @@ endif ()
if (ENABLE_OPENGL)
SET_AND_EXPOSE_TO_BUILD(USE_TEXTURE_MAPPER_GL TRUE)
SET_AND_EXPOSE_TO_BUILD(ENABLE_GRAPHICS_CONTEXT_3D TRUE)
+
+ # TODO: Add proper support of DynamicGL detection to Qt and use it
+ if (WIN32)
+ if (QT_USES_GLES2_ONLY)
+ # FIXME: Fix build with ANGLE-only Qt
+ message(FATAL_ERROR "Only dynamic GL is supported on Windows at the moment")
+ else ()
+ set(Qt5Gui_OPENGL_IMPLEMENTATION GL)
+ endif ()
+ endif ()
endif ()
if (NOT ENABLE_VIDEO)
@@ -642,23 +681,3 @@ include(KDEInstallDirs)
if (NOT qt_install_prefix_dir STREQUAL "${CMAKE_INSTALL_PREFIX}")
set(KDE_INSTALL_USE_QT_SYS_PATHS OFF)
endif ()
-
-set(QT_CONAN_DIR "" CACHE PATH "Directory containing conanbuildinfo.cmake and conanfile.txt")
-if (QT_CONAN_DIR)
- include("${QT_CONAN_DIR}/conanbuildinfo.cmake")
- conan_basic_setup()
-
- install(CODE "
- set(_conan_imports_dest \${CMAKE_INSTALL_PREFIX})
- if (DEFINED ENV{DESTDIR})
- get_filename_component(_absolute_destdir \$ENV{DESTDIR} ABSOLUTE)
- string(REGEX REPLACE \"^[A-z]:\" \"\" _conan_imports_dest \${CMAKE_INSTALL_PREFIX})
- set(_conan_imports_dest \"\${_absolute_destdir}\${_conan_imports_dest}\")
- endif ()
-
- execute_process(
- COMMAND conan imports -f \"${QT_CONAN_DIR}/conanfile.txt\" --dest \${_conan_imports_dest}
- WORKING_DIRECTORY \"${QT_CONAN_DIR}\"
- )
- ")
-endif ()
diff --git a/Source/cmake/WebKitFeatures.cmake b/Source/cmake/WebKitFeatures.cmake
index b52084f48..57915dfc2 100644
--- a/Source/cmake/WebKitFeatures.cmake
+++ b/Source/cmake/WebKitFeatures.cmake
@@ -214,6 +214,7 @@ macro(WEBKIT_OPTION_BEGIN)
WEBKIT_OPTION_DEPEND(ENABLE_SAMPLING_PROFILER ENABLE_JIT)
WEBKIT_OPTION_DEPEND(ENABLE_LEGACY_WEB_AUDIO ENABLE_WEB_AUDIO)
WEBKIT_OPTION_DEPEND(ENABLE_MEDIA_CONTROLS_SCRIPT ENABLE_VIDEO)
+ WEBKIT_OPTION_DEPEND(ENABLE_MEDIA_SOURCE ENABLE_VIDEO)
WEBKIT_OPTION_DEPEND(ENABLE_VIDEO_TRACK ENABLE_VIDEO)
WEBKIT_OPTION_DEPEND(ENABLE_TOUCH_SLIDER ENABLE_TOUCH_EVENTS)
endmacro()
diff --git a/Tools/QtTestBrowser/launcherwindow.cpp b/Tools/QtTestBrowser/launcherwindow.cpp
index 537eccf64..c1974552e 100644
--- a/Tools/QtTestBrowser/launcherwindow.cpp
+++ b/Tools/QtTestBrowser/launcherwindow.cpp
@@ -169,7 +169,10 @@ void LauncherWindow::initializeView()
WebViewGraphicsBased* view = new WebViewGraphicsBased(splitter);
m_view = view;
#ifndef QT_NO_OPENGL
- toggleQGLWidgetViewport(m_windowOptions.useQGLWidgetViewport);
+ if (!m_windowOptions.useQOpenGLWidgetViewport)
+ toggleQGLWidgetViewport(m_windowOptions.useQGLWidgetViewport);
+ if (!m_windowOptions.useQGLWidgetViewport)
+ toggleQOpenGLWidgetViewport(m_windowOptions.useQOpenGLWidgetViewport);
#endif
view->setPage(page());
@@ -213,7 +216,8 @@ void LauncherWindow::applyPrefs()
{
QWebSettings* settings = page()->settings();
#ifndef QT_NO_OPENGL
- settings->setAttribute(QWebSettings::AcceleratedCompositingEnabled, m_windowOptions.useCompositing && m_windowOptions.useQGLWidgetViewport);
+ settings->setAttribute(QWebSettings::AcceleratedCompositingEnabled, m_windowOptions.useCompositing
+ && (m_windowOptions.useQGLWidgetViewport || m_windowOptions.useQOpenGLWidgetViewport));
#endif
settings->setAttribute(QWebSettings::TiledBackingStoreEnabled, m_windowOptions.useTiledBackingStore);
settings->setAttribute(QWebSettings::FrameFlatteningEnabled, m_windowOptions.useFrameFlattening);
@@ -388,8 +392,12 @@ void LauncherWindow::createChrome()
QAction* toggleAcceleratedCompositing = graphicsViewMenu->addAction("Toggle Accelerated Compositing", this, SLOT(toggleAcceleratedCompositing(bool)));
toggleAcceleratedCompositing->setCheckable(true);
toggleAcceleratedCompositing->setChecked(settings->testAttribute(QWebSettings::AcceleratedCompositingEnabled));
- toggleAcceleratedCompositing->setEnabled(isGraphicsBased());
- toggleAcceleratedCompositing->connect(toggleGraphicsView, SIGNAL(toggled(bool)), SLOT(setEnabled(bool)));
+
+ QAction* toggleAccelerated2dCanvas = graphicsViewMenu->addAction("Toggle Accelerated 2D canvas", this, SLOT(toggleAccelerated2dCanvas(bool)));
+ toggleAccelerated2dCanvas->setCheckable(true);
+ toggleAccelerated2dCanvas->setEnabled(settings->testAttribute(QWebSettings::AcceleratedCompositingEnabled));
+ toggleAccelerated2dCanvas->setChecked(settings->testAttribute(QWebSettings::Accelerated2dCanvasEnabled));
+ toggleAccelerated2dCanvas->connect(toggleAcceleratedCompositing, SIGNAL(toggled(bool)), SLOT(setEnabled(bool)));
QAction* toggleResizesToContents = graphicsViewMenu->addAction("Toggle Resizes To Contents Mode", this, SLOT(toggleResizesToContents(bool)));
toggleResizesToContents->setCheckable(true);
@@ -409,6 +417,13 @@ void LauncherWindow::createChrome()
toggleQGLWidgetViewport->setChecked(m_windowOptions.useQGLWidgetViewport);
toggleQGLWidgetViewport->setEnabled(isGraphicsBased());
toggleQGLWidgetViewport->connect(toggleGraphicsView, SIGNAL(toggled(bool)), SLOT(setEnabled(bool)));
+#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
+ QAction* toggleQOpenGLWidgetViewport = graphicsViewMenu->addAction("Toggle use of QOpenGLWidget Viewport", this, SLOT(toggleQOpenGLWidgetViewport(bool)));
+ toggleQOpenGLWidgetViewport->setCheckable(true);
+ toggleQOpenGLWidgetViewport->setChecked(m_windowOptions.useQOpenGLWidgetViewport);
+ toggleQOpenGLWidgetViewport->setEnabled(isGraphicsBased());
+ toggleQOpenGLWidgetViewport->connect(toggleGraphicsView, SIGNAL(toggled(bool)), SLOT(setEnabled(bool)));
+#endif
#endif
QMenu* viewportUpdateMenu = graphicsViewMenu->addMenu("Change Viewport Update Mode");
@@ -517,6 +532,10 @@ void LauncherWindow::createChrome()
toggleJavascriptCanOpenWindows->setCheckable(true);
toggleJavascriptCanOpenWindows->setChecked(false);
+ QAction* togglePrivateBrowsing = settingsMenu->addAction("Enable Private Browsing", this, SLOT(togglePrivateBrowsing(bool)));
+ togglePrivateBrowsing->setCheckable(true);
+ togglePrivateBrowsing->setChecked(false);
+
QAction* toggleUseDiskCookies = settingsMenu->addAction("Save Cookies on Disk", this, SLOT(setUseDiskCookies(bool)));
toggleUseDiskCookies->setCheckable(true);
toggleUseDiskCookies->setChecked(m_windowOptions.useDiskCookies);
@@ -795,7 +814,10 @@ void LauncherWindow::screenshot()
#endif
#ifndef QT_NO_OPENGL
- toggleQGLWidgetViewport(m_windowOptions.useQGLWidgetViewport);
+ if (!m_windowOptions.useQOpenGLWidgetViewport)
+ toggleQGLWidgetViewport(m_windowOptions.useQGLWidgetViewport);
+ if (!m_windowOptions.useQGLWidgetViewport)
+ toggleQOpenGLWidgetViewport(m_windowOptions.useQOpenGLWidgetViewport);
#endif
}
@@ -886,6 +908,11 @@ void LauncherWindow::toggleAcceleratedCompositing(bool toggle)
page()->settings()->setAttribute(QWebSettings::AcceleratedCompositingEnabled, toggle);
}
+void LauncherWindow::toggleAccelerated2dCanvas(bool toggle)
+{
+ page()->settings()->setAttribute(QWebSettings::Accelerated2dCanvasEnabled, toggle);
+}
+
void LauncherWindow::toggleTiledBackingStore(bool toggle)
{
page()->settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, toggle);
@@ -958,6 +985,11 @@ void LauncherWindow::toggleJavascriptCanOpenWindows(bool enable)
page()->settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, enable);
}
+void LauncherWindow::togglePrivateBrowsing(bool enable)
+{
+ page()->settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, enable);
+}
+
void LauncherWindow::setUseDiskCookies(bool enable)
{
testBrowserCookieJarInstance()->setDiskStorageEnabled(enable);
@@ -984,11 +1016,28 @@ void LauncherWindow::toggleQGLWidgetViewport(bool enable)
if (!isGraphicsBased())
return;
+ if (enable)
+ m_windowOptions.useQOpenGLWidgetViewport = false;
m_windowOptions.useQGLWidgetViewport = enable;
- WebViewGraphicsBased* view = static_cast<WebViewGraphicsBased*>(m_view);
+ WebViewGraphicsBased* view = static_cast<WebViewGraphicsBased*>(m_view);
view->setViewport(enable ? new QGLWidget() : 0);
}
+
+void LauncherWindow::toggleQOpenGLWidgetViewport(bool enable)
+{
+ if (!isGraphicsBased())
+ return;
+
+#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
+ if (enable)
+ m_windowOptions.useQGLWidgetViewport = false;
+ m_windowOptions.useQOpenGLWidgetViewport = enable;
+
+ WebViewGraphicsBased* view = static_cast<WebViewGraphicsBased*>(m_view);
+ view->setViewport(enable ? new QOpenGLWidget() : 0);
+#endif
+}
#endif
void LauncherWindow::changeViewportUpdateMode(int mode)
diff --git a/Tools/QtTestBrowser/launcherwindow.h b/Tools/QtTestBrowser/launcherwindow.h
index d4a3b832d..c9388da85 100644
--- a/Tools/QtTestBrowser/launcherwindow.h
+++ b/Tools/QtTestBrowser/launcherwindow.h
@@ -38,6 +38,9 @@
#ifndef QT_NO_OPENGL
#include <QtOpenGL/QGLWidget>
#endif
+#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
+#include <QOpenGLWidget>
+#endif
#include <QDebug>
@@ -82,9 +85,8 @@ public:
bool useDiskCookies { true };
bool enableScrollAnimator { false };
quint64 offlineStorageDefaultQuotaSize { 0 };
-#ifndef QT_NO_OPENGL
bool useQGLWidgetViewport { false };
-#endif
+ bool useQOpenGLWidgetViewport { false };
bool printLoadedUrls { false };
QUrl inspectorUrl;
quint16 remoteInspectorPort { 0 };
@@ -128,6 +130,7 @@ protected Q_SLOTS:
void setTouchMocking(bool on);
void toggleWebView(bool graphicsBased);
void toggleAcceleratedCompositing(bool toggle);
+ void toggleAccelerated2dCanvas(bool toggle);
void toggleTiledBackingStore(bool toggle);
void toggleResizesToContents(bool toggle);
void toggleWebGL(bool toggle);
@@ -140,6 +143,7 @@ protected Q_SLOTS:
void toggleInterruptingJavaScriptEnabled(bool enable);
void toggleJavascriptCanOpenWindows(bool enable);
void toggleAutoLoadImages(bool enable);
+ void togglePrivateBrowsing(bool enable);
void setUseDiskCookies(bool enable);
void clearCookies();
void togglePlugins(bool enable);
@@ -154,6 +158,7 @@ protected Q_SLOTS:
#endif
#ifndef QT_NO_OPENGL
void toggleQGLWidgetViewport(bool enable);
+ void toggleQOpenGLWidgetViewport(bool enable);
#endif
void changeViewportUpdateMode(int mode);
diff --git a/Tools/QtTestBrowser/qttestbrowser.cpp b/Tools/QtTestBrowser/qttestbrowser.cpp
index 05726b822..4ec7425b1 100644
--- a/Tools/QtTestBrowser/qttestbrowser.cpp
+++ b/Tools/QtTestBrowser/qttestbrowser.cpp
@@ -136,8 +136,9 @@ void LauncherApplication::handleUserOptions()
<< "[-no-compositing]"
#if defined(QT_CONFIGURED_WITH_OPENGL)
<< "[-gl-viewport]"
- << "[-webgl]"
#endif
+ << "[-opengl-viewport]"
+ << "[-webgl]"
<< QString("[-viewport-update-mode %1]").arg(formatKeys(updateModes)).toLatin1().data()
#if !defined(QT_NO_NETWORKDISKCACHE) && !defined(QT_NO_DESKTOPSERVICES)
<< "[-disk-cache]"
@@ -169,7 +170,6 @@ void LauncherApplication::handleUserOptions()
windowOptions.useGraphicsView = true;
if (args.contains("-no-compositing")) {
- requiresGraphicsView("-no-compositing");
windowOptions.useCompositing = false;
}
@@ -245,11 +245,16 @@ void LauncherApplication::handleUserOptions()
windowOptions.useQGLWidgetViewport = true;
}
+#endif
if (args.contains("-webgl")) {
- requiresGraphicsView("-webgl");
windowOptions.useWebGL = true;
}
-#endif
+
+ if (args.contains("-opengl-viewport")) {
+ requiresGraphicsView("-opengl-viewport");
+ windowOptions.useQOpenGLWidgetViewport = true;
+ }
+
#if HAVE(QTTESTSUPPORT)
if (args.contains("-use-test-fonts"))
diff --git a/Tools/Scripts/webkitperl/FeatureList.pm b/Tools/Scripts/webkitperl/FeatureList.pm
index c3e03b3cc..067779122 100644
--- a/Tools/Scripts/webkitperl/FeatureList.pm
+++ b/Tools/Scripts/webkitperl/FeatureList.pm
@@ -161,10 +161,10 @@ sub isQtGstreamer { return isQt() && !isAnyWindows() && !isDarwin() }
my @features = (
{ option => "3d-rendering", desc => "Toggle 3D Rendering support",
- define => "ENABLE_3D_TRANSFORMS", default => (isAppleMacWebKit() || isIOSWebKit() || isGtk() || isEfl()), value => \$threeDTransformsSupport },
+ define => "ENABLE_3D_TRANSFORMS", default => (isAppleMacWebKit() || isIOSWebKit() || isGtk() || isEfl() || isQt()), value => \$threeDTransformsSupport },
{ option => "accelerated-2d-canvas", desc => "Toggle Accelerated 2D Canvas support",
- define => "ENABLE_ACCELERATED_2D_CANVAS", default => isGtk(), value => \$accelerated2DCanvasSupport },
+ define => "ENABLE_ACCELERATED_2D_CANVAS", default => (isGtk() || isQt()), value => \$accelerated2DCanvasSupport },
{ option => "allinone-build", desc => "Toggle all-in-one build",
define => "ENABLE_ALLINONE_BUILD", default => isWindows() || isQt(), value => \$allInOneBuild },
@@ -446,7 +446,7 @@ my @features = (
define => "ENABLE_VIDEO_TRACK", default => (isAppleWebKit() || isGtk() || isEfl() || isQt()), value => \$videoTrackSupport },
{ option => "webgl", desc => "Toggle WebGL support",
- define => "ENABLE_WEBGL", default => (isAppleMacWebKit() || isIOSWebKit() || isGtk() || isEfl()), value => \$webglSupport },
+ define => "ENABLE_WEBGL", default => (isAppleMacWebKit() || isIOSWebKit() || isGtk() || isEfl() || isQt()), value => \$webglSupport },
{ option => "webassembly", desc => "Toggle WebAssembly support",
define => "ENABLE_WEBASSEMBLY", default => 0, value => \$webAssemblySupport },
diff --git a/Tools/qmake/mkspecs/features/functions.prf b/Tools/qmake/mkspecs/features/functions.prf
index 2dcaa09ca..831e01a98 100644
--- a/Tools/qmake/mkspecs/features/functions.prf
+++ b/Tools/qmake/mkspecs/features/functions.prf
@@ -64,6 +64,10 @@ defineTest(isPlatformSupported) {
}
win32 {
+ qtConfig(opengles2):!qtConfig(dynamicgl) {
+ skipBuild("QtWebKit supports only dynamic GL Qt builds on Windows at the moment.")
+ }
+
CONFIG(debug, debug|release):!contains(QMAKE_HOST.arch, x86_64) {
# debug_and_release is built as release, see Tools/qmake/projects/run_cmake.pro
!debug_and_release {
@@ -102,6 +106,8 @@ defineTest(isPlatformSupported) {
skipBuild("C++11 support is required in order to build QtWebKit.")
}
+ isRubyVersionSupported()
+
isEmpty(skipBuildReason): return(true)
return(false)
}
@@ -113,6 +119,13 @@ defineTest(isGCCVersionSupported) {
return(false)
}
+defineTest(isRubyVersionSupported) {
+ ruby_version = $$system("ruby -e 'puts RUBY_VERSION'")
+ isVersionAtLeast($$ruby_version, "1.9"): return(true)
+ skipBuild("Using Ruby version $$ruby_version, but at least Ruby 1.9 is required to build QtWebKit.")
+ return(false)
+}
+
defineTest(programExistsInPath) {
equals(QMAKE_HOST.os, Windows): program = $${1}.exe
else: program = $$1
diff --git a/Tools/qmake/projects/run_cmake.pro b/Tools/qmake/projects/run_cmake.pro
index 75934e687..1192197bd 100644
--- a/Tools/qmake/projects/run_cmake.pro
+++ b/Tools/qmake/projects/run_cmake.pro
@@ -54,6 +54,10 @@ build_pass|!debug_and_release {
ZLIB_INCLUDE_DIRS=$$QTBASE_DIR/src/3rdparty/zlib
}
+ qtConfig(opengles2):!qtConfig(dynamicgl) {
+ CMAKE_CONFIG += QT_USES_GLES2_ONLY=1
+ }
+
exists($$ROOT_BUILD_DIR/conanbuildinfo.cmake):exists($$ROOT_BUILD_DIR/conanfile.txt) {
CMAKE_CONFIG += QT_CONAN_DIR=$$ROOT_BUILD_DIR
}
diff --git a/Tools/qt/convert-prl-libs-to-cmake.pl b/Tools/qt/convert-prl-libs-to-cmake.pl
index 1b304228c..40fab403c 100755
--- a/Tools/qt/convert-prl-libs-to-cmake.pl
+++ b/Tools/qt/convert-prl-libs-to-cmake.pl
@@ -4,26 +4,23 @@
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
#
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Inc. ("Apple") nor the names of
-# its contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
-# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
-# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
use File::Basename;
use File::Spec;
@@ -58,7 +55,7 @@ my $prl_name = File::Spec->join($qt_lib_dir, "$qt_lib_base.prl");
my $qmake_prl_libs;
open(my $prl, '<', $prl_name) or die "Cannot open $prl_name: $!";
-while(<$prl>) {
+while (<$prl>) {
next unless /^QMAKE_PRL_LIBS/;
chomp;
if (/^QMAKE_PRL_LIBS\s+=\s+(.*)$/) {
@@ -68,7 +65,7 @@ while(<$prl>) {
}
close $prl;
-unless($qmake_prl_libs) {
+unless ($qmake_prl_libs) {
print "QMAKE_PRL_LIBS variable is undefined or empty\n";
exit;
}
diff --git a/Tools/qt/jhbuild-qt-5.4.modules b/Tools/qt/jhbuild-qt-5.4.modules
index 3e9c4f57c..924a19a6b 100644
--- a/Tools/qt/jhbuild-qt-5.4.modules
+++ b/Tools/qt/jhbuild-qt-5.4.modules
@@ -3,16 +3,28 @@
<?xml-stylesheet type="text/xsl" href="moduleset.xsl"?>
<moduleset>
+ <metamodule id="qt">
+ <dependencies>
+ <dep package="qtbase"/>
+ <dep package="qtlocation"/>
+ <dep package="qtsensors"/>
+ </dependencies>
+ </metamodule>
+
<repository type="tarball" name="download.qt.io"
href="http://download.qt.io"/>
- <autotools id="qt"
+ <autotools id="qtbase"
+ supports-non-srcdir-builds="no"
makeinstallargs="install INSTALL_ROOT='$(DESTDIR)'"
autogen-template="%(srcdir)s/%(autogen-sh)s -prefix %(prefix)s -I%(prefix)s/include -L%(prefix)s/lib -libdir %(prefix)s/lib"
autogen-sh="configure
-opensource
-confirm-license
+ -force-debug-info
+ -separate-debug-info
+
-icu
-openssl
-openssl-linked
@@ -21,22 +33,6 @@
-nomake tools
-nomake tests
- -skip connectivity
- -skip enginio
- -skip graphicaleffects
- -skip imageformats
- -skip multimedia
- -skip quickcontrols
- -skip script
- -skip serialport
- -skip svg
- -skip translations
- -skip wayland
- -skip webengine
- -skip webkit
- -skip x11extras
- -skip xmlpatterns
-
-system-harfbuzz
-system-freetype
-system-libjpeg
@@ -62,10 +58,10 @@
-no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc -no-sql-psql -no-sql-sqlite2 -no-sql-tds
-plugin-sql-sqlite
">
- <branch module="archive/qt/5.4/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz" version="5.4.0"
+ <branch module="archive/qt/5.4/${version}/submodules/qtbase-opensource-src-${version}.tar.xz" version="5.4.0"
repo="download.qt.io"
- hash="sha256:b2d9df47b9fd2fcfa5ebd162e1373b7eddf4759e6ba148c4589f3d8b6628c39c">
- <patch file="qt-5.4-fontconfig-fix.patch" strip="1"/>
+ hash="sha256:daea240ba5e77bc2d78ec21a2cb664eed83b3d4ad409b6277a6f7d4c0c8e91d1">
+ <patch file="qtbase-5.4-fontconfig-fix.patch" strip="1"/>
</branch>
<dependencies>
<dep package="fontconfig"/>
@@ -76,4 +72,27 @@
</dependencies>
</autotools>
+ <autotools id="qtlocation"
+ autogen-template="%(prefix)s/bin/qmake %(srcdir)s"
+ makeinstallargs="install INSTALL_ROOT='$(DESTDIR)'"
+ supports-non-srcdir-builds="no">
+ <branch module="archive/qt/5.4/${version}/submodules/qtlocation-opensource-src-${version}.tar.xz" version="5.4.0"
+ repo="download.qt.io"
+ hash="sha256:e8420c1b5fdddbc44faa7aa1c653da91dc101055a869dcb518326188be81d456"/>
+ <dependencies>
+ <dep package="qtbase"/>
+ </dependencies>
+ </autotools>
+
+ <autotools id="qtsensors"
+ autogen-template="%(prefix)s/bin/qmake %(srcdir)s"
+ makeinstallargs="install INSTALL_ROOT='$(DESTDIR)'"
+ supports-non-srcdir-builds="no">
+ <branch module="archive/qt/5.4/${version}/submodules/qtsensors-opensource-src-${version}.tar.xz" version="5.4.0"
+ repo="download.qt.io"
+ hash="sha256:8a0f33ccf572b9fbcdc46fca602d75270979a2f851b6a1f399d039b1f7aae159"/>
+ <dependencies>
+ <dep package="qtbase"/>
+ </dependencies>
+ </autotools>
</moduleset>
diff --git a/Tools/qt/jhbuild.modules b/Tools/qt/jhbuild.modules
index 3053b1d2c..9a10e9f39 100644
--- a/Tools/qt/jhbuild.modules
+++ b/Tools/qt/jhbuild.modules
@@ -19,6 +19,10 @@
<dep package="gst-libav"/>
<dep package="openwebrtc"/>
<dep package="qt"/>
+ <if condition-set="linux">
+ <dep package="llvm"/>
+ <dep package="mesa"/>
+ </if>
</dependencies>
</metamodule>
@@ -47,6 +51,10 @@
href="http://webkitgtk.org/jhbuild_mirror/"/>
<repository type="tarball" name="nice.freedesktop.org"
href="http://nice.freedesktop.org/"/>
+ <repository type="tarball" name="people.freedesktop.org"
+ href="http://people.freedesktop.org"/>
+ <repository type="tarball" name="llvm.org"
+ href="http://llvm.org"/>
<autotools id="fonts" supports-non-srcdir-builds="no"
skip-autogen="true">
@@ -258,4 +266,24 @@
</branch>
</autotools>
+ <autotools id="llvm"
+ autogenargs="--enable-optimized --disable-terminfo --disable-zlib --enable-targets=host --disable-backtraces --disable-crash-overrides --disable-expensive-checks --disable-debug-runtime --disable-assertions --enable-shared">
+ <branch repo="llvm.org"
+ module="/releases/3.7.0/llvm-3.7.0.src.tar.xz" version="3.7.0" checkoutdir="llvm-3.7.0"
+ hash="sha256:ab45895f9dcdad1e140a3a79fd709f64b05ad7364e308c0e582c5b02e9cc3153"/>
+ </autotools>
+
+ <autotools id="mesa" autogenargs="--enable-xlib-glx --disable-dri --disable-egl --with-gallium-drivers=swrast" skip-install="true">
+ <!--- WARNING: At jhbuildrc, when we define the path to the Gallium llvmpipe software rasterizer (needed by XvfbDriver),
+ we assume that the directory is named "Mesa". So, don't change the checkoutdir name even if you update the version. -->
+ <branch module="/~brianp/mesa/11.0.6/mesa-11.0.6.tar.xz" version="11.0.6"
+ checkoutdir="Mesa"
+ repo="people.freedesktop.org"
+ hash="sha256:8340e64cdc91999840404c211496f3de38e7b4cb38db34e2f72f1642c5134760">
+ </branch>
+ <dependencies>
+ <dep package="llvm"/>
+ </dependencies>
+ </autotools>
+
</moduleset>
diff --git a/Tools/qt/jhbuildrc b/Tools/qt/jhbuildrc
index 58dea347f..d7f9b6f40 100644
--- a/Tools/qt/jhbuildrc
+++ b/Tools/qt/jhbuildrc
@@ -22,3 +22,9 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../jhbuild") )
import jhbuildrc_common
jhbuildrc_common.init(globals(), "qt")
+
+# LLVM requires that builddir != srcdir, and it's not possible to do that in jhbuild only
+# for a module, so we do it here globally since it's a good idea for all other modules as well.
+buildroot = os.path.join(os.path.dirname(checkoutroot), "Build")
+
+os.environ['LLVMPIPE_LIBGL_PATH'] = os.path.abspath(os.path.join(buildroot, 'Mesa', 'lib', 'gallium'))
diff --git a/Tools/qt/make-snapshot.pl b/Tools/qt/make-snapshot.pl
index 27c5621d6..316fe7b35 100755
--- a/Tools/qt/make-snapshot.pl
+++ b/Tools/qt/make-snapshot.pl
@@ -1,4 +1,26 @@
#!/usr/bin/env perl
+# Copyright (C) 2016 Konstantin Tokarev <annulen@yandex.ru>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
use Cwd;
use File::Basename;
diff --git a/Tools/qt/manifest.txt b/Tools/qt/manifest.txt
index 624fe3ba1..5d06c4530 100644
--- a/Tools/qt/manifest.txt
+++ b/Tools/qt/manifest.txt
@@ -80,6 +80,11 @@ file Source/WebCore/platform/win/SystemInfo.h
file Source/WebCore/platform/win/WebCoreInstanceHandle.cpp
file Source/WebCore/platform/win/WebCoreInstanceHandle.h
+# macOS-specific code
+file Source/WTF/wtf/cf
+file Source/WTF/wtf/text/cf
+file Source/WebCore/platform/cf/SharedBufferCF.cpp
+
# WK1 plugin code is in WebKit/win
file Source/WebKit/win/Plugins
diff --git a/Tools/qt/patches/qt-5.4-fontconfig-fix.patch b/Tools/qt/patches/qtbase-5.4-fontconfig-fix.patch
index 07395fe72..a6375fe28 100644
--- a/Tools/qt/patches/qt-5.4-fontconfig-fix.patch
+++ b/Tools/qt/patches/qtbase-5.4-fontconfig-fix.patch
@@ -13,10 +13,10 @@ Change-Id: If9ee3e185c42af10c05ae3852d088881da1d4f1a
.../fontdatabases/fontconfig/qfontconfigdatabase_p.h | 1 +
2 files changed, 8 insertions(+), 1 deletion(-)
-diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
index 8ebabf3..194f66c 100644
---- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
-+++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+--- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
@@ -471,7 +471,7 @@ static void populateFromPattern(FcPattern *pattern)
void QFontconfigDatabase::populateFontDatabase()
@@ -39,10 +39,10 @@ index 8ebabf3..194f66c 100644
QFontEngineMulti *QFontconfigDatabase::fontEngineMulti(QFontEngine *fontEngine, QChar::Script script)
{
return new QFontEngineMultiFontConfig(fontEngine, script);
-diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h
+diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h
index 2199f39..ab77fab 100644
---- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h
-+++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h
+--- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h
++++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h
@@ -56,6 +56,7 @@ class QFontconfigDatabase : public QBasicFontDatabase
{
public: