Coordinated Graphics: Remove the dependency of WebCoordinatedSurface::Handle from...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 12 Jan 2013 01:32:22 +0000 (01:32 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 12 Jan 2013 01:32:22 +0000 (01:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=104347

Patch by Huang Dongsung <luxtella@company100.net> on 2013-01-11
Reviewed by Noam Rosenthal.

It is a preparation patch for Threaded Coordinated Graphics on WK1.

Currently, UpdateAtlas and CoordinatedImageBacking use
WebCoordinatedSurface::Handle, but WebCoordinatedSurface::Handle can be
used only IPC-based Coordinated Graphics. So this patch removes the
dependency of WebCoordinatedSurface::Handle from UpdateAtlas and
CoordinatedImageBacking. Now CoordinatedLayerTreeHost converts the
handle to a WebCoordinatedSurface.

* WebProcess/WebPage/CoordinatedGraphics/CoordinatedImageBacking.cpp:
(WebKit::CoordinatedImageBacking::update):
(WebKit::CoordinatedImageBacking::releaseSurfaceIfNeeded):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedImageBacking.h:
(Coordinator):
(CoordinatedImageBacking):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
(WebKit::CoordinatedLayerTreeHost::updateImageBacking):
(WebKit::CoordinatedLayerTreeHost::createUpdateAtlas):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
(WebKit):
(CoordinatedLayerTreeHost):
* WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp:
(WebKit::UpdateAtlas::UpdateAtlas):
(WebKit::UpdateAtlas::~UpdateAtlas):
(WebKit::UpdateAtlas::beginPaintingOnAvailableBuffer):
* WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h:
(UpdateAtlasClient):
(UpdateAtlas):

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

Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedImageBacking.cpp
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedImageBacking.h
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h

index 3da7d9a6cc654f5aa8f63c58309fed61fd827acf..3419caf08cb08989c39abe242d153afdc0c185e7 100644 (file)
@@ -1,3 +1,39 @@
+2013-01-11  Huang Dongsung  <luxtella@company100.net>
+
+        Coordinated Graphics: Remove the dependency of WebCoordinatedSurface::Handle from Coordinated Graphics.
+        https://bugs.webkit.org/show_bug.cgi?id=104347
+
+        Reviewed by Noam Rosenthal.
+
+        It is a preparation patch for Threaded Coordinated Graphics on WK1.
+
+        Currently, UpdateAtlas and CoordinatedImageBacking use
+        WebCoordinatedSurface::Handle, but WebCoordinatedSurface::Handle can be
+        used only IPC-based Coordinated Graphics. So this patch removes the
+        dependency of WebCoordinatedSurface::Handle from UpdateAtlas and
+        CoordinatedImageBacking. Now CoordinatedLayerTreeHost converts the
+        handle to a WebCoordinatedSurface.
+
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedImageBacking.cpp:
+        (WebKit::CoordinatedImageBacking::update):
+        (WebKit::CoordinatedImageBacking::releaseSurfaceIfNeeded):
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedImageBacking.h:
+        (Coordinator):
+        (CoordinatedImageBacking):
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
+        (WebKit::CoordinatedLayerTreeHost::updateImageBacking):
+        (WebKit::CoordinatedLayerTreeHost::createUpdateAtlas):
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
+        (WebKit):
+        (CoordinatedLayerTreeHost):
+        * WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp:
+        (WebKit::UpdateAtlas::UpdateAtlas):
+        (WebKit::UpdateAtlas::~UpdateAtlas):
+        (WebKit::UpdateAtlas::beginPaintingOnAvailableBuffer):
+        * WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h:
+        (UpdateAtlasClient):
+        (UpdateAtlas):
+
 2013-01-11  Alexey Proskuryakov  <ap@apple.com>
 
         [WK2] Network process unblocks all waiting threads when any sync reply arrives
index 14681158b08a71d81b7f5a6ee132841b4ab9da33..7043149325ca5a76dc95b4752cd6ed2ff9b6a6f4 100644 (file)
@@ -104,10 +104,7 @@ void CoordinatedImageBacking::update()
     }
 
     m_surface = CoordinatedSurface::create(m_image->size(), m_image->currentFrameHasAlpha() ? CoordinatedSurface::SupportsAlpha : CoordinatedSurface::NoFlags);
-    m_handle = adoptPtr(new WebCoordinatedSurface::Handle());
-
-    if (!static_cast<WebCoordinatedSurface*>(m_surface.get())->createHandle(*m_handle)) {
-        releaseSurfaceIfNeeded();
+    if (!m_surface) {
         m_isDirty = false;
         return;
     }
@@ -118,15 +115,15 @@ void CoordinatedImageBacking::update()
 
     m_nativeImagePtr = m_image->nativeImageForCurrentFrame();
 
-    m_coordinator->updateImageBacking(id(), *m_handle);
-    m_isDirty = false;
+    // If sending the message fails, try again in the next update.
+    bool success = m_coordinator->updateImageBacking(id(), m_surface);
+    m_isDirty = !success;
 }
 
 void CoordinatedImageBacking::releaseSurfaceIfNeeded()
 {
     // We must keep m_surface until UI Process reads m_surface.
     // If m_surface exists, it was created in the previous update.
-    m_handle.clear();
     m_surface.clear();
 }
 
index edc6e442b1b67c1b6776e55e8f0260859886bdf2..2adb2a02eb82df27d910f5a9ccb0a70ce7434f41 100644 (file)
@@ -31,7 +31,6 @@
 #include "CoordinatedLayerInfo.h"
 #include "CoordinatedSurface.h"
 #include "Image.h"
-#include "WebCoordinatedSurface.h"
 #include <WebCore/Timer.h>
 #include <wtf/RefCounted.h>
 #include <wtf/Vector.h>
@@ -43,7 +42,7 @@ public:
     class Coordinator {
     public:
         virtual void createImageBacking(CoordinatedImageBackingID) = 0;
-        virtual void updateImageBacking(CoordinatedImageBackingID, const WebCoordinatedSurface::Handle&) = 0;
+        virtual bool updateImageBacking(CoordinatedImageBackingID, PassRefPtr<CoordinatedSurface>) = 0;
         virtual void clearImageBackingContents(CoordinatedImageBackingID) = 0;
         virtual void removeImageBacking(CoordinatedImageBackingID) = 0;
     };
@@ -82,7 +81,6 @@ private:
     Vector<Host*> m_hosts;
 
     RefPtr<CoordinatedSurface> m_surface;
-    OwnPtr<WebCoordinatedSurface::Handle> m_handle;
 
     WebCore::Timer<CoordinatedImageBacking> m_clearContentsTimer;
 
index bb9955ed80bd43531421bdd154ef8c21b6c7bfcc..797aee352b0eb08324f58ca9b3fd22fbf5caf96a 100644 (file)
@@ -37,6 +37,7 @@
 #include "GraphicsContext.h"
 #include "MessageID.h"
 #include "SurfaceUpdateInfo.h"
+#include "WebCoordinatedSurface.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebPage.h"
 #include "WebPageProxyMessages.h"
@@ -613,10 +614,15 @@ void CoordinatedLayerTreeHost::createImageBacking(CoordinatedImageBackingID imag
     m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::CreateImageBacking(imageID));
 }
 
