Chromium Code Reviews| 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/PaintInvalidator.h" | 5 #include "core/paint/PaintInvalidator.h" |
| 6 | 6 |
| 7 #include "core/editing/FrameSelection.h" | 7 #include "core/editing/FrameSelection.h" |
| 8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
| 9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
| 10 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 // For SVG, the input rect is in local SVG coordinates in which paint | 85 // For SVG, the input rect is in local SVG coordinates in which paint |
| 86 // offset doesn't apply. | 86 // offset doesn't apply. |
| 87 if (!is_svg_child) | 87 if (!is_svg_child) |
| 88 rect.MoveBy(Point(object.PaintOffset())); | 88 rect.MoveBy(Point(object.PaintOffset())); |
| 89 // Use enclosingIntRect to ensure the final visual rect will cover the | 89 // Use enclosingIntRect to ensure the final visual rect will cover the |
| 90 // rect in source coordinates no matter if the painting will use pixel | 90 // rect in source coordinates no matter if the painting will use pixel |
| 91 // snapping. | 91 // snapping. |
| 92 return LayoutRect(EnclosingIntRect(rect)); | 92 return LayoutRect(EnclosingIntRect(rect)); |
| 93 } | 93 } |
| 94 | 94 |
| 95 // If kForcedSubtreeNoRasterInvalidation is set, we map the rect to the | |
| 96 // temporary root paint property state instead of the paint invalidation | |
| 97 // backing. | |
| 98 bool map_to_backing = | |
|
chrishtr
2017/05/17 00:42:41
Is this mapping necessary for testing, or for repa
Xianzhu
2017/05/17 00:49:45
It's for repaint-after-layout checks to invalidate
| |
| 99 !(context.forced_subtree_invalidation_flags & | |
| 100 PaintInvalidatorContext::kForcedSubtreeNoRasterInvalidation); | |
| 101 | |
| 95 LayoutRect result; | 102 LayoutRect result; |
| 96 if (context.forced_subtree_invalidation_flags & | 103 if (context.forced_subtree_invalidation_flags & |
| 97 PaintInvalidatorContext::kForcedSubtreeSlowPathRect) { | 104 PaintInvalidatorContext::kForcedSubtreeSlowPathRect) { |
| 105 DCHECK(map_to_backing); | |
| 98 result = SlowMapToVisualRectInAncestorSpace( | 106 result = SlowMapToVisualRectInAncestorSpace( |
| 99 object, *context.paint_invalidation_container, rect); | 107 object, *context.paint_invalidation_container, rect); |
| 100 } else if (object == context.paint_invalidation_container) { | 108 } else if (object == context.paint_invalidation_container) { |
| 109 DCHECK(map_to_backing); | |
| 101 result = LayoutRect(rect); | 110 result = LayoutRect(rect); |
| 102 } else { | 111 } else { |
| 103 // For non-root SVG, the input rect is in local SVG coordinates in which | 112 // For non-root SVG, the input rect is in local SVG coordinates in which |
| 104 // paint offset doesn't apply. | 113 // paint offset doesn't apply. |
| 105 if (!is_svg_child) | 114 if (!is_svg_child) |
| 106 rect.MoveBy(Point(object.PaintOffset())); | 115 rect.MoveBy(Point(object.PaintOffset())); |
| 107 | 116 |
| 108 auto container_contents_properties = | 117 auto container_contents_properties = |
| 109 context.paint_invalidation_container->ContentsProperties(); | 118 map_to_backing |
| 119 ? context.paint_invalidation_container->ContentsProperties() | |
| 120 : PropertyTreeState::Root(); | |
| 110 if (context.tree_builder_context_->current.transform == | 121 if (context.tree_builder_context_->current.transform == |
| 111 container_contents_properties.Transform() && | 122 container_contents_properties.Transform() && |
| 112 context.tree_builder_context_->current.clip == | 123 context.tree_builder_context_->current.clip == |
| 113 container_contents_properties.Clip()) { | 124 container_contents_properties.Clip()) { |
| 114 result = LayoutRect(rect); | 125 result = LayoutRect(rect); |
| 115 } else { | 126 } else { |
| 116 // Use enclosingIntRect to ensure the final visual rect will cover the | 127 // Use enclosingIntRect to ensure the final visual rect will cover the |
| 117 // rect in source coordinates no matter if the painting will use pixel | 128 // rect in source coordinates no matter if the painting will use pixel |
| 118 // snapping, when transforms are applied. If there is no transform, | 129 // snapping, when transforms are applied. If there is no transform, |
| 119 // enclosingIntRect is applied in the last step of paint invalidation | 130 // enclosingIntRect is applied in the last step of paint invalidation |
| 120 // (see CompositedLayerMapping::setContentsNeedDisplayInRect()). | 131 // (see CompositedLayerMapping::setContentsNeedDisplayInRect()). |
| 121 if (!is_svg_child && context.tree_builder_context_->current.transform != | 132 if (!is_svg_child && context.tree_builder_context_->current.transform != |
| 122 container_contents_properties.Transform()) | 133 container_contents_properties.Transform()) |
| 123 rect = Rect(EnclosingIntRect(rect)); | 134 rect = Rect(EnclosingIntRect(rect)); |
| 124 | 135 |
| 125 PropertyTreeState current_tree_state( | 136 PropertyTreeState current_tree_state( |
| 126 context.tree_builder_context_->current.transform, | 137 context.tree_builder_context_->current.transform, |
| 127 context.tree_builder_context_->current.clip, nullptr); | 138 context.tree_builder_context_->current.clip, nullptr); |
| 128 | 139 |
| 129 FloatClipRect float_rect((FloatRect(rect))); | 140 FloatClipRect float_rect((FloatRect(rect))); |
| 130 GeometryMapper::SourceToDestinationVisualRect( | 141 GeometryMapper::SourceToDestinationVisualRect( |
| 131 current_tree_state, container_contents_properties, float_rect); | 142 current_tree_state, container_contents_properties, float_rect); |
| 132 result = LayoutRect(float_rect.Rect()); | 143 result = LayoutRect(float_rect.Rect()); |
| 133 } | 144 } |
| 134 | 145 |
| 135 // Convert the result to the container's contents space. | 146 // Convert the result to the container's contents space. |
| 136 result.MoveBy(-context.paint_invalidation_container->PaintOffset()); | 147 if (map_to_backing) |
| 148 result.MoveBy(-context.paint_invalidation_container->PaintOffset()); | |
| 137 } | 149 } |
| 138 | 150 |
| 139 object.AdjustVisualRectForRasterEffects(result); | 151 object.AdjustVisualRectForRasterEffects(result); |
| 152 if (!map_to_backing) | |
| 153 return result; | |
| 140 | 154 |
| 141 PaintLayer::MapRectInPaintInvalidationContainerToBacking( | 155 PaintLayer::MapRectInPaintInvalidationContainerToBacking( |
| 142 *context.paint_invalidation_container, result); | 156 *context.paint_invalidation_container, result); |
| 143 | 157 |
| 144 result.Move(object.ScrollAdjustmentForPaintInvalidation( | 158 result.Move(object.ScrollAdjustmentForPaintInvalidation( |
| 145 *context.paint_invalidation_container)); | 159 *context.paint_invalidation_container)); |
| 146 | 160 |
| 147 return result; | 161 return result; |
| 148 } | 162 } |
| 149 | 163 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 context.forced_subtree_invalidation_flags |= | 348 context.forced_subtree_invalidation_flags |= |
| 335 PaintInvalidatorContext::kForcedSubtreeFullInvalidation; | 349 PaintInvalidatorContext::kForcedSubtreeFullInvalidation; |
| 336 } | 350 } |
| 337 | 351 |
| 338 if (object == context.paint_invalidation_container) { | 352 if (object == context.paint_invalidation_container) { |
| 339 // When we hit a new paint invalidation container, we don't need to | 353 // When we hit a new paint invalidation container, we don't need to |
| 340 // continue forcing a check for paint invalidation, since we're | 354 // continue forcing a check for paint invalidation, since we're |
| 341 // descending into a different invalidation container. (For instance if | 355 // descending into a different invalidation container. (For instance if |
| 342 // our parents were moved, the entire container will just move.) | 356 // our parents were moved, the entire container will just move.) |
| 343 if (object != context.paint_invalidation_container_for_stacked_contents) { | 357 if (object != context.paint_invalidation_container_for_stacked_contents) { |
| 344 // However, we need to keep ForcedSubtreeVisualRectUpdate and | 358 // However, we need to keep kForcedSubtreeVisualRectUpdate and |
| 345 // ForcedSubtreeFullInvalidationForStackedContents flags if the current | 359 // kForcedSubtreeFullInvalidationForStackedContents flags if the current |
| 346 // object isn't the paint invalidation container of stacked contents. | 360 // object isn't the paint invalidation container of stacked contents. |
| 347 context.forced_subtree_invalidation_flags &= | 361 context.forced_subtree_invalidation_flags &= |
| 348 (PaintInvalidatorContext::kForcedSubtreeVisualRectUpdate | | 362 (PaintInvalidatorContext::kForcedSubtreeVisualRectUpdate | |
| 349 PaintInvalidatorContext:: | 363 PaintInvalidatorContext:: |
| 350 kForcedSubtreeFullInvalidationForStackedContents); | 364 kForcedSubtreeFullInvalidationForStackedContents); |
| 351 } else { | 365 } else { |
| 352 context.forced_subtree_invalidation_flags = 0; | 366 context.forced_subtree_invalidation_flags = 0; |
| 353 } | 367 } |
| 354 } | 368 } |
| 355 | 369 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 529 | 543 |
| 530 void PaintInvalidator::ProcessPendingDelayedPaintInvalidations() { | 544 void PaintInvalidator::ProcessPendingDelayedPaintInvalidations() { |
| 531 for (auto target : pending_delayed_paint_invalidations_) { | 545 for (auto target : pending_delayed_paint_invalidations_) { |
| 532 target->GetMutableForPainting() | 546 target->GetMutableForPainting() |
| 533 .SetShouldDoFullPaintInvalidationWithoutGeometryChange( | 547 .SetShouldDoFullPaintInvalidationWithoutGeometryChange( |
| 534 PaintInvalidationReason::kDelayedFull); | 548 PaintInvalidationReason::kDelayedFull); |
| 535 } | 549 } |
| 536 } | 550 } |
| 537 | 551 |
| 538 } // namespace blink | 552 } // namespace blink |
| OLD | NEW |