void PaintLayerCompositor::updateWithoutAcceleratedCompositing(CompositingUpdateType updateType) { ASSERT(!hasAcceleratedCompositing()); if (updateType >= CompositingUpdateAfterCompositingInputChange) CompositingInputsUpdater(rootLayer()).update(); #if ENABLE(ASSERT) CompositingInputsUpdater::assertNeedsCompositingInputsUpdateBitsCleared(rootLayer()); #endif }
void PaintLayerCompositor::updateIfNeeded() { CompositingUpdateType updateType = m_pendingUpdateType; m_pendingUpdateType = CompositingUpdateNone; if (!hasAcceleratedCompositing()) { updateWithoutAcceleratedCompositing(updateType); return; } if (updateType == CompositingUpdateNone) return; PaintLayer* updateRoot = rootLayer(); Vector<PaintLayer*> layersNeedingPaintInvalidation; if (updateType >= CompositingUpdateAfterCompositingInputChange) { CompositingInputsUpdater(updateRoot).update(); #if ENABLE(ASSERT) // FIXME: Move this check to the end of the compositing update. CompositingInputsUpdater::assertNeedsCompositingInputsUpdateBitsCleared(updateRoot); #endif CompositingRequirementsUpdater(m_layoutView, m_compositingReasonFinder).update(updateRoot); CompositingLayerAssigner layerAssigner(this); layerAssigner.assign(updateRoot, layersNeedingPaintInvalidation); bool layersChanged = layerAssigner.layersChanged(); { TRACE_EVENT0("blink", "PaintLayerCompositor::updateAfterCompositingChange"); if (const FrameView::ScrollableAreaSet* scrollableAreas = m_layoutView.frameView()->scrollableAreas()) { for (ScrollableArea* scrollableArea : *scrollableAreas) layersChanged |= scrollableArea->updateAfterCompositingChange(); } } if (layersChanged) { updateType = std::max(updateType, CompositingUpdateRebuildTree); if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) scrollingCoordinator->notifyGeometryChanged(); } } if (updateType != CompositingUpdateNone) { if (RuntimeEnabledFeatures::compositorWorkerEnabled() && m_scrollLayer) { if (Element* scrollingElement = m_layoutView.document().scrollingElement()) { uint64_t elementId = 0; uint32_t mutableProperties = WebCompositorMutablePropertyNone; if (scrollingElement->hasCompositorProxy()) { elementId = DOMNodeIds::idForNode(scrollingElement); mutableProperties = (WebCompositorMutablePropertyScrollLeft | WebCompositorMutablePropertyScrollTop) & scrollingElement->compositorMutableProperties(); } m_scrollLayer->setElementId(elementId); m_scrollLayer->setCompositorMutableProperties(mutableProperties); } } GraphicsLayerUpdater updater; updater.update(*updateRoot, layersNeedingPaintInvalidation); if (updater.needsRebuildTree()) updateType = std::max(updateType, CompositingUpdateRebuildTree); #if ENABLE(ASSERT) // FIXME: Move this check to the end of the compositing update. GraphicsLayerUpdater::assertNeedsToUpdateGraphicsLayerBitsCleared(*updateRoot); #endif } if (updateType >= CompositingUpdateRebuildTree) { GraphicsLayerTreeBuilder::AncestorInfo ancestorInfo; GraphicsLayerVector childList; ancestorInfo.childLayersOfEnclosingCompositedLayer = &childList; { TRACE_EVENT0("blink", "GraphicsLayerTreeBuilder::rebuild"); GraphicsLayerTreeBuilder().rebuild(*updateRoot, ancestorInfo); } if (childList.isEmpty()) destroyRootLayer(); else m_rootContentLayer->setChildren(childList); applyOverlayFullscreenVideoAdjustmentIfNeeded(); } if (m_needsUpdateFixedBackground) { rootFixedBackgroundsChanged(); m_needsUpdateFixedBackground = false; } for (unsigned i = 0; i < layersNeedingPaintInvalidation.size(); i++) forceRecomputePaintInvalidationRectsIncludingNonCompositingDescendants(layersNeedingPaintInvalidation[i]->layoutObject()); m_layoutView.frameView()->setFrameTimingRequestsDirty(true); // Inform the inspector that the layer tree has changed. if (m_layoutView.frame()->isMainFrame()) InspectorInstrumentation::layerTreeDidChange(m_layoutView.frame()); }
void RenderLayerCompositor::updateCompositingLayers(CompositingUpdateType updateType, RenderLayer* updateRoot) { bool checkForHierarchyUpdate = false; bool needGeometryUpdate = false; switch (updateType) { case CompositingUpdateAfterLayoutOrStyleChange: case CompositingUpdateOnPaitingOrHitTest: checkForHierarchyUpdate = true; break; case CompositingUpdateOnScroll: if (m_compositingConsultsOverlap) checkForHierarchyUpdate = true; // Overlap can change with scrolling, so need to check for hierarchy updates. needGeometryUpdate = true; break; } if (!checkForHierarchyUpdate && !needGeometryUpdate) return; ASSERT(inCompositingMode()); bool needHierarchyUpdate = m_compositingLayersNeedRebuild; if (!updateRoot) { // Only clear the flag if we're updating the entire hierarchy. m_compositingLayersNeedRebuild = false; updateRoot = rootRenderLayer(); } #if PROFILE_LAYER_REBUILD ++m_rootLayerUpdateCount; double startTime = WTF::currentTime(); #endif if (checkForHierarchyUpdate) { // Go through the layers in presentation order, so that we can compute which RenderLayers need compositing layers. // FIXME: we could maybe do this and the hierarchy udpate in one pass, but the parenting logic would be more complex. CompositingState compState(updateRoot); bool layersChanged = false; if (m_compositingConsultsOverlap) { OverlapMap overlapTestRequestMap; computeCompositingRequirements(updateRoot, &overlapTestRequestMap, compState, layersChanged); } else computeCompositingRequirements(updateRoot, 0, compState, layersChanged); needHierarchyUpdate |= layersChanged; } if (needHierarchyUpdate) { // Update the hierarchy of the compositing layers. CompositingState compState(updateRoot); Vector<GraphicsLayer*> childList; rebuildCompositingLayerTree(updateRoot, compState, childList); // Host the document layer in the RenderView's root layer. if (updateRoot == rootRenderLayer() && !childList.isEmpty()) m_rootPlatformLayer->setChildren(childList); } else if (needGeometryUpdate) { // We just need to do a geometry update. This is only used for position:fixed scrolling; // most of the time, geometry is updated via RenderLayer::styleChanged(). updateLayerTreeGeometry(updateRoot); } #if PROFILE_LAYER_REBUILD double endTime = WTF::currentTime(); if (updateRoot == rootRenderLayer()) fprintf(stderr, "Update %d: computeCompositingRequirements for the world took %fms\n", m_rootLayerUpdateCount, 1000.0 * (endTime - startTime)); #endif ASSERT(updateRoot || !m_compositingLayersNeedRebuild); if (!hasAcceleratedCompositing()) enableCompositingMode(false); }