Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(320)

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 1415143005: Preparation for enabling slimming paint synchronized painting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 m_isPainting = false; 218 m_isPainting = false;
219 m_visuallyNonEmptyCharacterCount = 0; 219 m_visuallyNonEmptyCharacterCount = 0;
220 m_visuallyNonEmptyPixelCount = 0; 220 m_visuallyNonEmptyPixelCount = 0;
221 m_isVisuallyNonEmpty = false; 221 m_isVisuallyNonEmpty = false;
222 clearScrollAnchor(); 222 clearScrollAnchor();
223 m_viewportConstrainedObjects.clear(); 223 m_viewportConstrainedObjects.clear();
224 m_layoutSubtreeRootList.clear(); 224 m_layoutSubtreeRootList.clear();
225 } 225 }
226 226
227 template <typename Function> 227 template <typename Function>
228 void FrameView::forAllFrameViews(Function function) 228 void FrameView::forAllNonThrottledFrameViews(Function function)
229 { 229 {
230 for (Frame* frame = m_frame.get(); frame; frame = frame->tree().traverseNext (m_frame.get())) { 230 if (shouldThrottleRendering())
231 if (!frame->isLocalFrame()) 231 return;
232
233 function(*this);
234
235 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) {
236 if (!child->isLocalFrame())
232 continue; 237 continue;
233 if (FrameView* view = toLocalFrame(frame)->view()) 238 if (FrameView* childView = toLocalFrame(child)->view())
234 function(*view); 239 childView->forAllNonThrottledFrameViews(function);
235 } 240 }
236 } 241 }
237 242
238 void FrameView::removeFromAXObjectCache() 243 void FrameView::removeFromAXObjectCache()
239 { 244 {
240 if (AXObjectCache* cache = axObjectCache()) { 245 if (AXObjectCache* cache = axObjectCache()) {
241 cache->remove(this); 246 cache->remove(this);
242 cache->childrenChanged(m_frame->pagePopupOwner()); 247 cache->childrenChanged(m_frame->pagePopupOwner());
243 } 248 }
244 } 249 }
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 } 1290 }
1286 1291
1287 bool FrameView::shouldSetCursor() const 1292 bool FrameView::shouldSetCursor() const
1288 { 1293 {
1289 Page* page = frame().page(); 1294 Page* page = frame().page();
1290 return page && page->visibilityState() != PageVisibilityStateHidden && page- >focusController().isActive() && page->settings().deviceSupportsMouse(); 1295 return page && page->visibilityState() != PageVisibilityStateHidden && page- >focusController().isActive() && page->settings().deviceSupportsMouse();
1291 } 1296 }
1292 1297
1293 void FrameView::scrollContentsIfNeededRecursive() 1298 void FrameView::scrollContentsIfNeededRecursive()
1294 { 1299 {
1295 forAllFrameViews([](FrameView& frameView) { 1300 forAllNonThrottledFrameViews([](FrameView& frameView) {
1296 if (frameView.shouldThrottleRendering())
1297 return;
1298 frameView.scrollContentsIfNeeded(); 1301 frameView.scrollContentsIfNeeded();
1299 }); 1302 });
1300 } 1303 }
1301 1304
1302 void FrameView::invalidateBackgroundAttachmentFixedObjects() 1305 void FrameView::invalidateBackgroundAttachmentFixedObjects()
1303 { 1306 {
1304 for (const auto& layoutObject : m_backgroundAttachmentFixedObjects) 1307 for (const auto& layoutObject : m_backgroundAttachmentFixedObjects)
1305 layoutObject->setShouldDoFullPaintInvalidation(); 1308 layoutObject->setShouldDoFullPaintInvalidation();
1306 } 1309 }
1307 1310
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1817 CompositedLayerMapping* compositedLayerMapping = layoutView()->layer()-> compositedLayerMapping(); 1820 CompositedLayerMapping* compositedLayerMapping = layoutView()->layer()-> compositedLayerMapping();
1818 compositedLayerMapping->updateContentsOpaque(); 1821 compositedLayerMapping->updateContentsOpaque();
1819 if (compositedLayerMapping->mainGraphicsLayer()) 1822 if (compositedLayerMapping->mainGraphicsLayer())
1820 compositedLayerMapping->mainGraphicsLayer()->setNeedsDisplay(); 1823 compositedLayerMapping->mainGraphicsLayer()->setNeedsDisplay();
1821 } 1824 }
1822 recalculateScrollbarOverlayStyle(); 1825 recalculateScrollbarOverlayStyle();
1823 } 1826 }
1824 1827
1825 void FrameView::updateBackgroundRecursively(const Color& backgroundColor, bool t ransparent) 1828 void FrameView::updateBackgroundRecursively(const Color& backgroundColor, bool t ransparent)
1826 { 1829 {
1827 forAllFrameViews([backgroundColor, transparent](FrameView& frameView) { 1830 forAllNonThrottledFrameViews([backgroundColor, transparent](FrameView& frame View) {
1828 frameView.setTransparent(transparent); 1831 frameView.setTransparent(transparent);
1829 frameView.setBaseBackgroundColor(backgroundColor); 1832 frameView.setBaseBackgroundColor(backgroundColor);
1830 }); 1833 });
1831 } 1834 }
1832 1835
1833 void FrameView::scrollToAnchor() 1836 void FrameView::scrollToAnchor()
1834 { 1837 {
1835 RefPtrWillBeRawPtr<Node> anchorNode = m_scrollAnchor; 1838 RefPtrWillBeRawPtr<Node> anchorNode = m_scrollAnchor;
1836 if (!anchorNode) 1839 if (!anchorNode)
1837 return; 1840 return;
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
2450 invalidateTreeIfNeededRecursive(); 2453 invalidateTreeIfNeededRecursive();
2451 2454
2452 if (view->compositor()->inCompositingMode()) 2455 if (view->compositor()->inCompositingMode())
2453 scrollingCoordinator()->updateAfterCompositingChangeIfNeeded(); 2456 scrollingCoordinator()->updateAfterCompositingChangeIfNeeded();
2454 2457
2455 updateCompositedSelectionIfNeeded(); 2458 updateCompositedSelectionIfNeeded();
2456 2459
2457 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 2460 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
2458 updatePaintProperties(); 2461 updatePaintProperties();
2459 2462
2460 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled ()) { 2463 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled () && !m_frame->document()->printing()) {
2461 synchronizedPaint(); 2464 synchronizedPaint();
2462 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 2465 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
2463 compositeForSlimmingPaintV2(); 2466 compositeForSlimmingPaintV2();
2464 } 2467 }
2465 2468
2466 if (RuntimeEnabledFeatures::frameTimingSupportEnabled()) 2469 if (RuntimeEnabledFeatures::frameTimingSupportEnabled())
2467 updateFrameTimingRequestsIfNeeded(); 2470 updateFrameTimingRequestsIfNeeded();
2468 2471
2469 ASSERT(!view->hasPendingSelection()); 2472 ASSERT(!view->hasPendingSelection());
2470 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationCl ean 2473 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationCl ean
2471 || (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && lifecycl e().state() == DocumentLifecycle::CompositingForSlimmingPaintV2Clean) 2474 || (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && lifecycl e().state() == DocumentLifecycle::CompositingForSlimmingPaintV2Clean)
2472 || (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEna bled() && lifecycle().state() == DocumentLifecycle::PaintClean)); 2475 || (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEna bled() && lifecycle().state() == DocumentLifecycle::PaintClean));
2473 } 2476 }
2474 } 2477 }
2475 2478
2476 updateViewportIntersectionsForSubtree(); 2479 updateViewportIntersectionsForSubtree();
2477 } 2480 }
2478 2481
2479 void FrameView::updatePaintProperties() 2482 void FrameView::updatePaintProperties()
2480 { 2483 {
2481 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); 2484 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
2482 2485
2483 forAllFrameViews([](FrameView& frameView) { frameView.lifecycle().advanceTo( DocumentLifecycle::InUpdatePaintProperties); }); 2486 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle( ).advanceTo(DocumentLifecycle::InUpdatePaintProperties); });
2484 PaintPropertyTreeBuilder().buildPropertyTrees(*this); 2487 PaintPropertyTreeBuilder().buildPropertyTrees(*this);
2485 forAllFrameViews([](FrameView& frameView) { frameView.lifecycle().advanceTo( DocumentLifecycle::UpdatePaintPropertiesClean); }); 2488 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle( ).advanceTo(DocumentLifecycle::UpdatePaintPropertiesClean); });
2486 } 2489 }
2487 2490
2488 void FrameView::synchronizedPaint() 2491 void FrameView::synchronizedPaint()
2489 { 2492 {
2490 ASSERT(RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()); 2493 ASSERT(RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled());
2491 ASSERT(frame() == page()->mainFrame() || (!frame().tree().parent()->isLocalF rame())); 2494 ASSERT(frame() == page()->mainFrame() || (!frame().tree().parent()->isLocalF rame()));
2492 2495
2493 LayoutView* view = layoutView(); 2496 LayoutView* view = layoutView();
2494 ASSERT(view); 2497 ASSERT(view);
2495 // TODO(chrishtr): figure out if there can be any GraphicsLayer above this o ne that draws content. 2498 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle( ).advanceTo(DocumentLifecycle::InPaint); });
2496 GraphicsLayer* rootGraphicsLayer = view->layer()->graphicsLayerBacking();
2497 forAllFrameViews([](FrameView& frameView) { frameView.lifecycle().advanceTo( DocumentLifecycle::InPaint); });
2498 2499
2499 // A null graphics layer can occur for painting of SVG images that are not p arented into the main frame tree. 2500 // A null graphics layer can occur for painting of SVG images that are not p arented into the main frame tree.
2500 if (rootGraphicsLayer) { 2501 if (GraphicsLayer* rootGraphicsLayer = view->layer()->graphicsLayerBacking() ) {
2501 synchronizedPaintRecursively(rootGraphicsLayer); 2502 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
2503 // TODO(wangxianzhu,chrishtr): What about the extra graphics layers for overflow control, virtual viewport, etc?
2504 GraphicsContext context(*rootGraphicsLayer->paintController());
2505 rootGraphicsLayer->paint(context, nullptr);
2506 } else {
2507 while (GraphicsLayer* parent = rootGraphicsLayer->parent())
chrishtr 2015/10/30 21:12:57 Ok can you add a comment here explaining?
Xianzhu 2015/10/30 21:46:26 Done.
2508 rootGraphicsLayer = parent;
2509 synchronizedPaintRecursively(rootGraphicsLayer);
2510 }
2502 } 2511 }
2503 2512
2504 forAllFrameViews([](FrameView& frameView) { 2513 forAllNonThrottledFrameViews([](FrameView& frameView) {
2505 frameView.lifecycle().advanceTo(DocumentLifecycle::PaintClean); 2514 frameView.lifecycle().advanceTo(DocumentLifecycle::PaintClean);
2506 frameView.layoutView()->layer()->clearNeedsRepaintRecursively(); 2515 frameView.layoutView()->layer()->clearNeedsRepaintRecursively();
2507 }); 2516 });
2508 } 2517 }
2509 2518
2510 void FrameView::synchronizedPaintRecursively(GraphicsLayer* graphicsLayer) 2519 void FrameView::synchronizedPaintRecursively(GraphicsLayer* graphicsLayer)
2511 { 2520 {
2521 ASSERT(!RuntimeEnabledFeatures::slimmingPaintV2Enabled());
2512 ASSERT(graphicsLayer->paintController()); 2522 ASSERT(graphicsLayer->paintController());
2513 GraphicsContext context(*graphicsLayer->paintController()); 2523 GraphicsContext context(*graphicsLayer->paintController());
2514 2524
2525 if (GraphicsLayer* maskLayer = graphicsLayer->maskLayer())
2526 synchronizedPaintRecursively(maskLayer);
2527 if (GraphicsLayer* contentsClippingMaskLayer = graphicsLayer->contentsClippi ngMaskLayer())
2528 synchronizedPaintRecursively(contentsClippingMaskLayer);
2529 if (GraphicsLayer* replicaLayer = graphicsLayer->replicaLayer())
2530 synchronizedPaintRecursively(replicaLayer);
2531
2532 // TODO(chrishtr): fix unit tests to not inject one-off interest rects.
2515 graphicsLayer->paint(context, nullptr); 2533 graphicsLayer->paint(context, nullptr);
2516 2534 graphicsLayer->paintController()->commitNewDisplayItems();
2517 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled())
2518 graphicsLayer->paintController()->commitNewDisplayItems();
2519 2535
2520 for (auto& child : graphicsLayer->children()) 2536 for (auto& child : graphicsLayer->children())
2521 synchronizedPaintRecursively(child); 2537 synchronizedPaintRecursively(child);
2522 } 2538 }
2523 2539
2524 void FrameView::compositeForSlimmingPaintV2() 2540 void FrameView::compositeForSlimmingPaintV2()
2525 { 2541 {
2526 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); 2542 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
2527 ASSERT(frame() == page()->mainFrame() || (!frame().tree().parent()->isLocalF rame())); 2543 ASSERT(frame() == page()->mainFrame() || (!frame().tree().parent()->isLocalF rame()));
2528 2544
2529 forAllFrameViews([](FrameView& frameView) { frameView.lifecycle().advanceTo( DocumentLifecycle::InCompositingForSlimmingPaintV2); }); 2545 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle( ).advanceTo(DocumentLifecycle::InCompositingForSlimmingPaintV2); });
2530 2546
2531 // Detached frames can have no root graphics layer.
2532 if (GraphicsLayer* rootGraphicsLayer = layoutView()->layer()->graphicsLayerB acking()) 2547 if (GraphicsLayer* rootGraphicsLayer = layoutView()->layer()->graphicsLayerB acking())
2533 rootGraphicsLayer->paintController()->commitNewDisplayItems(); 2548 rootGraphicsLayer->paintController()->commitNewDisplayItems();
2534 2549
2535 forAllFrameViews([](FrameView& frameView) { frameView.lifecycle().advanceTo( DocumentLifecycle::CompositingForSlimmingPaintV2Clean); }); 2550 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle( ).advanceTo(DocumentLifecycle::CompositingForSlimmingPaintV2Clean); });
2536 } 2551 }
2537 2552
2538 void FrameView::updateFrameTimingRequestsIfNeeded() 2553 void FrameView::updateFrameTimingRequestsIfNeeded()
2539 { 2554 {
2540 GraphicsLayerFrameTimingRequests graphicsLayerTimingRequests; 2555 GraphicsLayerFrameTimingRequests graphicsLayerTimingRequests;
2541 // TODO(mpb) use a 'dirty' bit to not call this every time. 2556 // TODO(mpb) use a 'dirty' bit to not call this every time.
2542 collectFrameTimingRequestsRecursive(graphicsLayerTimingRequests); 2557 collectFrameTimingRequestsRecursive(graphicsLayerTimingRequests);
2543 2558
2544 for (const auto& iter : graphicsLayerTimingRequests) { 2559 for (const auto& iter : graphicsLayerTimingRequests) {
2545 const GraphicsLayer* graphicsLayer = iter.key; 2560 const GraphicsLayer* graphicsLayer = iter.key;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2609 2624
2610 // We need to stop recursing here since a child frame view might not be thro ttled 2625 // We need to stop recursing here since a child frame view might not be thro ttled
2611 // even though we are (e.g., it didn't compute its visibility yet). 2626 // even though we are (e.g., it didn't compute its visibility yet).
2612 if (shouldThrottleRendering()) 2627 if (shouldThrottleRendering())
2613 return; 2628 return;
2614 TRACE_EVENT1("blink", "FrameView::invalidateTreeIfNeededRecursive", "root", layoutView()->debugName().ascii()); 2629 TRACE_EVENT1("blink", "FrameView::invalidateTreeIfNeededRecursive", "root", layoutView()->debugName().ascii());
2615 2630
2616 Vector<LayoutObject*> pendingDelayedPaintInvalidations; 2631 Vector<LayoutObject*> pendingDelayedPaintInvalidations;
2617 PaintInvalidationState rootPaintInvalidationState(*layoutView(), pendingDela yedPaintInvalidations); 2632 PaintInvalidationState rootPaintInvalidationState(*layoutView(), pendingDela yedPaintInvalidations);
2618 2633
2619 invalidateTreeIfNeeded(rootPaintInvalidationState); 2634 if (lifecycle().state() < DocumentLifecycle::PaintInvalidationClean)
2635 invalidateTreeIfNeeded(rootPaintInvalidationState);
2620 2636
2621 // Some frames may be not reached during the above invalidateTreeIfNeeded be cause 2637 // Some frames may be not reached during the above invalidateTreeIfNeeded be cause
2622 // - the frame is a detached frame; or 2638 // - the frame is a detached frame; or
2623 // - it didn't need paint invalidation. 2639 // - it didn't need paint invalidation.
2624 // We need to call invalidateTreeIfNeededRecursive() for such frames to fini sh required 2640 // We need to call invalidateTreeIfNeededRecursive() for such frames to fini sh required
2625 // paint invalidation and advance their life cycle state. 2641 // paint invalidation and advance their life cycle state.
2626 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) { 2642 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) {
2627 if (!child->isLocalFrame()) 2643 if (child->isLocalFrame())
2628 continue; 2644 toLocalFrame(child)->view()->invalidateTreeIfNeededRecursive();
2629 FrameView* childFrameView = toLocalFrame(child)->view();
2630 if (childFrameView->lifecycle().state() < DocumentLifecycle::PaintInvali dationClean)
2631 childFrameView->invalidateTreeIfNeededRecursive();
2632 } 2645 }
2633 2646
2634 // Process objects needing paint invalidation on the next frame. See the def inition of PaintInvalidationDelayedFull for more details. 2647 // Process objects needing paint invalidation on the next frame. See the def inition of PaintInvalidationDelayedFull for more details.
2635 for (auto& target : pendingDelayedPaintInvalidations) 2648 for (auto& target : pendingDelayedPaintInvalidations)
2636 target->setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull); 2649 target->setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull);
2637 } 2650 }
2638 2651
2639 void FrameView::enableAutoSizeMode(const IntSize& minSize, const IntSize& maxSiz e) 2652 void FrameView::enableAutoSizeMode(const IntSize& minSize, const IntSize& maxSiz e)
2640 { 2653 {
2641 if (!m_autoSizeInfo) 2654 if (!m_autoSizeInfo)
(...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after
4078 } 4091 }
4079 4092
4080 bool FrameView::canThrottleRendering() const 4093 bool FrameView::canThrottleRendering() const
4081 { 4094 {
4082 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) 4095 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled())
4083 return false; 4096 return false;
4084 return m_hiddenForThrottling && m_crossOriginForThrottling; 4097 return m_hiddenForThrottling && m_crossOriginForThrottling;
4085 } 4098 }
4086 4099
4087 } // namespace blink 4100 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.h ('k') | third_party/WebKit/Source/core/paint/LayerClipRecorderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698