OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/layout/PaintInvalidationState.h" | 5 #include "core/layout/PaintInvalidationState.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/frame/Settings.h" | 9 #include "core/frame/Settings.h" |
10 #include "core/layout/LayoutInline.h" | 10 #include "core/layout/LayoutInline.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // We are changing paintInvalidationContainer to | 146 // We are changing paintInvalidationContainer to |
147 // m_paintInvalidationContainerForStackedContents. Must disable cached | 147 // m_paintInvalidationContainerForStackedContents. Must disable cached |
148 // offsets because we didn't track paint offset from | 148 // offsets because we didn't track paint offset from |
149 // m_paintInvalidationContainerForStackedContents. | 149 // m_paintInvalidationContainerForStackedContents. |
150 // TODO(wangxianzhu): There are optimization opportunities: | 150 // TODO(wangxianzhu): There are optimization opportunities: |
151 // - Like what we do for fixed-position, calculate the paint offset in slow | 151 // - Like what we do for fixed-position, calculate the paint offset in slow |
152 // path and enable fast path for descendants if possible; or | 152 // path and enable fast path for descendants if possible; or |
153 // - Track offset between the two paintInvalidationContainers. | 153 // - Track offset between the two paintInvalidationContainers. |
154 cached_offsets_enabled_ = false; | 154 cached_offsets_enabled_ = false; |
155 if (forced_subtree_invalidation_flags_ & | 155 if (forced_subtree_invalidation_flags_ & |
156 PaintInvalidatorContext:: | 156 PaintInvalidatorContext::kSubtreeFullInvalidationForStackedContents) { |
157 kForcedSubtreeFullInvalidationForStackedContents) | |
158 forced_subtree_invalidation_flags_ |= | 157 forced_subtree_invalidation_flags_ |= |
159 PaintInvalidatorContext::kForcedSubtreeFullInvalidation; | 158 PaintInvalidatorContext::kSubtreeFullInvalidation; |
| 159 } |
160 } | 160 } |
161 | 161 |
162 if (!current_object.IsBoxModelObject() && !current_object.IsSVG()) | 162 if (!current_object.IsBoxModelObject() && !current_object.IsSVG()) |
163 return; | 163 return; |
164 | 164 |
165 if (cached_offsets_enabled_ || | 165 if (cached_offsets_enabled_ || |
166 current_object == paint_invalidation_container_) | 166 current_object == paint_invalidation_container_) |
167 cached_offsets_enabled_ = SupportsCachedOffsets(current_object); | 167 cached_offsets_enabled_ = SupportsCachedOffsets(current_object); |
168 | 168 |
169 if (current_object.IsSVG()) { | 169 if (current_object.IsSVG()) { |
(...skipping 11 matching lines...) Expand all Loading... |
181 | 181 |
182 if (current_object == paint_invalidation_container_) { | 182 if (current_object == paint_invalidation_container_) { |
183 // When we hit a new paint invalidation container, we don't need to | 183 // When we hit a new paint invalidation container, we don't need to |
184 // continue forcing a check for paint invalidation, since we're | 184 // continue forcing a check for paint invalidation, since we're |
185 // descending into a different invalidation container. (For instance if | 185 // descending into a different invalidation container. (For instance if |
186 // our parents were moved, the entire container will just move.) | 186 // our parents were moved, the entire container will just move.) |
187 if (current_object != paint_invalidation_container_for_stacked_contents_) { | 187 if (current_object != paint_invalidation_container_for_stacked_contents_) { |
188 // However, we need to keep the FullInvalidationForStackedContents flag | 188 // However, we need to keep the FullInvalidationForStackedContents flag |
189 // if the current object isn't the paint invalidation container of | 189 // if the current object isn't the paint invalidation container of |
190 // stacked contents. | 190 // stacked contents. |
191 forced_subtree_invalidation_flags_ &= PaintInvalidatorContext:: | 191 forced_subtree_invalidation_flags_ &= |
192 kForcedSubtreeFullInvalidationForStackedContents; | 192 PaintInvalidatorContext::kSubtreeFullInvalidationForStackedContents; |
193 } else { | 193 } else { |
194 forced_subtree_invalidation_flags_ = 0; | 194 forced_subtree_invalidation_flags_ = 0; |
195 if (current_object != container_for_absolute_position_ && | 195 if (current_object != container_for_absolute_position_ && |
196 cached_offsets_for_absolute_position_enabled_ && | 196 cached_offsets_for_absolute_position_enabled_ && |
197 cached_offsets_enabled_) { | 197 cached_offsets_enabled_) { |
198 // The current object is the new paintInvalidationContainer for | 198 // The current object is the new paintInvalidationContainer for |
199 // absolute-position descendants but is not their container. | 199 // absolute-position descendants but is not their container. |
200 // Call updateForCurrentObject() before resetting m_paintOffset to get | 200 // Call updateForCurrentObject() before resetting m_paintOffset to get |
201 // paint offset of the current object from the original | 201 // paint offset of the current object from the original |
202 // paintInvalidationContainerForStackingContents, then use this paint | 202 // paintInvalidationContainerForStackingContents, then use this paint |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 DCHECK(!did_update_for_children_); | 297 DCHECK(!did_update_for_children_); |
298 did_update_for_children_ = true; | 298 did_update_for_children_ = true; |
299 #endif | 299 #endif |
300 | 300 |
301 switch (reason) { | 301 switch (reason) { |
302 case PaintInvalidationReason::kDelayedFull: | 302 case PaintInvalidationReason::kDelayedFull: |
303 pending_delayed_paint_invalidations_.push_back(¤t_object_); | 303 pending_delayed_paint_invalidations_.push_back(¤t_object_); |
304 break; | 304 break; |
305 case PaintInvalidationReason::kSubtree: | 305 case PaintInvalidationReason::kSubtree: |
306 forced_subtree_invalidation_flags_ |= | 306 forced_subtree_invalidation_flags_ |= |
307 (PaintInvalidatorContext::kForcedSubtreeFullInvalidation | | 307 (PaintInvalidatorContext::kSubtreeFullInvalidation | |
308 PaintInvalidatorContext:: | 308 PaintInvalidatorContext::kSubtreeFullInvalidationForStackedContents); |
309 kForcedSubtreeFullInvalidationForStackedContents); | |
310 break; | 309 break; |
311 case PaintInvalidationReason::kSVGResource: | 310 case PaintInvalidationReason::kSVGResource: |
312 forced_subtree_invalidation_flags_ |= | 311 forced_subtree_invalidation_flags_ |= |
313 PaintInvalidatorContext::kForcedSubtreeSVGResourceChange; | 312 PaintInvalidatorContext::kSubtreeSVGResourceChange; |
314 break; | 313 break; |
315 default: | 314 default: |
316 break; | 315 break; |
317 } | 316 } |
318 | 317 |
319 UpdateForNormalChildren(); | 318 UpdateForNormalChildren(); |
320 | 319 |
321 if (current_object_ == container_for_absolute_position_) { | 320 if (current_object_ == container_for_absolute_position_) { |
322 if (paint_invalidation_container_ == | 321 if (paint_invalidation_container_ == |
323 paint_invalidation_container_for_stacked_contents_) { | 322 paint_invalidation_container_for_stacked_contents_) { |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 | 538 |
540 PaintLayer& PaintInvalidationState::PaintingLayer() const { | 539 PaintLayer& PaintInvalidationState::PaintingLayer() const { |
541 DCHECK_EQ(&painting_layer_, current_object_.PaintingLayer()); | 540 DCHECK_EQ(&painting_layer_, current_object_.PaintingLayer()); |
542 return painting_layer_; | 541 return painting_layer_; |
543 } | 542 } |
544 | 543 |
545 PaintInvalidatorContextAdapter::PaintInvalidatorContextAdapter( | 544 PaintInvalidatorContextAdapter::PaintInvalidatorContextAdapter( |
546 const PaintInvalidationState& paint_invalidation_state) | 545 const PaintInvalidationState& paint_invalidation_state) |
547 : PaintInvalidatorContext(), | 546 : PaintInvalidatorContext(), |
548 paint_invalidation_state_(paint_invalidation_state) { | 547 paint_invalidation_state_(paint_invalidation_state) { |
549 forced_subtree_invalidation_flags = | 548 subtree_flags = paint_invalidation_state.forced_subtree_invalidation_flags_; |
550 paint_invalidation_state.forced_subtree_invalidation_flags_; | |
551 paint_invalidation_container = | 549 paint_invalidation_container = |
552 &paint_invalidation_state.PaintInvalidationContainer(); | 550 &paint_invalidation_state.PaintInvalidationContainer(); |
553 painting_layer = &paint_invalidation_state.PaintingLayer(); | 551 painting_layer = &paint_invalidation_state.PaintingLayer(); |
554 } | 552 } |
555 | 553 |
556 void PaintInvalidatorContextAdapter::MapLocalRectToVisualRectInBacking( | 554 void PaintInvalidatorContextAdapter::MapLocalRectToVisualRectInBacking( |
557 const LayoutObject& object, | 555 const LayoutObject& object, |
558 LayoutRect& rect) const { | 556 LayoutRect& rect) const { |
559 DCHECK_EQ(&object, &paint_invalidation_state_.CurrentObject()); | 557 DCHECK_EQ(&object, &paint_invalidation_state_.CurrentObject()); |
560 paint_invalidation_state_.MapLocalRectToVisualRectInBacking(rect); | 558 paint_invalidation_state_.MapLocalRectToVisualRectInBacking(rect); |
561 } | 559 } |
562 | 560 |
563 } // namespace blink | 561 } // namespace blink |
OLD | NEW |