Diff
Modified: trunk/Source/WebKit2/ChangeLog (205394 => 205395)
--- trunk/Source/WebKit2/ChangeLog 2016-09-03 05:24:13 UTC (rev 205394)
+++ trunk/Source/WebKit2/ChangeLog 2016-09-03 05:45:10 UTC (rev 205395)
@@ -1,3 +1,65 @@
+2016-09-02 Carlos Garcia Campos <cgar...@igalia.com>
+
+ [Threaded Compositor] Move the viewport controller off the compositing thread
+ https://bugs.webkit.org/show_bug.cgi?id=161532
+
+ Reviewed by Michael Catanzaro.
+
+ While working on bug #161242 I've realized that having the view port controller in the compositing thread makes
+ everything more complex. The viewport controller receives changes about things like contents size, viewport
+ size, etc. and uses that information to compute the visible contents rect and page scale factor. Then it
+ notifies back to main thread about the computed visible contents rect and page scale. Those computations are not
+ heave at all, so they could be done in the main thread and we would avoid communications between the main and
+ compositing thread in both directions. The main thread needs the visible contents rect to notify the compositing
+ coordinator and the page cale to scale the page in case of pixed layout. But the compositing thread only needs
+ to know the effective scale and scroll position. So, instead of going to the compositing thread after every
+ change that might update the visible contents rect and page scale factor, we could do those calculations in the
+ main thread and only notify the compositing thread about the actual changes in the scroll position and effective scale.
+
+ * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
+ (WebKit::CoordinatedGraphicsScene::createTilesIfNeeded): Return early if backingStore is nullptr, which can
+ happen if the layer shouldn't have a backing store and was removed by the previous call to prepareContentBackingStore().
+ (WebKit::CoordinatedGraphicsScene::updateTilesIfNeeded): Ditto.
+ * Shared/CoordinatedGraphics/SimpleViewportController.cpp:
+ (WebKit::SimpleViewportController::SimpleViewportController): Remove the client since we no longer need to
+ notify about changes.
+ (WebKit::SimpleViewportController::didChangeViewportSize): Remove call to syncVisibleContents().
+ (WebKit::SimpleViewportController::didChangeContentsSize): Ditto.
+ (WebKit::SimpleViewportController::didChangeViewportAttributes): Ditto.
+ (WebKit::SimpleViewportController::didScroll): Removed unused scrollBy methods and renamed scrollTo as
+ didiScroll for consistency. Save the position without calling boundContentsPosition, because that's already
+ donde when the position is used to compute the contents visible rectangle.
+ (WebKit::SimpleViewportController::visibleContentsRect): No need to notify about the changes.
+ (WebKit::SimpleViewportController::visibleContentsSize): Deleted.
+ * Shared/CoordinatedGraphics/SimpleViewportController.h:
+ * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
+ (WebKit::ThreadedCompositor::create): Pass a reference to the client instead of a pointer. It's no longer
+ possible to have a valid pointer when the object has been destroyed, so we can better use a reference now.
+ (WebKit::ThreadedCompositor::ThreadedCompositor): Ditto.
+ (WebKit::ThreadedCompositor::~ThreadedCompositor): Remove assert.
+ (WebKit::ThreadedCompositor::invalidate): No need to invalidate the client.
+ (WebKit::ThreadedCompositor::setScaleFactor): Set the effective scale factor that should be used for rendering.
+ (WebKit::ThreadedCompositor::setScrollPosition): Set the current scroll position and effective scale factor.
+ (WebKit::ThreadedCompositor::setViewportSize): Set the viewport size and effective scale factor.
+ (WebKit::ThreadedCompositor::renderNextFrame): Update m_client use that is no longer a pointer.
+ (WebKit::ThreadedCompositor::commitScrollOffset): Ditto.
+ (WebKit::ThreadedCompositor::renderLayerTree): Call glViewport after a resize and use m_viewportSize,
+ m_scrollPosition and m_scaleFactor members.
+ (WebKit::ThreadedCompositor::didChangeVisibleRect): Deleted.
+ * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
+ * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
+ (WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost): Pass the compositor client as a
+ reference to ThreadedCompositor constructor.
+ (WebKit::ThreadedCoordinatedLayerTreeHost::scrollNonCompositedContents): Update the viewport and call didChangeViewport().
+ (WebKit::ThreadedCoordinatedLayerTreeHost::contentsSizeChanged): Ditto.
+ (WebKit::ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged): Pass the effective scale factor to
+ the compositor.
+ (WebKit::ThreadedCoordinatedLayerTreeHost::sizeDidChange): Update the viewport, the compositor and call didChangeViewport().
+ (WebKit::ThreadedCoordinatedLayerTreeHost::didChangeViewportProperties): Update the viewport and call didChangeViewport().
+ (WebKit::ThreadedCoordinatedLayerTreeHost::didChangeViewport): Notify the compositing coordinator about the new
+ visible contents rectangle, and update the threaded compositor if needed.
+ * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
+
2016-09-02 Beth Dakin <bda...@apple.com>
Need to updateEditorState if an element change edit-ability without changing
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp (205394 => 205395)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp 2016-09-03 05:24:13 UTC (rev 205394)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp 2016-09-03 05:45:10 UTC (rev 205395)
@@ -445,7 +445,9 @@
return;
RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer);
- ASSERT(backingStore);
+ ASSERT(backingStore || !layerShouldHaveBackingStore(layer));
+ if (!backingStore)
+ return;
for (auto& tile : state.tilesToCreate)
backingStore->createTile(tile.tileID, tile.scale);
@@ -472,7 +474,9 @@
return;
RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer);
- ASSERT(backingStore);
+ ASSERT(backingStore || !layerShouldHaveBackingStore(layer));
+ if (!backingStore)
+ return;
for (auto& tile : state.tilesToUpdate) {
const SurfaceUpdateInfo& surfaceUpdateInfo = tile.updateInfo;
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.cpp (205394 => 205395)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.cpp 2016-09-03 05:24:13 UTC (rev 205394)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.cpp 2016-09-03 05:45:10 UTC (rev 205395)
@@ -20,27 +20,20 @@
*/
#include "config.h"
+#include "SimpleViewportController.h"
#if USE(COORDINATED_GRAPHICS_THREADED)
-#include "SimpleViewportController.h"
using namespace WebCore;
namespace WebKit {
-SimpleViewportController::SimpleViewportController(Client* client)
- : m_client(client)
- , m_contentsPosition(FloatPoint())
- , m_contentsSize(FloatSize())
- , m_viewportSize(FloatSize())
- , m_allowsUserScaling(false)
- , m_initiallyFitToViewport(true)
- , m_hasViewportAttribute(false)
+SimpleViewportController::SimpleViewportController()
{
resetViewportToDefaultState();
}
-void SimpleViewportController::didChangeViewportSize(const FloatSize& newSize)
+void SimpleViewportController::didChangeViewportSize(const IntSize& newSize)
{
if (newSize.isEmpty())
return;
@@ -47,7 +40,6 @@
m_viewportSize = newSize;
updateMinimumScaleToFit();
- syncVisibleContents();
}
void SimpleViewportController::didChangeContentsSize(const IntSize& newSize)
@@ -62,11 +54,9 @@
m_rawAttributes.initialScale = m_minimumScaleToFit;
restrictScaleFactorToInitialScaleIfNotUserScalable(m_rawAttributes);
}
-
- syncVisibleContents();
}
-void SimpleViewportController::didChangeViewportAttribute(const ViewportAttributes& newAttributes)
+void SimpleViewportController::didChangeViewportAttributes(const ViewportAttributes& newAttributes)
{
if (newAttributes.layoutSize.isEmpty()) {
resetViewportToDefaultState();
@@ -83,40 +73,20 @@
restrictScaleFactorToInitialScaleIfNotUserScalable(m_rawAttributes);
updateMinimumScaleToFit();
-
- syncVisibleContents();
}
-void SimpleViewportController::scrollBy(const IntSize& scrollOffset)
+void SimpleViewportController::didScroll(const IntPoint& position)
{
- m_contentsPosition.move(scrollOffset);
- m_contentsPosition = boundContentsPosition(m_contentsPosition);
-
- syncVisibleContents();
+ m_contentsPosition = position;
}
-void SimpleViewportController::scrollTo(const IntPoint& position)
+FloatRect SimpleViewportController::visibleContentsRect() const
{
- if (m_contentsPosition == boundContentsPosition(position))
- return;
-
- m_contentsPosition = boundContentsPosition(position);
- syncVisibleContents();
-}
-
-void SimpleViewportController::syncVisibleContents()
-{
if (m_viewportSize.isEmpty() || m_contentsSize.isEmpty())
- return;
+ return { };
- m_client->didChangeVisibleRect();
-}
-
-FloatRect SimpleViewportController::visibleContentsRect() const
-{
FloatRect visibleContentsRect(boundContentsPosition(m_contentsPosition), visibleContentsSize());
visibleContentsRect.intersect(FloatRect(FloatPoint::zero(), m_contentsSize));
-
return visibleContentsRect;
}
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.h (205394 => 205395)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.h 2016-09-03 05:24:13 UTC (rev 205394)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.h 2016-09-03 05:45:10 UTC (rev 205395)
@@ -37,29 +37,19 @@
class SimpleViewportController {
WTF_MAKE_NONCOPYABLE(SimpleViewportController);
public:
- class Client {
- public:
- virtual void didChangeVisibleRect() = 0;
- };
+ SimpleViewportController();
- explicit SimpleViewportController(Client*);
-
- void didChangeViewportSize(const WebCore::FloatSize&);
+ void didChangeViewportSize(const WebCore::IntSize&);
void didChangeContentsSize(const WebCore::IntSize&);
- void didChangeViewportAttribute(const WebCore::ViewportAttributes&);
+ void didChangeViewportAttributes(const WebCore::ViewportAttributes&);
+ void didScroll(const WebCore::IntPoint&);
- void scrollBy(const WebCore::IntSize&);
- void scrollTo(const WebCore::IntPoint&);
-
WebCore::FloatRect visibleContentsRect() const;
float pageScaleFactor() const { return m_pageScaleFactor; }
private:
-
WebCore::FloatSize visibleContentsSize() const;
- void syncVisibleContents();
-
void applyScaleAfterRenderingContents(float scale);
void applyPositionAfterRenderingContents(const WebCore::FloatPoint& pos);
@@ -71,18 +61,16 @@
void resetViewportToDefaultState();
- Client* m_client;
-
- WebCore::FloatPoint m_contentsPosition;
+ WebCore::IntPoint m_contentsPosition;
WebCore::FloatSize m_contentsSize;
WebCore::FloatSize m_viewportSize;
- float m_pageScaleFactor;
+ float m_pageScaleFactor { 1 };
- bool m_allowsUserScaling;
- float m_minimumScaleToFit;
- bool m_initiallyFitToViewport;
+ bool m_allowsUserScaling { false };
+ float m_minimumScaleToFit { 1 };
+ bool m_initiallyFitToViewport { false };
- bool m_hasViewportAttribute;
+ bool m_hasViewportAttribute { false };
WebCore::ViewportAttributes m_rawAttributes;
};
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp (205394 => 205395)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp 2016-09-03 05:24:13 UTC (rev 205394)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp 2016-09-03 05:45:10 UTC (rev 205395)
@@ -42,12 +42,12 @@
namespace WebKit {
-Ref<ThreadedCompositor> ThreadedCompositor::create(Client* client, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync)
+Ref<ThreadedCompositor> ThreadedCompositor::create(Client& client, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync)
{
return adoptRef(*new ThreadedCompositor(client, nativeSurfaceHandle, doFrameSync));
}
-ThreadedCompositor::ThreadedCompositor(Client* client, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync)
+ThreadedCompositor::ThreadedCompositor(Client& client, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync)
: m_client(client)
, m_nativeSurfaceHandle(nativeSurfaceHandle)
, m_doFrameSync(doFrameSync)
@@ -55,7 +55,6 @@
{
m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this)] {
m_scene = adoptRef(new CoordinatedGraphicsScene(this));
- m_viewportController = std::make_unique<SimpleViewportController>(this);
m_scene->setActive(!!m_nativeSurfaceHandle);
});
}
@@ -62,7 +61,6 @@
ThreadedCompositor::~ThreadedCompositor()
{
- ASSERT(!m_client);
}
void ThreadedCompositor::invalidate()
@@ -73,10 +71,8 @@
m_scene->purgeGLResources();
m_context = nullptr;
m_scene = nullptr;
- m_viewportController = nullptr;
});
m_compositingRunLoop = nullptr;
- m_client = nullptr;
}
void ThreadedCompositor::setNativeSurfaceHandleForCompositing(uint64_t handle)
@@ -93,67 +89,51 @@
});
}
-void ThreadedCompositor::setDeviceScaleFactor(float scale)
+void ThreadedCompositor::setScaleFactor(float scale)
{
m_compositingRunLoop->performTask([this, protectedThis = makeRef(*this), scale] {
- m_deviceScaleFactor = scale;
+ m_scaleFactor = scale;
scheduleDisplayImmediately();
});
}
-void ThreadedCompositor::setDrawsBackground(bool drawsBackground)
+void ThreadedCompositor::setScrollPosition(const IntPoint& scrollPosition, float scale)
{
- m_compositingRunLoop->performTask([this, protectedThis = Ref<ThreadedCompositor>(*this), drawsBackground] {
- m_drawsBackground = drawsBackground;
+ m_compositingRunLoop->performTask([this, protectedThis = makeRef(*this), scrollPosition, scale] {
+ m_scrollPosition = scrollPosition;
+ m_scaleFactor = scale;
scheduleDisplayImmediately();
});
}
-void ThreadedCompositor::didChangeViewportSize(const IntSize& size)
+void ThreadedCompositor::setViewportSize(const IntSize& viewportSize, float scale)
{
- m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this), size] {
- m_viewportController->didChangeViewportSize(size);
+ m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this), viewportSize, scale] {
+ m_viewportSize = viewportSize;
+ m_scaleFactor = scale;
+ m_needsResize = true;
+ scheduleDisplayImmediately();
});
}
-void ThreadedCompositor::didChangeViewportAttribute(const ViewportAttributes& attr)
+void ThreadedCompositor::setDrawsBackground(bool drawsBackground)
{
- m_compositingRunLoop->performTask([this, protectedThis = makeRef(*this), attr] {
- m_viewportController->didChangeViewportAttribute(attr);
+ m_compositingRunLoop->performTask([this, protectedThis = Ref<ThreadedCompositor>(*this), drawsBackground] {
+ m_drawsBackground = drawsBackground;
+ scheduleDisplayImmediately();
});
}
-void ThreadedCompositor::didChangeContentsSize(const IntSize& size)
-{
- m_compositingRunLoop->performTask([this, protectedThis = makeRef(*this), size] {
- m_viewportController->didChangeContentsSize(size);
- });
-}
-
-void ThreadedCompositor::scrollTo(const IntPoint& position)
-{
- m_compositingRunLoop->performTask([this, protectedThis = makeRef(*this), position] {
- m_viewportController->scrollTo(position);
- });
-}
-
-void ThreadedCompositor::scrollBy(const IntSize& delta)
-{
- m_compositingRunLoop->performTask([this, protectedThis = makeRef(*this), delta] {
- m_viewportController->scrollBy(delta);
- });
-}
-
void ThreadedCompositor::renderNextFrame()
{
ASSERT(isMainThread());
- m_client->renderNextFrame();
+ m_client.renderNextFrame();
}
void ThreadedCompositor::commitScrollOffset(uint32_t layerID, const IntSize& offset)
{
ASSERT(isMainThread());
- m_client->commitScrollOffset(layerID, offset);
+ m_client.commitScrollOffset(layerID, offset);
}
void ThreadedCompositor::updateViewport()
@@ -194,16 +174,6 @@
});
}
-void ThreadedCompositor::didChangeVisibleRect()
-{
- RunLoop::main().dispatch([this, protectedThis = makeRef(*this), visibleRect = m_viewportController->visibleContentsRect(), scale = m_viewportController->pageScaleFactor()] {
- if (m_client)
- m_client->setVisibleContentsRect(visibleRect, FloatPoint::zero(), scale);
- });
-
- scheduleDisplayImmediately();
-}
-
void ThreadedCompositor::renderLayerTree()
{
if (!m_scene || !m_scene->isActive())
@@ -212,27 +182,21 @@
if (!makeContextCurrent())
return;
- // The window size may be out of sync with the page size at this point, and getting
- // the viewport parameters incorrect, means that the content will be misplaced. Thus,
- // we set the viewport parameters directly from the window size.
- IntSize contextSize = m_context->defaultFrameBufferSize();
- if (m_viewportSize != contextSize) {
- glViewport(0, 0, contextSize.width(), contextSize.height());
- m_viewportSize = contextSize;
+ if (m_needsResize) {
+ glViewport(0, 0, m_viewportSize.width(), m_viewportSize.height());
+ m_needsResize = false;
}
-
FloatRect clipRect(0, 0, m_viewportSize.width(), m_viewportSize.height());
TransformationMatrix viewportTransform;
- FloatPoint scrollPostion = m_viewportController->visibleContentsRect().location();
- viewportTransform.scale(m_viewportController->pageScaleFactor() * m_deviceScaleFactor);
- viewportTransform.translate(-scrollPostion.x(), -scrollPostion.y());
+ viewportTransform.scale(m_scaleFactor);
+ viewportTransform.translate(-m_scrollPosition.x(), -m_scrollPosition.y());
if (!m_drawsBackground) {
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
}
- m_scene->paintToCurrentGLContext(viewportTransform, 1, clipRect, Color::transparent, !m_drawsBackground, scrollPostion);
+ m_scene->paintToCurrentGLContext(viewportTransform, 1, clipRect, Color::transparent, !m_drawsBackground, m_scrollPosition);
m_context->swapBuffers();
}
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h (205394 => 205395)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h 2016-09-03 05:24:13 UTC (rev 205394)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h 2016-09-03 05:45:10 UTC (rev 205395)
@@ -30,7 +30,6 @@
#include "CompositingRunLoop.h"
#include "CoordinatedGraphicsScene.h"
-#include "SimpleViewportController.h"
#include <WebCore/GLContext.h>
#include <WebCore/IntSize.h>
#include <wtf/FastMalloc.h>
@@ -46,13 +45,12 @@
class CoordinatedGraphicsScene;
class CoordinatedGraphicsSceneClient;
-class ThreadedCompositor : public SimpleViewportController::Client, public CoordinatedGraphicsSceneClient, public ThreadSafeRefCounted<ThreadedCompositor> {
+class ThreadedCompositor : public CoordinatedGraphicsSceneClient, public ThreadSafeRefCounted<ThreadedCompositor> {
WTF_MAKE_NONCOPYABLE(ThreadedCompositor);
WTF_MAKE_FAST_ALLOCATED;
public:
class Client {
public:
- virtual void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&, float) = 0;
virtual void renderNextFrame() = 0;
virtual void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) = 0;
};
@@ -59,27 +57,23 @@
enum class ShouldDoFrameSync { No, Yes };
- static Ref<ThreadedCompositor> create(Client*, uint64_t nativeSurfaceHandle = 0, ShouldDoFrameSync = ShouldDoFrameSync::Yes);
+ static Ref<ThreadedCompositor> create(Client&, uint64_t nativeSurfaceHandle = 0, ShouldDoFrameSync = ShouldDoFrameSync::Yes);
virtual ~ThreadedCompositor();
void setNativeSurfaceHandleForCompositing(uint64_t);
- void setDeviceScaleFactor(float);
+ void setScaleFactor(float);
+ void setScrollPosition(const WebCore::IntPoint&, float scale);
+ void setViewportSize(const WebCore::IntSize&, float scale);
void setDrawsBackground(bool);
void updateSceneState(const WebCore::CoordinatedGraphicsState&);
- void didChangeViewportSize(const WebCore::IntSize&);
- void didChangeViewportAttribute(const WebCore::ViewportAttributes&);
- void didChangeContentsSize(const WebCore::IntSize&);
- void scrollTo(const WebCore::IntPoint&);
- void scrollBy(const WebCore::IntSize&);
-
void invalidate();
void forceRepaint();
private:
- ThreadedCompositor(Client*, uint64_t nativeSurfaceHandle, ShouldDoFrameSync);
+ ThreadedCompositor(Client&, uint64_t nativeSurfaceHandle, ShouldDoFrameSync);
// CoordinatedGraphicsSceneClient
void renderNextFrame() override;
@@ -86,24 +80,22 @@
void updateViewport() override;
void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) override;
- // SimpleViewportController::Client.
- void didChangeVisibleRect() override;
-
void renderLayerTree();
void scheduleDisplayImmediately();
bool makeContextCurrent();
- Client* m_client { nullptr };
+ Client& m_client;
RefPtr<CoordinatedGraphicsScene> m_scene;
- std::unique_ptr<SimpleViewportController> m_viewportController;
std::unique_ptr<WebCore::GLContext> m_context;
WebCore::IntSize m_viewportSize;
- float m_deviceScaleFactor { 1 };
+ WebCore::IntPoint m_scrollPosition;
+ float m_scaleFactor { 1 };
bool m_drawsBackground { true };
uint64_t m_nativeSurfaceHandle;
ShouldDoFrameSync m_doFrameSync;
+ bool m_needsResize { false };
std::unique_ptr<CompositingRunLoop> m_compositingRunLoop;
};
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp (205394 => 205395)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp 2016-09-03 05:24:13 UTC (rev 205394)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp 2016-09-03 05:45:10 UTC (rev 205395)
@@ -58,10 +58,10 @@
// Do not do frame sync when rendering offscreen in the web process to ensure that SwapBuffers never blocks.
// Rendering to the actual screen will happen later anyway since the UI process schedules a redraw for every update,
// the compositor will take care of syncing to vblank.
- m_compositor = ThreadedCompositor::create(&m_compositorClient, m_surface->window(), ThreadedCompositor::ShouldDoFrameSync::No);
+ m_compositor = ThreadedCompositor::create(m_compositorClient, m_surface->window(), ThreadedCompositor::ShouldDoFrameSync::No);
m_layerTreeContext.contextID = m_surface->surfaceID();
} else
- m_compositor = ThreadedCompositor::create(&m_compositorClient);
+ m_compositor = ThreadedCompositor::create(m_compositorClient);
}
void ThreadedCoordinatedLayerTreeHost::invalidate()
@@ -77,15 +77,16 @@
m_compositor->forceRepaint();
}
-void ThreadedCoordinatedLayerTreeHost::scrollNonCompositedContents(const WebCore::IntRect& rect)
+void ThreadedCoordinatedLayerTreeHost::scrollNonCompositedContents(const IntRect& rect)
{
- m_compositor->scrollTo(rect.location());
- scheduleLayerFlush();
+ m_viewportController.didScroll(rect.location());
+ didChangeViewport();
}
-void ThreadedCoordinatedLayerTreeHost::contentsSizeChanged(const WebCore::IntSize& newSize)
+void ThreadedCoordinatedLayerTreeHost::contentsSizeChanged(const IntSize& newSize)
{
- m_compositor->didChangeContentsSize(newSize);
+ m_viewportController.didChangeContentsSize(newSize);
+ didChangeViewport();
}
void ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged()
@@ -94,7 +95,7 @@
m_layerTreeContext.contextID = m_surface->surfaceID();
CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged();
- m_compositor->setDeviceScaleFactor(m_webPage.deviceScaleFactor());
+ m_compositor->setScaleFactor(m_webPage.deviceScaleFactor() * m_viewportController.pageScaleFactor());
}
void ThreadedCoordinatedLayerTreeHost::pageBackgroundTransparencyChanged()
@@ -109,19 +110,19 @@
m_layerTreeContext.contextID = m_surface->surfaceID();
CoordinatedLayerTreeHost::sizeDidChange(size);
- m_compositor->didChangeViewportSize(size);
+ m_viewportController.didChangeViewportSize(size);
+ IntSize scaledSize(size);
+ scaledSize.scale(m_webPage.deviceScaleFactor());
+ m_compositor->setViewportSize(scaledSize, m_webPage.deviceScaleFactor() * m_viewportController.pageScaleFactor());
+ didChangeViewport();
}
-void ThreadedCoordinatedLayerTreeHost::didChangeViewportProperties(const WebCore::ViewportAttributes& attr)
+void ThreadedCoordinatedLayerTreeHost::didChangeViewportProperties(const ViewportAttributes& attr)
{
- m_compositor->didChangeViewportAttribute(attr);
+ m_viewportController.didChangeViewportAttributes(attr);
+ didChangeViewport();
}
-void ThreadedCoordinatedLayerTreeHost::didScaleFactorChanged(float scale, const IntPoint& origin)
-{
- m_webPage.scalePage(scale, origin);
-}
-
#if PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
void ThreadedCoordinatedLayerTreeHost::setNativeSurfaceHandleForCompositing(uint64_t handle)
{
@@ -131,9 +132,11 @@
}
#endif
-void ThreadedCoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector, float scale)
+void ThreadedCoordinatedLayerTreeHost::didChangeViewport()
{
- FloatRect visibleRect(rect);
+ FloatRect visibleRect(m_viewportController.visibleContentsRect());
+ if (visibleRect.isEmpty())
+ return;
// When using non overlay scrollbars, the contents size doesn't include the scrollbars, but we need to include them
// in the visible area used by the compositor to ensure that the scrollbar layers are also updated.
@@ -146,17 +149,21 @@
if (scrollbar && !scrollbar->isOverlayScrollbar())
visibleRect.expand(0, scrollbar->height());
- CoordinatedLayerTreeHost::setVisibleContentsRect(visibleRect, trajectoryVector);
- if (m_lastScrollPosition != roundedIntPoint(visibleRect.location())) {
- m_lastScrollPosition = roundedIntPoint(visibleRect.location());
+ CoordinatedLayerTreeHost::setVisibleContentsRect(visibleRect, FloatPoint::zero());
+ float pageScale = m_viewportController.pageScaleFactor();
+ IntPoint scrollPosition = roundedIntPoint(visibleRect.location());
+ if (m_lastScrollPosition != scrollPosition) {
+ m_lastScrollPosition = scrollPosition;
+ m_compositor->setScrollPosition(m_lastScrollPosition, m_webPage.deviceScaleFactor() * pageScale);
+
if (!view->useFixedLayout())
view->notifyScrollPositionChanged(m_lastScrollPosition);
}
- if (m_lastScaleFactor != scale) {
- m_lastScaleFactor = scale;
- didScaleFactorChanged(m_lastScaleFactor, m_lastScrollPosition);
+ if (m_lastPageScaleFactor != pageScale) {
+ m_lastPageScaleFactor = pageScale;
+ m_webPage.scalePage(pageScale, m_lastScrollPosition);
}
}
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h (205394 => 205395)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h 2016-09-03 05:24:13 UTC (rev 205394)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h 2016-09-03 05:45:10 UTC (rev 205395)
@@ -31,6 +31,7 @@
#if USE(COORDINATED_GRAPHICS_THREADED)
#include "CoordinatedLayerTreeHost.h"
+#include "SimpleViewportController.h"
#include "ThreadedCompositor.h"
namespace WebCore {
@@ -78,11 +79,6 @@
}
private:
- void setVisibleContentsRect(const WebCore::FloatRect& rect, const WebCore::FloatPoint& trajectoryVector, float scale) override
- {
- m_layerTreeHost.setVisibleContentsRect(rect, trajectoryVector, scale);
- }
-
void renderNextFrame() override
{
m_layerTreeHost.renderNextFrame();
@@ -96,10 +92,8 @@
ThreadedCoordinatedLayerTreeHost& m_layerTreeHost;
};
- void didScaleFactorChanged(float scale, const WebCore::IntPoint& origin);
+ void didChangeViewport();
- void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&, float);
-
// CompositingCoordinator::Client
void didFlushRootLayer(const WebCore::FloatRect&) override { }
void commitSceneState(const WebCore::CoordinatedGraphicsState&) override;
@@ -107,8 +101,8 @@
CompositorClient m_compositorClient;
std::unique_ptr<AcceleratedSurface> m_surface;
RefPtr<ThreadedCompositor> m_compositor;
- float m_lastScaleFactor { 1 };
- WebCore::IntPoint m_prevScrollPosition;
+ SimpleViewportController m_viewportController;
+ float m_lastPageScaleFactor { 1 };
WebCore::IntPoint m_lastScrollPosition;
};