Skip to content

Commit

Permalink
[ARRISEOS-41099] Repaint page after receiving wpe_compositor_refresh_…
Browse files Browse the repository at this point in the history
…event

The entire page should be repainted after receiving
wpe_compositor_refresh_event. This will make webbrowser repond
to visibility change from awc_cli.

Event flow:
We receive an information about handle_configure method
execution in wpe-backend-rdk. Thanks to this execution we know
that the compositor change state and we need to repaint the
app.
As we get this info in network process thread we send it to the UI
thread in wpe-backend-rdk via
Wayland::EventDispatcher::singleton().sendEvent(). The wpe-browser
is attached to EventDispatcher so by IPC we get this info in
WPEView.cpp in wpe-webkit, wpe_view_backend_input_client callback.
This event is received in UI thread while WebPage is working on
network process thread. We send the event to the webpage by:
page.repaintAfterCompositorReconfigure(); When we receive event on
the proper thread, process and proper class we force the app to be
repainted. To this we execute: m_drawingArea->forceRepaint(true);
  • Loading branch information
jaroslaw-bojko-red committed Oct 27, 2022
1 parent e15dca9 commit 69abcdc
Show file tree
Hide file tree
Showing 18 changed files with 46 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,9 @@ void ThreadedCompositor::updateViewport()
m_compositingRunLoop->scheduleUpdate();
}

void ThreadedCompositor::forceRepaint()
void ThreadedCompositor::forceRepaint(bool afterCompositorReconfigure)
{
if(!afterCompositorReconfigure) {
// FIXME: Enable this for WPE once it's possible to do these forced updates
// in a way that doesn't starve out the underlying graphics buffers.
#if PLATFORM(GTK)
Expand All @@ -230,6 +231,13 @@ void ThreadedCompositor::forceRepaint()
renderLayerTree();
});
#endif
} else {
m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this)] {
SetForScope<bool> change(m_inForceRepaint, true);
renderLayerTree();
});
m_compositingRunLoop->scheduleUpdate();
}
}

void ThreadedCompositor::renderNonCompositedWebGL()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ThreadedCompositor : public CoordinatedGraphicsSceneClient, public ThreadS

void invalidate();

void forceRepaint();
void forceRepaint(bool afterCompositorReconfigure = false);

#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
RefPtr<WebCore::DisplayRefreshMonitor> displayRefreshMonitor(WebCore::PlatformDisplayID);
Expand Down
7 changes: 6 additions & 1 deletion Source/WebKit/UIProcess/API/wpe/WPEView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,15 @@ View::View(struct wpe_view_backend* backend, const API::PageConfiguration& baseC
page.handleTouchEvent(WebKit::NativeWebTouchEvent(event, page.deviceScaleFactor()));
#endif
},
// handle_wpe_compositor_refresh
[](void* data)
{
auto& page = reinterpret_cast<View*>(data)->page();
page.repaintAfterCompositorReconfigure();
},
// padding
nullptr,
nullptr,
nullptr,
nullptr
};
wpe_view_backend_set_input_client(m_backend, &s_inputClient, this);
Expand Down
8 changes: 8 additions & 0 deletions Source/WebKit/UIProcess/WebPageProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4354,6 +4354,14 @@ void WebPageProxy::didExitFullscreen()
m_uiClient->didExitFullscreen(this);
}

void WebPageProxy::repaintAfterCompositorReconfigure()
{
if (!isValid())
return;

m_process->send(Messages::WebPage::repaintAfterCompositorReconfigure(), m_pageID);
}

void WebPageProxy::closePage(bool stopResponsivenessTimer)
{
if (stopResponsivenessTimer)
Expand Down
2 changes: 2 additions & 0 deletions Source/WebKit/UIProcess/WebPageProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ class WebPageProxy : public API::ObjectImpl<API::Object::Type::Page>
void didEnterFullscreen();
void didExitFullscreen();

void repaintAfterCompositorReconfigure();

WebInspectorProxy* inspector() const;

void didChangeInspectorFrontendCount(unsigned count) { m_inspectorFrontendCount = count; }
Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void AcceleratedDrawingArea::setLayerTreeStateIsFrozen(bool isFrozen)
exitAcceleratedCompositingModeSoon();
}

