OLD | NEW |
---|---|
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/LayoutView.h" | 9 #include "core/layout/LayoutView.h" |
10 #include "core/layout/api/LayoutPartItem.h" | 10 #include "core/layout/api/LayoutPartItem.h" |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 layer.compositedLayerMapping()->setNonScrollingContentsNeedDisplayInRect( | 331 layer.compositedLayerMapping()->setNonScrollingContentsNeedDisplayInRect( |
332 rect, reason, m_object); | 332 rect, reason, m_object); |
333 } | 333 } |
334 } else { | 334 } else { |
335 // Otherwise invalidate everything. | 335 // Otherwise invalidate everything. |
336 layer.compositedLayerMapping()->setContentsNeedDisplayInRect(rect, reason, | 336 layer.compositedLayerMapping()->setContentsNeedDisplayInRect(rect, reason, |
337 m_object); | 337 m_object); |
338 } | 338 } |
339 } | 339 } |
340 | 340 |
341 static bool parentIsContainer(const LayoutObject& object) { | |
342 if (object.isTextOrSVGChild() || | |
wkorman
2017/02/22 21:52:22
Is there a relevant spec section or something we c
Xianzhu
2017/02/22 23:20:59
The conditions are the same conditions that Layout
| |
343 (!object.isOutOfFlowPositioned() && !object.isColumnSpanAll() && | |
344 !object.isFloating())) { | |
345 DCHECK(object.parent() == object.container()); | |
346 return true; | |
347 } | |
348 return false; | |
349 } | |
350 | |
341 void ObjectPaintInvalidator::invalidatePaintUsingContainer( | 351 void ObjectPaintInvalidator::invalidatePaintUsingContainer( |
342 const LayoutBoxModelObject& paintInvalidationContainer, | 352 const LayoutBoxModelObject& paintInvalidationContainer, |
343 const LayoutRect& dirtyRect, | 353 const LayoutRect& dirtyRect, |
344 PaintInvalidationReason invalidationReason) { | 354 PaintInvalidationReason invalidationReason) { |
345 // TODO(wangxianzhu): Enable the following assert after paint invalidation for | 355 // TODO(wangxianzhu): Enable the following assert after paint invalidation for |
346 // spv2 is ready. | 356 // spv2 is ready. |
347 // DCHECK(!RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | 357 // DCHECK(!RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
348 | 358 |
349 if (paintInvalidationContainer.frameView()->shouldThrottleRendering()) | 359 if (paintInvalidationContainer.frameView()->shouldThrottleRendering()) |
350 return; | 360 return; |
351 | 361 |
352 DCHECK(gDisablePaintInvalidationStateAsserts || | 362 DCHECK(gDisablePaintInvalidationStateAsserts || |
353 m_object.document().lifecycle().state() == | 363 m_object.document().lifecycle().state() == |
354 (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() | 364 (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() |
355 ? DocumentLifecycle::InPrePaint | 365 ? DocumentLifecycle::InPrePaint |
356 : DocumentLifecycle::InPaintInvalidation)); | 366 : DocumentLifecycle::InPaintInvalidation)); |
357 | 367 |
358 if (dirtyRect.isEmpty()) | 368 if (dirtyRect.isEmpty()) |
359 return; | 369 return; |
360 | 370 |
361 CHECK(m_object.isRooted()); | 371 DCHECK(m_object.isRooted()); |
wkorman
2017/02/22 21:52:22
Just curious, why shift to DCHECK?
Xianzhu
2017/02/22 23:20:59
isRooted() is slow because it traverse the layout/
| |
372 | |
373 if (m_object != paintInvalidationContainer && m_object.parent() && | |
wkorman
2017/02/22 21:52:22
Could be worth adding a comment to explain backgro
| |
374 m_object.parent() != paintInvalidationContainer && | |
375 isImmediateFullPaintInvalidationReason( | |
376 m_object.parent()->fullPaintInvalidationReason()) && | |
377 parentIsContainer(m_object) && | |
378 m_object.parent()->visualRect().contains(dirtyRect)) | |
379 return; | |
362 | 380 |
363 // FIXME: Unify "devtools.timeline.invalidationTracking" and | 381 // FIXME: Unify "devtools.timeline.invalidationTracking" and |
364 // "blink.invalidation". crbug.com/413527. | 382 // "blink.invalidation". crbug.com/413527. |
365 TRACE_EVENT_INSTANT1( | 383 TRACE_EVENT_INSTANT1( |
366 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.invalidationTracking"), | 384 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.invalidationTracking"), |
367 "PaintInvalidationTracking", TRACE_EVENT_SCOPE_THREAD, "data", | 385 "PaintInvalidationTracking", TRACE_EVENT_SCOPE_THREAD, "data", |
368 InspectorPaintInvalidationTrackingEvent::data( | 386 InspectorPaintInvalidationTrackingEvent::data( |
369 &m_object, paintInvalidationContainer)); | 387 &m_object, paintInvalidationContainer)); |
370 TRACE_EVENT2( | 388 TRACE_EVENT2( |
371 TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), | 389 TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
611 | 629 |
612 m_context.paintingLayer->setNeedsRepaint(); | 630 m_context.paintingLayer->setNeedsRepaint(); |
613 m_object.invalidateDisplayItemClients(reason); | 631 m_object.invalidateDisplayItemClients(reason); |
614 return reason; | 632 return reason; |
615 } | 633 } |
616 | 634 |
617 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts() | 635 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts() |
618 : m_disabler(&gDisablePaintInvalidationStateAsserts, true) {} | 636 : m_disabler(&gDisablePaintInvalidationStateAsserts, true) {} |
619 | 637 |
620 } // namespace blink | 638 } // namespace blink |
OLD | NEW |