summaryrefslogtreecommitdiff
path: root/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@qt.io>2017-05-30 12:48:17 +0200
committerOswald Buddenhagen <oswald.buddenhagen@qt.io>2017-05-30 12:48:17 +0200
commit881da28418d380042aa95a97f0cbd42560a64f7c (patch)
treea794dff3274695e99c651902dde93d934ea7a5af /Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp
parent7e104c57a70fdf551bb3d22a5d637cdcbc69dbea (diff)
parent0fcedcd17cc00d3dd44c718b3cb36c1033319671 (diff)
downloadqtwebkit-881da28418d380042aa95a97f0cbd42560a64f7c.tar.gz
Merge 'wip/next' into dev
Change-Id: Iff9ee5e23bb326c4371ec8ed81d56f2f05d680e9
Diffstat (limited to 'Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp')
-rw-r--r--Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp254
1 files changed, 111 insertions, 143 deletions
diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp
index bc18a7609..825c76585 100644
--- a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp
@@ -32,8 +32,10 @@
#include "UpdateInfo.h"
#include "WebPage.h"
#include "WebPageCreationParameters.h"
+#include "WebPreferencesKeys.h"
#include "WebProcess.h"
#include <WebCore/GraphicsContext.h>
+#include <WebCore/MainFrame.h>
#include <WebCore/Page.h>
#include <WebCore/Settings.h>
@@ -41,19 +43,18 @@ using namespace WebCore;
namespace WebKit {
-PassOwnPtr<DrawingAreaImpl> DrawingAreaImpl::create(WebPage* webPage, const WebPageCreationParameters& parameters)
-{
- return adoptPtr(new DrawingAreaImpl(webPage, parameters));
-}
-
DrawingAreaImpl::~DrawingAreaImpl()
{
if (m_layerTreeHost)
m_layerTreeHost->invalidate();
}
-DrawingAreaImpl::DrawingAreaImpl(WebPage* webPage, const WebPageCreationParameters& parameters)
+DrawingAreaImpl::DrawingAreaImpl(WebPage& webPage, const WebPageCreationParameters& parameters)
+#if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
+ : DrawingArea(DrawingAreaTypeCoordinated, webPage)
+#else
: DrawingArea(DrawingAreaTypeImpl, webPage)
+#endif
, m_backingStoreStateID(0)
, m_isPaintingEnabled(true)
, m_inUpdateBackingStoreState(false)
@@ -62,20 +63,11 @@ DrawingAreaImpl::DrawingAreaImpl(WebPage* webPage, const WebPageCreationParamete
, m_compositingAccordingToProxyMessages(false)
, m_layerTreeStateIsFrozen(false)
, m_wantsToExitAcceleratedCompositingMode(false)
- , m_isPaintingSuspended(!parameters.isVisible)
+ , m_isPaintingSuspended(!(parameters.viewState & ViewState::IsVisible))
, m_alwaysUseCompositing(false)
, m_displayTimer(RunLoop::main(), this, &DrawingAreaImpl::displayTimerFired)
, m_exitCompositingTimer(RunLoop::main(), this, &DrawingAreaImpl::exitAcceleratedCompositingMode)
{
- if (webPage->corePage()->settings()->acceleratedDrawingEnabled() || webPage->corePage()->settings()->forceCompositingMode())
- m_alwaysUseCompositing = true;
-
-#if USE(COORDINATED_GRAPHICS)
- m_alwaysUseCompositing = true;
-#endif
-
- if (m_alwaysUseCompositing)
- enterAcceleratedCompositingMode(0);
}
void DrawingAreaImpl::setNeedsDisplay()
@@ -89,7 +81,7 @@ void DrawingAreaImpl::setNeedsDisplay()
return;
}
- setNeedsDisplayInRect(m_webPage->bounds());
+ setNeedsDisplayInRect(m_webPage.bounds());
}
void DrawingAreaImpl::setNeedsDisplayInRect(const IntRect& rect)
@@ -104,7 +96,7 @@ void DrawingAreaImpl::setNeedsDisplayInRect(const IntRect& rect)
}
IntRect dirtyRect = rect;
- dirtyRect.intersect(m_webPage->bounds());
+ dirtyRect.intersect(m_webPage.bounds());
if (dirtyRect.isEmpty())
return;
@@ -195,9 +187,15 @@ void DrawingAreaImpl::setLayerTreeStateIsFrozen(bool isFrozen)
void DrawingAreaImpl::forceRepaint()
{
+ if (m_inUpdateBackingStoreState) {
+ m_forceRepaintAfterBackingStoreStateUpdate = true;
+ return;
+ }
+
+ m_forceRepaintAfterBackingStoreStateUpdate = false;
setNeedsDisplay();
- m_webPage->layoutIfNeeded();
+ m_webPage.layoutIfNeeded();
if (m_layerTreeHost) {
// FIXME: We need to do the same work as the layerHostDidFlushLayers function here,
@@ -223,65 +221,36 @@ bool DrawingAreaImpl::forceRepaintAsync(uint64_t callbackID)
return m_layerTreeHost && m_layerTreeHost->forceRepaintAsync(callbackID);
}
-void DrawingAreaImpl::didInstallPageOverlay(PageOverlay* pageOverlay)
-{
- if (m_layerTreeHost)
- m_layerTreeHost->didInstallPageOverlay(pageOverlay);
-}
-
-void DrawingAreaImpl::didUninstallPageOverlay(PageOverlay* pageOverlay)
-{
- if (m_layerTreeHost)
- m_layerTreeHost->didUninstallPageOverlay(pageOverlay);
-
- setNeedsDisplay();
-}
-
-void DrawingAreaImpl::setPageOverlayNeedsDisplay(PageOverlay* pageOverlay, const IntRect& rect)
+void DrawingAreaImpl::setPaintingEnabled(bool paintingEnabled)
{
- if (m_layerTreeHost) {
- m_layerTreeHost->setPageOverlayNeedsDisplay(pageOverlay, rect);
- return;
- }
-
- setNeedsDisplayInRect(rect);
+ m_isPaintingEnabled = paintingEnabled;
}
-void DrawingAreaImpl::setPageOverlayOpacity(PageOverlay* pageOverlay, float value)
+void DrawingAreaImpl::mainFrameContentSizeChanged(const WebCore::IntSize& newSize)
{
+#if USE(COORDINATED_GRAPHICS_THREADED)
if (m_layerTreeHost)
- m_layerTreeHost->setPageOverlayOpacity(pageOverlay, value);
-}
-
-bool DrawingAreaImpl::pageOverlayShouldApplyFadeWhenPainting() const
-{
- if (m_layerTreeHost && !m_layerTreeHost->pageOverlayShouldApplyFadeWhenPainting())
- return false;
-
- return true;
-}
-
-void DrawingAreaImpl::setPaintingEnabled(bool paintingEnabled)
-{
- m_isPaintingEnabled = paintingEnabled;
+ m_layerTreeHost->sizeDidChange(newSize);
+#else
+ UNUSED_PARAM(newSize);
+#endif
}
void DrawingAreaImpl::updatePreferences(const WebPreferencesStore& store)
{
-#if PLATFORM(MAC)
- // Soon we want pages with fixed positioned elements to be able to be scrolled by the ScrollingCoordinator.
- // As a part of that work, we have to composite fixed position elements, and we have to allow those
- // elements to create a stacking context.
- m_webPage->corePage()->settings()->setAcceleratedCompositingForFixedPositionEnabled(true);
- m_webPage->corePage()->settings()->setFixedPositionCreatesStackingContext(true);
-
- // <rdar://problem/10697417>: It is necessary to force compositing when accelerate drawing
- // is enabled on Mac so that scrollbars are always in their own layers.
- if (m_webPage->corePage()->settings()->acceleratedDrawingEnabled())
- m_webPage->corePage()->settings()->setForceCompositingMode(LayerTreeHost::supportsAcceleratedCompositing());
- else
+ Settings& settings = m_webPage.corePage()->settings();
+ settings.setForceCompositingMode(store.getBoolValueForKey(WebPreferencesKey::forceCompositingModeKey()));
+
+#if USE(COORDINATED_GRAPHICS_THREADED)
+ // Fixed position elements need to be composited and create stacking contexts
+ // in order to be scrolled by the ScrollingCoordinator.
+ settings.setAcceleratedCompositingForFixedPositionEnabled(true);
+ settings.setFixedPositionCreatesStackingContext(true);
#endif
- m_webPage->corePage()->settings()->setForceCompositingMode(store.getBoolValueForKey(WebPreferencesKey::forceCompositingModeKey()) && LayerTreeHost::supportsAcceleratedCompositing());
+
+ m_alwaysUseCompositing = settings.acceleratedDrawingEnabled() && settings.forceCompositingMode();
+ if (m_alwaysUseCompositing && !m_layerTreeHost)
+ enterAcceleratedCompositingMode(nullptr);
}
void DrawingAreaImpl::layerHostDidFlushLayers()
@@ -298,16 +267,13 @@ void DrawingAreaImpl::layerHostDidFlushLayers()
if (!m_layerTreeHost)
return;
-#if USE(ACCELERATED_COMPOSITING)
ASSERT(!m_compositingAccordingToProxyMessages);
if (!exitAcceleratedCompositingModePending()) {
- m_webPage->send(Messages::DrawingAreaProxy::EnterAcceleratedCompositingMode(m_backingStoreStateID, m_layerTreeHost->layerTreeContext()));
+ m_webPage.send(Messages::DrawingAreaProxy::EnterAcceleratedCompositingMode(m_backingStoreStateID, m_layerTreeHost->layerTreeContext()));
m_compositingAccordingToProxyMessages = true;
}
-#endif
}
-#if USE(ACCELERATED_COMPOSITING)
GraphicsLayerFactory* DrawingAreaImpl::graphicsLayerFactory()
{
if (m_layerTreeHost)
@@ -362,7 +328,11 @@ void DrawingAreaImpl::scheduleCompositingLayerFlush()
return;
m_layerTreeHost->scheduleLayerFlush();
}
-#endif
+
+void DrawingAreaImpl::scheduleCompositingLayerFlushImmediately()
+{
+ scheduleCompositingLayerFlush();
+}
void DrawingAreaImpl::updateBackingStoreState(uint64_t stateID, bool respondImmediately, float deviceScaleFactor, const WebCore::IntSize& size, const WebCore::IntSize& scrollOffset)
{
@@ -374,21 +344,21 @@ void DrawingAreaImpl::updateBackingStoreState(uint64_t stateID, bool respondImme
m_backingStoreStateID = stateID;
m_shouldSendDidUpdateBackingStoreState = true;
- m_webPage->setDeviceScaleFactor(deviceScaleFactor);
- m_webPage->setSize(size);
- m_webPage->layoutIfNeeded();
- m_webPage->scrollMainFrameIfNotAtMaxScrollPosition(scrollOffset);
+ m_webPage.setDeviceScaleFactor(deviceScaleFactor);
+ m_webPage.setSize(size);
+ m_webPage.layoutIfNeeded();
+ m_webPage.scrollMainFrameIfNotAtMaxScrollPosition(scrollOffset);
if (m_layerTreeHost) {
-#if USE(COORDINATED_GRAPHICS)
- // Coordinated Graphics sets the size of the root layer to contents size.
- if (!m_webPage->useFixedLayout())
+#if USE(COORDINATED_GRAPHICS_THREADED)
+ m_layerTreeHost->viewportSizeChanged(m_webPage.size());
+#else
+ m_layerTreeHost->sizeDidChange(m_webPage.size());
#endif
- m_layerTreeHost->sizeDidChange(m_webPage->size());
} else
- m_dirtyRegion = m_webPage->bounds();
+ m_dirtyRegion = m_webPage.bounds();
} else {
- ASSERT(size == m_webPage->size());
+ ASSERT(size == m_webPage.size());
if (!m_shouldSendDidUpdateBackingStoreState) {
// We've already sent a DidUpdateBackingStoreState message for this state. We have nothing more to do.
m_inUpdateBackingStoreState = false;
@@ -413,6 +383,8 @@ void DrawingAreaImpl::updateBackingStoreState(uint64_t stateID, bool respondImme
}
m_inUpdateBackingStoreState = false;
+ if (m_forceRepaintAfterBackingStoreStateUpdate)
+ forceRepaint();
}
void DrawingAreaImpl::sendDidUpdateBackingStoreState()
@@ -430,8 +402,8 @@ void DrawingAreaImpl::sendDidUpdateBackingStoreState()
LayerTreeContext layerTreeContext;
if (m_isPaintingSuspended || m_layerTreeHost) {
- updateInfo.viewSize = m_webPage->size();
- updateInfo.deviceScaleFactor = m_webPage->corePage()->deviceScaleFactor();
+ updateInfo.viewSize = m_webPage.size();
+ updateInfo.deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor();
if (m_layerTreeHost) {
layerTreeContext = m_layerTreeHost->layerTreeContext();
@@ -445,7 +417,7 @@ void DrawingAreaImpl::sendDidUpdateBackingStoreState()
}
}
- m_webPage->send(Messages::DrawingAreaProxy::DidUpdateBackingStoreState(m_backingStoreStateID, updateInfo, layerTreeContext));
+ m_webPage.send(Messages::DrawingAreaProxy::DidUpdateBackingStoreState(m_backingStoreStateID, updateInfo, layerTreeContext));
m_compositingAccordingToProxyMessages = !layerTreeContext.isEmpty();
}
@@ -471,8 +443,6 @@ void DrawingAreaImpl::suspendPainting()
m_isPaintingSuspended = true;
m_displayTimer.stop();
-
- m_webPage->corePage()->suspendScriptedAnimations();
}
void DrawingAreaImpl::resumePainting()
@@ -490,13 +460,6 @@ void DrawingAreaImpl::resumePainting()
// FIXME: We shouldn't always repaint everything here.
setNeedsDisplay();
-
-#if PLATFORM(MAC)
- if (m_webPage->windowIsVisible())
- m_webPage->corePage()->resumeScriptedAnimations();
-#else
- m_webPage->corePage()->resumeScriptedAnimations();
-#endif
}
void DrawingAreaImpl::enterAcceleratedCompositingMode(GraphicsLayer* graphicsLayer)
@@ -504,9 +467,15 @@ void DrawingAreaImpl::enterAcceleratedCompositingMode(GraphicsLayer* graphicsLay
m_exitCompositingTimer.stop();
m_wantsToExitAcceleratedCompositingMode = false;
+ m_webPage.send(Messages::DrawingAreaProxy::WillEnterAcceleratedCompositingMode(m_backingStoreStateID));
+
ASSERT(!m_layerTreeHost);
- m_layerTreeHost = LayerTreeHost::create(m_webPage);
+ m_layerTreeHost = LayerTreeHost::create(&m_webPage);
+#if USE(TEXTURE_MAPPER) && PLATFORM(GTK)
+ if (m_nativeSurfaceHandleForCompositing)
+ m_layerTreeHost->setNativeSurfaceHandleForCompositing(m_nativeSurfaceHandleForCompositing);
+#endif
if (!m_inUpdateBackingStoreState)
m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(true);
@@ -534,7 +503,7 @@ void DrawingAreaImpl::exitAcceleratedCompositingMode()
m_layerTreeHost->invalidate();
m_layerTreeHost = nullptr;
- m_dirtyRegion = m_webPage->bounds();
+ m_dirtyRegion = m_webPage.bounds();
if (m_inUpdateBackingStoreState)
return;
@@ -546,23 +515,21 @@ void DrawingAreaImpl::exitAcceleratedCompositingMode()
UpdateInfo updateInfo;
if (m_isPaintingSuspended) {
- updateInfo.viewSize = m_webPage->size();
- updateInfo.deviceScaleFactor = m_webPage->corePage()->deviceScaleFactor();
+ updateInfo.viewSize = m_webPage.size();
+ updateInfo.deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor();
} else
display(updateInfo);
-#if USE(ACCELERATED_COMPOSITING)
// Send along a complete update of the page so we can paint the contents right after we exit the
// accelerated compositing mode, eliminiating flicker.
if (m_compositingAccordingToProxyMessages) {
- m_webPage->send(Messages::DrawingAreaProxy::ExitAcceleratedCompositingMode(m_backingStoreStateID, updateInfo));
+ m_webPage.send(Messages::DrawingAreaProxy::ExitAcceleratedCompositingMode(m_backingStoreStateID, updateInfo));
m_compositingAccordingToProxyMessages = false;
} else {
// If we left accelerated compositing mode before we sent an EnterAcceleratedCompositingMode message to the
// UI process, we still need to let it know about the new contents, so send an Update message.
- m_webPage->send(Messages::DrawingAreaProxy::Update(m_backingStoreStateID, updateInfo));
+ m_webPage.send(Messages::DrawingAreaProxy::Update(m_backingStoreStateID, updateInfo));
}
-#endif
}
void DrawingAreaImpl::exitAcceleratedCompositingModeSoon()
@@ -628,7 +595,7 @@ void DrawingAreaImpl::display()
return;
}
- m_webPage->send(Messages::DrawingAreaProxy::Update(m_backingStoreStateID, updateInfo));
+ m_webPage.send(Messages::DrawingAreaProxy::Update(m_backingStoreStateID, updateInfo));
m_isWaitingForDidUpdate = true;
}
@@ -657,23 +624,24 @@ void DrawingAreaImpl::display(UpdateInfo& updateInfo)
{
ASSERT(!m_isPaintingSuspended);
ASSERT(!m_layerTreeHost);
- ASSERT(!m_webPage->size().isEmpty());
+ ASSERT(!m_webPage.size().isEmpty());
- m_webPage->layoutIfNeeded();
+ m_webPage.layoutIfNeeded();
// The layout may have put the page into accelerated compositing mode. If the LayerTreeHost is
// in charge of displaying, we have nothing more to do.
if (m_layerTreeHost)
return;
- updateInfo.viewSize = m_webPage->size();
- updateInfo.deviceScaleFactor = m_webPage->corePage()->deviceScaleFactor();
+ updateInfo.viewSize = m_webPage.size();
+ updateInfo.deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor();
- IntRect bounds = m_dirtyRegion.bounds();
- ASSERT(m_webPage->bounds().contains(bounds));
+ // Always render the whole page when we don't render the background.
+ IntRect bounds = m_webPage.drawsBackground() ? m_dirtyRegion.bounds() : m_webPage.bounds();
+ ASSERT(m_webPage.bounds().contains(bounds));
IntSize bitmapSize = bounds.size();
- float deviceScaleFactor = m_webPage->corePage()->deviceScaleFactor();
+ float deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor();
bitmapSize.scale(deviceScaleFactor);
RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bitmapSize, ShareableBitmap::SupportsAlpha);
if (!bitmap)
@@ -682,12 +650,16 @@ void DrawingAreaImpl::display(UpdateInfo& updateInfo)
if (!bitmap->createHandle(updateInfo.bitmapHandle))
return;
- Vector<IntRect> rects = m_dirtyRegion.rects();
+ Vector<IntRect> rects;
+ if (m_webPage.drawsBackground()) {
+ rects = m_dirtyRegion.rects();
- if (shouldPaintBoundsRect(bounds, rects)) {
- rects.clear();
+ if (shouldPaintBoundsRect(bounds, rects)) {
+ rects.clear();
+ rects.append(bounds);
+ }
+ } else
rects.append(bounds);
- }
updateInfo.scrollRect = m_scrollRect;
updateInfo.scrollOffset = m_scrollOffset;
@@ -696,24 +668,16 @@ void DrawingAreaImpl::display(UpdateInfo& updateInfo)
m_scrollRect = IntRect();
m_scrollOffset = IntSize();
- OwnPtr<GraphicsContext> graphicsContext = bitmap->createGraphicsContext();
+ auto graphicsContext = bitmap->createGraphicsContext();
graphicsContext->applyDeviceScaleFactor(deviceScaleFactor);
updateInfo.updateRectBounds = bounds;
graphicsContext->translate(-bounds.x(), -bounds.y());
- for (size_t i = 0; i < rects.size(); ++i) {
- m_webPage->drawRect(*graphicsContext, rects[i]);
-
- if (m_webPage->hasPageOverlay()) {
- PageOverlayList& pageOverlays = m_webPage->pageOverlays();
- PageOverlayList::iterator end = pageOverlays.end();
- for (PageOverlayList::iterator it = pageOverlays.begin(); it != end; ++it)
- m_webPage->drawPageOverlay(it->get(), *graphicsContext, rects[i]);
- }
-
- updateInfo.updateRects.append(rects[i]);
+ for (const auto& rect : rects) {
+ m_webPage.drawRect(*graphicsContext, rect);
+ updateInfo.updateRects.append(rect);
}
// Layout can trigger more calls to setNeedsDisplay and we don't want to process them
@@ -721,28 +685,32 @@ void DrawingAreaImpl::display(UpdateInfo& updateInfo)
m_displayTimer.stop();
}
-#if USE(COORDINATED_GRAPHICS)
-void DrawingAreaImpl::didReceiveCoordinatedLayerTreeHostMessage(CoreIPC::Connection* connection, CoreIPC::MessageDecoder& decoder)
-{
- if (m_layerTreeHost)
- m_layerTreeHost->didReceiveCoordinatedLayerTreeHostMessage(connection, decoder);
-}
-#endif
-
-#if PLATFORM(MAC)
-void DrawingAreaImpl::setLayerHostingMode(uint32_t opaqueLayerHostingMode)
+void DrawingAreaImpl::attachViewOverlayGraphicsLayer(WebCore::Frame* frame, WebCore::GraphicsLayer* viewOverlayRootLayer)
{
- LayerHostingMode layerHostingMode = static_cast<LayerHostingMode>(opaqueLayerHostingMode);
- m_webPage->setLayerHostingMode(layerHostingMode);
+ if (!frame->isMainFrame())
+ return;
if (!m_layerTreeHost)
return;
- LayerTreeContext oldLayerTreeContext = m_layerTreeHost->layerTreeContext();
- m_layerTreeHost->setLayerHostingMode(layerHostingMode);
+ m_layerTreeHost->setViewOverlayRootLayer(viewOverlayRootLayer);
+}
- if (m_layerTreeHost->layerTreeContext() != oldLayerTreeContext)
- m_webPage->send(Messages::DrawingAreaProxy::UpdateAcceleratedCompositingMode(m_backingStoreStateID, m_layerTreeHost->layerTreeContext()));
+#if USE(TEXTURE_MAPPER) && PLATFORM(GTK)
+void DrawingAreaImpl::setNativeSurfaceHandleForCompositing(uint64_t handle)
+{
+ m_nativeSurfaceHandleForCompositing = handle;
+
+ if (m_layerTreeHost) {
+ m_webPage.corePage()->settings().setAcceleratedCompositingEnabled(true);
+ m_layerTreeHost->setNativeSurfaceHandleForCompositing(handle);
+ }
+}
+
+void DrawingAreaImpl::destroyNativeSurfaceHandleForCompositing(bool& handled)
+{
+ handled = true;
+ setNativeSurfaceHandleForCompositing(0);
}
#endif