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

Side by Side Diff: Source/core/rendering/RenderObject.cpp

Issue 208143003: Issue trace events to gather repaint information. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase to master Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderObject.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2009 Google Inc. All rights reserved. 7 * Copyright (C) 2009 Google Inc. All rights reserved.
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 #include "core/rendering/compositing/RenderLayerCompositor.h" 75 #include "core/rendering/compositing/RenderLayerCompositor.h"
76 #include "core/rendering/style/ContentData.h" 76 #include "core/rendering/style/ContentData.h"
77 #include "core/rendering/style/CursorList.h" 77 #include "core/rendering/style/CursorList.h"
78 #include "core/rendering/style/ShadowList.h" 78 #include "core/rendering/style/ShadowList.h"
79 #include "core/rendering/svg/SVGRenderSupport.h" 79 #include "core/rendering/svg/SVGRenderSupport.h"
80 #include "platform/Partitions.h" 80 #include "platform/Partitions.h"
81 #include "platform/geometry/TransformState.h" 81 #include "platform/geometry/TransformState.h"
82 #include "platform/graphics/GraphicsContext.h" 82 #include "platform/graphics/GraphicsContext.h"
83 #include "wtf/RefCountedLeakCounter.h" 83 #include "wtf/RefCountedLeakCounter.h"
84 #include "wtf/text/StringBuilder.h" 84 #include "wtf/text/StringBuilder.h"
85 #include "wtf/text/WTFString.h"
85 #include <algorithm> 86 #include <algorithm>
86 #ifndef NDEBUG 87 #ifndef NDEBUG
87 #include <stdio.h> 88 #include <stdio.h>
88 #endif 89 #endif
89 90
90 using namespace std; 91 using namespace std;
91 92
92 namespace WebCore { 93 namespace WebCore {
93 94
94 using namespace HTMLNames; 95 using namespace HTMLNames;
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 // flow thread. Otherwise we will need to catch the repaint call and sen d it to the flow thread. 1361 // flow thread. Otherwise we will need to catch the repaint call and sen d it to the flow thread.
1361 RenderFlowThread* repaintContainerFlowThread = repaintContainer ? repain tContainer->flowThreadContainingBlock() : 0; 1362 RenderFlowThread* repaintContainerFlowThread = repaintContainer ? repain tContainer->flowThreadContainingBlock() : 0;
1362 if (!repaintContainerFlowThread || repaintContainerFlowThread != parentR enderFlowThread) 1363 if (!repaintContainerFlowThread || repaintContainerFlowThread != parentR enderFlowThread)
1363 repaintContainer = parentRenderFlowThread; 1364 repaintContainer = parentRenderFlowThread;
1364 } 1365 }
1365 return repaintContainer; 1366 return repaintContainer;
1366 } 1367 }
1367 1368
1368 void RenderObject::repaintUsingContainer(const RenderLayerModelObject* repaintCo ntainer, const IntRect& r) const 1369 void RenderObject::repaintUsingContainer(const RenderLayerModelObject* repaintCo ntainer, const IntRect& r) const
1369 { 1370 {
1371 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "RenderObject: :repaintUsingContainer()",
1372 "object", TRACE_STR_COPY(this->debugName().ascii().data()),
1373 "rect", TRACE_STR_COPY(String::format("%d,%d %dx%d", r.x(), r.y(), r.wid th(), r.height()).ascii().data()));
1374
1370 if (!repaintContainer) { 1375 if (!repaintContainer) {
1371 view()->repaintViewRectangle(r); 1376 view()->repaintViewRectangle(r);
1372 return; 1377 return;
1373 } 1378 }
1374 1379
1375 // FIXME: Don't read compositing state here since we do this in the middle o f recalc/layout. 1380 // FIXME: Don't read compositing state here since we do this in the middle o f recalc/layout.
1376 DisableCompositingQueryAsserts disabler; 1381 DisableCompositingQueryAsserts disabler;
1377 if (repaintContainer->compositingState() == PaintsIntoGroupedBacking) { 1382 if (repaintContainer->compositingState() == PaintsIntoGroupedBacking) {
1378 ASSERT(repaintContainer->groupedMapping()); 1383 ASSERT(repaintContainer->groupedMapping());
1379 ASSERT(repaintContainer->layer()); 1384 ASSERT(repaintContainer->layer());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 void RenderObject::repaint() const 1437 void RenderObject::repaint() const
1433 { 1438 {
1434 // Don't repaint if we're unrooted (note that view() still returns the view when unrooted) 1439 // Don't repaint if we're unrooted (note that view() still returns the view when unrooted)
1435 RenderView* view; 1440 RenderView* view;
1436 if (!isRooted(&view)) 1441 if (!isRooted(&view))
1437 return; 1442 return;
1438 1443
1439 if (view->document().printing()) 1444 if (view->document().printing())
1440 return; // Don't repaint if we're printing. 1445 return; // Don't repaint if we're printing.
1441 1446
1447 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "RenderObject: :repaint()",
1448 "object", TRACE_STR_COPY(this->debugName().ascii().data()));
1449
1442 // FIXME: really, we're in the repaint phase here, and the following queries are legal. 1450 // FIXME: really, we're in the repaint phase here, and the following queries are legal.
1443 // Until those states are fully fledged, I'll just disable the ASSERTS. 1451 // Until those states are fully fledged, I'll just disable the ASSERTS.
1444 DisableCompositingQueryAsserts disabler; 1452 DisableCompositingQueryAsserts disabler;
1445 RenderLayerModelObject* repaintContainer = containerForRepaint(); 1453 RenderLayerModelObject* repaintContainer = containerForRepaint();
1446 repaintUsingContainer(repaintContainer ? repaintContainer : view, pixelSnapp edIntRect(clippedOverflowRectForRepaint(repaintContainer))); 1454 repaintUsingContainer(repaintContainer ? repaintContainer : view, pixelSnapp edIntRect(clippedOverflowRectForRepaint(repaintContainer)));
1447 } 1455 }
1448 1456
1449 void RenderObject::repaintRectangle(const LayoutRect& r) const 1457 void RenderObject::repaintRectangle(const LayoutRect& r) const
1450 { 1458 {
1451 // Don't repaint if we're unrooted (note that view() still returns the view when unrooted) 1459 // Don't repaint if we're unrooted (note that view() still returns the view when unrooted)
1452 RenderView* view; 1460 RenderView* view;
1453 if (!isRooted(&view)) 1461 if (!isRooted(&view))
1454 return; 1462 return;
1455 1463
1456 if (view->document().printing()) 1464 if (view->document().printing())
1457 return; // Don't repaint if we're printing. 1465 return; // Don't repaint if we're printing.
1458 1466
1467 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "RenderObject: :repaintRectangle()",
1468 "object", TRACE_STR_COPY(this->debugName().ascii().data()));
1469
1459 LayoutRect dirtyRect(r); 1470 LayoutRect dirtyRect(r);
1460 1471
1461 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) { 1472 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) {
1462 // FIXME: layoutDelta needs to be applied in parts before/after transfor ms and 1473 // FIXME: layoutDelta needs to be applied in parts before/after transfor ms and
1463 // repaint containers. https://bugs.webkit.org/show_bug.cgi?id=23308 1474 // repaint containers. https://bugs.webkit.org/show_bug.cgi?id=23308
1464 dirtyRect.move(view->layoutDelta()); 1475 dirtyRect.move(view->layoutDelta());
1465 } 1476 }
1466 1477
1467 RenderLayerModelObject* repaintContainer = containerForRepaint(); 1478 RenderLayerModelObject* repaintContainer = containerForRepaint();
1468 computeRectForRepaint(repaintContainer, dirtyRect); 1479 computeRectForRepaint(repaintContainer, dirtyRect);
1469 repaintUsingContainer(repaintContainer ? repaintContainer : view, pixelSnapp edIntRect(dirtyRect)); 1480 repaintUsingContainer(repaintContainer ? repaintContainer : view, pixelSnapp edIntRect(dirtyRect));
1470 } 1481 }
1471 1482
1472 IntRect RenderObject::pixelSnappedAbsoluteClippedOverflowRect() const 1483 IntRect RenderObject::pixelSnappedAbsoluteClippedOverflowRect() const
1473 { 1484 {
1474 return pixelSnappedIntRect(absoluteClippedOverflowRect()); 1485 return pixelSnappedIntRect(absoluteClippedOverflowRect());
1475 } 1486 }
1476 1487
1488 const char* RenderObject::invalidationReasonToString(const InvalidationReason re ason) const
1489 {
1490 switch (reason) {
1491 case InvalidationIncremental:
1492 return "incremental";
1493 case InvalidationSelfLayout:
1494 return "self layout";
1495 case InvalidationBorderFitLines:
1496 return "border fit lines";
1497 case InvalidationBorderRadius:
1498 return "border radius";
1499 case InvalidationBoundsChangeWithBackground:
1500 return "bounds change with background";
1501 case InvalidationBoundsChange:
1502 return "bounds change";
1503 default:
1504 return "unknown";
Julien - ping for review 2014/03/31 18:26:45 ASSERT_NOT_REACHED()?
dsinclair 2014/03/31 19:24:34 Done.
1505 }
1506 }
1507
1477 bool RenderObject::repaintAfterLayoutIfNeeded(const RenderLayerModelObject* repa intContainer, bool wasSelfLayout, 1508 bool RenderObject::repaintAfterLayoutIfNeeded(const RenderLayerModelObject* repa intContainer, bool wasSelfLayout,
1478 const LayoutRect& oldBounds, const LayoutRect* newBoundsPtr) 1509 const LayoutRect& oldBounds, const LayoutRect* newBoundsPtr)
1479 { 1510 {
1480 RenderView* v = view(); 1511 RenderView* v = view();
1481 if (v->document().printing()) 1512 if (v->document().printing())
1482 return false; // Don't repaint if we're printing. 1513 return false; // Don't repaint if we're printing.
1483 1514
1515 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "RenderObject: :repaintAfterLayoutIfNeeded",
1516 "object", TRACE_STR_COPY(this->debugName().ascii().data()));
1517
1484 // This ASSERT fails due to animations. See https://bugs.webkit.org/show_bu g.cgi?id=37048 1518 // This ASSERT fails due to animations. See https://bugs.webkit.org/show_bu g.cgi?id=37048
1485 // ASSERT(!newBoundsPtr || *newBoundsPtr == clippedOverflowRectForRepaint(re paintContainer)); 1519 // ASSERT(!newBoundsPtr || *newBoundsPtr == clippedOverflowRectForRepaint(re paintContainer));
1486 LayoutRect newBounds = newBoundsPtr ? *newBoundsPtr : clippedOverflowRectFor Repaint(repaintContainer); 1520 LayoutRect newBounds = newBoundsPtr ? *newBoundsPtr : clippedOverflowRectFor Repaint(repaintContainer);
1487 1521
1488 bool fullRepaint = wasSelfLayout; 1522 InvalidationReason invalidationReason = InvalidationIncremental;
1523 if (wasSelfLayout)
1524 invalidationReason = InvalidationSelfLayout;
Julien - ping for review 2014/03/31 18:26:45 We should just use the ternary operator ? here as
dsinclair 2014/03/31 19:24:34 Done.
1525
1489 // Presumably a background or a border exists if border-fit:lines was specif ied. 1526 // Presumably a background or a border exists if border-fit:lines was specif ied.
1490 if (!fullRepaint && style()->borderFit() == BorderFitLines) 1527 if (invalidationReason == InvalidationIncremental && style()->borderFit() == BorderFitLines)
1491 fullRepaint = true; 1528 invalidationReason = InvalidationBorderFitLines;
1492 if (!fullRepaint && style()->hasBorderRadius()) { 1529
1530 if (invalidationReason == InvalidationIncremental&& style()->hasBorderRadius ()) {
1493 // If a border-radius exists and width/height is smaller than 1531 // If a border-radius exists and width/height is smaller than
1494 // radius width/height, we cannot use delta-repaint. 1532 // radius width/height, we cannot use delta-repaint.
1495 RoundedRect oldRoundedRect = style()->getRoundedBorderFor(oldBounds); 1533 RoundedRect oldRoundedRect = style()->getRoundedBorderFor(oldBounds);
1496 RoundedRect newRoundedRect = style()->getRoundedBorderFor(newBounds); 1534 RoundedRect newRoundedRect = style()->getRoundedBorderFor(newBounds);
1497 fullRepaint = oldRoundedRect.radii() != newRoundedRect.radii(); 1535 if (oldRoundedRect.radii() != newRoundedRect.radii())
1536 invalidationReason = InvalidationBorderRadius;
1498 } 1537 }
1499 1538
1500 if (!fullRepaint && (mustRepaintBackgroundOrBorder() && (newBounds != oldBou nds))) 1539 if (invalidationReason == InvalidationIncremental && (mustRepaintBackgroundO rBorder() && (newBounds != oldBounds)))
1501 fullRepaint = true; 1540 invalidationReason = InvalidationBoundsChangeWithBackground;
1502 1541
1503 // If we shifted, we don't know the exact reason so we are conservative and trigger a full invalidation. Shifting could 1542 // If we shifted, we don't know the exact reason so we are conservative and trigger a full invalidation. Shifting could
1504 // be caused by some layout property (left / top) or some in-flow renderer i nserted / removed before us in the tree. 1543 // be caused by some layout property (left / top) or some in-flow renderer i nserted / removed before us in the tree.
1505 if (!fullRepaint && newBounds.location() != oldBounds.location()) 1544 if (invalidationReason == InvalidationIncremental && newBounds.location() != oldBounds.location())
1506 fullRepaint = true; 1545 invalidationReason = InvalidationBoundsChange;
1507 1546
1508 if (!repaintContainer) 1547 if (!repaintContainer)
1509 repaintContainer = v; 1548 repaintContainer = v;
1510 1549
1511 if (fullRepaint) { 1550 if (invalidationReason != InvalidationIncremental) {
1551 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "i nvalidation_reason",
1552 "object", TRACE_STR_COPY(this->debugName().ascii().data()),
1553 "reason", invalidationReasonToString(invalidationReason));
Julien - ping for review 2014/03/31 18:26:45 Why don't we just pass the invalidation reason to
dsinclair 2014/03/31 19:24:34 Done.
1554
1512 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(oldBounds)); 1555 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(oldBounds));
1513 if (newBounds != oldBounds) 1556 if (newBounds != oldBounds)
1514 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(newBound s)); 1557 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(newBound s));
1515 return true; 1558 return true;
1516 } 1559 }
1517 1560
1518 if (oldBounds == newBounds) 1561 if (oldBounds == newBounds)
1519 return false; 1562 return false;
1520 1563
1564 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "inval idation_reason",
1565 "object", TRACE_STR_COPY(this->debugName().ascii().data()),
1566 "reason", invalidationReasonToString(invalidationReason));
1567
1521 LayoutUnit deltaLeft = newBounds.x() - oldBounds.x(); 1568 LayoutUnit deltaLeft = newBounds.x() - oldBounds.x();
1522 if (deltaLeft > 0) 1569 if (deltaLeft > 0)
1523 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(oldBounds.x( ), oldBounds.y(), deltaLeft, oldBounds.height())); 1570 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(oldBounds.x( ), oldBounds.y(), deltaLeft, oldBounds.height()));
1524 else if (deltaLeft < 0) 1571 else if (deltaLeft < 0)
1525 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(newBounds.x( ), newBounds.y(), -deltaLeft, newBounds.height())); 1572 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(newBounds.x( ), newBounds.y(), -deltaLeft, newBounds.height()));
1526 1573
1527 LayoutUnit deltaRight = newBounds.maxX() - oldBounds.maxX(); 1574 LayoutUnit deltaRight = newBounds.maxX() - oldBounds.maxX();
1528 if (deltaRight > 0) 1575 if (deltaRight > 0)
1529 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(oldBounds.ma xX(), newBounds.y(), deltaRight, newBounds.height())); 1576 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(oldBounds.ma xX(), newBounds.y(), deltaRight, newBounds.height()));
1530 else if (deltaRight < 0) 1577 else if (deltaRight < 0)
(...skipping 1798 matching lines...) Expand 10 before | Expand all | Expand 10 after
3329 { 3376 {
3330 if (object1) { 3377 if (object1) {
3331 const WebCore::RenderObject* root = object1; 3378 const WebCore::RenderObject* root = object1;
3332 while (root->parent()) 3379 while (root->parent())
3333 root = root->parent(); 3380 root = root->parent();
3334 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 3381 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
3335 } 3382 }
3336 } 3383 }
3337 3384
3338 #endif 3385 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderObject.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698