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

Side by Side Diff: sky/engine/core/rendering/RenderObject.cpp

Issue 840403003: First pass at deleting paint invalidation code. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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) 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 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 } 1211 }
1212 1212
1213 const RenderLayerModelObject* RenderObject::adjustCompositedContainerForSpecialA ncestors(const RenderLayerModelObject* paintInvalidationContainer) const 1213 const RenderLayerModelObject* RenderObject::adjustCompositedContainerForSpecialA ncestors(const RenderLayerModelObject* paintInvalidationContainer) const
1214 { 1214 {
1215 // FIXME(sky): We shouldn't have any special ancestors and we don't have com posited containers 1215 // FIXME(sky): We shouldn't have any special ancestors and we don't have com posited containers
1216 if (paintInvalidationContainer) 1216 if (paintInvalidationContainer)
1217 return paintInvalidationContainer; 1217 return paintInvalidationContainer;
1218 return view(); 1218 return view();
1219 } 1219 }
1220 1220
1221 template <typename T>
1222 void addJsonObjectForRect(TracedValue* value, const char* name, const T& rect)
1223 {
1224 value->beginDictionary(name);
1225 value->setDouble("x", rect.x());
1226 value->setDouble("y", rect.y());
1227 value->setDouble("width", rect.width());
1228 value->setDouble("height", rect.height());
1229 value->endDictionary();
1230 }
1231
1232 static PassRefPtr<TraceEvent::ConvertableToTraceFormat> jsonObjectForPaintInvali dationInfo(const LayoutRect& rect, const String& invalidationReason)
1233 {
1234 RefPtr<TracedValue> value = TracedValue::create();
1235 addJsonObjectForRect(value.get(), "rect", rect);
1236 value->setString("invalidation_reason", invalidationReason);
1237 return value;
1238 }
1239
1240 LayoutRect RenderObject::computePaintInvalidationRect(const RenderLayerModelObje ct* paintInvalidationContainer, const PaintInvalidationState* paintInvalidationS tate) const 1221 LayoutRect RenderObject::computePaintInvalidationRect(const RenderLayerModelObje ct* paintInvalidationContainer, const PaintInvalidationState* paintInvalidationS tate) const
1241 { 1222 {
1242 return clippedOverflowRectForPaintInvalidation(paintInvalidationContainer, p aintInvalidationState); 1223 return clippedOverflowRectForPaintInvalidation(paintInvalidationContainer, p aintInvalidationState);
1243 } 1224 }
1244 1225
1245 void RenderObject::invalidatePaintUsingContainer(const RenderLayerModelObject* p aintInvalidationContainer, const LayoutRect& r, InvalidationReason invalidationR eason) const
1246 {
1247 if (r.isEmpty())
1248 return;
1249
1250 // FIXME: This should be an assert, but editing/selection can trigger this c ase to invalidate
1251 // the selection. crbug.com/368140.
1252 if (!isRooted())
1253 return;
1254
1255 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "RenderObject: :invalidatePaintUsingContainer()",
1256 "object", this->debugName().ascii().data(),
1257 "info", jsonObjectForPaintInvalidationInfo(r, invalidationReasonToString (invalidationReason)));
1258
1259 if (paintInvalidationContainer->hasFilter() && paintInvalidationContainer->l ayer()->requiresFullLayerImageForFilters()) {
1260 paintInvalidationContainer->layer()->paintInvalidator().setFilterBackend NeedsPaintInvalidationInRect(r);
1261 return;
1262 }
1263
1264 if (paintInvalidationContainer->isRenderView()) {
1265 toRenderView(paintInvalidationContainer)->invalidatePaintForRectangle(r) ;
1266 return;
1267 }
1268 }
1269
1270 void RenderObject::invalidatePaintForWholeRenderer() const
1271 {
1272 if (!isRooted())
1273 return;
1274
1275 const RenderLayerModelObject* paintInvalidationContainer = containerForPaint Invalidation();
1276
1277 // FIXME: We should invalidate only previousPaintInvalidationRect, but for n ow we invalidate both the previous
1278 // and current paint rects to meet the expectations of some callers in some cases (crbug.com/397555):
1279 // - transform style change without a layout - crbug.com/394004;
1280 // - some objects don't save previousPaintInvalidationRect - crbug.com/39413 3.
1281 LayoutRect paintInvalidationRect = boundsRectForPaintInvalidation(paintInval idationContainer);
1282 invalidatePaintUsingContainer(paintInvalidationContainer, paintInvalidationR ect, InvalidationPaint);
1283 if (paintInvalidationRect != previousPaintInvalidationRect())
1284 invalidatePaintUsingContainer(paintInvalidationContainer, previousPaintI nvalidationRect(), InvalidationPaint);
1285 }
1286
1287 LayoutRect RenderObject::boundsRectForPaintInvalidation(const RenderLayerModelOb ject* paintInvalidationContainer, const PaintInvalidationState* paintInvalidatio nState) const 1226 LayoutRect RenderObject::boundsRectForPaintInvalidation(const RenderLayerModelOb ject* paintInvalidationContainer, const PaintInvalidationState* paintInvalidatio nState) const
1288 { 1227 {
1289 if (!paintInvalidationContainer) 1228 if (!paintInvalidationContainer)
1290 return computePaintInvalidationRect(paintInvalidationContainer, paintInv alidationState); 1229 return computePaintInvalidationRect(paintInvalidationContainer, paintInv alidationState);
1291 return RenderLayer::computePaintInvalidationRect(this, paintInvalidationCont ainer->layer(), paintInvalidationState); 1230 return RenderLayer::computePaintInvalidationRect(this, paintInvalidationCont ainer->layer(), paintInvalidationState);
1292 } 1231 }
1293 1232
1233 // FIXME(sky): Remove
1294 void RenderObject::invalidatePaintRectangle(const LayoutRect& r) const 1234 void RenderObject::invalidatePaintRectangle(const LayoutRect& r) const
1295 { 1235 {
1296 if (!isRooted())
1297 return;
1298
1299 LayoutRect dirtyRect(r);
1300
1301 const RenderLayerModelObject* paintInvalidationContainer = containerForPaint Invalidation();
1302 RenderLayer::mapRectToPaintInvalidationBacking(this, paintInvalidationContai ner, dirtyRect);
1303 invalidatePaintUsingContainer(paintInvalidationContainer, dirtyRect, Invalid ationPaintRectangle);
1304 } 1236 }
1305 1237
1306 IntRect RenderObject::pixelSnappedAbsoluteClippedOverflowRect() const 1238 IntRect RenderObject::pixelSnappedAbsoluteClippedOverflowRect() const
1307 { 1239 {
1308 return pixelSnappedIntRect(absoluteClippedOverflowRect()); 1240 return pixelSnappedIntRect(absoluteClippedOverflowRect());
1309 } 1241 }
1310 1242
1311 const char* RenderObject::invalidationReasonToString(InvalidationReason reason) const 1243 const char* RenderObject::invalidationReasonToString(InvalidationReason reason) const
1312 { 1244 {
1313 switch (reason) { 1245 switch (reason) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 return; 1278 return;
1347 1279
1348 clearPaintInvalidationState(paintInvalidationState); 1280 clearPaintInvalidationState(paintInvalidationState);
1349 1281
1350 for (RenderObject* child = slowFirstChild(); child; child = child->nextSibli ng()) { 1282 for (RenderObject* child = slowFirstChild(); child; child = child->nextSibli ng()) {
1351 if (!child->isOutOfFlowPositioned()) 1283 if (!child->isOutOfFlowPositioned())
1352 child->invalidateTreeIfNeeded(paintInvalidationState); 1284 child->invalidateTreeIfNeeded(paintInvalidationState);
1353 } 1285 }
1354 } 1286 }
1355 1287
1356 static PassRefPtr<TraceEvent::ConvertableToTraceFormat> jsonObjectForOldAndNewRe cts(const LayoutRect& oldRect, const LayoutRect& newRect)
1357 {
1358 RefPtr<TracedValue> value = TracedValue::create();
1359 addJsonObjectForRect(value.get(), "old", oldRect);
1360 addJsonObjectForRect(value.get(), "new", newRect);
1361 return value;
1362 }
1363
1364 InvalidationReason RenderObject::invalidatePaintIfNeeded(const RenderLayerModelO bject& paintInvalidationContainer, const LayoutRect& oldBounds, const LayoutPoin t& oldLocation, const PaintInvalidationState& paintInvalidationState)
1365 {
1366 const LayoutRect& newBounds = previousPaintInvalidationRect();
1367 const LayoutPoint& newLocation = previousPositionFromPaintInvalidationContai ner();
1368
1369 // FIXME(sky): Do we need this now that we don't have flipForWritingMode?
1370 // FIXME: PaintInvalidationState should not be required here, but the call t o flipForWritingMode
1371 // in mapRectToPaintInvalidationBacking will give us the wrong results with it disabled.
1372 // crbug.com/393762
1373 ASSERT(newBounds == boundsRectForPaintInvalidation(&paintInvalidationContain er, &paintInvalidationState));
1374
1375 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "RenderObject: :invalidatePaintIfNeeded()",
1376 "object", this->debugName().ascii().data(),
1377 "info", jsonObjectForOldAndNewRects(oldBounds, newBounds));
1378
1379 InvalidationReason invalidationReason = getPaintInvalidationReason(paintInva lidationContainer, oldBounds, oldLocation, newBounds, newLocation);
1380
1381 if (invalidationReason == InvalidationNone)
1382 return invalidationReason;
1383
1384 if (invalidationReason == InvalidationIncremental) {
1385 incrementallyInvalidatePaint(paintInvalidationContainer, oldBounds, newB ounds, newLocation);
1386 return invalidationReason;
1387 }
1388
1389 fullyInvalidatePaint(paintInvalidationContainer, invalidationReason, oldBoun ds, newBounds);
1390 return invalidationReason;
1391 }
1392
1393 InvalidationReason RenderObject::getPaintInvalidationReason(const RenderLayerMod elObject& paintInvalidationContainer, 1288 InvalidationReason RenderObject::getPaintInvalidationReason(const RenderLayerMod elObject& paintInvalidationContainer,
1394 const LayoutRect& oldBounds, const LayoutPoint& oldLocation, const LayoutRec t& newBounds, const LayoutPoint& newLocation) 1289 const LayoutRect& oldBounds, const LayoutPoint& oldLocation, const LayoutRec t& newBounds, const LayoutPoint& newLocation)
1395 { 1290 {
1396 if (shouldDoFullPaintInvalidation()) 1291 if (shouldDoFullPaintInvalidation())
1397 return InvalidationFull; 1292 return InvalidationFull;
1398 1293
1399 if (newLocation != oldLocation) 1294 if (newLocation != oldLocation)
1400 return InvalidationLocationChange; 1295 return InvalidationLocationChange;
1401 1296
1402 // If the bounds are the same then we know that none of the statements below 1297 // If the bounds are the same then we know that none of the statements below
(...skipping 17 matching lines...) Expand all
1420 // This covers the case where we mark containing blocks for layout 1315 // This covers the case where we mark containing blocks for layout
1421 // and they change size but don't have anything to paint. This is 1316 // and they change size but don't have anything to paint. This is
1422 // a pretty common case for <body> as we add / remove children 1317 // a pretty common case for <body> as we add / remove children
1423 // (and the default background is done by FrameView). 1318 // (and the default background is done by FrameView).
1424 if (skipInvalidationWhenLaidOutChildren() && !mayNeedPaintInvalidation()) 1319 if (skipInvalidationWhenLaidOutChildren() && !mayNeedPaintInvalidation())
1425 return InvalidationNone; 1320 return InvalidationNone;
1426 1321
1427 return InvalidationIncremental; 1322 return InvalidationIncremental;
1428 } 1323 }
1429 1324
1430 void RenderObject::incrementallyInvalidatePaint(const RenderLayerModelObject& pa intInvalidationContainer, const LayoutRect& oldBounds, const LayoutRect& newBoun ds, const LayoutPoint& positionFromPaintInvalidationContainer)
1431 {
1432 ASSERT(oldBounds.location() == newBounds.location());
1433
1434 LayoutUnit deltaRight = newBounds.maxX() - oldBounds.maxX();
1435 if (deltaRight > 0)
1436 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ol dBounds.maxX(), newBounds.y(), deltaRight, newBounds.height()), InvalidationIncr emental);
1437 else if (deltaRight < 0)
1438 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ne wBounds.maxX(), oldBounds.y(), -deltaRight, oldBounds.height()), InvalidationInc remental);
1439
1440 LayoutUnit deltaBottom = newBounds.maxY() - oldBounds.maxY();
1441 if (deltaBottom > 0)
1442 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ne wBounds.x(), oldBounds.maxY(), newBounds.width(), deltaBottom), InvalidationIncr emental);
1443 else if (deltaBottom < 0)
1444 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ol dBounds.x(), newBounds.maxY(), oldBounds.width(), -deltaBottom), InvalidationInc remental);
1445 }
1446
1447 void RenderObject::fullyInvalidatePaint(const RenderLayerModelObject& paintInval idationContainer, InvalidationReason invalidationReason, const LayoutRect& oldBo unds, const LayoutRect& newBounds)
1448 {
1449 // Otherwise do full paint invalidation.
1450 invalidatePaintUsingContainer(&paintInvalidationContainer, oldBounds, invali dationReason);
1451 if (newBounds != oldBounds)
1452 invalidatePaintUsingContainer(&paintInvalidationContainer, newBounds, in validationReason);
1453 }
1454
1455 void RenderObject::invalidatePaintForOverflow() 1325 void RenderObject::invalidatePaintForOverflow()
1456 { 1326 {
1457 } 1327 }
1458 1328
1459 void RenderObject::invalidatePaintForOverflowIfNeeded() 1329 void RenderObject::invalidatePaintForOverflowIfNeeded()
1460 { 1330 {
1461 if (shouldInvalidateOverflowForPaint()) 1331 if (shouldInvalidateOverflowForPaint())
1462 invalidatePaintForOverflow(); 1332 invalidatePaintForOverflow();
1463 } 1333 }
1464 1334
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after
2494 return false; 2364 return false;
2495 } 2365 }
2496 2366
2497 bool RenderObject::isRelayoutBoundaryForInspector() const 2367 bool RenderObject::isRelayoutBoundaryForInspector() const
2498 { 2368 {
2499 return objectIsRelayoutBoundary(this); 2369 return objectIsRelayoutBoundary(this);
2500 } 2370 }
2501 2371
2502 void RenderObject::setShouldDoFullPaintInvalidation(bool b, MarkingBehavior mark Behavior) 2372 void RenderObject::setShouldDoFullPaintInvalidation(bool b, MarkingBehavior mark Behavior)
2503 { 2373 {
2504 m_bitfields.setShouldDoFullPaintInvalidation(b);
2505
2506 if (markBehavior == MarkContainingBlockChain && b) { 2374 if (markBehavior == MarkContainingBlockChain && b) {
2507 ASSERT(document().lifecycle().state() != DocumentLifecycle::InPaintInval idation); 2375 ASSERT(document().lifecycle().state() != DocumentLifecycle::InPaintInval idation);
2376 // FIXME(sky): Do we still need this here?
2508 frame()->page()->animator().scheduleVisualUpdate(); // In case that this is called not during FrameView::updateLayoutAndStyleForPainting(). 2377 frame()->page()->animator().scheduleVisualUpdate(); // In case that this is called not during FrameView::updateLayoutAndStyleForPainting().
2509 markContainingBlockChainForPaintInvalidation();
2510 } 2378 }
2511 } 2379 }
2512 2380
2513 void RenderObject::clearPaintInvalidationState(const PaintInvalidationState& pai ntInvalidationState) 2381 void RenderObject::clearPaintInvalidationState(const PaintInvalidationState& pai ntInvalidationState)
2514 { 2382 {
2515 // paintInvalidationStateIsDirty should be kept in sync with the 2383 // paintInvalidationStateIsDirty should be kept in sync with the
2516 // booleans that are cleared below. 2384 // booleans that are cleared below.
2517 ASSERT(paintInvalidationState.forceCheckForPaintInvalidation() || paintInval idationStateIsDirty()); 2385 ASSERT(paintInvalidationState.forceCheckForPaintInvalidation() || paintInval idationStateIsDirty());
2518 setShouldDoFullPaintInvalidation(false); 2386 setShouldDoFullPaintInvalidation(false);
2519 setShouldDoFullPaintInvalidationIfSelfPaintingLayer(false);
2520 setOnlyNeededPositionedMovementLayout(false); 2387 setOnlyNeededPositionedMovementLayout(false);
2521 setNeededLayoutBecauseOfChildren(false); 2388 setNeededLayoutBecauseOfChildren(false);
2522 setShouldInvalidateOverflowForPaint(false); 2389 setShouldInvalidateOverflowForPaint(false);
2523 setLayoutDidGetCalled(false); 2390 setLayoutDidGetCalled(false);
2524 setMayNeedPaintInvalidation(false);
2525 } 2391 }
2526 2392
2527 bool RenderObject::isAllowedToModifyRenderTreeStructure(Document& document) 2393 bool RenderObject::isAllowedToModifyRenderTreeStructure(Document& document)
2528 { 2394 {
2529 return document.lifecycle().stateAllowsRenderTreeMutations(); 2395 return document.lifecycle().stateAllowsRenderTreeMutations();
2530 } 2396 }
2531 2397
2532 } // namespace blink 2398 } // namespace blink
2533 2399
2534 #ifndef NDEBUG 2400 #ifndef NDEBUG
(...skipping 19 matching lines...) Expand all
2554 { 2420 {
2555 if (object1) { 2421 if (object1) {
2556 const blink::RenderObject* root = object1; 2422 const blink::RenderObject* root = object1;
2557 while (root->parent()) 2423 while (root->parent())
2558 root = root->parent(); 2424 root = root->parent();
2559 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 2425 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
2560 } 2426 }
2561 } 2427 }
2562 2428
2563 #endif 2429 #endif
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderObject.h ('k') | sky/engine/core/rendering/RenderObjectChildList.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698