summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/platform/graphics')
-rw-r--r--Source/WebCore/platform/graphics/PlatformDisplay.cpp18
-rw-r--r--Source/WebCore/platform/graphics/WOFFFileFormat.cpp35
-rw-r--r--Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp9
-rw-r--r--Source/WebCore/platform/graphics/filters/FilterEffect.cpp13
-rw-r--r--Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp3
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp7
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp274
-rw-r--r--Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp14
-rw-r--r--Source/WebCore/platform/graphics/qt/FontPlatformData.h3
-rw-r--r--Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp15
-rw-r--r--Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp2
11 files changed, 257 insertions, 136 deletions
diff --git a/Source/WebCore/platform/graphics/PlatformDisplay.cpp b/Source/WebCore/platform/graphics/PlatformDisplay.cpp
index 19a6b99a8..bdae5f45f 100644
--- a/Source/WebCore/platform/graphics/PlatformDisplay.cpp
+++ b/Source/WebCore/platform/graphics/PlatformDisplay.cpp
@@ -26,6 +26,7 @@
#include "config.h"
#include "PlatformDisplay.h"
+#include <cstdlib>
#include <mutex>
#include <wtf/NeverDestroyed.h>
@@ -112,10 +113,8 @@ PlatformDisplay::PlatformDisplay()
PlatformDisplay::~PlatformDisplay()
{
- // WinCairo crashes when terminating EGL on exit.
- // https://bugs.webkit.org/show_bug.cgi?id=145832
-#if USE(EGL) && !PLATFORM(WIN)
- terminateEGLDisplay();
+#if USE(EGL)
+ ASSERT(m_eglDisplay == EGL_NO_DISPLAY);
#endif
}
@@ -159,10 +158,21 @@ void PlatformDisplay::initializeEGLDisplay()
terminateEGLDisplay();
return;
}
+
+ // EGL registers atexit handlers to cleanup its global display list.
+ // Since the global PlatformDisplay instance is created before,
+ // when the PlatformDisplay destructor is called, EGL has already removed the
+ // display from the list, causing eglTerminate() to crash. So, here we register
+ // our own atexit handler, after EGL has been initialized and after the global
+ // instance has been created to ensure we call eglTerminate() before the other
+ // EGL atexit handlers and the PlatformDisplay destructor.
+ // See https://bugs.webkit.org/show_bug.cgi?id=157973.
+ std::atexit([] { PlatformDisplay::sharedDisplay().terminateEGLDisplay(); });
}
void PlatformDisplay::terminateEGLDisplay()
{
+ ASSERT(m_eglDisplayInitialized);
if (m_eglDisplay == EGL_NO_DISPLAY)
return;
eglTerminate(m_eglDisplay);
diff --git a/Source/WebCore/platform/graphics/WOFFFileFormat.cpp b/Source/WebCore/platform/graphics/WOFFFileFormat.cpp
index 051871ac6..61a58b904 100644
--- a/Source/WebCore/platform/graphics/WOFFFileFormat.cpp
+++ b/Source/WebCore/platform/graphics/WOFFFileFormat.cpp
@@ -30,6 +30,11 @@
#include "SharedBuffer.h"
#include <wtf/ByteOrder.h>
+#if USE(WOFF2)
+#include "woff2_common.h"
+#include "woff2_dec.h"
+#endif
+
namespace WebCore {
static bool readUInt32(SharedBuffer* buffer, size_t& offset, uint32_t& value)
@@ -75,7 +80,14 @@ bool isWOFF(SharedBuffer* buffer)
size_t offset = 0;
uint32_t signature;
- return readUInt32(buffer, offset, signature) && signature == woffSignature;
+ if (!readUInt32(buffer, offset, signature))
+ return false;
+
+#if USE(WOFF2)
+ return signature == woffSignature || signature == woff2::kWoff2Signature;
+#else
+ return signature == woffSignature;
+#endif
}
bool convertWOFFToSfnt(SharedBuffer* woff, Vector<char>& sfnt)
@@ -86,7 +98,26 @@ bool convertWOFFToSfnt(SharedBuffer* woff, Vector<char>& sfnt)
// Read the WOFF header.
uint32_t signature;
- if (!readUInt32(woff, offset, signature) || signature != woffSignature) {
+ if (!readUInt32(woff, offset, signature)) {
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+
+#if USE(WOFF2)
+ if (signature == woff2::kWoff2Signature) {
+ const uint8_t* woffData = reinterpret_cast_ptr<const uint8_t*>(woff->data());
+ const size_t woffSize = woff->size();
+ const size_t sfntSize = woff2::ComputeWOFF2FinalSize(woffData, woffSize);
+
+ if (!sfnt.tryReserveCapacity(sfntSize))
+ return false;
+ sfnt.resize(sfntSize);
+
+ return woff2::ConvertWOFF2ToTTF(reinterpret_cast<uint8_t*>(sfnt.data()), sfnt.size(), woffData, woffSize);
+ }
+#endif
+
+ if (signature != woffSignature) {
ASSERT_NOT_REACHED();
return false;
}
diff --git a/Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp b/Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp
index 1904ed91a..e50ec669d 100644
--- a/Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp
+++ b/Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp
@@ -5,7 +5,7 @@
* Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
* Copyright (C) 2010 Igalia, S.L.
* Copyright (C) Research In Motion Limited 2010. All rights reserved.
- * Copyright (C) 2015 Apple, Inc. All rights reserved.
+ * Copyright (C) 2015-2016 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
@@ -540,9 +540,12 @@ void FEGaussianBlur::platformApplySoftware()
IntSize paintSize = absolutePaintRect().size();
paintSize.scale(filter().filterScale());
RefPtr<Uint8ClampedArray> tmpImageData = Uint8ClampedArray::createUninitialized(paintSize.width() * paintSize.height() * 4);
- Uint8ClampedArray* tmpPixelArray = tmpImageData.get();
+ if (!tmpImageData) {
+ WTFLogAlways("FEGaussianBlur::platformApplySoftware Unable to create buffer. Requested size was %d x %d\n", paintSize.width(), paintSize.height());
+ return;
+ }
- platformApply(srcPixelArray, tmpPixelArray, kernelSize.width(), kernelSize.height(), paintSize);
+ platformApply(srcPixelArray, tmpImageData.get(), kernelSize.width(), kernelSize.height(), paintSize);
}
void FEGaussianBlur::dump()
diff --git a/Source/WebCore/platform/graphics/filters/FilterEffect.cpp b/Source/WebCore/platform/graphics/filters/FilterEffect.cpp
index 1dcb0cb06..515d1299b 100644
--- a/Source/WebCore/platform/graphics/filters/FilterEffect.cpp
+++ b/Source/WebCore/platform/graphics/filters/FilterEffect.cpp
@@ -3,7 +3,7 @@
* Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
* Copyright (C) Research In Motion Limited 2010. All rights reserved.
* Copyright (C) 2012 University of Szeged
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2016 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
@@ -260,6 +260,9 @@ inline void FilterEffect::copyImageBytes(Uint8ClampedArray* source, Uint8Clamped
IntSize scaledPaintSize(m_absolutePaintRect.size());
scaledPaintSize.scale(m_filter.filterScale());
+ if (!source || !destination)
+ return;
+
// Initialize the destination to transparent black, if not entirely covered by the source.
if (scaledRect.x() < 0 || scaledRect.y() < 0 || scaledRect.maxX() > scaledPaintSize.width() || scaledRect.maxY() > scaledPaintSize.height())
memset(destination->data(), 0, destination->length());
@@ -315,6 +318,10 @@ void FilterEffect::copyUnmultipliedImage(Uint8ClampedArray* destination, const I
ASSERT(!ImageBuffer::sizeNeedsClamping(inputSize));
inputSize.scale(m_filter.filterScale());
m_unmultipliedImageResult = Uint8ClampedArray::createUninitialized(inputSize.width() * inputSize.height() * 4);
+ if (!m_unmultipliedImageResult) {
+ WTFLogAlways("FilterEffect::copyUnmultipliedImage Unable to create buffer. Requested size was %d x %d\n", inputSize.width(), inputSize.height());
+ return;
+ }
unsigned char* sourceComponent = m_premultipliedImageResult->data();
unsigned char* destinationComponent = m_unmultipliedImageResult->data();
unsigned char* end = sourceComponent + (inputSize.width() * inputSize.height() * 4);
@@ -351,6 +358,10 @@ void FilterEffect::copyPremultipliedImage(Uint8ClampedArray* destination, const
ASSERT(!ImageBuffer::sizeNeedsClamping(inputSize));
inputSize.scale(m_filter.filterScale());
m_premultipliedImageResult = Uint8ClampedArray::createUninitialized(inputSize.width() * inputSize.height() * 4);
+ if (!m_premultipliedImageResult) {
+ WTFLogAlways("FilterEffect::copyPremultipliedImage Unable to create buffer. Requested size was %d x %d\n", inputSize.width(), inputSize.height());
+ return;
+ }
unsigned char* sourceComponent = m_unmultipliedImageResult->data();
unsigned char* destinationComponent = m_premultipliedImageResult->data();
unsigned char* end = sourceComponent + (inputSize.width() * inputSize.height() * 4);
diff --git a/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp b/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp
index a1a189a2b..27517db20 100644
--- a/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp
+++ b/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp
@@ -91,6 +91,9 @@ bool FontCustomPlatformData::supportsFormat(const String& format)
{
return equalLettersIgnoringASCIICase(format, "truetype")
|| equalLettersIgnoringASCIICase(format, "opentype")
+#if USE(WOFF2)
+ || equalLettersIgnoringASCIICase(format, "woff2")
+#endif
|| equalLettersIgnoringASCIICase(format, "woff");
}
diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
index 428038c08..310a02247 100644
--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
@@ -537,11 +537,18 @@ void MediaPlayerPrivateGStreamerBase::repaint()
void MediaPlayerPrivateGStreamerBase::triggerRepaint(GstSample* sample)
{
+ bool triggerResize;
{
WTF::GMutexLocker<GMutex> lock(m_sampleMutex);
+ triggerResize = !m_sample;
m_sample = sample;
}
+ if (triggerResize) {
+ LOG_MEDIA_MESSAGE("First sample reached the sink, triggering video dimensions update");
+ m_player->sizeChanged();
+ }
+
#if USE(COORDINATED_GRAPHICS_THREADED)
#if USE(GSTREAMER_GL)
pushTextureToCompositor();
diff --git a/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
index d2ae28f2c..df7c46836 100644
--- a/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
+++ b/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
@@ -39,6 +39,8 @@
#include <gst/app/gstappsrc.h>
#include <gst/gst.h>
#include <gst/pbutils/missing-plugins.h>
+#include <wtf/Condition.h>
+#include <wtf/Lock.h>
#include <wtf/MainThread.h>
#include <wtf/Noncopyable.h>
#include <wtf/glib/GMutexLocker.h>
@@ -83,7 +85,7 @@ class CachedResourceStreamingClient final : public PlatformMediaResourceClient,
class ResourceHandleStreamingClient : public ResourceHandleClient, public StreamingClient {
WTF_MAKE_NONCOPYABLE(ResourceHandleStreamingClient); WTF_MAKE_FAST_ALLOCATED;
public:
- ResourceHandleStreamingClient(WebKitWebSrc*, const ResourceRequest&);
+ ResourceHandleStreamingClient(WebKitWebSrc*, ResourceRequest&&);
virtual ~ResourceHandleStreamingClient();
// StreamingClient virtual methods.
@@ -102,6 +104,12 @@ class ResourceHandleStreamingClient : public ResourceHandleClient, public Stream
virtual void wasBlocked(ResourceHandle*);
virtual void cannotShowURL(ResourceHandle*);
+ ThreadIdentifier m_thread { 0 };
+ Lock m_initializeRunLoopConditionMutex;
+ Condition m_initializeRunLoopCondition;
+ RunLoop* m_runLoop { nullptr };
+ Lock m_terminateRunLoopConditionMutex;
+ Condition m_terminateRunLoopCondition;
RefPtr<ResourceHandle> m_resource;
};
@@ -127,18 +135,19 @@ struct _WebKitWebSrcPrivate {
RefPtr<PlatformMediaResourceLoader> loader;
RefPtr<PlatformMediaResource> resource;
- ResourceHandleStreamingClient* client;
+ std::unique_ptr<ResourceHandleStreamingClient> client;
bool didPassAccessControlCheck;
guint64 offset;
guint64 size;
gboolean seekable;
- gboolean paused;
+ bool paused;
bool isSeeking;
guint64 requestedOffset;
+ bool createdInMainThread;
MainThreadNotifier<MainThreadSourceNotification> notifier;
GRefPtr<GstBuffer> buffer;
};
@@ -172,57 +181,20 @@ static gboolean webKitWebSrcQueryWithParent(GstPad*, GstObject*, GstQuery*);
static void webKitWebSrcNeedData(WebKitWebSrc*);
static void webKitWebSrcEnoughData(WebKitWebSrc*);
-static void webKitWebSrcSeek(WebKitWebSrc*);
+static gboolean webKitWebSrcSeek(WebKitWebSrc*, guint64);
static GstAppSrcCallbacks appsrcCallbacks = {
// need_data
[](GstAppSrc*, guint, gpointer userData) {
- WebKitWebSrc* src = WEBKIT_WEB_SRC(userData);
- WebKitWebSrcPrivate* priv = src->priv;
-
- {
- WTF::GMutexLocker<GMutex> locker(*GST_OBJECT_GET_LOCK(src));
- if (!priv->paused)
- return;
- }
-
- GRefPtr<WebKitWebSrc> protector = WTF::ensureGRef(src);
- priv->notifier.notify(MainThreadSourceNotification::NeedData, [protector] { webKitWebSrcNeedData(protector.get()); });
+ webKitWebSrcNeedData(WEBKIT_WEB_SRC(userData));
},
// enough_data
[](GstAppSrc*, gpointer userData) {
- WebKitWebSrc* src = WEBKIT_WEB_SRC(userData);
- WebKitWebSrcPrivate* priv = src->priv;
-
- {
- WTF::GMutexLocker<GMutex> locker(*GST_OBJECT_GET_LOCK(src));
- if (priv->paused)
- return;
- }
-
- GRefPtr<WebKitWebSrc> protector = WTF::ensureGRef(src);
- priv->notifier.notify(MainThreadSourceNotification::EnoughData, [protector] { webKitWebSrcEnoughData(protector.get()); });
+ webKitWebSrcEnoughData(WEBKIT_WEB_SRC(userData));
},
// seek_data
[](GstAppSrc*, guint64 offset, gpointer userData) -> gboolean {
- WebKitWebSrc* src = WEBKIT_WEB_SRC(userData);
- WebKitWebSrcPrivate* priv = src->priv;
-
- {
- WTF::GMutexLocker<GMutex> locker(*GST_OBJECT_GET_LOCK(src));
- if (offset == priv->offset && priv->requestedOffset == priv->offset)
- return TRUE;
-
- if (!priv->seekable)
- return FALSE;
-
- priv->isSeeking = true;
- priv->requestedOffset = offset;
- }
-
- GRefPtr<WebKitWebSrc> protector = WTF::ensureGRef(src);
- priv->notifier.notify(MainThreadSourceNotification::Seek, [protector] { webKitWebSrcSeek(protector.get()); });
- return TRUE;
+ return webKitWebSrcSeek(WEBKIT_WEB_SRC(userData), offset);
},
{ nullptr }
};
@@ -287,6 +259,8 @@ static void webkit_web_src_init(WebKitWebSrc* src)
src->priv = priv;
new (priv) WebKitWebSrcPrivate();
+ priv->createdInMainThread = isMainThread();
+
priv->appsrc = GST_APP_SRC(gst_element_factory_make("appsrc", 0));
if (!priv->appsrc) {
GST_ERROR_OBJECT(src, "Failed to create appsrc");
@@ -412,28 +386,37 @@ static void webKitWebSrcStop(WebKitWebSrc* src)
{
WebKitWebSrcPrivate* priv = src->priv;
- ASSERT(isMainThread());
+ if (priv->resource || (priv->loader && !priv->keepAlive)) {
+ GRefPtr<WebKitWebSrc> protector = WTF::ensureGRef(src);
+ priv->notifier.cancelPendingNotifications(MainThreadSourceNotification::NeedData | MainThreadSourceNotification::EnoughData | MainThreadSourceNotification::Seek);
+ bool keepAlive = priv->keepAlive;
+ priv->notifier.notify(MainThreadSourceNotification::Stop, [protector, keepAlive] {
+ WebKitWebSrcPrivate* priv = protector->priv;
+
+ WTF::GMutexLocker<GMutex> locker(*GST_OBJECT_GET_LOCK(protector.get()));
+ if (priv->resource) {
+ priv->resource->stop();
+ priv->resource->setClient(nullptr);
+ priv->resource = nullptr;
+ }
+
+ if (!keepAlive)
+ priv->loader = nullptr;
+ });
+ }
WTF::GMutexLocker<GMutex> locker(*GST_OBJECT_GET_LOCK(src));
bool wasSeeking = std::exchange(priv->isSeeking, false);
- priv->notifier.cancelPendingNotifications(MainThreadSourceNotification::NeedData | MainThreadSourceNotification::EnoughData | MainThreadSourceNotification::Seek);
-
- if (priv->client) {
- delete priv->client;
- priv->client = 0;
- }
-
- if (!priv->keepAlive)
- priv->loader = nullptr;
+ priv->client = nullptr;
if (priv->buffer) {
unmapGstBuffer(priv->buffer.get());
priv->buffer.clear();
}
- priv->paused = FALSE;
+ priv->paused = false;
priv->offset = 0;
priv->seekable = FALSE;
@@ -510,8 +493,6 @@ static void webKitWebSrcStart(WebKitWebSrc* src)
{
WebKitWebSrcPrivate* priv = src->priv;
- ASSERT(isMainThread());
-
WTF::GMutexLocker<GMutex> locker(*GST_OBJECT_GET_LOCK(src));
priv->didPassAccessControlCheck = false;
@@ -576,37 +557,41 @@ static void webKitWebSrcStart(WebKitWebSrc* src)
// We always request Icecast/Shoutcast metadata, just in case ...
request.setHTTPHeaderField(HTTPHeaderName::IcyMetadata, "1");
- bool loadFailed = true;
- if (priv->player && !priv->loader)
- priv->loader = priv->player->createResourceLoader();
+ if (!priv->player || !priv->createdInMainThread) {
+ priv->client = std::make_unique<ResourceHandleStreamingClient>(src, WTFMove(request));
+ if (priv->client->loadFailed()) {
+ GST_ERROR_OBJECT(src, "Failed to setup streaming client");
+ priv->client = nullptr;
+ locker.unlock();
+ webKitWebSrcStop(src);
+ } else
+ GST_DEBUG_OBJECT(src, "Started request");
+ return;
+ }
+
+ locker.unlock();
+ GRefPtr<WebKitWebSrc> protector = WTF::ensureGRef(src);
+ priv->notifier.notify(MainThreadSourceNotification::Start, [protector, request] {
+ WebKitWebSrcPrivate* priv = protector->priv;
+
+ WTF::GMutexLocker<GMutex> locker(*GST_OBJECT_GET_LOCK(protector.get()));
+ if (!priv->loader)
+ priv->loader = priv->player->createResourceLoader();
- if (priv->loader) {
PlatformMediaResourceLoader::LoadOptions loadOptions = 0;
if (request.url().protocolIsBlob())
loadOptions |= PlatformMediaResourceLoader::LoadOption::BufferData;
priv->resource = priv->loader->requestResource(request, loadOptions);
- loadFailed = !priv->resource;
-
- if (priv->resource)
- priv->resource->setClient(std::make_unique<CachedResourceStreamingClient>(src));
- } else {
- priv->client = new ResourceHandleStreamingClient(src, request);
- loadFailed = priv->client->loadFailed();
- }
-
- if (loadFailed) {
- GST_ERROR_OBJECT(src, "Failed to setup streaming client");
- if (priv->client) {
- delete priv->client;
- priv->client = nullptr;
+ if (priv->resource) {
+ priv->resource->setClient(std::make_unique<CachedResourceStreamingClient>(protector.get()));
+ GST_DEBUG_OBJECT(protector.get(), "Started request");
+ } else {
+ GST_ERROR_OBJECT(protector.get(), "Failed to setup streaming client");
+ priv->loader = nullptr;
+ locker.unlock();
+ webKitWebSrcStop(protector.get());
}
- priv->loader = nullptr;
- priv->resource = nullptr;
- locker.unlock();
- webKitWebSrcStop(src);
- return;
- }
- GST_DEBUG_OBJECT(src, "Started request");
+ });
}
static GstStateChangeReturn webKitWebSrcChangeState(GstElement* element, GstStateChange transition)
@@ -638,16 +623,13 @@ static GstStateChangeReturn webKitWebSrcChangeState(GstElement* element, GstStat
case GST_STATE_CHANGE_READY_TO_PAUSED:
{
GST_DEBUG_OBJECT(src, "READY->PAUSED");
- GRefPtr<WebKitWebSrc> protector = WTF::ensureGRef(src);
- priv->notifier.notify(MainThreadSourceNotification::Start, [protector] { webKitWebSrcStart(protector.get()); });
+ webKitWebSrcStart(src);
break;
}
case GST_STATE_CHANGE_PAUSED_TO_READY:
{
GST_DEBUG_OBJECT(src, "PAUSED->READY");
- priv->notifier.cancelPendingNotifications();
- GRefPtr<WebKitWebSrc> protector = WTF::ensureGRef(src);
- priv->notifier.notify(MainThreadSourceNotification::Stop, [protector] { webKitWebSrcStop(protector.get()); });
+ webKitWebSrcStop(src);
break;
}
default:
@@ -772,59 +754,91 @@ static void webKitWebSrcUriHandlerInit(gpointer gIface, gpointer)
iface->set_uri = webKitWebSrcSetUri;
}
-// appsrc callbacks
-
static void webKitWebSrcNeedData(WebKitWebSrc* src)
{
WebKitWebSrcPrivate* priv = src->priv;
- ASSERT(isMainThread());
-
GST_DEBUG_OBJECT(src, "Need more data");
{
WTF::GMutexLocker<GMutex> locker(*GST_OBJECT_GET_LOCK(src));
- priv->paused = FALSE;
+ if (!priv->paused)
+ return;
+ priv->paused = false;
+ if (priv->client) {
+ priv->client->setDefersLoading(false);
+ return;
+ }
}
- if (priv->client)
- priv->client->setDefersLoading(false);
- if (priv->resource)
- priv->resource->setDefersLoading(false);
+ GRefPtr<WebKitWebSrc> protector = WTF::ensureGRef(src);
+ priv->notifier.notify(MainThreadSourceNotification::NeedData, [protector] {
+ WebKitWebSrcPrivate* priv = protector->priv;
+ if (priv->resource)
+ priv->resource->setDefersLoading(false);
+ });
}
static void webKitWebSrcEnoughData(WebKitWebSrc* src)
{
WebKitWebSrcPrivate* priv = src->priv;
- ASSERT(isMainThread());
-
GST_DEBUG_OBJECT(src, "Have enough data");
{
WTF::GMutexLocker<GMutex> locker(*GST_OBJECT_GET_LOCK(src));
- priv->paused = TRUE;
+ if (priv->paused)
+ return;
+ priv->paused = true;
+ if (priv->client) {
+ priv->client->setDefersLoading(true);
+ return;
+ }
}
- if (priv->client)
- priv->client->setDefersLoading(true);
- if (priv->resource)
- priv->resource->setDefersLoading(true);
+ GRefPtr<WebKitWebSrc> protector = WTF::ensureGRef(src);
+ priv->notifier.notify(MainThreadSourceNotification::EnoughData, [protector] {
+ WebKitWebSrcPrivate* priv = protector->priv;
+ if (priv->resource)
+ priv->resource->setDefersLoading(true);
+ });
}
-static void webKitWebSrcSeek(WebKitWebSrc* src)
+static gboolean webKitWebSrcSeek(WebKitWebSrc* src, guint64 offset)
{
- ASSERT(isMainThread());
+ WebKitWebSrcPrivate* priv = src->priv;
+
+ {
+ WTF::GMutexLocker<GMutex> locker(*GST_OBJECT_GET_LOCK(src));
+ if (offset == priv->offset && priv->requestedOffset == priv->offset)
+ return TRUE;
+
+ if (!priv->seekable)
+ return FALSE;
+
+ priv->isSeeking = true;
+ priv->requestedOffset = offset;
+ }
GST_DEBUG_OBJECT(src, "Seeking to offset: %" G_GUINT64_FORMAT, src->priv->requestedOffset);
+ if (priv->client) {
+ webKitWebSrcStop(src);
+ webKitWebSrcStart(src);
+ return TRUE;
+ }
- webKitWebSrcStop(src);
- webKitWebSrcStart(src);
+ GRefPtr<WebKitWebSrc> protector = WTF::ensureGRef(src);
+ priv->notifier.notify(MainThreadSourceNotification::Seek, [protector] {
+ webKitWebSrcStop(protector.get());
+ webKitWebSrcStart(protector.get());
+ });
+ return TRUE;
}
void webKitWebSrcSetMediaPlayer(WebKitWebSrc* src, WebCore::MediaPlayer* player)
{
ASSERT(player);
+ ASSERT(src->priv->createdInMainThread);
WTF::GMutexLocker<GMutex> locker(*GST_OBJECT_GET_LOCK(src));
src->priv->player = player;
}
@@ -1051,17 +1065,47 @@ void CachedResourceStreamingClient::loadFinished(PlatformMediaResource&)
handleNotifyFinished();
}
-ResourceHandleStreamingClient::ResourceHandleStreamingClient(WebKitWebSrc* src, const ResourceRequest& request)
+ResourceHandleStreamingClient::ResourceHandleStreamingClient(WebKitWebSrc* src, ResourceRequest&& request)
: StreamingClient(src)
{
- m_resource = ResourceHandle::create(0 /*context*/, request, this, false, false);
+ LockHolder locker(m_initializeRunLoopConditionMutex);
+ m_thread = createThread("ResourceHandleStreamingClient", [this, request] {
+ {
+ LockHolder locker(m_initializeRunLoopConditionMutex);
+ m_runLoop = &RunLoop::current();
+ m_resource = ResourceHandle::create(nullptr /*context*/, request, this, true, false);
+ m_initializeRunLoopCondition.notifyOne();
+ }
+ if (!m_resource)
+ return;
+
+ m_runLoop->dispatch([this] { m_resource->setDefersLoading(false); });
+ m_runLoop->run();
+ {
+ LockHolder locker(m_terminateRunLoopConditionMutex);
+ m_runLoop = nullptr;
+ m_resource->clearClient();
+ m_resource->cancel();
+ m_resource = nullptr;
+ m_terminateRunLoopCondition.notifyOne();
+ }
+ });
+ m_initializeRunLoopCondition.wait(m_initializeRunLoopConditionMutex);
}
ResourceHandleStreamingClient::~ResourceHandleStreamingClient()
{
- if (m_resource) {
- m_resource->cancel();
- m_resource = nullptr;
+ if (m_thread) {
+ detachThread(m_thread);
+ m_thread = 0;
+ }
+
+ if (m_runLoop == &RunLoop::current())
+ m_runLoop->stop();
+ else {
+ LockHolder locker(m_terminateRunLoopConditionMutex);
+ m_runLoop->stop();
+ m_terminateRunLoopCondition.wait(m_terminateRunLoopConditionMutex);
}
}
@@ -1072,8 +1116,10 @@ bool ResourceHandleStreamingClient::loadFailed() const
void ResourceHandleStreamingClient::setDefersLoading(bool defers)
{
- if (m_resource)
- m_resource->setDefersLoading(defers);
+ m_runLoop->dispatch([this, defers] {
+ if (m_resource)
+ m_resource->setDefersLoading(defers);
+ });
}
char* ResourceHandleStreamingClient::getOrCreateReadBuffer(size_t requestedSize, size_t& actualSize)
diff --git a/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp b/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp
index 39cd47ce2..78e159aa0 100644
--- a/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp
@@ -24,9 +24,7 @@
#include "FontPlatformData.h"
#include "SharedBuffer.h"
-#if USE(ZLIB)
#include "WOFFFileFormat.h"
-#endif
#include <QStringList>
namespace WebCore {
@@ -41,7 +39,6 @@ FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription&
std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer& buffer)
{
-#if USE(ZLIB)
SharedBuffer* fontBuffer = &buffer;
RefPtr<SharedBuffer> sfntBuffer;
if (isWOFF(&buffer)) {
@@ -52,15 +49,9 @@ std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffe
sfntBuffer = SharedBuffer::adoptVector(sfnt);
fontBuffer = sfntBuffer.get();
}
-#endif // USE(ZLIB)
const QByteArray fontData(fontBuffer->data(), fontBuffer->size());
-#if !USE(ZLIB)
- if (fontData.startsWith("wOFF")) {
- qWarning("WOFF support requires QtWebKit to be built with zlib support.");
- return 0;
- }
-#endif // !USE(ZLIB)
+
// Pixel size doesn't matter at this point, it is set in FontCustomPlatformData::fontPlatformData.
QRawFont rawFont(fontData, /*pixelSize = */0, QFont::PreferDefaultHinting);
if (!rawFont.isValid())
@@ -75,8 +66,9 @@ bool FontCustomPlatformData::supportsFormat(const String& format)
{
return equalLettersIgnoringASCIICase(format, "truetype")
|| equalLettersIgnoringASCIICase(format, "opentype")
-#if USE(ZLIB)
|| equalLettersIgnoringASCIICase(format, "woff")
+#if USE(WOFF2)
+ || equalLettersIgnoringASCIICase(format, "woff2")
#endif
;
}
diff --git a/Source/WebCore/platform/graphics/qt/FontPlatformData.h b/Source/WebCore/platform/graphics/qt/FontPlatformData.h
index 14e36f018..c8375ebcd 100644
--- a/Source/WebCore/platform/graphics/qt/FontPlatformData.h
+++ b/Source/WebCore/platform/graphics/qt/FontPlatformData.h
@@ -34,6 +34,8 @@
namespace WebCore {
+class SharedBuffer;
+
class FontPlatformDataPrivate : public RefCounted<FontPlatformDataPrivate> {
WTF_MAKE_NONCOPYABLE(FontPlatformDataPrivate); WTF_MAKE_FAST_ALLOCATED;
public:
@@ -117,6 +119,7 @@ public:
FontOrientation orientation() const { return Horizontal; } // FIXME: Implement.
void setOrientation(FontOrientation) { } // FIXME: Implement.
+ PassRefPtr<SharedBuffer> openTypeTable(uint32_t table) const;
unsigned hash() const;
diff --git a/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp b/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp
index a239d643d..2ed4a98c3 100644
--- a/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp
@@ -25,6 +25,7 @@
#include "FontPlatformData.h"
#include "FontCascade.h"
+#include "SharedBuffer.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -139,6 +140,20 @@ bool FontPlatformData::operator==(const FontPlatformData& other) const
return equals;
}
+PassRefPtr<SharedBuffer> FontPlatformData::openTypeTable(uint32_t table) const
+{
+ const char tag[4] = {
+ char(table & 0xff),
+ char((table & 0xff00) >> 8),
+ char((table & 0xff0000) >> 16),
+ char(table >> 24)
+ };
+ QByteArray tableData = m_data->rawFont.fontTable(tag);
+
+ // TODO: Wrap SharedBuffer around QByteArray when it's possible
+ return SharedBuffer::create(tableData.data(), tableData.size());
+}
+
unsigned FontPlatformData::hash() const
{
if (!m_data)
diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
index 618bf63ae..9e992381c 100644
--- a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
@@ -362,7 +362,7 @@ void GraphicsContext3DPrivate::createGraphicsSurfaces(const IntSize& size)
{
#if USE(GRAPHICS_SURFACE)
if (size.isEmpty())
- m_graphicsSurface.clear();
+ m_graphicsSurface = nullptr;
else
m_graphicsSurface = GraphicsSurface::create(size, m_surfaceFlags, m_platformContext);
#endif