[Threaded Compositor] Initialize the threaded compositor with the current size
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jan 2017 06:55:46 +0000 (06:55 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jan 2017 06:55:46 +0000 (06:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167196

Reviewed by Žan Doberšek.

We are always creating the threaded compositor with an empty size and then a sizeDidChange always happen when
the backing store state changes. This is always happening because the threaded compositor is created before the
first backing store state, but if we wanted to create it later, for example to enter/leave AC mode on demand,
the threaded compositor will not have the viewport size unless the window is resized, or sizeDidChange is called
manually when entering AC mode. Creating the threaded compositor is sync and changing the size too, so it's
better to do both things at the same time using the same sync operation.

* Shared/CoordinatedGraphics/SimpleViewportController.cpp:
(WebKit::SimpleViewportController::SimpleViewportController): Pass an initial size to the constructor.
* Shared/CoordinatedGraphics/SimpleViewportController.h:
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
(WebKit::ThreadedCompositor::create): Add viewportSize and scaleFactor construction parameters,
(WebKit::ThreadedCompositor::ThreadedCompositor): Ditto. Also mark as needs resize if the given size is not empty.
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
* WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
(WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost): Initialize the threaded compositor
with an initial viewport size and scale factor.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210954 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.cpp
Source/WebKit2/Shared/CoordinatedGraphics/SimpleViewportController.h
Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp

index c18b534..477c557 100644 (file)
@@ -1,3 +1,28 @@
+2017-01-19  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [Threaded Compositor] Initialize the threaded compositor with the current size
+        https://bugs.webkit.org/show_bug.cgi?id=167196
+
+        Reviewed by Žan Doberšek.
+
+        We are always creating the threaded compositor with an empty size and then a sizeDidChange always happen when
+        the backing store state changes. This is always happening because the threaded compositor is created before the
+        first backing store state, but if we wanted to create it later, for example to enter/leave AC mode on demand,
+        the threaded compositor will not have the viewport size unless the window is resized, or sizeDidChange is called
+        manually when entering AC mode. Creating the threaded compositor is sync and changing the size too, so it's
+        better to do both things at the same time using the same sync operation.
+
+        * Shared/CoordinatedGraphics/SimpleViewportController.cpp:
+        (WebKit::SimpleViewportController::SimpleViewportController): Pass an initial size to the constructor.
+        * Shared/CoordinatedGraphics/SimpleViewportController.h:
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
+        (WebKit::ThreadedCompositor::create): Add viewportSize and scaleFactor construction parameters,
+        (WebKit::ThreadedCompositor::ThreadedCompositor): Ditto. Also mark as needs resize if the given size is not empty.
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
+        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
+        (WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost): Initialize the threaded compositor
+        with an initial viewport size and scale factor.
+
 2017-01-19  Chris Dumez  <cdumez@apple.com>
 
         iterable<> should be enabled on WK1
 2017-01-19  Chris Dumez  <cdumez@apple.com>
 
         iterable<> should be enabled on WK1
index a7bdbcb..bfb6ed3 100644 (file)
@@ -28,7 +28,8 @@ using namespace WebCore;
 
 namespace WebKit {
 
 
 namespace WebKit {
 
-SimpleViewportController::SimpleViewportController()
+SimpleViewportController::SimpleViewportController(const IntSize& size)
+    : m_viewportSize(size)
 {
     resetViewportToDefaultState();
 }
 {
     resetViewportToDefaultState();
 }
index 30829e8..a311cd3 100644 (file)
@@ -37,7 +37,7 @@ namespace WebKit {
 class SimpleViewportController {
     WTF_MAKE_NONCOPYABLE(SimpleViewportController);
 public:
 class SimpleViewportController {
     WTF_MAKE_NONCOPYABLE(SimpleViewportController);
 public:
-    SimpleViewportController();
+    SimpleViewportController(const WebCore::IntSize&);
 
     void didChangeViewportSize(const WebCore::IntSize&);
     void didChangeContentsSize(const WebCore::IntSize&);
 
     void didChangeViewportSize(const WebCore::IntSize&);
     void didChangeContentsSize(const WebCore::IntSize&);
index 64d5340..091d8b4 100644 (file)
@@ -42,16 +42,19 @@ using namespace WebCore;
 
 namespace WebKit {
 
 
 namespace WebKit {
 
-Ref<ThreadedCompositor> ThreadedCompositor::create(Client& client, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
+Ref<ThreadedCompositor> ThreadedCompositor::create(Client& client, const IntSize& viewportSize, float scaleFactor, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
 {
 {
-    return adoptRef(*new ThreadedCompositor(client, nativeSurfaceHandle, doFrameSync, paintFlags));
+    return adoptRef(*new ThreadedCompositor(client, viewportSize, scaleFactor, nativeSurfaceHandle, doFrameSync, paintFlags));
 }
 
 }
 
-ThreadedCompositor::ThreadedCompositor(Client& client, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
+ThreadedCompositor::ThreadedCompositor(Client& client, const IntSize& viewportSize, float scaleFactor, uint64_t nativeSurfaceHandle, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
     : m_client(client)
     : m_client(client)
+    , m_viewportSize(viewportSize)
+    , m_scaleFactor(scaleFactor)
     , m_nativeSurfaceHandle(nativeSurfaceHandle)
     , m_doFrameSync(doFrameSync)
     , m_paintFlags(paintFlags)
     , m_nativeSurfaceHandle(nativeSurfaceHandle)
     , m_doFrameSync(doFrameSync)
     , m_paintFlags(paintFlags)
+    , m_needsResize(!viewportSize.isEmpty())
     , m_compositingRunLoop(std::make_unique<CompositingRunLoop>([this] { renderLayerTree(); }))
 {
     m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this)] {
     , m_compositingRunLoop(std::make_unique<CompositingRunLoop>([this] { renderLayerTree(); }))
 {
     m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this)] {
index d7ffc82..b174a2e 100644 (file)
@@ -58,7 +58,7 @@ public:
 
     enum class ShouldDoFrameSync { No, Yes };
 
 
     enum class ShouldDoFrameSync { No, Yes };
 
-    static Ref<ThreadedCompositor> create(Client&, uint64_t nativeSurfaceHandle = 0, ShouldDoFrameSync = ShouldDoFrameSync::Yes, WebCore::TextureMapper::PaintFlags = 0);
+    static Ref<ThreadedCompositor> create(Client&, const WebCore::IntSize&, float scaleFactor, uint64_t nativeSurfaceHandle = 0, ShouldDoFrameSync = ShouldDoFrameSync::Yes, WebCore::TextureMapper::PaintFlags = 0);
     virtual ~ThreadedCompositor();
 
     void setNativeSurfaceHandleForCompositing(uint64_t);
     virtual ~ThreadedCompositor();
 
     void setNativeSurfaceHandleForCompositing(uint64_t);
@@ -74,7 +74,7 @@ public:
     void forceRepaint();
 
 private:
     void forceRepaint();
 
 private:
-    ThreadedCompositor(Client&, uint64_t nativeSurfaceHandle, ShouldDoFrameSync, WebCore::TextureMapper::PaintFlags);
+    ThreadedCompositor(Client&, const WebCore::IntSize&, float scaleFactor, uint64_t nativeSurfaceHandle, ShouldDoFrameSync, WebCore::TextureMapper::PaintFlags);
 
     // CoordinatedGraphicsSceneClient
     void renderNextFrame() override;
 
     // CoordinatedGraphicsSceneClient
     void renderNextFrame() override;
index 57a0a1f..58da8eb 100644 (file)
@@ -53,7 +53,12 @@ ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost(WebPage& webP
     : CoordinatedLayerTreeHost(webPage)
     , m_compositorClient(*this)
     , m_surface(AcceleratedSurface::create(webPage))
     : CoordinatedLayerTreeHost(webPage)
     , m_compositorClient(*this)
     , m_surface(AcceleratedSurface::create(webPage))
+    , m_viewportController(webPage.size())
 {
 {
+    IntSize scaledSize(m_webPage.size());
+    scaledSize.scale(m_webPage.deviceScaleFactor());
+    float scaleFactor = m_webPage.deviceScaleFactor() * m_viewportController.pageScaleFactor();
+
     if (m_surface) {
         TextureMapper::PaintFlags paintFlags = 0;
 
     if (m_surface) {
         TextureMapper::PaintFlags paintFlags = 0;
 
@@ -63,10 +68,12 @@ 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.
         // 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, paintFlags);
+        m_compositor = ThreadedCompositor::create(m_compositorClient, scaledSize, scaleFactor, m_surface->window(), ThreadedCompositor::ShouldDoFrameSync::No, paintFlags);
         m_layerTreeContext.contextID = m_surface->surfaceID();
     } else
         m_layerTreeContext.contextID = m_surface->surfaceID();
     } else
-        m_compositor = ThreadedCompositor::create(m_compositorClient);
+        m_compositor = ThreadedCompositor::create(m_compositorClient, scaledSize, scaleFactor);
+
+    didChangeViewport();
 }
 
 void ThreadedCoordinatedLayerTreeHost::invalidate()
 }
 
 void ThreadedCoordinatedLayerTreeHost::invalidate()