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

Side by Side Diff: third_party/WebKit/Source/core/paint/ObjectPaintInvalidator.cpp

Issue 2423513002: Simplify incremental paint invalidation (Closed)
Patch Set: Created 4 years, 2 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/ObjectPaintInvalidator.h" 5 #include "core/paint/ObjectPaintInvalidator.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/frame/LocalFrame.h" 8 #include "core/frame/LocalFrame.h"
9 #include "core/layout/LayoutBlockFlow.h" 9 #include "core/layout/LayoutBlockFlow.h"
10 #include "core/layout/LayoutView.h" 10 #include "core/layout/LayoutView.h"
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 m_object.invalidateDisplayItemClients(PaintInvalidationRectangle); 366 m_object.invalidateDisplayItemClients(PaintInvalidationRectangle);
367 367
368 return dirtyRectOnBacking; 368 return dirtyRectOnBacking;
369 } 369 }
370 370
371 void ObjectPaintInvalidator::slowSetPaintingLayerNeedsRepaint() { 371 void ObjectPaintInvalidator::slowSetPaintingLayerNeedsRepaint() {
372 if (PaintLayer* paintingLayer = m_object.paintingLayer()) 372 if (PaintLayer* paintingLayer = m_object.paintingLayer())
373 paintingLayer->setNeedsRepaint(); 373 paintingLayer->setNeedsRepaint();
374 } 374 }
375 375
376 bool ObjectPaintInvalidatorWithContext::incrementallyInvalidatePaint() {
377 const LayoutRect& oldBounds = m_context.oldBounds;
378 const LayoutRect& newBounds = m_context.newBounds;
379
380 DCHECK(oldBounds.location() == newBounds.location());
381
382 LayoutUnit deltaRight = newBounds.maxX() - oldBounds.maxX();
383 LayoutUnit deltaBottom = newBounds.maxY() - oldBounds.maxY();
384 if (!deltaRight && !deltaBottom)
385 return false;
386
387 if (deltaRight > 0) {
388 LayoutRect invalidationRect(oldBounds.maxX(), newBounds.y(), deltaRight,
389 newBounds.height());
390 invalidatePaintUsingContainer(*m_context.paintInvalidationContainer,
391 invalidationRect,
392 PaintInvalidationIncremental);
393 } else if (deltaRight < 0) {
394 LayoutRect invalidationRect(newBounds.maxX(), oldBounds.y(), -deltaRight,
395 oldBounds.height());
396 invalidatePaintUsingContainer(*m_context.paintInvalidationContainer,
397 invalidationRect,
398 PaintInvalidationIncremental);
399 }
400
401 if (deltaBottom > 0) {
402 LayoutRect invalidationRect(newBounds.x(), oldBounds.maxY(),
403 newBounds.width(), deltaBottom);
404 invalidatePaintUsingContainer(*m_context.paintInvalidationContainer,
405 invalidationRect,
406 PaintInvalidationIncremental);
407 } else if (deltaBottom < 0) {
408 LayoutRect invalidationRect(oldBounds.x(), newBounds.maxY(),
409 oldBounds.width(), -deltaBottom);
410 invalidatePaintUsingContainer(*m_context.paintInvalidationContainer,
411 invalidationRect,
412 PaintInvalidationIncremental);
413 }
414
415 return true;
416 }
417
418 void ObjectPaintInvalidatorWithContext::fullyInvalidatePaint( 376 void ObjectPaintInvalidatorWithContext::fullyInvalidatePaint(
419 PaintInvalidationReason reason, 377 PaintInvalidationReason reason,
420 const LayoutRect& oldBounds, 378 const LayoutRect& oldBounds,
421 const LayoutRect& newBounds) { 379 const LayoutRect& newBounds) {
422 // The following logic avoids invalidating twice if one set of bounds contains 380 // The following logic avoids invalidating twice if one set of bounds contains
423 // the other. 381 // the other.
424 if (!newBounds.contains(oldBounds)) { 382 if (!newBounds.contains(oldBounds)) {
425 LayoutRect invalidationRect = oldBounds; 383 LayoutRect invalidationRect = oldBounds;
426 invalidatePaintUsingContainer(*m_context.paintInvalidationContainer, 384 invalidatePaintUsingContainer(*m_context.paintInvalidationContainer,
427 invalidationRect, reason); 385 invalidationRect, reason);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 } 492 }
535 493
536 PaintInvalidationReason 494 PaintInvalidationReason
537 ObjectPaintInvalidatorWithContext::invalidatePaintIfNeededWithComputedReason( 495 ObjectPaintInvalidatorWithContext::invalidatePaintIfNeededWithComputedReason(
538 PaintInvalidationReason reason) { 496 PaintInvalidationReason reason) {
539 // We need to invalidate the selection before checking for whether we are 497 // We need to invalidate the selection before checking for whether we are
540 // doing a full invalidation. This is because we need to update the previous 498 // doing a full invalidation. This is because we need to update the previous
541 // selection rect regardless. 499 // selection rect regardless.
542 invalidateSelectionIfNeeded(reason); 500 invalidateSelectionIfNeeded(reason);
543 501
544 if (reason == PaintInvalidationIncremental && !incrementallyInvalidatePaint()) 502 if (reason == PaintInvalidationIncremental) {
545 reason = PaintInvalidationNone; 503 reason = m_context.oldBounds == m_context.newBounds ? PaintInvalidationNone
504 : PaintInvalidationFull;
505 }
546 506
547 switch (reason) { 507 switch (reason) {
548 case PaintInvalidationNone: 508 case PaintInvalidationNone:
549 // TODO(trchen): Currently we don't keep track of paint offset of layout 509 // TODO(trchen): Currently we don't keep track of paint offset of layout
550 // objects. There are corner cases that the display items need to be 510 // objects. There are corner cases that the display items need to be
551 // invalidated for paint offset mutation, but incurs no pixel difference 511 // invalidated for paint offset mutation, but incurs no pixel difference
552 // (i.e. bounds stay the same) so no rect-based invalidation is issued. 512 // (i.e. bounds stay the same) so no rect-based invalidation is issued.
553 // See crbug.com/508383 and crbug.com/515977. This is a workaround to 513 // See crbug.com/508383 and crbug.com/515977. This is a workaround to
554 // force display items to update paint offset. 514 // force display items to update paint offset.
555 if (m_context.forcedSubtreeInvalidationFlags & 515 if (m_context.forcedSubtreeInvalidationFlags &
556 PaintInvalidatorContext::ForcedSubtreeInvalidationChecking) { 516 PaintInvalidatorContext::ForcedSubtreeInvalidationChecking) {
557 reason = PaintInvalidationLocationChange; 517 reason = PaintInvalidationLocationChange;
558 break; 518 break;
559 } 519 }
560 return PaintInvalidationNone; 520 return PaintInvalidationNone;
561 case PaintInvalidationIncremental:
562 break;
563 case PaintInvalidationDelayedFull: 521 case PaintInvalidationDelayedFull:
564 return PaintInvalidationDelayedFull; 522 return PaintInvalidationDelayedFull;
565 default: 523 default:
566 DCHECK(isImmediateFullPaintInvalidationReason(reason)); 524 DCHECK(isImmediateFullPaintInvalidationReason(reason));
567 fullyInvalidatePaint(reason, m_context.oldBounds, m_context.newBounds); 525 fullyInvalidatePaint(reason, m_context.oldBounds, m_context.newBounds);
568 } 526 }
569 527
570 m_context.paintingLayer->setNeedsRepaint(); 528 m_context.paintingLayer->setNeedsRepaint();
571 m_object.invalidateDisplayItemClients(reason); 529 m_object.invalidateDisplayItemClients(reason);
572 return reason; 530 return reason;
573 } 531 }
574 532
575 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts() 533 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts()
576 : m_disabler(&gDisablePaintInvalidationStateAsserts, true) {} 534 : m_disabler(&gDisablePaintInvalidationStateAsserts, true) {}
577 535
578 } // namespace blink 536 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698