-void CoordinatedLayerTreeHost::updateImageBacking(CoordinatedImageBackingID imageID, const WebCoordinatedSurface::Handle& handle)
+bool CoordinatedLayerTreeHost::updateImageBacking(CoordinatedImageBackingID imageID, PassRefPtr<CoordinatedSurface> coordinatedSurface)
 {
     m_shouldSyncFrame = true;
+    WebCoordinatedSurface* webCoordinatedSurface = static_cast<WebCoordinatedSurface*>(coordinatedSurface.get());
+    WebCoordinatedSurface::Handle handle;
+    if (!webCoordinatedSurface->createHandle(handle))
+        return false;
     m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::UpdateImageBacking(imageID, handle));
+    return true;
 }
 
 void CoordinatedLayerTreeHost::clearImageBackingContents(CoordinatedImageBackingID imageID)
@@ -704,9 +710,14 @@ void CoordinatedLayerTreeHost::removeTile(CoordinatedLayerID layerID, uint32_t t
     m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::RemoveTileForLayer(layerID, tileID));
 }
 
-void CoordinatedLayerTreeHost::createUpdateAtlas(uint32_t atlasID, const WebCoordinatedSurface::Handle& handle)
+bool CoordinatedLayerTreeHost::createUpdateAtlas(uint32_t atlasID, PassRefPtr<CoordinatedSurface> coordinatedSurface)
 {
+    WebCoordinatedSurface* webCoordinatedSurface = static_cast<WebCoordinatedSurface*>(coordinatedSurface.get());
+    WebCoordinatedSurface::Handle handle;
+    if (!webCoordinatedSurface->createHandle(handle))
+        return false;
     m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::CreateUpdateAtlas(atlasID, handle));
+    return true;
 }
 
 void CoordinatedLayerTreeHost::removeUpdateAtlas(uint32_t atlasID)
index 4818ed9f000f9b848deaf6a2631b9e76208a6bf7..01022b2cc4e98488a4df787ea3690b72accff729 100644 (file)
@@ -28,7 +28,6 @@
 #include "LayerTreeHost.h"
 #include "Timer.h"
 #include "UpdateAtlas.h"
