void ScrollingCoordinatorCoordinatedGraphics::willDestroyScrollableArea(ScrollableArea& scrollableArea) { CoordinatedGraphicsLayer* layer = toCoordinatedGraphicsLayer(scrollLayerForScrollableArea(scrollableArea)); if (!layer) return; layer->setScrollableArea(nullptr); }
void ScrollingCoordinatorCoordinatedGraphics::scrollableAreaScrollLayerDidChange(ScrollableArea& scrollableArea) { CoordinatedGraphicsLayer* layer = toCoordinatedGraphicsLayer(scrollLayerForScrollableArea(scrollableArea)); if (!layer) return; layer->setScrollableArea(&scrollableArea); }
void ScrollingCoordinatorCoordinatedGraphics::detachFromStateTree(ScrollingNodeID nodeID) { ScrollingStateNode* node = m_scrollingStateTree->stateNodeForID(nodeID); if (node && node->nodeType() == FixedNode) toCoordinatedGraphicsLayer(node->layer())->setFixedToViewport(false); m_scrollingStateTree->detachNode(nodeID); }
void CoordinatedLayerTreeHost::initializeRootCompositingLayerIfNeeded() { if (m_didInitializeRootCompositingLayer) return; m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::SetRootCompositingLayer(toCoordinatedGraphicsLayer(m_rootLayer.get())->id())); m_didInitializeRootCompositingLayer = true; m_shouldSyncFrame = true; }
void CompositingCoordinator::initializeRootCompositingLayerIfNeeded() { if (m_didInitializeRootCompositingLayer) return; m_state.rootCompositingLayer = toCoordinatedGraphicsLayer(m_rootLayer.get())->id(); m_didInitializeRootCompositingLayer = true; m_shouldSyncFrame = true; }
void CoordinatedGraphicsLayer::syncPendingStateChangesIncludingSubLayers() { if (m_layerState.hasPendingChanges()) { m_coordinator->syncLayerState(m_id, m_layerState); resetLayerState(); } for (size_t i = 0; i < children().size(); ++i) toCoordinatedGraphicsLayer(children()[i])->syncPendingStateChangesIncludingSubLayers(); }
bool CoordinatedGraphicsLayer::selfOrAncestorHasActiveTransformAnimation() const { if (m_animations.hasActiveAnimationsOfType(AnimatedPropertyWebkitTransform)) return true; if (!parent()) return false; return toCoordinatedGraphicsLayer(parent())->selfOrAncestorHasActiveTransformAnimation(); }
CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage* webPage) : LayerTreeHost(webPage) , m_notifyAfterScheduledLayerFlush(false) , m_isValid(true) , m_isPurging(false) , m_isFlushingLayerChanges(false) , m_waitingForUIProcess(true) , m_isSuspended(false) , m_contentsScale(1) , m_shouldSendScrollPositionUpdate(true) , m_shouldSyncFrame(false) , m_didInitializeRootCompositingLayer(false) , m_layerFlushTimer(this, &CoordinatedLayerTreeHost::layerFlushTimerFired) , m_releaseInactiveAtlasesTimer(this, &CoordinatedLayerTreeHost::releaseInactiveAtlasesTimerFired) , m_layerFlushSchedulingEnabled(true) , m_forceRepaintAsyncCallbackID(0) , m_animationsLocked(false) { // Create a root layer. m_rootLayer = GraphicsLayer::create(this, this); CoordinatedGraphicsLayer* coordinatedRootLayer = toCoordinatedGraphicsLayer(m_rootLayer.get()); coordinatedRootLayer->setRootLayer(true); #ifndef NDEBUG m_rootLayer->setName("CoordinatedLayerTreeHost root layer"); #endif m_rootLayer->setDrawsContent(false); m_rootLayer->setSize(m_webPage->size()); m_layerTreeContext.coordinatedLayerID = toCoordinatedGraphicsLayer(coordinatedRootLayer)->id(); m_nonCompositedContentLayer = GraphicsLayer::create(this, this); #ifndef NDEBUG m_nonCompositedContentLayer->setName("CoordinatedLayerTreeHost non-composited content"); #endif m_nonCompositedContentLayer->setDrawsContent(true); m_nonCompositedContentLayer->setSize(m_webPage->size()); m_rootLayer->addChild(m_nonCompositedContentLayer.get()); if (m_webPage->hasPageOverlay()) createPageOverlayLayer(); scheduleLayerFlush(); }
void CoordinatedGraphicsLayer::flushCompositingState(const FloatRect& rect) { if (!m_coordinator->isFlushingLayerChanges()) { if (client()) client()->notifyFlushRequired(this); return; } if (CoordinatedGraphicsLayer* mask = toCoordinatedGraphicsLayer(maskLayer())) mask->flushCompositingStateForThisLayerOnly(); if (CoordinatedGraphicsLayer* replica = toCoordinatedGraphicsLayer(replicaLayer())) replica->flushCompositingStateForThisLayerOnly(); flushCompositingStateForThisLayerOnly(); for (size_t i = 0; i < children().size(); ++i) children()[i]->flushCompositingState(rect); }
bool LayerTreeCoordinator::flushPendingLayerChanges() { if (m_waitingForUIProcess) return false; for (size_t i = 0; i < m_detachedLayers.size(); ++i) m_webPage->send(Messages::LayerTreeCoordinatorProxy::DeleteCompositingLayer(m_detachedLayers[i])); m_detachedLayers.clear(); bool didSync = m_webPage->corePage()->mainFrame()->view()->flushCompositingStateIncludingSubframes(); m_nonCompositedContentLayer->flushCompositingStateForThisLayerOnly(); if (m_pageOverlayLayer) m_pageOverlayLayer->flushCompositingStateForThisLayerOnly(); m_rootLayer->flushCompositingStateForThisLayerOnly(); purgeReleasedImages(); if (m_shouldSyncRootLayer) { m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetRootCompositingLayer(toCoordinatedGraphicsLayer(m_rootLayer.get())->id())); m_shouldSyncRootLayer = false; } if (m_shouldSyncFrame) { didSync = true; IntSize contentsSize = roundedIntSize(m_nonCompositedContentLayer->size()); IntRect coveredRect = toCoordinatedGraphicsLayer(m_nonCompositedContentLayer.get())->coverRect(); m_webPage->send(Messages::LayerTreeCoordinatorProxy::DidRenderFrame(contentsSize, coveredRect)); m_waitingForUIProcess = true; m_shouldSyncFrame = false; } else unlockAnimations(); if (m_forceRepaintAsyncCallbackID) { m_webPage->send(Messages::WebPageProxy::VoidCallback(m_forceRepaintAsyncCallbackID)); m_forceRepaintAsyncCallbackID = 0; } return didSync; }
LayerTreeCoordinator::LayerTreeCoordinator(WebPage* webPage) : LayerTreeHost(webPage) , m_notifyAfterScheduledLayerFlush(false) , m_isValid(true) , m_waitingForUIProcess(true) , m_isSuspended(false) , m_contentsScale(1) , m_shouldSendScrollPositionUpdate(true) , m_shouldSyncFrame(false) , m_shouldSyncRootLayer(true) , m_layerFlushTimer(this, &LayerTreeCoordinator::layerFlushTimerFired) , m_layerFlushSchedulingEnabled(true) , m_forceRepaintAsyncCallbackID(0) { // Create a root layer. m_rootLayer = GraphicsLayer::create(this); CoordinatedGraphicsLayer* webRootLayer = toCoordinatedGraphicsLayer(m_rootLayer.get()); webRootLayer->setRootLayer(true); #ifndef NDEBUG m_rootLayer->setName("LayerTreeCoordinator root layer"); #endif m_rootLayer->setDrawsContent(false); m_rootLayer->setSize(m_webPage->size()); m_layerTreeContext.webLayerID = toCoordinatedGraphicsLayer(webRootLayer)->id(); m_nonCompositedContentLayer = GraphicsLayer::create(this); toCoordinatedGraphicsLayer(m_rootLayer.get())->setCoordinatedGraphicsLayerClient(this); #ifndef NDEBUG m_nonCompositedContentLayer->setName("LayerTreeCoordinator non-composited content"); #endif m_nonCompositedContentLayer->setDrawsContent(true); m_nonCompositedContentLayer->setSize(m_webPage->size()); m_rootLayer->addChild(m_nonCompositedContentLayer.get()); if (m_webPage->hasPageOverlay()) createPageOverlayLayer(); scheduleLayerFlush(); }
CoordinatedGraphicsLayer* CoordinatedGraphicsLayer::findFirstDescendantWithContentsRecursively() { if (shouldHaveBackingStore()) return this; for (auto& child : children()) { CoordinatedGraphicsLayer* layer = toCoordinatedGraphicsLayer(child)->findFirstDescendantWithContentsRecursively(); if (layer) return layer; } return 0; }
bool CoordinatedGraphicsLayer::selfOrAncestorHaveNonAffineTransforms() { if (m_animations.hasActiveAnimationsOfType(AnimatedPropertyWebkitTransform)) return true; if (!m_layerTransform.combined().isAffine()) return true; if (!parent()) return false; return toCoordinatedGraphicsLayer(parent())->selfOrAncestorHaveNonAffineTransforms(); }
CoordinatedGraphicsLayer* CoordinatedGraphicsLayer::findFirstDescendantWithContentsRecursively() { if (shouldHaveBackingStore()) return this; for (size_t i = 0; i < children().size(); ++i) { CoordinatedGraphicsLayer* layer = toCoordinatedGraphicsLayer(children()[i])->findFirstDescendantWithContentsRecursively(); if (layer) return layer; } return 0; }
bool CompositingCoordinator::flushPendingLayerChanges() { TemporaryChange<bool> protector(m_isFlushingLayerChanges, true); initializeRootCompositingLayerIfNeeded(); bool viewportIsStable = m_page->mainFrame().view()->viewportIsStable(); m_rootLayer->flushCompositingStateForThisLayerOnly(viewportIsStable); m_client->didFlushRootLayer(m_visibleContentsRect); if (m_overlayCompositingLayer) m_overlayCompositingLayer->flushCompositingState(FloatRect(FloatPoint(), m_rootLayer->size()), viewportIsStable); bool didSync = m_page->mainFrame().view()->flushCompositingStateIncludingSubframes(); toCoordinatedGraphicsLayer(m_rootLayer.get())->updateContentBuffersIncludingSubLayers(); toCoordinatedGraphicsLayer(m_rootLayer.get())->syncPendingStateChangesIncludingSubLayers(); flushPendingImageBackingChanges(); if (m_shouldSyncFrame) { didSync = true; if (m_rootCompositingLayer) { m_state.contentsSize = roundedIntSize(m_rootCompositingLayer->size()); if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer()) m_state.coveredRect = contentsLayer->coverRect(); } m_state.scrollPosition = m_visibleContentsRect.location(); m_client->commitSceneState(m_state); clearPendingStateChanges(); m_shouldSyncFrame = false; } return didSync; }
bool CoordinatedLayerTreeHost::flushPendingLayerChanges() { if (m_waitingForUIProcess) return false; TemporaryChange<bool> protector(m_isFlushingLayerChanges, true); createCompositingLayers(); initializeRootCompositingLayerIfNeeded(); m_rootLayer->flushCompositingStateForThisLayerOnly(); m_nonCompositedContentLayer->flushCompositingStateForThisLayerOnly(); if (m_pageOverlayLayer) m_pageOverlayLayer->flushCompositingStateForThisLayerOnly(); bool didSync = m_webPage->corePage()->mainFrame()->view()->flushCompositingStateIncludingSubframes(); flushPendingImageBackingChanges(); deleteCompositingLayers(); if (m_shouldSyncFrame) { didSync = true; m_state.contentsSize = roundedIntSize(m_nonCompositedContentLayer->size()); m_state.coveredRect = toCoordinatedGraphicsLayer(m_nonCompositedContentLayer.get())->coverRect(); m_state.scrollPosition = m_visibleContentsRect.location(); m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::CommitCoordinatedGraphicsState(m_state)); m_state.layersToUpdate.clear(); m_state.imagesToUpdate.clear(); m_waitingForUIProcess = true; m_shouldSyncFrame = false; } else unlockAnimations(); if (m_forceRepaintAsyncCallbackID) { m_webPage->send(Messages::WebPageProxy::VoidCallback(m_forceRepaintAsyncCallbackID)); m_forceRepaintAsyncCallbackID = 0; } return didSync; }
bool CoordinatedGraphicsLayer::hasPendingVisibleChanges() { if (opacity() < 0.01 && !m_animations.hasActiveAnimationsOfType(AnimatedPropertyOpacity)) return false; for (size_t i = 0; i < children().size(); ++i) { if (toCoordinatedGraphicsLayer(children()[i])->hasPendingVisibleChanges()) return true; } bool shouldSyncCanvas = false; #if USE(GRAPHICS_SURFACE) shouldSyncCanvas = m_pendingCanvasOperation & SyncCanvas; #endif if (!m_shouldSyncLayerState && !m_shouldSyncChildren && !m_shouldSyncFilters && !m_shouldSyncImageBacking && !m_shouldSyncAnimations && !shouldSyncCanvas) return false; return tiledBackingStoreVisibleRect().intersects(tiledBackingStoreContentsRect()); }
void ScrollingCoordinatorCoordinatedGraphics::updateViewportConstrainedNode(ScrollingNodeID nodeID, const ViewportConstraints& constraints, GraphicsLayer* graphicsLayer) { ASSERT(supportsFixedPositionLayers()); ScrollingStateNode* node = m_scrollingStateTree->stateNodeForID(nodeID); if (!node) return; switch (constraints.constraintType()) { case ViewportConstraints::FixedPositionConstraint: { toCoordinatedGraphicsLayer(graphicsLayer)->setFixedToViewport(true); // FIXME : Use constraints! downcast<ScrollingStateFixedNode>(*node).setLayer(graphicsLayer); break; } case ViewportConstraints::StickyPositionConstraint: break; // FIXME : Support sticky elements. default: ASSERT_NOT_REACHED(); } }
void CoordinatedGraphicsLayer::setMaskLayer(GraphicsLayer* layer) { if (layer == maskLayer()) return; GraphicsLayer::setMaskLayer(layer); if (!layer) return; layer->setSize(size()); layer->setContentsVisible(contentsAreVisible()); CoordinatedGraphicsLayer* coordinatedLayer = toCoordinatedGraphicsLayer(layer); coordinatedLayer->didChangeLayerState(); m_layerState.mask = coordinatedLayer->id(); m_layerState.maskChanged = true; didChangeLayerState(); }
void LayerTreeCoordinator::performScheduledLayerFlush() { if (m_isSuspended || m_waitingForUIProcess) return; // We lock the animations while performing layout, to avoid flickers caused by animations continuing in the UI process while // the web process layout wants to cancel them. lockAnimations(); syncDisplayState(); // We can unlock the animations before flushing if there are no visible changes, for example if there are content updates // in a layer with opacity 0. bool canUnlockBeforeFlush = !m_isValid || !toCoordinatedGraphicsLayer(m_rootLayer.get())->hasPendingVisibleChanges(); if (canUnlockBeforeFlush) unlockAnimations(); if (!m_isValid) return; if (flushPendingLayerChanges()) didPerformScheduledLayerFlush(); }
CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage* webPage) : LayerTreeHost(webPage) , m_notifyAfterScheduledLayerFlush(false) , m_isValid(true) , m_isSuspended(false) , m_isWaitingForRenderer(true) , m_layerFlushTimer(this, &CoordinatedLayerTreeHost::layerFlushTimerFired) , m_layerFlushSchedulingEnabled(true) , m_forceRepaintAsyncCallbackID(0) { m_coordinator = CompositingCoordinator::create(webPage->corePage(), this); m_coordinator->createRootLayer(webPage->size()); m_layerTreeContext.coordinatedLayerID = toCoordinatedGraphicsLayer(m_coordinator->rootLayer())->id(); CoordinatedSurface::setFactory(createCoordinatedSurface); if (webPage->hasPageOverlay()) createPageOverlayLayer(); scheduleLayerFlush(); }
void CoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector) { // A zero trajectoryVector indicates that tiles all around the viewport are requested. toCoordinatedGraphicsLayer(m_nonCompositedContentLayer.get())->setVisibleContentRectTrajectoryVector(trajectoryVector); bool contentsRectDidChange = rect != m_visibleContentsRect; if (contentsRectDidChange) { m_visibleContentsRect = rect; LayerMap::iterator end = m_registeredLayers.end(); for (LayerMap::iterator it = m_registeredLayers.begin(); it != end; ++it) { it->value->setNeedsVisibleRectAdjustment(); } } scheduleLayerFlush(); if (m_webPage->useFixedLayout()) { // Round the rect instead of enclosing it to make sure that its size stays // the same while panning. This can have nasty effects on layout. m_webPage->setFixedVisibleContentRect(roundedIntRect(rect)); } }
static void updateOffsetFromViewportForSelf(RenderLayer* renderLayer) { // These conditions must match the conditions in RenderLayerCompositor::requiresCompositingForPosition. RenderLayerBacking* backing = renderLayer->backing(); if (!backing) return; RenderStyle* style = renderLayer->renderer()->style(); if (!style) return; if (!renderLayer->renderer()->isOutOfFlowPositioned() || renderLayer->renderer()->style()->position() != FixedPosition) return; if (!renderLayer->renderer()->container()->isRenderView()) return; if (!renderLayer->isStackingContext()) return; CoordinatedGraphicsLayer* graphicsLayer = toCoordinatedGraphicsLayer(backing->graphicsLayer()); graphicsLayer->setFixedToViewport(true); }
void CoordinatedGraphicsLayer::computeTransformedVisibleRect() { if (!m_shouldUpdateVisibleRect && !m_movingVisibleRect) return; m_shouldUpdateVisibleRect = false; TransformationMatrix currentTransform = transform(); if (m_movingVisibleRect) client().getCurrentTransform(this, currentTransform); m_layerTransform.setLocalTransform(currentTransform); m_layerTransform.setAnchorPoint(m_adjustedAnchorPoint); m_layerTransform.setPosition(m_adjustedPosition); m_layerTransform.setSize(m_adjustedSize); m_layerTransform.setFlattening(!preserves3D()); m_layerTransform.setChildrenTransform(childrenTransform()); m_layerTransform.combineTransforms(parent() ? toCoordinatedGraphicsLayer(parent())->m_layerTransform.combinedForChildren() : TransformationMatrix()); m_cachedInverseTransform = m_layerTransform.combined().inverse(); // The combined transform will be used in tiledBackingStoreVisibleRect. setNeedsVisibleRectAdjustment(); }
void CoordinatedGraphicsLayer::removeFromParent() { if (CoordinatedGraphicsLayer* parentLayer = toCoordinatedGraphicsLayer(parent())) parentLayer->didChangeChildren(); GraphicsLayer::removeFromParent(); }
static CoordinatedLayerID toCoordinatedLayerID(GraphicsLayer* layer) { return layer ? toCoordinatedGraphicsLayer(layer)->id() : 0; }