Diff
Modified: trunk/Source/WebKit2/ChangeLog (138467 => 138468)
--- trunk/Source/WebKit2/ChangeLog 2012-12-26 01:56:48 UTC (rev 138467)
+++ trunk/Source/WebKit2/ChangeLog 2012-12-26 02:04:45 UTC (rev 138468)
@@ -1,3 +1,51 @@
+2012-12-25 Huang Dongsung <[email protected]>
+
+ Coordinated Graphics: Manage the lifecycle of CoordinatedGraphicsLayer explicitly.
+ https://bugs.webkit.org/show_bug.cgi?id=104990
+
+ Reviewed by Noam Rosenthal.
+
+ Send explicit commands to the UI process to create/delete compositing
+ layers, instead of having the UI process decide lazily when to create
+ them.
+
+ Avoid creating a compositing layer at all if it was deleted in the same
+ cycle.
+
+ * UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp:
+ (WebKit::CoordinatedLayerTreeHostProxy::createCompositingLayer):
+ (WebKit):
+ * UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h:
+ (CoordinatedLayerTreeHostProxy):
+ * UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.messages.in:
+ * UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp:
+ (WebKit::LayerTreeRenderer::createCanvas):
+ (WebKit::LayerTreeRenderer::destroyCanvas):
+ (WebKit::LayerTreeRenderer::setLayerChildren):
+ (WebKit::LayerTreeRenderer::setLayerFilters):
+ (WebKit::LayerTreeRenderer::setLayerState):
+ (WebKit::LayerTreeRenderer::getLayerByIDIfExists):
+ (WebKit):
+ (WebKit::LayerTreeRenderer::createLayer):
+ (WebKit::LayerTreeRenderer::deleteLayer):
+ (WebKit::LayerTreeRenderer::setRootLayerID):
+ (WebKit::LayerTreeRenderer::createTile):
+ (WebKit::LayerTreeRenderer::removeTile):
+ (WebKit::LayerTreeRenderer::updateTile):
+ (WebKit::LayerTreeRenderer::ensureRootLayer):
+ (WebKit::LayerTreeRenderer::setLayerAnimations):
+ * UIProcess/CoordinatedGraphics/LayerTreeRenderer.h:
+ (LayerTreeRenderer):
+ (WebKit::LayerTreeRenderer::layerByID):
+ * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
+ (WebKit::CoordinatedLayerTreeHost::flushPendingLayerChanges):
+ (WebKit::CoordinatedLayerTreeHost::createCompositingLayers):
+ (WebKit):
+ (WebKit::CoordinatedLayerTreeHost::deleteCompositingLayers):
+ (WebKit::CoordinatedLayerTreeHost::detachLayer):
+ (WebKit::CoordinatedLayerTreeHost::createGraphicsLayer):
+ * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
+
2012-12-25 Sam Weinig <[email protected]>
Fix Qt build.
Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp (138467 => 138468)
--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp 2012-12-26 01:56:48 UTC (rev 138467)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp 2012-12-26 02:04:45 UTC (rev 138468)
@@ -95,6 +95,11 @@
m_surfaces.remove(atlasID);
}
+void CoordinatedLayerTreeHostProxy::createCompositingLayer(CoordinatedLayerID id)
+{
+ dispatchUpdate(bind(&LayerTreeRenderer::createLayer, m_renderer.get(), id));
+}
+
void CoordinatedLayerTreeHostProxy::deleteCompositingLayer(CoordinatedLayerID id)
{
dispatchUpdate(bind(&LayerTreeRenderer::deleteLayer, m_renderer.get(), id));
Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h (138467 => 138468)
--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h 2012-12-26 01:56:48 UTC (rev 138467)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h 2012-12-26 02:04:45 UTC (rev 138468)
@@ -60,6 +60,7 @@
void createCustomFilterProgram(int id, const WebCore::CustomFilterProgramInfo&);
void removeCustomFilterProgram(int id);
#endif
+ void createCompositingLayer(CoordinatedLayerID);
void deleteCompositingLayer(CoordinatedLayerID);
void setRootCompositingLayer(CoordinatedLayerID);
void setContentsSize(const WebCore::FloatSize&);
Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.messages.in (138467 => 138468)
--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.messages.in 2012-12-26 01:56:48 UTC (rev 138467)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.messages.in 2012-12-26 02:04:45 UTC (rev 138468)
@@ -29,6 +29,7 @@
RemoveCustomFilterProgram(int id)
#endif
SetRootCompositingLayer(uint32_t id)
+ CreateCompositingLayer(uint32_t id)
DeleteCompositingLayer(uint32_t id)
CreateTileForLayer(uint32_t layerID, uint32_t tileID, WebCore::IntRect tileRect, WebKit::SurfaceUpdateInfo updateInfo)
UpdateTileForLayer(uint32_t layerID, uint32_t tileID, WebCore::IntRect tileRect, WebKit::SurfaceUpdateInfo updateInfo)
Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp (138467 => 138468)
--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp 2012-12-26 01:56:48 UTC (rev 138467)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp 2012-12-26 02:04:45 UTC (rev 138468)
@@ -89,13 +89,6 @@
{
}
-PassOwnPtr<GraphicsLayer> LayerTreeRenderer::createLayer(CoordinatedLayerID)
-{
- GraphicsLayerTextureMapper* newLayer = new GraphicsLayerTextureMapper(this);
- newLayer->setHasOwnBackingStore(false);
- return adoptPtr(newLayer);
-}
-
void LayerTreeRenderer::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity, const FloatRect& clipRect, TextureMapper::PaintFlags PaintFlags)
{
if (!m_textureMapper) {
@@ -231,7 +224,6 @@
{
ASSERT(m_textureMapper);
GraphicsLayer* layer = layerByID(id);
- ASSERT(layer);
ASSERT(!m_surfaceBackingStores.contains(id));
RefPtr<TextureMapperSurfaceBackingStore> canvasBackingStore(TextureMapperSurfaceBackingStore::create());
@@ -256,7 +248,6 @@
{
ASSERT(m_textureMapper);
GraphicsLayer* layer = layerByID(id);
- ASSERT(layer);
ASSERT(m_surfaceBackingStores.contains(id));
m_surfaceBackingStores.remove(id);
@@ -266,17 +257,12 @@
void LayerTreeRenderer::setLayerChildren(CoordinatedLayerID id, const Vector<CoordinatedLayerID>& childIDs)
{
- GraphicsLayer* layer = ensureLayer(id);
+ GraphicsLayer* layer = layerByID(id);
Vector<GraphicsLayer*> children;
for (size_t i = 0; i < childIDs.size(); ++i) {
CoordinatedLayerID childID = childIDs[i];
GraphicsLayer* child = layerByID(childID);
- if (!child) {
- OwnPtr<GraphicsLayer*> newChild = createLayer(childID);
- child = newChild.get();
- m_layers.add(childID, newChild.release());
- }
children.append(child);
}
layer->setChildren(children);
@@ -285,7 +271,7 @@
#if ENABLE(CSS_FILTERS)
void LayerTreeRenderer::setLayerFilters(CoordinatedLayerID id, const FilterOperations& filters)
{
- GraphicsLayer* layer = ensureLayer(id);
+ GraphicsLayer* layer = layerByID(id);
#if ENABLE(CSS_SHADERS)
injectCachedCustomFilterPrograms(filters);
@@ -329,10 +315,10 @@
void LayerTreeRenderer::setLayerState(CoordinatedLayerID id, const CoordinatedLayerInfo& layerInfo)
{
ASSERT(m_rootLayerID != InvalidCoordinatedLayerID);
- GraphicsLayer* layer = ensureLayer(id);
+ GraphicsLayer* layer = layerByID(id);
- layer->setReplicatedByLayer(layerByID(layerInfo.replica));
- layer->setMaskLayer(layerByID(layerInfo.mask));
+ layer->setReplicatedByLayer(getLayerByIDIfExists(layerInfo.replica));
+ layer->setMaskLayer(getLayerByIDIfExists(layerInfo.mask));
layer->setAnchorPoint(layerInfo.anchorPoint);
layer->setPosition(layerInfo.pos);
@@ -362,11 +348,22 @@
layer->setPreserves3D(layerInfo.preserves3D);
}
+GraphicsLayer* LayerTreeRenderer::getLayerByIDIfExists(CoordinatedLayerID id)
+{
+ return (id != InvalidCoordinatedLayerID) ? layerByID(id) : 0;
+}
+
+void LayerTreeRenderer::createLayer(CoordinatedLayerID id)
+{
+ OwnPtr<WebCore::GraphicsLayer> newLayer = GraphicsLayer::create(0 /* factory */, this);
+ toGraphicsLayerTextureMapper(newLayer.get())->setHasOwnBackingStore(false);
+ m_layers.add(id, newLayer.release());
+}
+
void LayerTreeRenderer::deleteLayer(CoordinatedLayerID layerID)
{
OwnPtr<GraphicsLayer> layer = m_layers.take(layerID);
- if (!layer)
- return;
+ ASSERT(layer);
layer->removeFromParent();
m_pendingSyncBackingStores.remove(toTextureMapperLayer(layer.get()));
@@ -376,20 +373,6 @@
#endif
}
-
-WebCore::GraphicsLayer* LayerTreeRenderer::ensureLayer(CoordinatedLayerID id)
-{
- LayerMap::iterator it = m_layers.find(id);
- if (it != m_layers.end())
- return it->value.get();
-
- OwnPtr<WebCore::GraphicsLayer> newLayer = createLayer(id);
- WebCore::GraphicsLayer* layer = newLayer.get();
- m_layers.add(id, newLayer.release());
-
- return layer;
-}
-
void LayerTreeRenderer::setRootLayerID(CoordinatedLayerID layerID)
{
ASSERT(layerID != InvalidCoordinatedLayerID);
@@ -398,7 +381,7 @@
m_rootLayerID = layerID;
m_rootLayer->removeAllChildren();
- GraphicsLayer* layer = ensureLayer(layerID);
+ GraphicsLayer* layer = layerByID(layerID);
m_rootLayer->addChild(layer);
}
@@ -482,7 +465,6 @@
void LayerTreeRenderer::createTile(CoordinatedLayerID layerID, uint32_t tileID, float scale)
{
GraphicsLayer* layer = layerByID(layerID);
- ASSERT(layer);
CoordinatedBackingStore* backingStore = getBackingStore(layer);
ASSERT(backingStore);
backingStore->createTile(tileID, scale);
@@ -492,7 +474,6 @@
void LayerTreeRenderer::removeTile(CoordinatedLayerID layerID, uint32_t tileID)
{
GraphicsLayer* layer = layerByID(layerID);
- ASSERT(layer);
CoordinatedBackingStore* backingStore = getBackingStore(layer);
if (!backingStore)
return;
@@ -505,7 +486,6 @@
void LayerTreeRenderer::updateTile(CoordinatedLayerID layerID, uint32_t tileID, const TileUpdate& update)
{
GraphicsLayer* layer = layerByID(layerID);
- ASSERT(layer);
RefPtr<CoordinatedBackingStore> backingStore = getBackingStore(layer);
ASSERT(backingStore);
backingStore->updateTile(tileID, update.sourceRect, update.tileRect, update.surface, update.offset);
@@ -614,7 +594,7 @@
if (m_rootLayer)
return;
- m_rootLayer = createLayer(InvalidCoordinatedLayerID);
+ m_rootLayer = GraphicsLayer::create(0 /* factory */, this);
m_rootLayer->setMasksToBounds(false);
m_rootLayer->setDrawsContent(false);
m_rootLayer->setAnchorPoint(FloatPoint3D(0, 0, 0));
@@ -677,8 +657,6 @@
void LayerTreeRenderer::setLayerAnimations(CoordinatedLayerID id, const GraphicsLayerAnimations& animations)
{
GraphicsLayerTextureMapper* layer = toGraphicsLayerTextureMapper(layerByID(id));
- if (!layer)
- return;
#if ENABLE(CSS_SHADERS)
for (size_t i = 0; i < animations.animations().size(); ++i) {
const KeyframeValueList& keyframes = animations.animations().at(i).keyframes();
Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h (138467 => 138468)
--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h 2012-12-26 01:56:48 UTC (rev 138467)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h 2012-12-26 02:04:45 UTC (rev 138468)
@@ -86,6 +86,7 @@
void purgeGLResources();
void setActive(bool);
+ void createLayer(CoordinatedLayerID);
void deleteLayer(CoordinatedLayerID);
void setRootLayerID(CoordinatedLayerID);
void setLayerChildren(CoordinatedLayerID, const Vector<CoordinatedLayerID>&);
@@ -117,9 +118,13 @@
#endif
private:
- PassOwnPtr<WebCore::GraphicsLayer> createLayer(CoordinatedLayerID);
-
- WebCore::GraphicsLayer* layerByID(CoordinatedLayerID id) { return (id == InvalidCoordinatedLayerID) ? 0 : m_layers.get(id); }
+ WebCore::GraphicsLayer* layerByID(CoordinatedLayerID id)
+ {
+ ASSERT(m_layers.contains(id));
+ ASSERT(id != InvalidCoordinatedLayerID);
+ return m_layers.get(id);
+ }
+ WebCore::GraphicsLayer* getLayerByIDIfExists(CoordinatedLayerID);
WebCore::GraphicsLayer* rootLayer() { return m_rootLayer.get(); }
void syncRemoteContent();
@@ -141,7 +146,6 @@
void assignImageBackingToLayer(WebCore::GraphicsLayer*, CoordinatedImageBackingID);
void removeReleasedImageBackingsIfNeeded();
void ensureRootLayer();
- WebCore::GraphicsLayer* ensureLayer(CoordinatedLayerID);
void commitPendingBackingStoreOperations();
CoordinatedBackingStore* getBackingStore(WebCore::GraphicsLayer*);
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp (138467 => 138468)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp 2012-12-26 01:56:48 UTC (rev 138467)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp 2012-12-26 02:04:45 UTC (rev 138468)
@@ -269,6 +269,8 @@
TemporaryChange<bool> protector(m_isFlushingLayerChanges, true);
+ createCompositingLayers();
+
initializeRootCompositingLayerIfNeeded();
m_rootLayer->flushCompositingStateForThisLayerOnly();
@@ -280,9 +282,7 @@
flushPendingImageBackingChanges();
- for (size_t i = 0; i < m_detachedLayers.size(); ++i)
- m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::DeleteCompositingLayer(m_detachedLayers[i]));
- m_detachedLayers.clear();
+ deleteCompositingLayers();
if (m_shouldSyncFrame) {
didSync = true;
@@ -303,6 +303,42 @@
return didSync;
}
+void CoordinatedLayerTreeHost::createCompositingLayers()
+{
+ if (m_layersToCreate.isEmpty())
+ return;
+
+ // If a layer gets created and deleted in the same cycle, we can simply remove it from m_layersToCreate and m_layersToDelete.
+ for (int i = m_layersToCreate.size() - 1; i >= 0; --i) {
+ size_t index = m_layersToDelete.find(m_layersToCreate[i]);
+ if (index != notFound) {
+ m_layersToCreate.remove(i);
+ m_layersToDelete.remove(index);
+ }
+ }
+
+ for (size_t i = 0; i < m_layersToCreate.size(); ++i)
+ m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::CreateCompositingLayer(m_layersToCreate[i]));
+ m_layersToCreate.clear();
+ m_shouldSyncFrame = true;
+}
+
+void CoordinatedLayerTreeHost::deleteCompositingLayers()
+{
+ if (m_layersToDelete.isEmpty())
+ return;
+
+ if (m_isPurging) {
+ m_layersToDelete.clear();
+ return;
+ }
+
+ for (size_t i = 0; i < m_layersToDelete.size(); ++i)
+ m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::DeleteCompositingLayer(m_layersToDelete[i]));
+ m_layersToDelete.clear();
+ m_shouldSyncFrame = true;
+}
+
void CoordinatedLayerTreeHost::initializeRootCompositingLayerIfNeeded()
{
if (m_didInitializeRootCompositingLayer)
@@ -422,8 +458,7 @@
void CoordinatedLayerTreeHost::detachLayer(CoordinatedGraphicsLayer* layer)
{
m_registeredLayers.remove(layer);
- m_shouldSyncFrame = true;
- m_detachedLayers.append(layer->id());
+ m_layersToDelete.append(layer->id());
scheduleLayerFlush();
}
@@ -637,8 +672,10 @@
CoordinatedGraphicsLayer* layer = new CoordinatedGraphicsLayer(client);
layer->setCoordinator(this);
m_registeredLayers.add(layer);
+ m_layersToCreate.append(layer->id());
layer->setContentsScale(m_contentsScale);
layer->setNeedsVisibleRectAdjustment();
+ scheduleLayerFlush();
return adoptPtr(layer);
}
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h (138467 => 138468)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h 2012-12-26 01:56:48 UTC (rev 138467)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h 2012-12-26 02:04:45 UTC (rev 138468)
@@ -140,6 +140,8 @@
void createPageOverlayLayer();
void destroyPageOverlayLayer();
bool flushPendingLayerChanges();
+ void createCompositingLayers();
+ void deleteCompositingLayers();
void cancelPendingLayerFlush();
void performScheduledLayerFlush();
void didPerformScheduledLayerFlush();
@@ -173,7 +175,8 @@
OwnPtr<WebCore::GraphicsLayer> m_pageOverlayLayer;
HashSet<WebCore::CoordinatedGraphicsLayer*> m_registeredLayers;
- Vector<CoordinatedLayerID> m_detachedLayers;
+ Vector<CoordinatedLayerID> m_layersToCreate;
+ Vector<CoordinatedLayerID> m_layersToDelete;
typedef HashMap<CoordinatedImageBackingID, RefPtr<CoordinatedImageBacking> > ImageBackingMap;
ImageBackingMap m_imageBackings;
Vector<OwnPtr<UpdateAtlas> > m_updateAtlases;