void AcceleratedDrawingArea::forceRepaint()
void AcceleratedDrawingArea::forceRepaint(bool afterCompositorReconfigure)
{
setNeedsDisplay();

Expand All @@ -139,7 +139,7 @@ void AcceleratedDrawingArea::forceRepaint()
// but clearly it doesn't make sense to call the function with that name.
// Consider refactoring and renaming it.
if (m_compositingAccordingToProxyMessages)
m_layerTreeHost->forceRepaint();
m_layerTreeHost->forceRepaint(afterCompositorReconfigure);
else {
// Call setShouldNotifyAfterNextScheduledLayerFlush(false) here to
// prevent layerHostDidFlushLayers() from being called a second time.
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class AcceleratedDrawingArea : public DrawingArea {
void setLayerTreeStateIsFrozen(bool) override;
bool layerTreeStateIsFrozen() const override { return m_layerTreeStateIsFrozen; }
LayerTreeHost* layerTreeHost() const override { return m_layerTreeHost.get(); }
void forceRepaint() override;
void forceRepaint(bool afterCompositorReconfigure = false) override;
bool forceRepaintAsync(CallbackID) override;

void setPaintingEnabled(bool) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void CoordinatedLayerTreeHost::resumeRendering()
LayerTreeHost::resumeRendering();
}

void CoordinatedLayerTreeHost::forceRepaint()
void CoordinatedLayerTreeHost::forceRepaint(bool afterCompositorReconfigure)
{
// This is necessary for running layout tests. Since in this case we are not waiting for a UIProcess to reply nicely.
// Instead we are just triggering forceRepaint. But we still want to have the scripted animation callbacks being executed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class CoordinatedLayerTreeHost : public LayerTreeHost, public CompositingCoordin
void pauseRendering() override;
void resumeRendering() override;

void forceRepaint() override;
void forceRepaint(bool afterCompositorReconfigure = false) override;
bool forceRepaintAsync(CallbackID) override;
void sizeDidChange(const WebCore::IntSize& newSize) override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ void ThreadedCoordinatedLayerTreeHost::invalidate()
m_surface = nullptr;
}

void ThreadedCoordinatedLayerTreeHost::forceRepaint()
void ThreadedCoordinatedLayerTreeHost::forceRepaint(bool afterCompositorReconfigure)
{
CoordinatedLayerTreeHost::forceRepaint();
m_compositor->forceRepaint();
m_compositor->forceRepaint(afterCompositorReconfigure);
}

void ThreadedCoordinatedLayerTreeHost::pauseRendering()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class ThreadedCoordinatedLayerTreeHost final : public CoordinatedLayerTreeHost,

void invalidate() override;

void forceRepaint() override;
void forceRepaint(bool afterCompositorReconfigure = false) override;

void pauseRendering() override;
void resumeRendering() override;
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/WebProcess/WebPage/DrawingArea.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class DrawingArea : public IPC::MessageReceiver {

// FIXME: These should be pure virtual.
virtual void pageBackgroundTransparencyChanged() { }
virtual void forceRepaint() { }
virtual void forceRepaint(bool afterCompositorReconfigure = false) { }
virtual bool forceRepaintAsync(CallbackID) { return false; }
virtual void setLayerTreeStateIsFrozen(bool) { }
virtual bool layerTreeStateIsFrozen() const { return false; }
Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void DrawingAreaImpl::scroll(const IntRect& scrollRect, const IntSize& scrollDel
m_scrollOffset += scrollDelta;
}

void DrawingAreaImpl::forceRepaint()
void DrawingAreaImpl::forceRepaint(bool afterCompositorReconfigure)
{
if (m_inUpdateBackingStoreState) {
m_forceRepaintAfterBackingStoreStateUpdate = true;
Expand All @@ -157,7 +157,7 @@ void DrawingAreaImpl::forceRepaint()
m_forceRepaintAfterBackingStoreStateUpdate = false;

if (m_layerTreeHost) {
AcceleratedDrawingArea::forceRepaint();
AcceleratedDrawingArea::forceRepaint(afterCompositorReconfigure);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class DrawingAreaImpl final : public AcceleratedDrawingArea {
void setNeedsDisplay() override;
void setNeedsDisplayInRect(const WebCore::IntRect&) override;
void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) override;
void forceRepaint() override;
void forceRepaint(bool afterCompositorReconfigure = false) override;

void updatePreferences(const WebPreferencesStore&) override;

Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/WebProcess/WebPage/LayerTreeHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class LayerTreeHost : public RefCounted<LayerTreeHost> {
virtual void setNonCompositedContentsNeedDisplay() { };
virtual void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) { };
virtual void scrollNonCompositedContents(const WebCore::IntRect&) { };
virtual void forceRepaint() = 0;
virtual void forceRepaint(bool afterCompositorReconfigure = false) = 0;
virtual bool forceRepaintAsync(CallbackID) { return false; }
virtual void sizeDidChange(const WebCore::IntSize& newSize) = 0;
virtual void pageBackgroundTransparencyChanged() = 0;
Expand Down
5 changes: 5 additions & 0 deletions Source/WebKit/WebProcess/WebPage/WebPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3148,6 +3148,11 @@ void WebPage::forceRepaintWithoutCallback()
m_drawingArea->forceRepaint();
}

void WebPage::repaintAfterCompositorReconfigure()
{
m_drawingArea->forceRepaint(true);
}

void WebPage::forceRepaint(CallbackID callbackID)
{
if (m_drawingArea->forceRepaintAsync(callbackID))
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/WebProcess/WebPage/WebPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@ class WebPage : public API::ObjectImpl<API::Object::Type::BundlePage>, public IP
float deviceScaleFactor() const;

void forceRepaintWithoutCallback();
void repaintAfterCompositorReconfigure();

void unmarkAllMisspellings();
void unmarkAllBadGrammar();
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/WebProcess/WebPage/WebPage.messages.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
messages -> WebPage LegacyReceiver {
SetInitialFocus(bool forward, bool isKeyboardEventValid, WebKit::WebKeyboardEvent event, WebKit::CallbackID callbackID)
SetActivityState(OptionSet<WebCore::ActivityState::Flag> activityState, WebKit::ActivityStateChangeID activityStateChangeID, Vector<WebKit::CallbackID> callbackIDs)
repaintAfterCompositorReconfigure()
SetLayerHostingMode(enum WebKit::LayerHostingMode layerHostingMode)

SetDrawsBackground(bool drawsBackground)
Expand Down

0 comments on commit 69abcdc

Please sign in to comment.