Chromium Code Reviews| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 transformArray->addItem(flattenedMatrix[i]); | 103 transformArray->addItem(flattenedMatrix[i]); |
| 104 layerObject->setTransform(transformArray); | 104 layerObject->setTransform(transformArray); |
| 105 const FloatPoint3D& anchor = graphicsLayer->anchorPoint(); | 105 const FloatPoint3D& anchor = graphicsLayer->anchorPoint(); |
| 106 layerObject->setAnchorX(anchor.x()); | 106 layerObject->setAnchorX(anchor.x()); |
| 107 layerObject->setAnchorY(anchor.y()); | 107 layerObject->setAnchorY(anchor.y()); |
| 108 layerObject->setAnchorZ(anchor.z()); | 108 layerObject->setAnchorZ(anchor.z()); |
| 109 } | 109 } |
| 110 return layerObject; | 110 return layerObject; |
| 111 } | 111 } |
| 112 | 112 |
| 113 static void addRegionObjects(const blink::WebVector<blink::WebRect>& regions, | |
| 114 TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect>& scrollRects, | |
| 115 const TypeBuilder::LayerTree::ScrollRect::Type::Enum& type, | |
| 116 const TypeBuilder::LayerTree::LayerId& layerId) | |
| 117 { | |
| 118 for (size_t i = 0; i < regions.size(); ++i) { | |
| 119 RefPtr<TypeBuilder::LayerTree::ScrollRect> regionObject = TypeBuilder::L ayerTree::ScrollRect::create() | |
| 120 .setLayerId(layerId) | |
| 121 .setX(regions[i].x) | |
| 122 .setY(regions[i].y) | |
| 123 .setHeight(regions[i].height) | |
| 124 .setWidth(regions[i].width) | |
| 125 .setType(type); | |
| 126 scrollRects.addItem(regionObject); | |
| 127 } | |
| 128 } | |
| 129 | |
| 130 | |
|
caseq
2014/02/24 14:38:56
drop the extra line please
malch
2014/02/25 10:36:40
Done.
| |
| 131 static void addScrollRectsForLayer(GraphicsLayer* graphicsLayer, | |
| 132 TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect>& scrollRects) | |
| 133 { | |
| 134 blink::WebLayer* webLayer = graphicsLayer->platformLayer(); | |
| 135 addRegionObjects(webLayer->nonFastScrollableRegion(), | |
| 136 scrollRects, | |
| 137 TypeBuilder::LayerTree::ScrollRect::Type::RepaintsOnScroll, | |
| 138 idForLayer(graphicsLayer)); | |
| 139 addRegionObjects(webLayer->touchEventHandlerRegion(), | |
| 140 scrollRects, | |
| 141 TypeBuilder::LayerTree::ScrollRect::Type::TouchEventHandler, | |
| 142 idForLayer(graphicsLayer)); | |
| 143 if (webLayer->haveWheelEventHandlers()) { | |
| 144 RefPtr<TypeBuilder::LayerTree::ScrollRect> regionObject = TypeBuilder::L ayerTree::ScrollRect::create() | |
| 145 .setLayerId(idForLayer(graphicsLayer)) | |
| 146 .setX(webLayer->position().x) | |
| 147 .setY(webLayer->position().y) | |
| 148 .setHeight(webLayer->bounds().height) | |
| 149 .setWidth(webLayer->bounds().width) | |
| 150 .setType(TypeBuilder::LayerTree::ScrollRect::Type::WheelEventHandler ); | |
| 151 scrollRects.addItem(regionObject); | |
| 152 } | |
| 153 } | |
| 154 | |
| 155 void InspectorLayerTreeAgent::gatherGraphicsLayers(GraphicsLayer* root, HashMap< int, int>& layerIdToNodeIdMap, | |
| 156 TypeBuilder::Array<TypeBuilder::LayerTree::Layer>& layers, TypeBuilder::Arra y<TypeBuilder::LayerTree::ScrollRect>& scrollRects) | |
| 157 { | |
| 158 int layerId = root->platformLayer()->id(); | |
| 159 if (m_pageOverlayLayerIds.find(layerId) != WTF::kNotFound) | |
| 160 return; | |
| 161 layers.addItem(buildObjectForLayer(root, layerIdToNodeIdMap.get(layerId))); | |
| 162 addScrollRectsForLayer(root, scrollRects); | |
| 163 if (GraphicsLayer* replica = root->replicaLayer()) | |
| 164 gatherGraphicsLayers(replica, layerIdToNodeIdMap, layers, scrollRects); | |
| 165 for (size_t i = 0, size = root->children().size(); i < size; ++i) | |
| 166 gatherGraphicsLayers(root->children()[i], layerIdToNodeIdMap, layers, sc rollRects); | |
| 167 } | |
| 168 | |
| 113 InspectorLayerTreeAgent::InspectorLayerTreeAgent(InspectorDOMAgent* domAgent, Pa ge* page) | 169 InspectorLayerTreeAgent::InspectorLayerTreeAgent(InspectorDOMAgent* domAgent, Pa ge* page) |
| 114 : InspectorBaseAgent<InspectorLayerTreeAgent>("LayerTree") | 170 : InspectorBaseAgent<InspectorLayerTreeAgent>("LayerTree") |
| 115 , m_frontend(0) | 171 , m_frontend(0) |
| 116 , m_page(page) | 172 , m_page(page) |
| 117 , m_domAgent(domAgent) | 173 , m_domAgent(domAgent) |
| 118 { | 174 { |
| 119 } | 175 } |
| 120 | 176 |
| 121 InspectorLayerTreeAgent::~InspectorLayerTreeAgent() | 177 InspectorLayerTreeAgent::~InspectorLayerTreeAgent() |
| 122 { | 178 { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 147 } | 203 } |
| 148 | 204 |
| 149 void InspectorLayerTreeAgent::disable(ErrorString*) | 205 void InspectorLayerTreeAgent::disable(ErrorString*) |
| 150 { | 206 { |
| 151 m_instrumentingAgents->setInspectorLayerTreeAgent(0); | 207 m_instrumentingAgents->setInspectorLayerTreeAgent(0); |
| 152 m_snapshotById.clear(); | 208 m_snapshotById.clear(); |
| 153 } | 209 } |
| 154 | 210 |
| 155 void InspectorLayerTreeAgent::layerTreeDidChange() | 211 void InspectorLayerTreeAgent::layerTreeDidChange() |
| 156 { | 212 { |
| 157 m_frontend->layerTreeDidChange(buildLayerTree()); | 213 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > layers = TypeBuil der::Array<TypeBuilder::LayerTree::Layer>::create(); |
| 214 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect> > scrollRects = TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect>::create(); | |
| 215 if (buildLayerTree(*layers, *scrollRects)) | |
| 216 m_frontend->layerTreeDidChange(layers, scrollRects); | |
| 217 else | |
| 218 m_frontend->layerTreeDidChange(nullptr, nullptr); | |
| 158 } | 219 } |
| 159 | 220 |
| 160 void InspectorLayerTreeAgent::didPaint(RenderObject*, const GraphicsLayer* graph icsLayer, GraphicsContext*, const LayoutRect& rect) | 221 void InspectorLayerTreeAgent::didPaint(RenderObject*, const GraphicsLayer* graph icsLayer, GraphicsContext*, const LayoutRect& rect) |
| 161 { | 222 { |
| 162 // Should only happen for FrameView paints when compositing is off. Consider different instrumentation method for that. | 223 // Should only happen for FrameView paints when compositing is off. Consider different instrumentation method for that. |
| 163 if (!graphicsLayer) | 224 if (!graphicsLayer) |
| 164 return; | 225 return; |
| 165 | 226 |
| 166 RefPtr<TypeBuilder::DOM::Rect> domRect = TypeBuilder::DOM::Rect::create() | 227 RefPtr<TypeBuilder::DOM::Rect> domRect = TypeBuilder::DOM::Rect::create() |
| 167 .setX(rect.x()) | 228 .setX(rect.x()) |
| 168 .setY(rect.y()) | 229 .setY(rect.y()) |
| 169 .setWidth(rect.width()) | 230 .setWidth(rect.width()) |
| 170 .setHeight(rect.height()); | 231 .setHeight(rect.height()); |
| 171 m_frontend->layerPainted(idForLayer(graphicsLayer), domRect.release()); | 232 m_frontend->layerPainted(idForLayer(graphicsLayer), domRect.release()); |
| 172 } | 233 } |
| 173 | 234 |
| 174 PassRefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > InspectorLayerTre eAgent::buildLayerTree() | 235 bool InspectorLayerTreeAgent::buildLayerTree(TypeBuilder::Array<TypeBuilder::Lay erTree::Layer>& layers, |
| 236 TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect>& scrollRects) | |
| 175 { | 237 { |
| 176 RenderLayerCompositor* compositor = renderLayerCompositor(); | 238 RenderLayerCompositor* compositor = renderLayerCompositor(); |
| 177 if (!compositor || !compositor->inCompositingMode()) | 239 if (!compositor || !compositor->inCompositingMode()) |
| 178 return nullptr; | 240 return false; |
| 179 LayerIdToNodeIdMap layerIdToNodeIdMap; | 241 LayerIdToNodeIdMap layerIdToNodeIdMap; |
| 180 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> > layers = TypeBuil der::Array<TypeBuilder::LayerTree::Layer>::create(); | |
| 181 buildLayerIdToNodeIdMap(compositor->rootRenderLayer(), layerIdToNodeIdMap); | 242 buildLayerIdToNodeIdMap(compositor->rootRenderLayer(), layerIdToNodeIdMap); |
| 182 gatherGraphicsLayers(compositor->rootGraphicsLayer(), layerIdToNodeIdMap, la yers); | 243 gatherGraphicsLayers(compositor->rootGraphicsLayer(), layerIdToNodeIdMap, la yers, scrollRects); |
| 183 return layers.release(); | 244 return true; |
| 184 } | 245 } |
| 185 | 246 |
| 186 void InspectorLayerTreeAgent::buildLayerIdToNodeIdMap(RenderLayer* root, LayerId ToNodeIdMap& layerIdToNodeIdMap) | 247 void InspectorLayerTreeAgent::buildLayerIdToNodeIdMap(RenderLayer* root, LayerId ToNodeIdMap& layerIdToNodeIdMap) |
| 187 { | 248 { |
| 188 if (root->hasCompositedLayerMapping()) { | 249 if (root->hasCompositedLayerMapping()) { |
| 189 if (Node* node = root->renderer()->generatingNode()) { | 250 if (Node* node = root->renderer()->generatingNode()) { |
| 190 GraphicsLayer* graphicsLayer = root->compositedLayerMapping()->child ForSuperlayers(); | 251 GraphicsLayer* graphicsLayer = root->compositedLayerMapping()->child ForSuperlayers(); |
| 191 layerIdToNodeIdMap.set(graphicsLayer->platformLayer()->id(), idForNo de(node)); | 252 layerIdToNodeIdMap.set(graphicsLayer->platformLayer()->id(), idForNo de(node)); |
| 192 } | 253 } |
| 193 } | 254 } |
| 194 for (RenderLayer* child = root->firstChild(); child; child = child->nextSibl ing()) | 255 for (RenderLayer* child = root->firstChild(); child; child = child->nextSibl ing()) |
| 195 buildLayerIdToNodeIdMap(child, layerIdToNodeIdMap); | 256 buildLayerIdToNodeIdMap(child, layerIdToNodeIdMap); |
| 196 if (!root->renderer()->isRenderIFrame()) | 257 if (!root->renderer()->isRenderIFrame()) |
| 197 return; | 258 return; |
| 198 FrameView* childFrameView = toFrameView(toRenderWidget(root->renderer())->wi dget()); | 259 FrameView* childFrameView = toFrameView(toRenderWidget(root->renderer())->wi dget()); |
| 199 if (RenderView* childRenderView = childFrameView->renderView()) { | 260 if (RenderView* childRenderView = childFrameView->renderView()) { |
| 200 if (RenderLayerCompositor* childCompositor = childRenderView->compositor ()) | 261 if (RenderLayerCompositor* childCompositor = childRenderView->compositor ()) |
| 201 buildLayerIdToNodeIdMap(childCompositor->rootRenderLayer(), layerIdT oNodeIdMap); | 262 buildLayerIdToNodeIdMap(childCompositor->rootRenderLayer(), layerIdT oNodeIdMap); |
| 202 } | 263 } |
| 203 } | 264 } |
| 204 | 265 |
| 205 void InspectorLayerTreeAgent::gatherGraphicsLayers(GraphicsLayer* root, HashMap< int, int>& layerIdToNodeIdMap, RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree: :Layer> >& layers) | |
|
caseq
2014/02/24 14:38:56
Why did this move?
malch
2014/02/25 10:36:40
Done.
| |
| 206 { | |
| 207 int layerId = root->platformLayer()->id(); | |
| 208 if (m_pageOverlayLayerIds.find(layerId) != WTF::kNotFound) | |
| 209 return; | |
| 210 layers->addItem(buildObjectForLayer(root, layerIdToNodeIdMap.get(layerId))); | |
| 211 if (GraphicsLayer* replica = root->replicaLayer()) | |
| 212 gatherGraphicsLayers(replica, layerIdToNodeIdMap, layers); | |
| 213 for (size_t i = 0, size = root->children().size(); i < size; ++i) | |
| 214 gatherGraphicsLayers(root->children()[i], layerIdToNodeIdMap, layers); | |
| 215 } | |
| 216 | |
| 217 int InspectorLayerTreeAgent::idForNode(Node* node) | 266 int InspectorLayerTreeAgent::idForNode(Node* node) |
| 218 { | 267 { |
| 219 int nodeId = m_domAgent->boundNodeId(node); | 268 int nodeId = m_domAgent->boundNodeId(node); |
| 220 if (!nodeId) { | 269 if (!nodeId) { |
| 221 ErrorString ignoredError; | 270 ErrorString ignoredError; |
| 222 nodeId = m_domAgent->pushNodeToFrontend(&ignoredError, m_domAgent->bound NodeId(&node->document()), node); | 271 nodeId = m_domAgent->pushNodeToFrontend(&ignoredError, m_domAgent->bound NodeId(&node->document()), node); |
| 223 } | 272 } |
| 224 return nodeId; | 273 return nodeId; |
| 225 } | 274 } |
| 226 | 275 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 void InspectorLayerTreeAgent::didRemovePageOverlay(const GraphicsLayer* layer) | 443 void InspectorLayerTreeAgent::didRemovePageOverlay(const GraphicsLayer* layer) |
| 395 { | 444 { |
| 396 size_t index = m_pageOverlayLayerIds.find(layer->platformLayer()->id()); | 445 size_t index = m_pageOverlayLayerIds.find(layer->platformLayer()->id()); |
| 397 if (index == WTF::kNotFound) | 446 if (index == WTF::kNotFound) |
| 398 return; | 447 return; |
| 399 m_pageOverlayLayerIds.remove(index); | 448 m_pageOverlayLayerIds.remove(index); |
| 400 } | 449 } |
| 401 | 450 |
| 402 | 451 |
| 403 } // namespace WebCore | 452 } // namespace WebCore |
| OLD | NEW |