WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
wk2-tc-viewport-controller.diff (text/plain), 30.34 KB, created by
Carlos Garcia Campos
on 2016-09-02 06:59:16 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Carlos Garcia Campos
Created:
2016-09-02 06:59:16 PDT
Size:
30.34 KB
patch
obsolete
>diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog >index 4709536..2661c67 100644 >--- a/Source/WebKit2/ChangeLog >+++ b/Source/WebKit2/ChangeLog >@@ -1,3 +1,65 @@ >+2016-09-02 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [Threaded Compositor] Move the viewport controller off the compositing thread >+ https://bugs.webkit.org/show_bug.cgi?id=161532 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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 Zan Dobersek <zdobersek@igalia.com> > > Fix GObject bindings build breakage when compiling with ENABLE_USER_TIMING disabled. >diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp b/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp >index a19e852..8c466d3 100644 >--- a/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp >+++ b/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp >@@ -445,7 +445,9 @@ void CoordinatedGraphicsScene::createTilesIfNeeded(TextureMapperLayer* layer, co > 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 @@ void CoordinatedGraphicsScene::updateTilesIfNeeded(TextureMapperLayer* layer, co > 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; >diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.cpp b/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.cpp >index 11b55be..a7bdbcb 100644 >--- a/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.cpp >+++ b/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.cpp >@@ -20,34 +20,26 @@ > */ > > #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; > > m_viewportSize = newSize; > updateMinimumScaleToFit(); >- syncVisibleContents(); > } > > void SimpleViewportController::didChangeContentsSize(const IntSize& newSize) >@@ -62,11 +54,9 @@ void SimpleViewportController::didChangeContentsSize(const IntSize& newSize) > 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 @@ void SimpleViewportController::didChangeViewportAttribute(const ViewportAttribut > 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) >-{ >- if (m_contentsPosition == boundContentsPosition(position)) >- return; >- >- m_contentsPosition = boundContentsPosition(position); >- syncVisibleContents(); >-} >- >-void SimpleViewportController::syncVisibleContents() >+FloatRect SimpleViewportController::visibleContentsRect() const > { > if (m_viewportSize.isEmpty() || m_contentsSize.isEmpty()) >- return; >- >- m_client->didChangeVisibleRect(); >-} >+ return { }; > >-FloatRect SimpleViewportController::visibleContentsRect() const >-{ > FloatRect visibleContentsRect(boundContentsPosition(m_contentsPosition), visibleContentsSize()); > visibleContentsRect.intersect(FloatRect(FloatPoint::zero(), m_contentsSize)); >- > return visibleContentsRect; > } > >diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.h b/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.h >index c2ed49f..30829e8 100644 >--- a/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.h >+++ b/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.h >@@ -37,29 +37,19 @@ namespace WebKit { > 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 scrollBy(const WebCore::IntSize&); >- void scrollTo(const WebCore::IntPoint&); >+ void didChangeViewportAttributes(const WebCore::ViewportAttributes&); >+ void didScroll(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 @@ private: > > 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; > }; > >diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp >index 54a610c..d28855f 100644 >--- a/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp >+++ b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp >@@ -42,12 +42,12 @@ using namespace WebCore; > > 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,14 +55,12 @@ ThreadedCompositor::ThreadedCompositor(Client* client, uint64_t nativeSurfaceHan > { > 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); > }); > } > > ThreadedCompositor::~ThreadedCompositor() > { >- ASSERT(!m_client); > } > > void ThreadedCompositor::invalidate() >@@ -73,10 +71,8 @@ void ThreadedCompositor::invalidate() > 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::setNativeSurfaceHandleForCompositing(uint64_t handle) > }); > } > >-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) >-{ >- m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this), size] { >- m_viewportController->didChangeViewportSize(size); >- }); >-} >- >-void ThreadedCompositor::didChangeViewportAttribute(const ViewportAttributes& attr) >+void ThreadedCompositor::setViewportSize(const IntSize& viewportSize, float scale) > { >- m_compositingRunLoop->performTask([this, protectedThis = makeRef(*this), attr] { >- m_viewportController->didChangeViewportAttribute(attr); >- }); >-} >- >-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); >+ m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this), viewportSize, scale] { >+ m_viewportSize = viewportSize; >+ m_scaleFactor = scale; >+ m_needsResize = true; >+ scheduleDisplayImmediately(); > }); > } > >-void ThreadedCompositor::scrollBy(const IntSize& delta) >+void ThreadedCompositor::setDrawsBackground(bool drawsBackground) > { >- m_compositingRunLoop->performTask([this, protectedThis = makeRef(*this), delta] { >- m_viewportController->scrollBy(delta); >+ m_compositingRunLoop->performTask([this, protectedThis = Ref<ThreadedCompositor>(*this), drawsBackground] { >+ m_drawsBackground = drawsBackground; >+ scheduleDisplayImmediately(); > }); > } > > 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::forceRepaint() > }); > } > >-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 @@ void ThreadedCompositor::renderLayerTree() > 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(); > } >diff --git a/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h >index 63684f8..dd603d6 100644 >--- a/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h >+++ b/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h >@@ -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,64 +45,57 @@ namespace WebKit { > 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; > }; > > 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; > 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; > }; >diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp >index 8ce684e..9be2ddb 100644 >--- a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp >+++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp >@@ -58,10 +58,10 @@ ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost(WebPage& webP > // 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 @@ void ThreadedCoordinatedLayerTreeHost::forceRepaint() > 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 @@ void ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged() > 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,17 +110,17 @@ void ThreadedCoordinatedLayerTreeHost::sizeDidChange(const IntSize& size) > 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); >-} >- >-void ThreadedCoordinatedLayerTreeHost::didScaleFactorChanged(float scale, const IntPoint& origin) >-{ >- m_webPage.scalePage(scale, origin); >+ m_viewportController.didChangeViewportAttributes(attr); >+ didChangeViewport(); > } > > #if PLATFORM(GTK) && !USE(REDIRECTED_XCOMPOSITE_WINDOW) >@@ -131,9 +132,11 @@ void ThreadedCoordinatedLayerTreeHost::setNativeSurfaceHandleForCompositing(uint > } > #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 @@ void ThreadedCoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& r > 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); > } > } > >diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h >index 890e7be..137108f 100644 >--- a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h >+++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h >@@ -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: > } > > 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,9 +92,7 @@ private: > ThreadedCoordinatedLayerTreeHost& m_layerTreeHost; > }; > >- void didScaleFactorChanged(float scale, const WebCore::IntPoint& origin); >- >- void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&, float); >+ void didChangeViewport(); > > // CompositingCoordinator::Client > void didFlushRootLayer(const WebCore::FloatRect&) override { } >@@ -107,8 +101,8 @@ private: > 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; > }; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
mcatanzaro
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 161532
: 287757 |
287761