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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 2766943002: Do-not-commit: Count layout tree memory usage
Patch Set: Rebase, add object paint property counter Created 3 years, 8 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) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 return; 1329 return;
1330 1330
1331 #if DCHECK_IS_ON() 1331 #if DCHECK_IS_ON()
1332 // Post-layout assert that nobody was re-marked as needing layout during 1332 // Post-layout assert that nobody was re-marked as needing layout during
1333 // layout. 1333 // layout.
1334 layoutView()->assertSubtreeIsLaidOut(); 1334 layoutView()->assertSubtreeIsLaidOut();
1335 #endif 1335 #endif
1336 1336
1337 frame().document()->layoutUpdated(); 1337 frame().document()->layoutUpdated();
1338 checkDoesNotNeedLayout(); 1338 checkDoesNotNeedLayout();
1339
1340 printLayoutTreeStats();
1341 }
1342
1343 struct TreeStats {
1344 int frames;
1345 int layoutObjects;
1346 int objectPaintProperties;
1347 int layoutObjectMemory;
1348 int layoutTreeApproximateHeapMemoryUsage;
1349 int paintPropertiesMemoryUsage;
1350 int paintPropertyTransformNodes;
1351 int paintPropertyScrollNodes;
1352 int paintPropertyClipNodes;
1353 int paintPropertyEffectNodes;
1354 int borderBoxProperties;
1355 int contentsProperties;
1356 };
1357
1358 void FrameView::printLayoutTreeStats() const {
1359 TreeStats stats = {};
1360 countLayoutTreeStats(stats, *this);
1361 LOG(ERROR) << "Layout Tree Stats -------------";
1362 LOG(ERROR) << " frame count: " << stats.frames;
1363 LOG(ERROR) << " layout object count: " << stats.layoutObjects;
1364 LOG(ERROR) << " layout object memory: " << stats.layoutObjectMemory
1365 << " bytes";
1366 LOG(ERROR) << " layout tree additional heap memory: "
1367 << stats.layoutTreeApproximateHeapMemoryUsage << " bytes";
1368 LOG(ERROR) << " object paint properties: " << stats.objectPaintProperties;
1369 LOG(ERROR) << " paint properties memory: "
1370 << stats.paintPropertiesMemoryUsage << " bytes";
1371 LOG(ERROR) << " transform nodes (" << sizeof(TransformPaintPropertyNode)
1372 << " bytes): " << stats.paintPropertyTransformNodes;
1373 LOG(ERROR) << " scroll nodes (" << sizeof(ScrollPaintPropertyNode)
1374 << " bytes): " << stats.paintPropertyScrollNodes;
1375 LOG(ERROR) << " clip nodes (" << sizeof(ClipPaintPropertyNode)
1376 << " bytes): " << stats.paintPropertyClipNodes;
1377 LOG(ERROR) << " effect nodes (" << sizeof(EffectPaintPropertyNode)
1378 << " bytes): " << stats.paintPropertyEffectNodes;
1379 LOG(ERROR) << " border box properties (" << sizeof(PropertyTreeState)
1380 << " bytes): " << stats.borderBoxProperties;
1381 LOG(ERROR) << " contents properties (" << sizeof(PropertyTreeState)
1382 << " bytes): " << stats.contentsProperties;
1383 }
1384
1385 void FrameView::countLayoutTreeStats(TreeStats& stats,
1386 const FrameView& frame) const {
1387 stats.frames++;
1388 if (frame.m_preTranslation) {
1389 stats.paintPropertyTransformNodes++;
1390 stats.paintPropertiesMemoryUsage += sizeof(TransformPaintPropertyNode);
1391 }
1392 if (frame.m_scrollTranslation) {
1393 stats.paintPropertyTransformNodes++;
1394 stats.paintPropertyScrollNodes++;
1395 stats.paintPropertiesMemoryUsage += sizeof(TransformPaintPropertyNode);
1396 stats.paintPropertiesMemoryUsage += sizeof(ScrollPaintPropertyNode);
1397 }
1398 if (frame.m_contentClip) {
1399 stats.paintPropertyClipNodes++;
1400 stats.paintPropertiesMemoryUsage += sizeof(ClipPaintPropertyNode);
1401 }
1402 if (frame.m_totalPropertyTreeStateForContents) {
1403 stats.paintPropertiesMemoryUsage += sizeof(PropertyTreeState);
1404 }
1405 if (LayoutView* view = frame.layoutView())
1406 countLayoutTreeStats(stats, *view);
1407 }
1408
1409 void FrameView::countLayoutTreeStats(TreeStats& stats,
1410 const LayoutObject& object) const {
1411 stats.layoutObjects++;
1412 stats.layoutObjectMemory += object.objectSize();
1413 stats.layoutTreeApproximateHeapMemoryUsage +=
1414 object.approximateHeapMemoryUsage();
1415
1416 if (const auto* properties = object.paintProperties()) {
1417 stats.objectPaintProperties++;
1418 stats.paintPropertiesMemoryUsage += sizeof(ObjectPaintProperties);
1419 stats.paintPropertiesMemoryUsage += properties->heapMemoryUsage();
1420
1421 if (properties->paintOffsetTranslation())
1422 stats.paintPropertyTransformNodes++;
1423 if (properties->transform())
1424 stats.paintPropertyTransformNodes++;
1425 if (properties->effect())
1426 stats.paintPropertyEffectNodes++;
1427 if (properties->filter())
1428 stats.paintPropertyEffectNodes++;
1429 if (properties->mask())
1430 stats.paintPropertyEffectNodes++;
1431 if (properties->maskClip())
1432 stats.paintPropertyClipNodes++;
1433 if (properties->cssClip())
1434 stats.paintPropertyClipNodes++;
1435 if (properties->cssClipFixedPosition())
1436 stats.paintPropertyClipNodes++;
1437 if (properties->innerBorderRadiusClip())
1438 stats.paintPropertyClipNodes++;
1439 if (properties->overflowClip())
1440 stats.paintPropertyClipNodes++;
1441 if (properties->perspective())
1442 stats.paintPropertyTransformNodes++;
1443 if (properties->svgLocalToBorderBoxTransform())
1444 stats.paintPropertyTransformNodes++;
1445 if (properties->scrollTranslation()) {
1446 stats.paintPropertyTransformNodes++;
1447 stats.paintPropertyScrollNodes++;
1448 }
1449 if (properties->scrollbarPaintOffset())
1450 stats.paintPropertyTransformNodes++;
1451
1452 if (properties->localBorderBoxProperties())
1453 stats.borderBoxProperties++;
1454 if (properties->hasContentsProperties())
1455 stats.contentsProperties++;
1456 }
1457
1458 for (const LayoutObject* child = object.slowFirstChild(); child;
1459 child = child->nextSibling()) {
1460 countLayoutTreeStats(stats, *child);
1461 }
1462 if (object.isLayoutPart()) {
1463 const LayoutPart& layoutPart = toLayoutPart(object);
1464 FrameViewBase* frameViewBase = layoutPart.frameViewBase();
1465 if (frameViewBase && frameViewBase->isFrameView())
1466 countLayoutTreeStats(stats, *toFrameView(frameViewBase));
1467 }
1339 } 1468 }
1340 1469
1341 void FrameView::invalidateTreeIfNeeded( 1470 void FrameView::invalidateTreeIfNeeded(
1342 const PaintInvalidationState& paintInvalidationState) { 1471 const PaintInvalidationState& paintInvalidationState) {
1343 DCHECK(!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()); 1472 DCHECK(!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled());
1344 1473
1345 if (shouldThrottleRendering()) 1474 if (shouldThrottleRendering())
1346 return; 1475 return;
1347 1476
1348 lifecycle().advanceTo(DocumentLifecycle::InPaintInvalidation); 1477 lifecycle().advanceTo(DocumentLifecycle::InPaintInvalidation);
(...skipping 3911 matching lines...) Expand 10 before | Expand all | Expand 10 after
5260 void FrameView::setAnimationHost( 5389 void FrameView::setAnimationHost(
5261 std::unique_ptr<CompositorAnimationHost> host) { 5390 std::unique_ptr<CompositorAnimationHost> host) {
5262 m_animationHost = std::move(host); 5391 m_animationHost = std::move(host);
5263 } 5392 }
5264 5393
5265 LayoutUnit FrameView::caretWidth() const { 5394 LayoutUnit FrameView::caretWidth() const {
5266 return LayoutUnit(getHostWindow()->windowToViewportScalar(1)); 5395 return LayoutUnit(getHostWindow()->windowToViewportScalar(1));
5267 } 5396 }
5268 5397
5269 } // namespace blink 5398 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.h ('k') | third_party/WebKit/Source/core/layout/LayoutBR.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698