| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 gatherGraphicsLayers(replica, layerIdToNodeIdMap, layers); | 101 gatherGraphicsLayers(replica, layerIdToNodeIdMap, layers); |
| 102 for (size_t i = 0, size = root->children().size(); i < size; ++i) | 102 for (size_t i = 0, size = root->children().size(); i < size; ++i) |
| 103 gatherGraphicsLayers(root->children()[i], layerIdToNodeIdMap, layers); | 103 gatherGraphicsLayers(root->children()[i], layerIdToNodeIdMap, layers); |
| 104 } | 104 } |
| 105 | 105 |
| 106 InspectorLayerTreeAgent::InspectorLayerTreeAgent(InstrumentingAgents* instrument
ingAgents, InspectorCompositeState* state, InspectorDOMAgent* domAgent, Page* pa
ge) | 106 InspectorLayerTreeAgent::InspectorLayerTreeAgent(InstrumentingAgents* instrument
ingAgents, InspectorCompositeState* state, InspectorDOMAgent* domAgent, Page* pa
ge) |
| 107 : InspectorBaseAgent<InspectorLayerTreeAgent>("LayerTree", instrumentingAgen
ts, state) | 107 : InspectorBaseAgent<InspectorLayerTreeAgent>("LayerTree", instrumentingAgen
ts, state) |
| 108 , m_frontend(0) | 108 , m_frontend(0) |
| 109 , m_page(page) | 109 , m_page(page) |
| 110 , m_domAgent(domAgent) | 110 , m_domAgent(domAgent) |
| 111 , m_notificationTimer(this, &InspectorLayerTreeAgent::notificationTimerFired
) |
| 112 , m_notifyAfterNextLayersUpdate(false) |
| 111 { | 113 { |
| 112 } | 114 } |
| 113 | 115 |
| 114 InspectorLayerTreeAgent::~InspectorLayerTreeAgent() | 116 InspectorLayerTreeAgent::~InspectorLayerTreeAgent() |
| 115 { | 117 { |
| 116 } | 118 } |
| 117 | 119 |
| 118 void InspectorLayerTreeAgent::setFrontend(InspectorFrontend* frontend) | 120 void InspectorLayerTreeAgent::setFrontend(InspectorFrontend* frontend) |
| 119 { | 121 { |
| 120 m_frontend = frontend->layertree(); | 122 m_frontend = frontend->layertree(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 135 | 137 |
| 136 void InspectorLayerTreeAgent::enable(ErrorString*) | 138 void InspectorLayerTreeAgent::enable(ErrorString*) |
| 137 { | 139 { |
| 138 m_instrumentingAgents->setInspectorLayerTreeAgent(this); | 140 m_instrumentingAgents->setInspectorLayerTreeAgent(this); |
| 139 layerTreeDidChange(); | 141 layerTreeDidChange(); |
| 140 } | 142 } |
| 141 | 143 |
| 142 void InspectorLayerTreeAgent::disable(ErrorString*) | 144 void InspectorLayerTreeAgent::disable(ErrorString*) |
| 143 { | 145 { |
| 144 m_instrumentingAgents->setInspectorLayerTreeAgent(0); | 146 m_instrumentingAgents->setInspectorLayerTreeAgent(0); |
| 147 m_notificationTimer.stop(); |
| 145 } | 148 } |
| 146 | 149 |
| 147 void InspectorLayerTreeAgent::layerTreeDidChange() | 150 void InspectorLayerTreeAgent::layerTreeDidChange() |
| 148 { | 151 { |
| 152 if (m_notificationTimer.isActive()) |
| 153 return; |
| 154 if (m_notifyAfterNextLayersUpdate) { |
| 155 m_notifyAfterNextLayersUpdate = false; |
| 156 m_frontend->layerTreeDidChange(buildLayerTree()); |
| 157 return; |
| 158 } |
| 159 const double layerTreeUpdateDelayInSeconds = 0.1; |
| 160 m_notificationTimer.startOneShot(layerTreeUpdateDelayInSeconds); |
| 161 } |
| 162 |
| 163 void InspectorLayerTreeAgent::notificationTimerFired(Timer<InspectorLayerTreeAge
nt>*) |
| 164 { |
| 165 RenderLayerCompositor* compositor = renderLayerCompositor(); |
| 166 if (compositor && compositor->compositingLayersNeedRebuild()) { |
| 167 // Bad time for building layer tree -- let's do it as soon as it gets re
build. |
| 168 m_notifyAfterNextLayersUpdate = true; |
| 169 return; |
| 170 } |
| 149 m_frontend->layerTreeDidChange(buildLayerTree()); | 171 m_frontend->layerTreeDidChange(buildLayerTree()); |
| 150 } | 172 } |
| 151 | 173 |
| 152 void InspectorLayerTreeAgent::didPaint(RenderObject* renderer, GraphicsContext*,
const LayoutRect& rect) | 174 void InspectorLayerTreeAgent::didPaint(RenderObject* renderer, GraphicsContext*,
const LayoutRect& rect) |
| 153 { | 175 { |
| 154 RenderLayer* renderLayer = toRenderLayerModelObject(renderer)->layer(); | 176 RenderLayer* renderLayer = toRenderLayerModelObject(renderer)->layer(); |
| 155 CompositedLayerMapping* compositedLayerMapping = renderLayer->compositedLaye
rMapping(); | 177 CompositedLayerMapping* compositedLayerMapping = renderLayer->compositedLaye
rMapping(); |
| 156 // Should only happen for FrameView paints when compositing is off. Consider
different instrumentation method for that. | 178 // Should only happen for FrameView paints when compositing is off. Consider
different instrumentation method for that. |
| 157 if (!compositedLayerMapping) | 179 if (!compositedLayerMapping) |
| 158 return; | 180 return; |
| 159 GraphicsLayer* graphicsLayer = compositedLayerMapping->mainGraphicsLayer(); | 181 GraphicsLayer* graphicsLayer = compositedLayerMapping->mainGraphicsLayer(); |
| 160 RefPtr<TypeBuilder::DOM::Rect> domRect = TypeBuilder::DOM::Rect::create() | 182 RefPtr<TypeBuilder::DOM::Rect> domRect = TypeBuilder::DOM::Rect::create() |
| 161 .setX(rect.x()) | 183 .setX(rect.x()) |
| 162 .setY(rect.y()) | 184 .setY(rect.y()) |
| 163 .setWidth(rect.width()) | 185 .setWidth(rect.width()) |
| 164 .setHeight(rect.height()); | 186 .setHeight(rect.height()); |
| 165 m_frontend->layerPainted(idForLayer(graphicsLayer), domRect.release()); | 187 m_frontend->layerPainted(idForLayer(graphicsLayer), domRect.release()); |
| 166 } | 188 } |
| 167 | 189 |
| 168 PassRefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > InspectorLayerTre
eAgent::buildLayerTree() | 190 PassRefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > InspectorLayerTre
eAgent::buildLayerTree() |
| 169 { | 191 { |
| 170 RenderLayerCompositor* compositor = renderLayerCompositor(); | 192 RenderLayerCompositor* compositor = renderLayerCompositor(); |
| 171 if (!compositor || !compositor->inCompositingMode()) | 193 if (!compositor || !compositor->inCompositingMode()) |
| 172 return 0; | 194 return 0; |
| 195 // Caller is responsible for only calling this when layer tree is up to date
(preferrably just in the end of RenderLayerCompositor::updateCompositingLayers(
) |
| 196 ASSERT(!compositor->compositingLayersNeedRebuild()); |
| 173 LayerIdToNodeIdMap layerIdToNodeIdMap; | 197 LayerIdToNodeIdMap layerIdToNodeIdMap; |
| 174 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > layers = TypeBuil
der::Array<TypeBuilder::LayerTree::Layer>::create(); | 198 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > layers = TypeBuil
der::Array<TypeBuilder::LayerTree::Layer>::create(); |
| 175 buildLayerIdToNodeIdMap(compositor->rootRenderLayer(), layerIdToNodeIdMap); | 199 buildLayerIdToNodeIdMap(compositor->rootRenderLayer(), layerIdToNodeIdMap); |
| 176 gatherGraphicsLayers(compositor->rootGraphicsLayer(), layerIdToNodeIdMap, la
yers); | 200 gatherGraphicsLayers(compositor->rootGraphicsLayer(), layerIdToNodeIdMap, la
yers); |
| 177 return layers.release(); | 201 return layers.release(); |
| 178 } | 202 } |
| 179 | 203 |
| 180 void InspectorLayerTreeAgent::buildLayerIdToNodeIdMap(RenderLayer* root, LayerId
ToNodeIdMap& layerIdToNodeIdMap) | 204 void InspectorLayerTreeAgent::buildLayerIdToNodeIdMap(RenderLayer* root, LayerId
ToNodeIdMap& layerIdToNodeIdMap) |
| 181 { | 205 { |
| 182 if (root->compositedLayerMapping()) { | 206 if (root->compositedLayerMapping()) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 continue; | 322 continue; |
| 299 reasonStrings->addItem(compositingReasonNames[i].protocolName); | 323 reasonStrings->addItem(compositingReasonNames[i].protocolName); |
| 300 #ifndef _NDEBUG | 324 #ifndef _NDEBUG |
| 301 reasonsBitmask &= ~compositingReasonNames[i].mask; | 325 reasonsBitmask &= ~compositingReasonNames[i].mask; |
| 302 #endif | 326 #endif |
| 303 } | 327 } |
| 304 ASSERT(!reasonsBitmask); | 328 ASSERT(!reasonsBitmask); |
| 305 } | 329 } |
| 306 | 330 |
| 307 } // namespace WebCore | 331 } // namespace WebCore |
| OLD | NEW |