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 |
| 387 if (pending_update_type_ < kCompositingUpdateAfterCompositingInputChange && |
| 388 target_state == DocumentLifecycle::kCompositingInputsClean) { |
| 389 // The compositing inputs are already clean and that is our target state. |
| 390 // Early-exit here without clearing the pending update type since we haven't |
| 391 // handled e.g. geometry updates. |
| 392 Lifecycle().AdvanceTo(DocumentLifecycle::kCompositingInputsClean); |
| 393 return; |
| 394 } |
| 395 |
375 CompositingUpdateType update_type = pending_update_type_; | 396 CompositingUpdateType update_type = pending_update_type_; |
376 pending_update_type_ = kCompositingUpdateNone; | 397 pending_update_type_ = kCompositingUpdateNone; |
377 | 398 |
378 if (!HasAcceleratedCompositing()) { | 399 if (!HasAcceleratedCompositing()) { |
379 UpdateWithoutAcceleratedCompositing(update_type); | 400 UpdateWithoutAcceleratedCompositing(update_type); |
| 401 Lifecycle().AdvanceTo( |
| 402 std::min(DocumentLifecycle::kCompositingClean, target_state)); |
380 return; | 403 return; |
381 } | 404 } |
382 | 405 |
383 if (update_type == kCompositingUpdateNone) | 406 if (update_type == kCompositingUpdateNone) { |
| 407 Lifecycle().AdvanceTo( |
| 408 std::min(DocumentLifecycle::kCompositingClean, target_state)); |
384 return; | 409 return; |
| 410 } |
385 | 411 |
386 PaintLayer* update_root = RootLayer(); | 412 PaintLayer* update_root = RootLayer(); |
387 | 413 |
388 Vector<PaintLayer*> layers_needing_paint_invalidation; | 414 Vector<PaintLayer*> layers_needing_paint_invalidation; |
389 | 415 |
390 if (update_type >= kCompositingUpdateAfterCompositingInputChange) { | 416 if (update_type >= kCompositingUpdateAfterCompositingInputChange) { |
391 CompositingInputsUpdater(update_root).Update(); | 417 CompositingInputsUpdater(update_root).Update(); |
392 | 418 |
393 #if DCHECK_IS_ON() | 419 #if DCHECK_IS_ON() |
394 // FIXME: Move this check to the end of the compositing update. | 420 // FIXME: Move this check to the end of the compositing update. |
395 CompositingInputsUpdater::AssertNeedsCompositingInputsUpdateBitsCleared( | 421 CompositingInputsUpdater::AssertNeedsCompositingInputsUpdateBitsCleared( |
396 update_root); | 422 update_root); |
397 #endif | 423 #endif |
398 | 424 |
| 425 // In the case where we only want to make compositing inputs clean, we |
| 426 // early-exit here. Because we have not handled the other implications of |
| 427 // |pending_update_type_| > kCompositingUpdateNone, we must restore the |
| 428 // pending update type for a future call. |
| 429 if (target_state == DocumentLifecycle::kCompositingInputsClean) { |
| 430 pending_update_type_ = update_type; |
| 431 Lifecycle().AdvanceTo(DocumentLifecycle::kCompositingInputsClean); |
| 432 return; |
| 433 } |
| 434 |
399 CompositingRequirementsUpdater(layout_view_, compositing_reason_finder_) | 435 CompositingRequirementsUpdater(layout_view_, compositing_reason_finder_) |
400 .Update(update_root); | 436 .Update(update_root); |
401 | 437 |
402 CompositingLayerAssigner layer_assigner(this); | 438 CompositingLayerAssigner layer_assigner(this); |
403 layer_assigner.Assign(update_root, layers_needing_paint_invalidation); | 439 layer_assigner.Assign(update_root, layers_needing_paint_invalidation); |
404 | 440 |
405 bool layers_changed = layer_assigner.LayersChanged(); | 441 bool layers_changed = layer_assigner.LayersChanged(); |
406 | 442 |
407 { | 443 { |
408 TRACE_EVENT0("blink", | 444 TRACE_EVENT0("blink", |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 if (Page* page = layout_view_.GetFrame()->GetPage()) { | 519 if (Page* page = layout_view_.GetFrame()->GetPage()) { |
484 page->GetChromeClient().AttachRootGraphicsLayer(RootGraphicsLayer(), | 520 page->GetChromeClient().AttachRootGraphicsLayer(RootGraphicsLayer(), |
485 layout_view_.GetFrame()); | 521 layout_view_.GetFrame()); |
486 root_layer_attachment_ = kRootLayerAttachedViaChromeClient; | 522 root_layer_attachment_ = kRootLayerAttachedViaChromeClient; |
487 } | 523 } |
488 } | 524 } |
489 | 525 |
490 // Inform the inspector that the layer tree has changed. | 526 // Inform the inspector that the layer tree has changed. |
491 if (IsMainFrame()) | 527 if (IsMainFrame()) |
492 probe::layerTreeDidChange(layout_view_.GetFrame()); | 528 probe::layerTreeDidChange(layout_view_.GetFrame()); |
| 529 |
| 530 Lifecycle().AdvanceTo(DocumentLifecycle::kCompositingClean); |
493 } | 531 } |
494 | 532 |
495 static void RestartAnimationOnCompositor(const LayoutObject& layout_object) { | 533 static void RestartAnimationOnCompositor(const LayoutObject& layout_object) { |
496 Node* node = layout_object.GetNode(); | 534 Node* node = layout_object.GetNode(); |
497 ElementAnimations* element_animations = | 535 ElementAnimations* element_animations = |
498 (node && node->IsElementNode()) ? ToElement(node)->GetElementAnimations() | 536 (node && node->IsElementNode()) ? ToElement(node)->GetElementAnimations() |
499 : nullptr; | 537 : nullptr; |
500 if (element_animations) | 538 if (element_animations) |
501 element_animations->RestartAnimationOnCompositor(); | 539 element_animations->RestartAnimationOnCompositor(); |
502 } | 540 } |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 } else if (graphics_layer == scroll_layer_.get()) { | 1373 } else if (graphics_layer == scroll_layer_.get()) { |
1336 name = "Frame Scrolling Layer"; | 1374 name = "Frame Scrolling Layer"; |
1337 } else { | 1375 } else { |
1338 NOTREACHED(); | 1376 NOTREACHED(); |
1339 } | 1377 } |
1340 | 1378 |
1341 return name; | 1379 return name; |
1342 } | 1380 } |
1343 | 1381 |
1344 } // namespace blink | 1382 } // namespace blink |
OLD | NEW |