Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(651)

Side by Side Diff: Source/core/inspector/InspectorLayerTreeAgent.cpp

Issue 166273018: Added showing slow scroll rectangles in Layers panel. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixes. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 int layerId; 67 int layerId;
68 RefPtr<GraphicsContextSnapshot> graphicsSnapshot; 68 RefPtr<GraphicsContextSnapshot> graphicsSnapshot;
69 }; 69 };
70 70
71 inline String idForLayer(const GraphicsLayer* graphicsLayer) 71 inline String idForLayer(const GraphicsLayer* graphicsLayer)
72 { 72 {
73 return String::number(graphicsLayer->platformLayer()->id()); 73 return String::number(graphicsLayer->platformLayer()->id());
74 } 74 }
75 75
76 static void buildRegionObjects(const blink::WebVector<blink::WebRect>& regions,
pfeldman 2014/02/28 07:43:43 Builders return objects: we have buildObjectFor an
malch 2014/02/28 12:19:57 Done.
77 TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect>& scrollRects,
78 const TypeBuilder::LayerTree::ScrollRect::Type::Enum& type,
79 const TypeBuilder::LayerTree::LayerId& layerId)
pfeldman 2014/02/28 07:43:43 Looks like this is unused.
malch 2014/02/28 12:19:57 Done.
80 {
81 for (size_t i = 0; i < regions.size(); ++i) {
82 RefPtr<TypeBuilder::DOM::Rect> rectObject = TypeBuilder::DOM::Rect::crea te()
83 .setX(regions[i].x)
84 .setY(regions[i].y)
85 .setHeight(regions[i].height)
86 .setWidth(regions[i].width);
87 RefPtr<TypeBuilder::LayerTree::ScrollRect> regionObject = TypeBuilder::L ayerTree::ScrollRect::create()
88 .setRect(rectObject)
89 .setType(type);
90 scrollRects.addItem(regionObject);
91 }
92 }
93
94 static PassRefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect> > build ScrollRectsForLayer(GraphicsLayer* graphicsLayer)
95 {
96 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect> > scrollRects = TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect>::create();
97 blink::WebLayer* webLayer = graphicsLayer->platformLayer();
98 buildRegionObjects(webLayer->nonFastScrollableRegion(), *scrollRects, TypeBu ilder::LayerTree::ScrollRect::Type::RepaintsOnScroll, idForLayer(graphicsLayer)) ;
99 buildRegionObjects(webLayer->touchEventHandlerRegion(), *scrollRects, TypeBu ilder::LayerTree::ScrollRect::Type::TouchEventHandler, idForLayer(graphicsLayer) );
100 if (webLayer->haveWheelEventHandlers()) {
101 RefPtr<TypeBuilder::DOM::Rect> rectObject = TypeBuilder::DOM::Rect::crea te()
pfeldman 2014/02/28 07:43:43 Then you would be able to reuse builder method her
malch 2014/02/28 12:19:57 Done.
102 .setX(webLayer->position().x)
103 .setY(webLayer->position().y)
104 .setHeight(webLayer->bounds().height)
105 .setWidth(webLayer->bounds().width);
106 RefPtr<TypeBuilder::LayerTree::ScrollRect> regionObject = TypeBuilder::L ayerTree::ScrollRect::create()
107 .setRect(rectObject)
108 .setType(TypeBuilder::LayerTree::ScrollRect::Type::WheelEventHandler );
109 scrollRects->addItem(regionObject);
110 }
111 return scrollRects->length() ? scrollRects : nullptr;
112 }
113
76 static PassRefPtr<TypeBuilder::LayerTree::Layer> buildObjectForLayer(GraphicsLay er* graphicsLayer, int nodeId) 114 static PassRefPtr<TypeBuilder::LayerTree::Layer> buildObjectForLayer(GraphicsLay er* graphicsLayer, int nodeId)
77 { 115 {
78 blink::WebLayer* webLayer = graphicsLayer->platformLayer(); 116 blink::WebLayer* webLayer = graphicsLayer->platformLayer();
79 RefPtr<TypeBuilder::LayerTree::Layer> layerObject = TypeBuilder::LayerTree:: Layer::create() 117 RefPtr<TypeBuilder::LayerTree::Layer> layerObject = TypeBuilder::LayerTree:: Layer::create()
80 .setLayerId(idForLayer(graphicsLayer)) 118 .setLayerId(idForLayer(graphicsLayer))
81 .setOffsetX(webLayer->position().x) 119 .setOffsetX(webLayer->position().x)
82 .setOffsetY(webLayer->position().y) 120 .setOffsetY(webLayer->position().y)
83 .setWidth(webLayer->bounds().width) 121 .setWidth(webLayer->bounds().width)
84 .setHeight(webLayer->bounds().height) 122 .setHeight(webLayer->bounds().height)
85 .setPaintCount(graphicsLayer->paintCount()); 123 .setPaintCount(graphicsLayer->paintCount());
(...skipping 14 matching lines...) Expand all
100 transform.toColumnMajorFloatArray(flattenedMatrix); 138 transform.toColumnMajorFloatArray(flattenedMatrix);
101 RefPtr<TypeBuilder::Array<double> > transformArray = TypeBuilder::Array< double>::create(); 139 RefPtr<TypeBuilder::Array<double> > transformArray = TypeBuilder::Array< double>::create();
102 for (size_t i = 0; i < WTF_ARRAY_LENGTH(flattenedMatrix); ++i) 140 for (size_t i = 0; i < WTF_ARRAY_LENGTH(flattenedMatrix); ++i)
103 transformArray->addItem(flattenedMatrix[i]); 141 transformArray->addItem(flattenedMatrix[i]);
104 layerObject->setTransform(transformArray); 142 layerObject->setTransform(transformArray);
105 const FloatPoint3D& anchor = graphicsLayer->anchorPoint(); 143 const FloatPoint3D& anchor = graphicsLayer->anchorPoint();
106 layerObject->setAnchorX(anchor.x()); 144 layerObject->setAnchorX(anchor.x());
107 layerObject->setAnchorY(anchor.y()); 145 layerObject->setAnchorY(anchor.y());
108 layerObject->setAnchorZ(anchor.z()); 146 layerObject->setAnchorZ(anchor.z());
109 } 147 }
148 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::ScrollRect> > scrollRects =
149 buildScrollRectsForLayer(graphicsLayer);
150 if (scrollRects)
151 layerObject->setScrollRects(buildScrollRectsForLayer(graphicsLayer));
pfeldman 2014/02/28 07:43:43 Why building twice, use scrollRects instead? Do y
malch 2014/02/28 12:19:57 Done.
110 return layerObject; 152 return layerObject;
111 } 153 }
112 154
113 InspectorLayerTreeAgent::InspectorLayerTreeAgent(InspectorDOMAgent* domAgent, Pa ge* page) 155 InspectorLayerTreeAgent::InspectorLayerTreeAgent(InspectorDOMAgent* domAgent, Pa ge* page)
114 : InspectorBaseAgent<InspectorLayerTreeAgent>("LayerTree") 156 : InspectorBaseAgent<InspectorLayerTreeAgent>("LayerTree")
115 , m_frontend(0) 157 , m_frontend(0)
116 , m_page(page) 158 , m_page(page)
117 , m_domAgent(domAgent) 159 , m_domAgent(domAgent)
118 { 160 {
119 } 161 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 buildLayerIdToNodeIdMap(child, layerIdToNodeIdMap); 237 buildLayerIdToNodeIdMap(child, layerIdToNodeIdMap);
196 if (!root->renderer()->isRenderIFrame()) 238 if (!root->renderer()->isRenderIFrame())
197 return; 239 return;
198 FrameView* childFrameView = toFrameView(toRenderWidget(root->renderer())->wi dget()); 240 FrameView* childFrameView = toFrameView(toRenderWidget(root->renderer())->wi dget());
199 if (RenderView* childRenderView = childFrameView->renderView()) { 241 if (RenderView* childRenderView = childFrameView->renderView()) {
200 if (RenderLayerCompositor* childCompositor = childRenderView->compositor ()) 242 if (RenderLayerCompositor* childCompositor = childRenderView->compositor ())
201 buildLayerIdToNodeIdMap(childCompositor->rootRenderLayer(), layerIdT oNodeIdMap); 243 buildLayerIdToNodeIdMap(childCompositor->rootRenderLayer(), layerIdT oNodeIdMap);
202 } 244 }
203 } 245 }
204 246
205 void InspectorLayerTreeAgent::gatherGraphicsLayers(GraphicsLayer* root, HashMap< int, int>& layerIdToNodeIdMap, RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree: :Layer> >& layers) 247 void InspectorLayerTreeAgent::gatherGraphicsLayers(GraphicsLayer* root, HashMap< int, int>& layerIdToNodeIdMap,
248 RefPtr<TypeBuilder::Array<TypeBuilder::LayerTree::Layer> >& layers)
pfeldman 2014/02/28 07:43:43 no need for new line here.
malch 2014/02/28 12:19:57 Done.
206 { 249 {
207 int layerId = root->platformLayer()->id(); 250 int layerId = root->platformLayer()->id();
208 if (m_pageOverlayLayerIds.find(layerId) != WTF::kNotFound) 251 if (m_pageOverlayLayerIds.find(layerId) != WTF::kNotFound)
209 return; 252 return;
210 layers->addItem(buildObjectForLayer(root, layerIdToNodeIdMap.get(layerId))); 253 layers->addItem(buildObjectForLayer(root, layerIdToNodeIdMap.get(layerId)));
211 if (GraphicsLayer* replica = root->replicaLayer()) 254 if (GraphicsLayer* replica = root->replicaLayer())
212 gatherGraphicsLayers(replica, layerIdToNodeIdMap, layers); 255 gatherGraphicsLayers(replica, layerIdToNodeIdMap, layers);
213 for (size_t i = 0, size = root->children().size(); i < size; ++i) 256 for (size_t i = 0, size = root->children().size(); i < size; ++i)
214 gatherGraphicsLayers(root->children()[i], layerIdToNodeIdMap, layers); 257 gatherGraphicsLayers(root->children()[i], layerIdToNodeIdMap, layers);
215 } 258 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 void InspectorLayerTreeAgent::didRemovePageOverlay(const GraphicsLayer* layer) 396 void InspectorLayerTreeAgent::didRemovePageOverlay(const GraphicsLayer* layer)
354 { 397 {
355 size_t index = m_pageOverlayLayerIds.find(layer->platformLayer()->id()); 398 size_t index = m_pageOverlayLayerIds.find(layer->platformLayer()->id());
356 if (index == WTF::kNotFound) 399 if (index == WTF::kNotFound)
357 return; 400 return;
358 m_pageOverlayLayerIds.remove(index); 401 m_pageOverlayLayerIds.remove(index);
359 } 402 }
360 403
361 404
362 } // namespace WebCore 405 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698