Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp (107232 => 107233)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp 2012-02-09 14:31:44 UTC (rev 107232)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp 2012-02-09 14:33:33 UTC (rev 107233)
@@ -87,7 +87,7 @@
, m_hasPendingAnimations(false)
, m_inUpdateMode(false)
#if USE(TILED_BACKING_STORE)
- , m_layerTreeTileClient(0)
+ , m_webGraphicsLayerClient(0)
, m_mainBackingStore(adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this))))
, m_contentsScale(1.f)
#endif
@@ -105,8 +105,8 @@
// This would tell the UI process to release the backing store.
setContentsToImage(0);
- if (m_layerTreeTileClient)
- m_layerTreeTileClient->didDeleteLayer(id());
+ if (m_webGraphicsLayerClient)
+ m_webGraphicsLayerClient->detachLayer(this);
}
bool WebGraphicsLayer::setChildren(const Vector<GraphicsLayer*>& children)
@@ -116,7 +116,7 @@
return false;
for (int i = 0; i < children.size(); ++i) {
WebGraphicsLayer* child = toWebGraphicsLayer(children[i]);
- child->setVisibleContentRectAndScale(m_pageVisibleRect, m_contentsScale);
+ child->setWebGraphicsLayerClient(m_webGraphicsLayerClient);
child->notifyChange();
}
notifyChange();
@@ -126,7 +126,7 @@
void WebGraphicsLayer::addChild(GraphicsLayer* layer)
{
GraphicsLayer::addChild(layer);
- toWebGraphicsLayer(layer)->setVisibleContentRectAndScale(m_pageVisibleRect, m_contentsScale);
+ toWebGraphicsLayer(layer)->setWebGraphicsLayerClient(m_webGraphicsLayerClient);
toWebGraphicsLayer(layer)->notifyChange();
notifyChange();
}
@@ -134,7 +134,7 @@
void WebGraphicsLayer::addChildAtIndex(GraphicsLayer* layer, int index)
{
GraphicsLayer::addChildAtIndex(layer, index);
- toWebGraphicsLayer(layer)->setVisibleContentRectAndScale(m_pageVisibleRect, m_contentsScale);
+ toWebGraphicsLayer(layer)->setWebGraphicsLayerClient(m_webGraphicsLayerClient);
toWebGraphicsLayer(layer)->notifyChange();
notifyChange();
}
@@ -142,7 +142,7 @@
void WebGraphicsLayer::addChildAbove(GraphicsLayer* layer, GraphicsLayer* sibling)
{
GraphicsLayer::addChildAbove(layer, sibling);
- toWebGraphicsLayer(layer)->setVisibleContentRectAndScale(m_pageVisibleRect, m_contentsScale);
+ toWebGraphicsLayer(layer)->setWebGraphicsLayerClient(m_webGraphicsLayerClient);
toWebGraphicsLayer(layer)->notifyChange();
notifyChange();
}
@@ -150,7 +150,7 @@
void WebGraphicsLayer::addChildBelow(GraphicsLayer* layer, GraphicsLayer* sibling)
{
GraphicsLayer::addChildBelow(layer, sibling);
- toWebGraphicsLayer(layer)->setVisibleContentRectAndScale(m_pageVisibleRect, m_contentsScale);
+ toWebGraphicsLayer(layer)->setWebGraphicsLayerClient(m_webGraphicsLayerClient);
toWebGraphicsLayer(layer)->notifyChange();
notifyChange();
}
@@ -162,8 +162,7 @@
return false;
notifyChange();
toWebGraphicsLayer(oldChild)->notifyChange();
- toWebGraphicsLayer(oldChild)->setLayerTreeTileClient(0);
- toWebGraphicsLayer(newChild)->setVisibleContentRectAndScale(m_pageVisibleRect, m_contentsScale);
+ toWebGraphicsLayer(newChild)->setWebGraphicsLayerClient(m_webGraphicsLayerClient);
toWebGraphicsLayer(newChild)->notifyChange();
return true;
}
@@ -175,7 +174,6 @@
GraphicsLayer::removeFromParent();
notifyChange();
- setLayerTreeTileClient(0);
}
void WebGraphicsLayer::setPosition(const FloatPoint& p)
@@ -347,17 +345,16 @@
{
if (image == m_image)
return;
- WebLayerTreeTileClient* client = layerTreeTileClient();
int64_t newID = 0;
- if (client) {
+ if (m_webGraphicsLayerClient) {
// We adopt first, in case this is the same frame - that way we avoid destroying and recreating the image.
- newID = client->adoptImageBackingStore(image);
- client->releaseImageBackingStore(m_layerInfo.imageBackingStoreID);
+ newID = m_webGraphicsLayerClient->adoptImageBackingStore(image);
+ m_webGraphicsLayerClient->releaseImageBackingStore(m_layerInfo.imageBackingStoreID);
notifyChange();
if (m_layerInfo.imageBackingStoreID && newID == m_layerInfo.imageBackingStoreID)
return;
} else {
- // If client not set yet there should be no backing store ID.
+ // If m_webGraphicsLayerClient is not set yet there should be no backing store ID.
ASSERT(!m_layerInfo.imageBackingStoreID);
notifyChange();
}
@@ -380,9 +377,8 @@
layer->setSize(size());
WebGraphicsLayer* webGraphicsLayer = toWebGraphicsLayer(layer);
- webGraphicsLayer->setLayerTreeTileClient(layerTreeTileClient());
+ webGraphicsLayer->setWebGraphicsLayerClient(m_webGraphicsLayerClient);
webGraphicsLayer->setMaskTarget(this);
- webGraphicsLayer->setVisibleContentRectAndScale(m_pageVisibleRect, m_contentsScale);
webGraphicsLayer->notifyChange();
notifyChange();
@@ -394,7 +390,7 @@
return;
if (layer)
- toWebGraphicsLayer(layer)->setLayerTreeTileClient(layerTreeTileClient());
+ toWebGraphicsLayer(layer)->setWebGraphicsLayerClient(m_webGraphicsLayerClient);
GraphicsLayer::setReplicatedByLayer(layer);
notifyChange();
@@ -438,9 +434,6 @@
void WebGraphicsLayer::syncCompositingStateForThisLayerOnly()
{
- if (!m_layerTreeTileClient)
- m_layerTreeTileClient = layerTreeTileClient();
-
updateContentBuffers();
if (!m_modified)
@@ -469,11 +462,11 @@
for (size_t i = 0; i < children().size(); ++i)
m_layerInfo.children.append(toWebLayerID(children()[i]));
- ASSERT(m_layerTreeTileClient);
+ ASSERT(m_webGraphicsLayerClient);
if (m_layerInfo.imageIsUpdated && m_image && !m_layerInfo.imageBackingStoreID)
- m_layerInfo.imageBackingStoreID = m_layerTreeTileClient->adoptImageBackingStore(m_image.get());
+ m_layerInfo.imageBackingStoreID = m_webGraphicsLayerClient->adoptImageBackingStore(m_image.get());
- m_layerTreeTileClient->didSyncCompositingStateForLayer(m_layerInfo);
+ m_webGraphicsLayerClient->didSyncCompositingStateForLayer(m_layerInfo);
m_modified = false;
m_layerInfo.imageIsUpdated = false;
if (m_hasPendingAnimations)
@@ -512,11 +505,6 @@
m_mainBackingStore->setContentsScale(scale);
} else
m_mainBackingStore->adjustVisibleRect();
-
- if (maskLayer())
- toWebGraphicsLayer(maskLayer())->setVisibleContentRectAndScale(pageVisibleRect, scale);
- for (size_t i = 0; i < children().size(); ++i)
- toWebGraphicsLayer(children()[i])->setVisibleContentRectAndScale(pageVisibleRect, scale);
}
void WebGraphicsLayer::tiledBackingStorePaint(GraphicsContext* context, const IntRect& rect)
@@ -535,9 +523,7 @@
{
if (!m_inUpdateMode)
return false;
- if (WebLayerTreeTileClient* client = layerTreeTileClient())
- return client->layerTreeTileUpdatesAllowed();
- return false;
+ return m_webGraphicsLayerClient->layerTreeTileUpdatesAllowed();
}
IntRect WebGraphicsLayer::tiledBackingStoreContentsRect()
@@ -572,22 +558,19 @@
void WebGraphicsLayer::createTile(int tileID, const UpdateInfo& updateInfo)
{
m_modified = true;
- if (WebLayerTreeTileClient* client = layerTreeTileClient())
- client->createTile(id(), tileID, updateInfo);
+ m_webGraphicsLayerClient->createTile(id(), tileID, updateInfo);
}
void WebGraphicsLayer::updateTile(int tileID, const UpdateInfo& updateInfo)
{
m_modified = true;
- if (WebLayerTreeTileClient* client = layerTreeTileClient())
- client->updateTile(id(), tileID, updateInfo);
+ m_webGraphicsLayerClient->updateTile(id(), tileID, updateInfo);
}
void WebGraphicsLayer::removeTile(int tileID)
{
m_modified = true;
- if (WebLayerTreeTileClient* client = layerTreeTileClient())
- client->removeTile(id(), tileID);
+ m_webGraphicsLayerClient->removeTile(id(), tileID);
}
void WebGraphicsLayer::updateTileBuffersRecursively()
@@ -602,23 +585,6 @@
mask->updateTileBuffersRecursively();
}
-WebLayerTreeTileClient* WebGraphicsLayer::layerTreeTileClient() const
-{
- if (m_layerTreeTileClient)
- return m_layerTreeTileClient;
- WebGraphicsLayer* parent;
- if (this->replicatedLayer())
- parent = toWebGraphicsLayer(this->replicatedLayer());
- else if (this->maskTarget())
- parent = toWebGraphicsLayer(this->maskTarget());
- else
- parent = toWebGraphicsLayer(this->parent());
-
- if (!parent)
- return 0;
- return parent->layerTreeTileClient();
-}
-
void WebGraphicsLayer::updateContentBuffers()
{
// Backing-stores for directly composited images is handled in LayerTreeHost.
@@ -627,9 +593,7 @@
if (!drawsContent())
return;
- WebLayerTreeTileClient* client = layerTreeTileClient();
- if (!client)
- return;
+
m_inUpdateMode = true;
m_mainBackingStore->updateTileBuffers();
m_inUpdateMode = false;
@@ -651,7 +615,7 @@
if (!m_layerInfo.imageBackingStoreID)
return;
- layerTreeTileClient()->releaseImageBackingStore(m_layerInfo.imageBackingStoreID);
+ m_webGraphicsLayerClient->releaseImageBackingStore(m_layerInfo.imageBackingStoreID);
m_layerInfo.imageBackingStoreID = 0;
}
@@ -673,24 +637,26 @@
setContentsNeedsDisplay();
}
-void WebGraphicsLayer::setLayerTreeTileClient(WebKit::WebLayerTreeTileClient* client)
+void WebGraphicsLayer::setWebGraphicsLayerClient(WebKit::WebGraphicsLayerClient* client)
{
- if (m_layerTreeTileClient == client)
+ if (m_webGraphicsLayerClient == client)
return;
if (WebGraphicsLayer* replica = toWebGraphicsLayer(replicaLayer()))
- replica->setLayerTreeTileClient(client);
+ replica->setWebGraphicsLayerClient(client);
if (WebGraphicsLayer* mask = toWebGraphicsLayer(maskLayer()))
- mask->setLayerTreeTileClient(client);
+ mask->setWebGraphicsLayerClient(client);
for (size_t i = 0; i < children().size(); ++i) {
WebGraphicsLayer* layer = toWebGraphicsLayer(this->children()[i]);
- layer->setLayerTreeTileClient(client);
+ layer->setWebGraphicsLayerClient(client);
}
// Have to force detach from remote layer here if layer tile client changes.
- if (m_layerTreeTileClient)
- m_layerTreeTileClient->didDeleteLayer(id());
- m_layerTreeTileClient = client;
+ if (m_webGraphicsLayerClient)
+ m_webGraphicsLayerClient->detachLayer(this);
+ m_webGraphicsLayerClient = client;
+ if (client)
+ client->attachLayer(this);
}
void WebGraphicsLayer::computeTransformedVisibleRect()
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h (107232 => 107233)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h 2012-02-09 14:31:44 UTC (rev 107232)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h 2012-02-09 14:33:33 UTC (rev 107233)
@@ -39,19 +39,25 @@
#if USE(ACCELERATED_COMPOSITING)
+namespace WebCore {
+class WebGraphicsLayer;
+}
+
namespace WebKit {
-class WebLayerTreeTileClient {
+class WebGraphicsLayerClient {
public:
// TiledBackingStoreRemoteTileClient
virtual void createTile(WebLayerID, int tileID, const UpdateInfo&) = 0;
virtual void updateTile(WebLayerID, int tileID, const UpdateInfo&) = 0;
virtual void removeTile(WebLayerID, int tileID) = 0;
+
virtual bool layerTreeTileUpdatesAllowed() const = 0;
virtual int64_t adoptImageBackingStore(WebCore::Image*) = 0;
virtual void releaseImageBackingStore(int64_t) = 0;
virtual void didSyncCompositingStateForLayer(const WebLayerInfo&) = 0;
- virtual void didDeleteLayer(WebLayerID) = 0;
+ virtual void attachLayer(WebCore::WebGraphicsLayer*) = 0;
+ virtual void detachLayer(WebCore::WebGraphicsLayer*) = 0;
};
}
@@ -129,8 +135,7 @@
virtual void updateTile(int tileID, const WebKit::UpdateInfo&);
virtual void removeTile(int tileID);
- void setLayerTreeTileClient(WebKit::WebLayerTreeTileClient*);
- WebKit::WebLayerTreeTileClient* layerTreeTileClient() const;
+ void setWebGraphicsLayerClient(WebKit::WebGraphicsLayerClient*);
bool isReadyForTileBufferSwap() const;
void updateTileBuffersRecursively();
@@ -161,7 +166,7 @@
#if USE(TILED_BACKING_STORE)
void computeTransformedVisibleRect();
- WebKit::WebLayerTreeTileClient* m_layerTreeTileClient;
+ WebKit::WebGraphicsLayerClient* m_webGraphicsLayerClient;
OwnPtr<WebCore::TiledBackingStore> m_mainBackingStore;
OwnPtr<WebCore::TiledBackingStore> m_previousBackingStore;
float m_contentsScale;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp (107232 => 107233)
--- trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp 2012-02-09 14:31:44 UTC (rev 107232)
+++ trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp 2012-02-09 14:33:33 UTC (rev 107233)
@@ -52,8 +52,13 @@
LayerTreeHostQt::~LayerTreeHostQt()
{
- if (m_rootLayer)
- toWebGraphicsLayer(m_rootLayer.get())->setLayerTreeTileClient(0);
+ // Prevent setWebGraphicsLayerClient(0) -> detachLayer() from modifying the set while we iterate it.
+ HashSet<WebCore::WebGraphicsLayer*> registeredLayers;
+ registeredLayers.swap(m_registeredLayers);
+
+ HashSet<WebCore::WebGraphicsLayer*>::iterator end = registeredLayers.end();
+ for (HashSet<WebCore::WebGraphicsLayer*>::iterator it = registeredLayers.begin(); it != end; ++it)
+ (*it)->setWebGraphicsLayerClient(0);
}
LayerTreeHostQt::LayerTreeHostQt(WebPage* webPage)
@@ -63,6 +68,7 @@
#if USE(TILED_BACKING_STORE)
, m_waitingForUIProcess(false)
, m_isSuspended(false)
+ , m_contentsScale(1)
#endif
, m_shouldSyncFrame(false)
, m_shouldSyncRootLayer(true)
@@ -83,7 +89,7 @@
m_nonCompositedContentLayer = GraphicsLayer::create(this);
#if USE(TILED_BACKING_STORE)
- toWebGraphicsLayer(m_rootLayer.get())->setLayerTreeTileClient(this);
+ toWebGraphicsLayer(m_rootLayer.get())->setWebGraphicsLayerClient(this);
#endif
#ifndef NDEBUG
m_nonCompositedContentLayer->setName("LayerTreeHostQt non-composited content");
@@ -232,10 +238,19 @@
m_webPage->send(Messages::LayerTreeHostProxy::SyncCompositingLayerState(info));
}
-void LayerTreeHostQt::didDeleteLayer(WebLayerID id)
+void LayerTreeHostQt::attachLayer(WebGraphicsLayer* layer)
{
+ ASSERT(!m_registeredLayers.contains(layer));
+ m_registeredLayers.add(layer);
+
+ layer->setVisibleContentRectAndScale(m_visibleContentsRect, m_contentsScale);
+}
+
+void LayerTreeHostQt::detachLayer(WebGraphicsLayer* layer)
+{
+ m_registeredLayers.remove(layer);
m_shouldSyncFrame = true;
- m_webPage->send(Messages::LayerTreeHostProxy::DeleteCompositingLayer(id));
+ m_webPage->send(Messages::LayerTreeHostProxy::DeleteCompositingLayer(layer->id()));
}
void LayerTreeHostQt::performScheduledLayerFlush()
@@ -403,10 +418,15 @@
void LayerTreeHostQt::setVisibleContentRectAndScale(const IntRect& rect, float scale)
{
- if (m_rootLayer) {
- toWebGraphicsLayer(m_rootLayer.get())->setVisibleContentRectAndScale(rect, scale);
- scheduleLayerFlush();
- }
+ if (rect == m_visibleContentsRect && scale == m_contentsScale)
+ return;
+ m_visibleContentsRect = rect;
+ m_contentsScale = scale;
+
+ HashSet<WebCore::WebGraphicsLayer*>::iterator end = m_registeredLayers.end();
+ for (HashSet<WebCore::WebGraphicsLayer*>::iterator it = m_registeredLayers.begin(); it != end; ++it)
+ (*it)->setVisibleContentRectAndScale(rect, scale);
+ scheduleLayerFlush();
}
void LayerTreeHostQt::setVisibleContentRectTrajectoryVector(const FloatPoint& trajectoryVector)
Modified: trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h (107232 => 107233)
--- trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h 2012-02-09 14:31:44 UTC (rev 107232)
+++ trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h 2012-02-09 14:33:33 UTC (rev 107233)
@@ -34,7 +34,7 @@
class LayerTreeHostQt : public LayerTreeHost, WebCore::GraphicsLayerClient
#if USE(TILED_BACKING_STORE)
- , public WebLayerTreeTileClient
+ , public WebGraphicsLayerClient
#endif
{
public:
@@ -75,7 +75,8 @@
virtual void setVisibleContentRectAndScale(const WebCore::IntRect&, float scale);
virtual void setVisibleContentRectTrajectoryVector(const WebCore::FloatPoint&);
virtual void didSyncCompositingStateForLayer(const WebLayerInfo&);
- virtual void didDeleteLayer(WebLayerID);
+ virtual void attachLayer(WebCore::WebGraphicsLayer*);
+ virtual void detachLayer(WebCore::WebGraphicsLayer*);
#endif
protected:
@@ -106,6 +107,7 @@
// The page overlay layer. Will be null if there's no page overlay.
OwnPtr<WebCore::GraphicsLayer> m_pageOverlayLayer;
+ HashSet<WebCore::WebGraphicsLayer*> m_registeredLayers;
HashMap<int64_t, int> m_directlyCompositedImageRefCounts;
bool m_notifyAfterScheduledLayerFlush;
@@ -113,6 +115,8 @@
#if USE(TILED_BACKING_STORE)
bool m_waitingForUIProcess;
bool m_isSuspended;
+ WebCore::IntRect m_visibleContentsRect;
+ float m_contentsScale;
#endif
LayerTreeContext m_layerTreeContext;
bool m_shouldSyncFrame;