OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 fullscreen_element = | 177 fullscreen_element = |
178 Fullscreen::CurrentFullScreenElementFrom(*content_document); | 178 Fullscreen::CurrentFullScreenElementFrom(*content_document); |
179 if (!isHTMLVideoElement(fullscreen_element)) | 179 if (!isHTMLVideoElement(fullscreen_element)) |
180 return nullptr; | 180 return nullptr; |
181 LayoutObject* layout_object = fullscreen_element->GetLayoutObject(); | 181 LayoutObject* layout_object = fullscreen_element->GetLayoutObject(); |
182 if (!layout_object) | 182 if (!layout_object) |
183 return nullptr; | 183 return nullptr; |
184 return ToLayoutVideo(layout_object); | 184 return ToLayoutVideo(layout_object); |
185 } | 185 } |
186 | 186 |
187 void PaintLayerCompositor::UpdateIfNeededRecursive() { | 187 void PaintLayerCompositor::UpdateIfNeededRecursive( |
188 DocumentLifecycle::LifecycleState target_state) { | |
188 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.Compositing.UpdateTime"); | 189 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.Compositing.UpdateTime"); |
189 UpdateIfNeededRecursiveInternal(); | 190 UpdateIfNeededRecursiveInternal(target_state); |
190 } | 191 } |
191 | 192 |
192 void PaintLayerCompositor::UpdateIfNeededRecursiveInternal() { | 193 void PaintLayerCompositor::UpdateIfNeededRecursiveInternal( |
194 DocumentLifecycle::LifecycleState target_state) { | |
195 DCHECK(target_state >= DocumentLifecycle::kCompositingInputsClean); | |
196 | |
193 FrameView* view = layout_view_.GetFrameView(); | 197 FrameView* view = layout_view_.GetFrameView(); |
194 if (view->ShouldThrottleRendering()) | 198 if (view->ShouldThrottleRendering()) |
195 return; | 199 return; |
196 | 200 |
197 for (Frame* child = | 201 for (Frame* child = |
198 layout_view_.GetFrameView()->GetFrame().Tree().FirstChild(); | 202 layout_view_.GetFrameView()->GetFrame().Tree().FirstChild(); |
199 child; child = child->Tree().NextSibling()) { | 203 child; child = child->Tree().NextSibling()) { |
200 if (!child->IsLocalFrame()) | 204 if (!child->IsLocalFrame()) |
201 continue; | 205 continue; |
202 LocalFrame* local_frame = ToLocalFrame(child); | 206 LocalFrame* local_frame = ToLocalFrame(child); |
203 // It's possible for trusted Pepper plugins to force hit testing in | 207 // It's possible for trusted Pepper plugins to force hit testing in |
204 // situations where the frame tree is in an inconsistent state, such as in | 208 // situations where the frame tree is in an inconsistent state, such as in |
205 // the middle of frame detach. | 209 // the middle of frame detach. |
206 // TODO(bbudge) Remove this check when trusted Pepper plugins are gone. | 210 // TODO(bbudge) Remove this check when trusted Pepper plugins are gone. |
207 if (local_frame->GetDocument()->IsActive() && | 211 if (local_frame->GetDocument()->IsActive() && |
208 !local_frame->ContentLayoutItem().IsNull()) | 212 !local_frame->ContentLayoutItem().IsNull()) { |
209 local_frame->ContentLayoutItem() | 213 local_frame->ContentLayoutItem() |
210 .Compositor() | 214 .Compositor() |
211 ->UpdateIfNeededRecursiveInternal(); | 215 ->UpdateIfNeededRecursiveInternal(target_state); |
216 } | |
212 } | 217 } |
213 | 218 |
214 TRACE_EVENT0("blink", "PaintLayerCompositor::updateIfNeededRecursive"); | 219 TRACE_EVENT0("blink", "PaintLayerCompositor::updateIfNeededRecursive"); |
215 | 220 |
216 DCHECK(!layout_view_.NeedsLayout()); | 221 DCHECK(!layout_view_.NeedsLayout()); |
217 | 222 |
218 ScriptForbiddenScope forbid_script; | 223 ScriptForbiddenScope forbid_script; |
219 | 224 |
220 // FIXME: enableCompositingModeIfNeeded can trigger a | 225 // FIXME: enableCompositingModeIfNeeded can trigger a |
221 // CompositingUpdateRebuildTree, which asserts that it's not | 226 // CompositingUpdateRebuildTree, which asserts that it's not |
222 // InCompositingUpdate. | 227 // InCompositingUpdate. |
223 EnableCompositingModeIfNeeded(); | 228 EnableCompositingModeIfNeeded(); |
224 | 229 |
225 RootLayer()->UpdateDescendantDependentFlags(); | 230 RootLayer()->UpdateDescendantDependentFlags(); |
226 | 231 |
227 layout_view_.CommitPendingSelection(); | 232 layout_view_.CommitPendingSelection(); |
228 | 233 |
229 Lifecycle().AdvanceTo(DocumentLifecycle::kInCompositingUpdate); | 234 UpdateIfNeeded(target_state); |
230 UpdateIfNeeded(); | 235 DCHECK(Lifecycle().GetState() == DocumentLifecycle::kCompositingInputsClean || |
231 Lifecycle().AdvanceTo(DocumentLifecycle::kCompositingClean); | 236 Lifecycle().GetState() == DocumentLifecycle::kCompositingClean); |
237 if (target_state == DocumentLifecycle::kCompositingInputsClean) | |
238 return; | |
232 | 239 |
233 Optional<CompositorElementIdSet> composited_element_ids; | 240 Optional<CompositorElementIdSet> composited_element_ids; |
234 DocumentAnimations::UpdateAnimations(layout_view_.GetDocument(), | 241 DocumentAnimations::UpdateAnimations(layout_view_.GetDocument(), |
235 DocumentLifecycle::kCompositingClean, | 242 DocumentLifecycle::kCompositingClean, |
236 composited_element_ids); | 243 composited_element_ids); |
237 | 244 |
238 layout_view_.GetFrameView() | 245 layout_view_.GetFrameView() |
239 ->GetScrollableArea() | 246 ->GetScrollableArea() |
240 ->UpdateCompositorScrollAnimations(); | 247 ->UpdateCompositorScrollAnimations(); |
241 if (const FrameView::ScrollableAreaSet* animating_scrollable_areas = | 248 if (const FrameView::ScrollableAreaSet* animating_scrollable_areas = |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
364 GraphicsLayer* PaintLayerCompositor::ParentForContentLayers() const { | 371 GraphicsLayer* PaintLayerCompositor::ParentForContentLayers() const { |
365 if (root_content_layer_) | 372 if (root_content_layer_) |
366 return root_content_layer_.get(); | 373 return root_content_layer_.get(); |
367 | 374 |
368 DCHECK(RuntimeEnabledFeatures::rootLayerScrollingEnabled()); | 375 DCHECK(RuntimeEnabledFeatures::rootLayerScrollingEnabled()); |
369 // Iframe content layers will be connected by the parent frame using | 376 // Iframe content layers will be connected by the parent frame using |
370 // attachFrameContentLayersToIframeLayer. | 377 // attachFrameContentLayersToIframeLayer. |
371 return IsMainFrame() ? GetVisualViewport().ScrollLayer() : nullptr; | 378 return IsMainFrame() ? GetVisualViewport().ScrollLayer() : nullptr; |
372 } | 379 } |
373 | 380 |
374 void PaintLayerCompositor::UpdateIfNeeded() { | 381 void PaintLayerCompositor::UpdateIfNeeded( |
382 DocumentLifecycle::LifecycleState target_state) { | |
383 DCHECK(target_state >= DocumentLifecycle::kCompositingInputsClean); | |
384 | |
385 Lifecycle().AdvanceTo(DocumentLifecycle::kInCompositingUpdate); | |
386 | |
375 CompositingUpdateType update_type = pending_update_type_; | 387 CompositingUpdateType update_type = pending_update_type_; |
376 pending_update_type_ = kCompositingUpdateNone; | 388 pending_update_type_ = kCompositingUpdateNone; |
377 | 389 |
378 if (!HasAcceleratedCompositing()) { | 390 if (!HasAcceleratedCompositing()) { |
379 UpdateWithoutAcceleratedCompositing(update_type); | 391 UpdateWithoutAcceleratedCompositing(update_type); |
392 Lifecycle().AdvanceTo( | |
393 std::min(DocumentLifecycle::kCompositingClean, target_state)); | |
380 return; | 394 return; |
381 } | 395 } |
382 | 396 |
383 if (update_type == kCompositingUpdateNone) | 397 if (update_type == kCompositingUpdateNone) { |
398 Lifecycle().AdvanceTo( | |
399 std::min(DocumentLifecycle::kCompositingClean, target_state)); | |
384 return; | 400 return; |
401 } | |
385 | 402 |
386 PaintLayer* update_root = RootLayer(); | 403 PaintLayer* update_root = RootLayer(); |
387 | 404 |
405 // TODO(smcgruer): This function should be refactored, but for now just place | |
406 // this here to make the target behavioral change clear. | |
407 if (target_state == DocumentLifecycle::kCompositingInputsClean) { | |
408 // Restore the update type. | |
409 pending_update_type_ = update_type; | |
410 if (pending_update_type_ >= kCompositingUpdateAfterCompositingInputChange) { | |
411 CompositingInputsUpdater(update_root).Update(); | |
412 } | |
413 Lifecycle().AdvanceTo(DocumentLifecycle::kCompositingInputsClean); | |
414 return; | |
415 } | |
416 | |
388 Vector<PaintLayer*> layers_needing_paint_invalidation; | 417 Vector<PaintLayer*> layers_needing_paint_invalidation; |
389 | 418 |
390 if (update_type >= kCompositingUpdateAfterCompositingInputChange) { | 419 if (update_type >= kCompositingUpdateAfterCompositingInputChange) { |
391 CompositingInputsUpdater(update_root).Update(); | 420 CompositingInputsUpdater(update_root).Update(); |
392 | 421 |
393 #if DCHECK_IS_ON() | 422 #if DCHECK_IS_ON() |
394 // FIXME: Move this check to the end of the compositing update. | 423 // FIXME: Move this check to the end of the compositing update. |
395 CompositingInputsUpdater::AssertNeedsCompositingInputsUpdateBitsCleared( | 424 CompositingInputsUpdater::AssertNeedsCompositingInputsUpdateBitsCleared( |
flackr
2017/04/11 20:46:28
We should have this assert for CompositingInputsCl
smcgruer
2017/04/12 15:33:04
Done.
| |
396 update_root); | 425 update_root); |
397 #endif | 426 #endif |
398 | 427 |
399 CompositingRequirementsUpdater(layout_view_, compositing_reason_finder_) | 428 CompositingRequirementsUpdater(layout_view_, compositing_reason_finder_) |
400 .Update(update_root); | 429 .Update(update_root); |
401 | 430 |
402 CompositingLayerAssigner layer_assigner(this); | 431 CompositingLayerAssigner layer_assigner(this); |
403 layer_assigner.Assign(update_root, layers_needing_paint_invalidation); | 432 layer_assigner.Assign(update_root, layers_needing_paint_invalidation); |
404 | 433 |
405 bool layers_changed = layer_assigner.LayersChanged(); | 434 bool layers_changed = layer_assigner.LayersChanged(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
481 if (Page* page = layout_view_.GetFrame()->GetPage()) { | 510 if (Page* page = layout_view_.GetFrame()->GetPage()) { |
482 page->GetChromeClient().AttachRootGraphicsLayer(RootGraphicsLayer(), | 511 page->GetChromeClient().AttachRootGraphicsLayer(RootGraphicsLayer(), |
483 layout_view_.GetFrame()); | 512 layout_view_.GetFrame()); |
484 root_layer_attachment_ = kRootLayerAttachedViaChromeClient; | 513 root_layer_attachment_ = kRootLayerAttachedViaChromeClient; |
485 } | 514 } |
486 } | 515 } |
487 | 516 |
488 // Inform the inspector that the layer tree has changed. | 517 // Inform the inspector that the layer tree has changed. |
489 if (IsMainFrame()) | 518 if (IsMainFrame()) |
490 probe::layerTreeDidChange(layout_view_.GetFrame()); | 519 probe::layerTreeDidChange(layout_view_.GetFrame()); |
520 | |
521 Lifecycle().AdvanceTo(DocumentLifecycle::kCompositingClean); | |
491 } | 522 } |
492 | 523 |
493 static void RestartAnimationOnCompositor(const LayoutObject& layout_object) { | 524 static void RestartAnimationOnCompositor(const LayoutObject& layout_object) { |
494 Node* node = layout_object.GetNode(); | 525 Node* node = layout_object.GetNode(); |
495 ElementAnimations* element_animations = | 526 ElementAnimations* element_animations = |
496 (node && node->IsElementNode()) ? ToElement(node)->GetElementAnimations() | 527 (node && node->IsElementNode()) ? ToElement(node)->GetElementAnimations() |
497 : nullptr; | 528 : nullptr; |
498 if (element_animations) | 529 if (element_animations) |
499 element_animations->RestartAnimationOnCompositor(); | 530 element_animations->RestartAnimationOnCompositor(); |
500 } | 531 } |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1333 } else if (graphics_layer == scroll_layer_.get()) { | 1364 } else if (graphics_layer == scroll_layer_.get()) { |
1334 name = "Frame Scrolling Layer"; | 1365 name = "Frame Scrolling Layer"; |
1335 } else { | 1366 } else { |
1336 NOTREACHED(); | 1367 NOTREACHED(); |
1337 } | 1368 } |
1338 | 1369 |
1339 return name; | 1370 return name; |
1340 } | 1371 } |
1341 | 1372 |
1342 } // namespace blink | 1373 } // namespace blink |
OLD | NEW |