Changeset 205395 in webkit
- Timestamp:
- Sep 2, 2016 10:45:10 PM (8 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r205381 r205395 1 2016-09-02 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [Threaded Compositor] Move the viewport controller off the compositing thread 4 https://bugs.webkit.org/show_bug.cgi?id=161532 5 6 Reviewed by Michael Catanzaro. 7 8 While working on bug #161242 I've realized that having the view port controller in the compositing thread makes 9 everything more complex. The viewport controller receives changes about things like contents size, viewport 10 size, etc. and uses that information to compute the visible contents rect and page scale factor. Then it 11 notifies back to main thread about the computed visible contents rect and page scale. Those computations are not 12 heave at all, so they could be done in the main thread and we would avoid communications between the main and 13 compositing thread in both directions. The main thread needs the visible contents rect to notify the compositing 14 coordinator and the page cale to scale the page in case of pixed layout. But the compositing thread only needs 15 to know the effective scale and scroll position. So, instead of going to the compositing thread after every 16 change that might update the visible contents rect and page scale factor, we could do those calculations in the 17 main thread and only notify the compositing thread about the actual changes in the scroll position and effective scale. 18 19 * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp: 20 (WebKit::CoordinatedGraphicsScene::createTilesIfNeeded): Return early if backingStore is nullptr, which can 21 happen if the layer shouldn't have a backing store and was removed by the previous call to prepareContentBackingStore(). 22 (WebKit::CoordinatedGraphicsScene::updateTilesIfNeeded): Ditto. 23 * Shared/CoordinatedGraphics/SimpleViewportController.cpp: 24 (WebKit::SimpleViewportController::SimpleViewportController): Remove the client since we no longer need to 25 notify about changes. 26 (WebKit::SimpleViewportController::didChangeViewportSize): Remove call to syncVisibleContents(). 27 (WebKit::SimpleViewportController::didChangeContentsSize): Ditto. 28 (WebKit::SimpleViewportController::didChangeViewportAttributes): Ditto. 29 (WebKit::SimpleViewportController::didScroll): Removed unused scrollBy methods and renamed scrollTo as 30 didiScroll for consistency. Save the position without calling boundContentsPosition, because that's already 31 donde when the position is used to compute the contents visible rectangle. 32 (WebKit::SimpleViewportController::visibleContentsRect): No need to notify about the changes. 33 (WebKit::SimpleViewportController::visibleContentsSize): Deleted. 34 * Shared/CoordinatedGraphics/SimpleViewportController.h: 35 * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp: 36 (WebKit::ThreadedCompositor::create): Pass a reference to the client instead of a pointer. It's no longer 37 possible to have a valid pointer when the object has been destroyed, so we can better use a reference now. 38 (WebKit::ThreadedCompositor::ThreadedCompositor): Ditto. 39 (WebKit::ThreadedCompositor::~ThreadedCompositor): Remove assert. 40 (WebKit::ThreadedCompositor::invalidate): No need to invalidate the client. 41 (WebKit::ThreadedCompositor::setScaleFactor): Set the effective scale factor that should be used for rendering. 42 (WebKit::ThreadedCompositor::setScrollPosition): Set the current scroll position and effective scale factor. 43 (WebKit::ThreadedCompositor::setViewportSize): Set the viewport size and effective scale factor. 44 (WebKit::ThreadedCompositor::renderNextFrame): Update m_client use that is no longer a pointer. 45 (WebKit::ThreadedCompositor::commitScrollOffset): Ditto. 46 (WebKit::ThreadedCompositor::renderLayerTree): Call glViewport after a resize and use m_viewportSize, 47 m_scrollPosition and m_scaleFactor members. 48 (WebKit::ThreadedCompositor::didChangeVisibleRect): Deleted. 49 * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h: 50 * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp: 51 (WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost): Pass the compositor client as a 52 reference to ThreadedCompositor constructor. 53 (WebKit::ThreadedCoordinatedLayerTreeHost::scrollNonCompositedContents): Update the viewport and call didChangeViewport(). 54 (WebKit::ThreadedCoordinatedLayerTreeHost::contentsSizeChanged): Ditto. 55 (WebKit::ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged): Pass the effective scale factor to 56 the compositor. 57 (WebKit::ThreadedCoordinatedLayerTreeHost::sizeDidChange): Update the viewport, the compositor and call didChangeViewport(). 58 (WebKit::ThreadedCoordinatedLayerTreeHost::didChangeViewportProperties): Update the viewport and call didChangeViewport(). 59 (WebKit::ThreadedCoordinatedLayerTreeHost::didChangeViewport): Notify the compositing coordinator about the new 60 visible contents rectangle, and update the threaded compositor if needed. 61 * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h: 62 1 63 2016-09-02 Beth Dakin <bdakin@apple.com> 2 64 -
trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp
r203776 r205395 446 446 447 447 RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer); 448 ASSERT(backingStore); 448 ASSERT(backingStore || !layerShouldHaveBackingStore(layer)); 449 if (!backingStore) 450 return; 449 451 450 452 for (auto& tile : state.tilesToCreate) … … 473 475 474 476 RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer); 475 ASSERT(backingStore); 477 ASSERT(backingStore || !layerShouldHaveBackingStore(layer)); 478 if (!backingStore) 479 return; 476 480 477 481 for (auto& tile : state.tilesToUpdate) { -
trunk/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.cpp
r177276 r205395 21 21 22 22 #include "config.h" 23 #include "SimpleViewportController.h" 23 24 24 25 #if USE(COORDINATED_GRAPHICS_THREADED) 25 #include "SimpleViewportController.h"26 26 27 27 using namespace WebCore; … … 29 29 namespace WebKit { 30 30 31 SimpleViewportController::SimpleViewportController(Client* client) 32 : m_client(client) 33 , m_contentsPosition(FloatPoint()) 34 , m_contentsSize(FloatSize()) 35 , m_viewportSize(FloatSize()) 36 , m_allowsUserScaling(false) 37 , m_initiallyFitToViewport(true) 38 , m_hasViewportAttribute(false) 31 SimpleViewportController::SimpleViewportController() 39 32 { 40 33 resetViewportToDefaultState(); 41 34 } 42 35 43 void SimpleViewportController::didChangeViewportSize(const FloatSize& newSize)36 void SimpleViewportController::didChangeViewportSize(const IntSize& newSize) 44 37 { 45 38 if (newSize.isEmpty()) … … 48 41 m_viewportSize = newSize; 49 42 updateMinimumScaleToFit(); 50 syncVisibleContents();51 43 } 52 44 … … 63 55 restrictScaleFactorToInitialScaleIfNotUserScalable(m_rawAttributes); 64 56 } 65 66 syncVisibleContents();67 57 } 68 58 69 void SimpleViewportController::didChangeViewportAttribute (const ViewportAttributes& newAttributes)59 void SimpleViewportController::didChangeViewportAttributes(const ViewportAttributes& newAttributes) 70 60 { 71 61 if (newAttributes.layoutSize.isEmpty()) { … … 84 74 85 75 updateMinimumScaleToFit(); 86 87 syncVisibleContents();88 76 } 89 77 90 void SimpleViewportController:: scrollBy(const IntSize& scrollOffset)78 void SimpleViewportController::didScroll(const IntPoint& position) 91 79 { 92 m_contentsPosition.move(scrollOffset); 93 m_contentsPosition = boundContentsPosition(m_contentsPosition); 94 95 syncVisibleContents(); 96 } 97 98 void SimpleViewportController::scrollTo(const IntPoint& position) 99 { 100 if (m_contentsPosition == boundContentsPosition(position)) 101 return; 102 103 m_contentsPosition = boundContentsPosition(position); 104 syncVisibleContents(); 105 } 106 107 void SimpleViewportController::syncVisibleContents() 108 { 109 if (m_viewportSize.isEmpty() || m_contentsSize.isEmpty()) 110 return; 111 112 m_client->didChangeVisibleRect(); 80 m_contentsPosition = position; 113 81 } 114 82 115 83 FloatRect SimpleViewportController::visibleContentsRect() const 116 84 { 85 if (m_viewportSize.isEmpty() || m_contentsSize.isEmpty()) 86 return { }; 87 117 88 FloatRect visibleContentsRect(boundContentsPosition(m_contentsPosition), visibleContentsSize()); 118 89 visibleContentsRect.intersect(FloatRect(FloatPoint::zero(), m_contentsSize)); 119 120 90 return visibleContentsRect; 121 91 } -
trunk/Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.h
r177276 r205395 38 38 WTF_MAKE_NONCOPYABLE(SimpleViewportController); 39 39 public: 40 class Client { 41 public: 42 virtual void didChangeVisibleRect() = 0; 43 }; 40 SimpleViewportController(); 44 41 45 explicit SimpleViewportController(Client*); 46 47 void didChangeViewportSize(const WebCore::FloatSize&); 42 void didChangeViewportSize(const WebCore::IntSize&); 48 43 void didChangeContentsSize(const WebCore::IntSize&); 49 void didChangeViewportAttribute(const WebCore::ViewportAttributes&); 50 51 void scrollBy(const WebCore::IntSize&); 52 void scrollTo(const WebCore::IntPoint&); 44 void didChangeViewportAttributes(const WebCore::ViewportAttributes&); 45 void didScroll(const WebCore::IntPoint&); 53 46 54 47 WebCore::FloatRect visibleContentsRect() const; … … 56 49 57 50 private: 58 59 51 WebCore::FloatSize visibleContentsSize() const; 60 61 void syncVisibleContents();62 52 63 53 void applyScaleAfterRenderingContents(float scale); … … 72 62 void resetViewportToDefaultState(); 73 63 74 Client* m_client; 75 76 WebCore::FloatPoint m_contentsPosition; 64 WebCore::IntPoint m_contentsPosition; 77 65 WebCore::FloatSize m_contentsSize; 78 66 WebCore::FloatSize m_viewportSize; 79 float m_pageScaleFactor ;67 float m_pageScaleFactor { 1 }; 80 68 81 bool m_allowsUserScaling ;82 float m_minimumScaleToFit ;83 bool m_initiallyFitToViewport ;69 bool m_allowsUserScaling { false }; 70 float m_minimumScaleToFit { 1 }; 71 bool m_initiallyFitToViewport { false }; 84 72 85 bool m_hasViewportAttribute ;73 bool m_hasViewportAttribute { false }; 86 74 WebCore::ViewportAttributes m_rawAttributes; 87 75 }; -
trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
r205116 r205395 43 43 namespace WebKit { 44 44 45 Ref<ThreadedCompositor> ThreadedCompositor::create(Client *client, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync)45 Ref<ThreadedCompositor> ThreadedCompositor::create(Client& client, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync) 46 46 { 47 47 return adoptRef(*new ThreadedCompositor(client, nativeSurfaceHandle, doFrameSync)); 48 48 } 49 49 50 ThreadedCompositor::ThreadedCompositor(Client *client, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync)50 ThreadedCompositor::ThreadedCompositor(Client& client, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync) 51 51 : m_client(client) 52 52 , m_nativeSurfaceHandle(nativeSurfaceHandle) … … 56 56 m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this)] { 57 57 m_scene = adoptRef(new CoordinatedGraphicsScene(this)); 58 m_viewportController = std::make_unique<SimpleViewportController>(this);59 58 m_scene->setActive(!!m_nativeSurfaceHandle); 60 59 }); … … 63 62 ThreadedCompositor::~ThreadedCompositor() 64 63 { 65 ASSERT(!m_client);66 64 } 67 65 … … 74 72 m_context = nullptr; 75 73 m_scene = nullptr; 76 m_viewportController = nullptr;77 74 }); 78 75 m_compositingRunLoop = nullptr; 79 m_client = nullptr;80 76 } 81 77 … … 94 90 } 95 91 96 void ThreadedCompositor::set DeviceScaleFactor(float scale)92 void ThreadedCompositor::setScaleFactor(float scale) 97 93 { 98 94 m_compositingRunLoop->performTask([this, protectedThis = makeRef(*this), scale] { 99 m_deviceScaleFactor = scale; 95 m_scaleFactor = scale; 96 scheduleDisplayImmediately(); 97 }); 98 } 99 100 void ThreadedCompositor::setScrollPosition(const IntPoint& scrollPosition, float scale) 101 { 102 m_compositingRunLoop->performTask([this, protectedThis = makeRef(*this), scrollPosition, scale] { 103 m_scrollPosition = scrollPosition; 104 m_scaleFactor = scale; 105 scheduleDisplayImmediately(); 106 }); 107 } 108 109 void ThreadedCompositor::setViewportSize(const IntSize& viewportSize, float scale) 110 { 111 m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this), viewportSize, scale] { 112 m_viewportSize = viewportSize; 113 m_scaleFactor = scale; 114 m_needsResize = true; 100 115 scheduleDisplayImmediately(); 101 116 }); … … 110 125 } 111 126 112 void ThreadedCompositor::didChangeViewportSize(const IntSize& size)113 {114 m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this), size] {115 m_viewportController->didChangeViewportSize(size);116 });117 }118 119 void ThreadedCompositor::didChangeViewportAttribute(const ViewportAttributes& attr)120 {121 m_compositingRunLoop->performTask([this, protectedThis = makeRef(*this), attr] {122 m_viewportController->didChangeViewportAttribute(attr);123 });124 }125 126 void ThreadedCompositor::didChangeContentsSize(const IntSize& size)127 {128 m_compositingRunLoop->performTask([this, protectedThis = makeRef(*this), size] {129 m_viewportController->didChangeContentsSize(size);130 });131 }132 133 void ThreadedCompositor::scrollTo(const IntPoint& position)134 {135 m_compositingRunLoop->performTask([this, protectedThis = makeRef(*this), position] {136 m_viewportController->scrollTo(position);137 });138 }139 140 void ThreadedCompositor::scrollBy(const IntSize& delta)141 {142 m_compositingRunLoop->performTask([this, protectedThis = makeRef(*this), delta] {143 m_viewportController->scrollBy(delta);144 });145 }146 147 127 void ThreadedCompositor::renderNextFrame() 148 128 { 149 129 ASSERT(isMainThread()); 150 m_client ->renderNextFrame();130 m_client.renderNextFrame(); 151 131 } 152 132 … … 154 134 { 155 135 ASSERT(isMainThread()); 156 m_client ->commitScrollOffset(layerID, offset);136 m_client.commitScrollOffset(layerID, offset); 157 137 } 158 138 … … 195 175 } 196 176 197 void ThreadedCompositor::didChangeVisibleRect()198 {199 RunLoop::main().dispatch([this, protectedThis = makeRef(*this), visibleRect = m_viewportController->visibleContentsRect(), scale = m_viewportController->pageScaleFactor()] {200 if (m_client)201 m_client->setVisibleContentsRect(visibleRect, FloatPoint::zero(), scale);202 });203 204 scheduleDisplayImmediately();205 }206 207 177 void ThreadedCompositor::renderLayerTree() 208 178 { … … 213 183 return; 214 184 215 // The window size may be out of sync with the page size at this point, and getting 216 // the viewport parameters incorrect, means that the content will be misplaced. Thus, 217 // we set the viewport parameters directly from the window size. 218 IntSize contextSize = m_context->defaultFrameBufferSize(); 219 if (m_viewportSize != contextSize) { 220 glViewport(0, 0, contextSize.width(), contextSize.height()); 221 m_viewportSize = contextSize; 185 if (m_needsResize) { 186 glViewport(0, 0, m_viewportSize.width(), m_viewportSize.height()); 187 m_needsResize = false; 222 188 } 223 224 189 FloatRect clipRect(0, 0, m_viewportSize.width(), m_viewportSize.height()); 225 190 226 191 TransformationMatrix viewportTransform; 227 FloatPoint scrollPostion = m_viewportController->visibleContentsRect().location(); 228 viewportTransform.scale(m_viewportController->pageScaleFactor() * m_deviceScaleFactor); 229 viewportTransform.translate(-scrollPostion.x(), -scrollPostion.y()); 192 viewportTransform.scale(m_scaleFactor); 193 viewportTransform.translate(-m_scrollPosition.x(), -m_scrollPosition.y()); 230 194 231 195 if (!m_drawsBackground) { … … 233 197 glClear(GL_COLOR_BUFFER_BIT); 234 198 } 235 m_scene->paintToCurrentGLContext(viewportTransform, 1, clipRect, Color::transparent, !m_drawsBackground, scrollPostion);199 m_scene->paintToCurrentGLContext(viewportTransform, 1, clipRect, Color::transparent, !m_drawsBackground, m_scrollPosition); 236 200 237 201 m_context->swapBuffers(); -
trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h
r205116 r205395 31 31 #include "CompositingRunLoop.h" 32 32 #include "CoordinatedGraphicsScene.h" 33 #include "SimpleViewportController.h"34 33 #include <WebCore/GLContext.h> 35 34 #include <WebCore/IntSize.h> … … 47 46 class CoordinatedGraphicsSceneClient; 48 47 49 class ThreadedCompositor : public SimpleViewportController::Client, publicCoordinatedGraphicsSceneClient, public ThreadSafeRefCounted<ThreadedCompositor> {48 class ThreadedCompositor : public CoordinatedGraphicsSceneClient, public ThreadSafeRefCounted<ThreadedCompositor> { 50 49 WTF_MAKE_NONCOPYABLE(ThreadedCompositor); 51 50 WTF_MAKE_FAST_ALLOCATED; … … 53 52 class Client { 54 53 public: 55 virtual void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&, float) = 0;56 54 virtual void renderNextFrame() = 0; 57 55 virtual void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) = 0; … … 60 58 enum class ShouldDoFrameSync { No, Yes }; 61 59 62 static Ref<ThreadedCompositor> create(Client *, uint64_t nativeSurfaceHandle = 0, ShouldDoFrameSync = ShouldDoFrameSync::Yes);60 static Ref<ThreadedCompositor> create(Client&, uint64_t nativeSurfaceHandle = 0, ShouldDoFrameSync = ShouldDoFrameSync::Yes); 63 61 virtual ~ThreadedCompositor(); 64 62 65 63 void setNativeSurfaceHandleForCompositing(uint64_t); 66 void setDeviceScaleFactor(float); 64 void setScaleFactor(float); 65 void setScrollPosition(const WebCore::IntPoint&, float scale); 66 void setViewportSize(const WebCore::IntSize&, float scale); 67 67 void setDrawsBackground(bool); 68 68 69 69 void updateSceneState(const WebCore::CoordinatedGraphicsState&); 70 71 void didChangeViewportSize(const WebCore::IntSize&);72 void didChangeViewportAttribute(const WebCore::ViewportAttributes&);73 void didChangeContentsSize(const WebCore::IntSize&);74 void scrollTo(const WebCore::IntPoint&);75 void scrollBy(const WebCore::IntSize&);76 70 77 71 void invalidate(); … … 80 74 81 75 private: 82 ThreadedCompositor(Client *, uint64_t nativeSurfaceHandle, ShouldDoFrameSync);76 ThreadedCompositor(Client&, uint64_t nativeSurfaceHandle, ShouldDoFrameSync); 83 77 84 78 // CoordinatedGraphicsSceneClient … … 87 81 void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) override; 88 82 89 // SimpleViewportController::Client.90 void didChangeVisibleRect() override;91 92 83 void renderLayerTree(); 93 84 void scheduleDisplayImmediately(); … … 95 86 bool makeContextCurrent(); 96 87 97 Client * m_client { nullptr };88 Client& m_client; 98 89 RefPtr<CoordinatedGraphicsScene> m_scene; 99 std::unique_ptr<SimpleViewportController> m_viewportController;100 90 std::unique_ptr<WebCore::GLContext> m_context; 101 91 102 92 WebCore::IntSize m_viewportSize; 103 float m_deviceScaleFactor { 1 }; 93 WebCore::IntPoint m_scrollPosition; 94 float m_scaleFactor { 1 }; 104 95 bool m_drawsBackground { true }; 105 96 uint64_t m_nativeSurfaceHandle; 106 97 ShouldDoFrameSync m_doFrameSync; 98 bool m_needsResize { false }; 107 99 108 100 std::unique_ptr<CompositingRunLoop> m_compositingRunLoop; -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp
r205116 r205395 59 59 // Rendering to the actual screen will happen later anyway since the UI process schedules a redraw for every update, 60 60 // the compositor will take care of syncing to vblank. 61 m_compositor = ThreadedCompositor::create( &m_compositorClient, m_surface->window(), ThreadedCompositor::ShouldDoFrameSync::No);61 m_compositor = ThreadedCompositor::create(m_compositorClient, m_surface->window(), ThreadedCompositor::ShouldDoFrameSync::No); 62 62 m_layerTreeContext.contextID = m_surface->surfaceID(); 63 63 } else 64 m_compositor = ThreadedCompositor::create( &m_compositorClient);64 m_compositor = ThreadedCompositor::create(m_compositorClient); 65 65 } 66 66 … … 78 78 } 79 79 80 void ThreadedCoordinatedLayerTreeHost::scrollNonCompositedContents(const WebCore::IntRect& rect)80 void ThreadedCoordinatedLayerTreeHost::scrollNonCompositedContents(const IntRect& rect) 81 81 { 82 m_ compositor->scrollTo(rect.location());83 scheduleLayerFlush();82 m_viewportController.didScroll(rect.location()); 83 didChangeViewport(); 84 84 } 85 85 86 void ThreadedCoordinatedLayerTreeHost::contentsSizeChanged(const WebCore::IntSize& newSize)86 void ThreadedCoordinatedLayerTreeHost::contentsSizeChanged(const IntSize& newSize) 87 87 { 88 m_compositor->didChangeContentsSize(newSize); 88 m_viewportController.didChangeContentsSize(newSize); 89 didChangeViewport(); 89 90 } 90 91 … … 95 96 96 97 CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged(); 97 m_compositor->set DeviceScaleFactor(m_webPage.deviceScaleFactor());98 m_compositor->setScaleFactor(m_webPage.deviceScaleFactor() * m_viewportController.pageScaleFactor()); 98 99 } 99 100 … … 110 111 111 112 CoordinatedLayerTreeHost::sizeDidChange(size); 112 m_compositor->didChangeViewportSize(size); 113 m_viewportController.didChangeViewportSize(size); 114 IntSize scaledSize(size); 115 scaledSize.scale(m_webPage.deviceScaleFactor()); 116 m_compositor->setViewportSize(scaledSize, m_webPage.deviceScaleFactor() * m_viewportController.pageScaleFactor()); 117 didChangeViewport(); 113 118 } 114 119 115 void ThreadedCoordinatedLayerTreeHost::didChangeViewportProperties(const WebCore::ViewportAttributes& attr)120 void ThreadedCoordinatedLayerTreeHost::didChangeViewportProperties(const ViewportAttributes& attr) 116 121 { 117 m_compositor->didChangeViewportAttribute(attr); 118 } 119 120 void ThreadedCoordinatedLayerTreeHost::didScaleFactorChanged(float scale, const IntPoint& origin) 121 { 122 m_webPage.scalePage(scale, origin); 122 m_viewportController.didChangeViewportAttributes(attr); 123 didChangeViewport(); 123 124 } 124 125 … … 132 133 #endif 133 134 134 void ThreadedCoordinatedLayerTreeHost:: setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector, float scale)135 void ThreadedCoordinatedLayerTreeHost::didChangeViewport() 135 136 { 136 FloatRect visibleRect(rect); 137 FloatRect visibleRect(m_viewportController.visibleContentsRect()); 138 if (visibleRect.isEmpty()) 139 return; 137 140 138 141 // When using non overlay scrollbars, the contents size doesn't include the scrollbars, but we need to include them … … 147 150 visibleRect.expand(0, scrollbar->height()); 148 151 149 CoordinatedLayerTreeHost::setVisibleContentsRect(visibleRect, trajectoryVector); 150 if (m_lastScrollPosition != roundedIntPoint(visibleRect.location())) { 151 m_lastScrollPosition = roundedIntPoint(visibleRect.location()); 152 CoordinatedLayerTreeHost::setVisibleContentsRect(visibleRect, FloatPoint::zero()); 153 154 float pageScale = m_viewportController.pageScaleFactor(); 155 IntPoint scrollPosition = roundedIntPoint(visibleRect.location()); 156 if (m_lastScrollPosition != scrollPosition) { 157 m_lastScrollPosition = scrollPosition; 158 m_compositor->setScrollPosition(m_lastScrollPosition, m_webPage.deviceScaleFactor() * pageScale); 152 159 153 160 if (!view->useFixedLayout()) … … 155 162 } 156 163 157 if (m_last ScaleFactor != scale) {158 m_last ScaleFactor = scale;159 didScaleFactorChanged(m_lastScaleFactor, m_lastScrollPosition);164 if (m_lastPageScaleFactor != pageScale) { 165 m_lastPageScaleFactor = pageScale; 166 m_webPage.scalePage(pageScale, m_lastScrollPosition); 160 167 } 161 168 } -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h
r205116 r205395 32 32 33 33 #include "CoordinatedLayerTreeHost.h" 34 #include "SimpleViewportController.h" 34 35 #include "ThreadedCompositor.h" 35 36 … … 79 80 80 81 private: 81 void setVisibleContentsRect(const WebCore::FloatRect& rect, const WebCore::FloatPoint& trajectoryVector, float scale) override82 {83 m_layerTreeHost.setVisibleContentsRect(rect, trajectoryVector, scale);84 }85 86 82 void renderNextFrame() override 87 83 { … … 97 93 }; 98 94 99 void didScaleFactorChanged(float scale, const WebCore::IntPoint& origin); 100 101 void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&, float); 95 void didChangeViewport(); 102 96 103 97 // CompositingCoordinator::Client … … 108 102 std::unique_ptr<AcceleratedSurface> m_surface; 109 103 RefPtr<ThreadedCompositor> m_compositor; 110 float m_lastScaleFactor { 1 };111 WebCore::IntPoint m_prevScrollPosition;104 SimpleViewportController m_viewportController; 105 float m_lastPageScaleFactor { 1 }; 112 106 WebCore::IntPoint m_lastScrollPosition; 113 107 };
Note: See TracChangeset
for help on using the changeset viewer.