-#include "WebCoordinatedSurface.h"
 #include <WebCore/GraphicsLayerClient.h>
 #include <WebCore/GraphicsLayerFactory.h>
 #include <wtf/OwnPtr.h>
@@ -39,6 +38,7 @@
 
 namespace WebKit {
 
+class CoordinatedSurface;
 class UpdateInfo;
 class WebPage;
 
@@ -107,7 +107,7 @@ public:
     virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, CoordinatedSurface::Flags, uint32_t& atlasID, WebCore::IntPoint&);
 
     // UpdateAtlasClient
-    virtual void createUpdateAtlas(uint32_t atlasID, const WebCoordinatedSurface::Handle&);
+    virtual bool createUpdateAtlas(uint32_t atlasID, PassRefPtr<CoordinatedSurface>) OVERRIDE;
     virtual void removeUpdateAtlas(uint32_t atlasID);
 
 #if ENABLE(REQUEST_ANIMATION_FRAME)
@@ -126,7 +126,7 @@ private:
 
     // CoordinatedImageBacking::Coordinator
     virtual void createImageBacking(CoordinatedImageBackingID) OVERRIDE;
-    virtual void updateImageBacking(CoordinatedImageBackingID, const WebCoordinatedSurface::Handle&) OVERRIDE;
+    virtual bool updateImageBacking(CoordinatedImageBackingID, PassRefPtr<CoordinatedSurface>) OVERRIDE;
     virtual void clearImageBackingContents(CoordinatedImageBackingID) OVERRIDE;
     virtual void removeImageBacking(CoordinatedImageBackingID) OVERRIDE;
 
index 4f2404786f6790c9fe6b19c7470ddfcae498d15c..d82d32fc6ffc102cf6d4a643f5c328784d6b571c 100644 (file)
@@ -33,25 +33,21 @@ namespace WebKit {
 
 UpdateAtlas::UpdateAtlas(UpdateAtlasClient* client, int dimension, CoordinatedSurface::Flags flags)
     : m_client(client)
-    , m_flags(flags)
     , m_inactivityInSeconds(0)
-    , m_isValid(true)
 {
     static uint32_t nextID = 0;
     m_ID = ++nextID;
     IntSize size = nextPowerOfTwo(IntSize(dimension, dimension));
     m_surface = CoordinatedSurface::create(size, flags);
 
-    if (!static_cast<WebCoordinatedSurface*>(m_surface.get())->createHandle(m_handle)) {
-        m_isValid = false;
-        return;
-    }
-    m_client->createUpdateAtlas(m_ID, m_handle);
+    // FIXME: Currently, if sending the message fails, UpdateAtlas gives up drawing anything implicitly.
+    if (!m_client->createUpdateAtlas(m_ID, m_surface))
+        m_surface.clear();
 }
 
 UpdateAtlas::~UpdateAtlas()
 {
-    if (m_isValid)
+    if (m_surface)
         m_client->removeUpdateAtlas(m_ID);
 }
 
@@ -78,7 +74,7 @@ PassOwnPtr<GraphicsContext> UpdateAtlas::beginPaintingOnAvailableBuffer(uint32_t
     if (rect.isEmpty())
         return PassOwnPtr<GraphicsContext>();
 
-    if (!m_isValid)
+    if (!m_surface)
         return PassOwnPtr<GraphicsContext>();
 
     atlasID = m_ID;
index 0f4aaa67760785d2326d1ea79e2699ed7b93c0f3..ed5863b84d0d8dbaccbae39b12e234148338762c 100644 (file)
@@ -22,8 +22,8 @@
 #define UpdateAtlas_h
 
 #include "AreaAllocator.h"
+#include "CoordinatedSurface.h"
 #include "IntSize.h"
-#include "WebCoordinatedSurface.h"
 
 #if USE(COORDINATED_GRAPHICS)
 namespace WebCore {
@@ -35,7 +35,7 @@ namespace WebKit {
 
 class UpdateAtlasClient {
 public:
-    virtual void createUpdateAtlas(uint32_t atlasID, const WebCoordinatedSurface::Handle&) = 0;
+    virtual bool createUpdateAtlas(uint32_t atlasID, PassRefPtr<CoordinatedSurface>) = 0;
     virtual void removeUpdateAtlas(uint32_t atlasID) = 0;
 };
 
@@ -70,12 +70,9 @@ private:
 private:
     UpdateAtlasClient* m_client;
     OwnPtr<GeneralAreaAllocator> m_areaAllocator;
-    ShareableBitmap::Flags m_flags;
     RefPtr<CoordinatedSurface> m_surface;
-    WebCoordinatedSurface::Handle m_handle;
     double m_inactivityInSeconds;
     uint32_t m_ID;
-    bool m_isValid;
 };
 
 }