本文整理汇总了C++中GraphicsLayer::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsLayer::addChild方法的具体用法?C++ GraphicsLayer::addChild怎么用?C++ GraphicsLayer::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsLayer
的用法示例。
在下文中一共展示了GraphicsLayer::addChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showPaintRect
void WebInspectorClient::showPaintRect(const FloatRect& rect)
{
if (!m_paintRectOverlay) {
m_paintRectOverlay = PageOverlay::create(this, PageOverlay::OverlayType::Document);
m_page->installPageOverlay(m_paintRectOverlay, PageOverlay::FadeMode::DoNotFade);
}
if (!m_paintIndicatorLayerClient)
m_paintIndicatorLayerClient = std::make_unique<RepaintIndicatorLayerClient>(*this);
std::unique_ptr<GraphicsLayer> paintLayer = GraphicsLayer::create(m_page->drawingArea()->graphicsLayerFactory(), *m_paintIndicatorLayerClient);
paintLayer->setAnchorPoint(FloatPoint3D());
paintLayer->setPosition(rect.location());
paintLayer->setSize(rect.size());
paintLayer->setBackgroundColor(Color(1.0f, 0.0f, 0.0f, 0.2f));
KeyframeValueList fadeKeyframes(AnimatedPropertyOpacity);
OwnPtr<AnimationValue> intialValue = FloatAnimationValue::create(0, 1);
fadeKeyframes.insert(intialValue.release());
OwnPtr<AnimationValue> finalValue = FloatAnimationValue::create(0.25, 0);
fadeKeyframes.insert(finalValue.release());
RefPtr<Animation> opacityAnimation = Animation::create();
opacityAnimation->setDuration(0.25);
paintLayer->addAnimation(fadeKeyframes, FloatSize(), opacityAnimation.get(), ASCIILiteral("opacity"), 0);
m_paintRectLayers.add(paintLayer.get());
GraphicsLayer* overlayRootLayer = m_paintRectOverlay->layer();
overlayRootLayer->addChild(paintLayer.release());
}
示例2: setCompositingParent
void RenderLayerCompositor::setCompositingParent(RenderLayer* childLayer, RenderLayer* parentLayer)
{
ASSERT(!parentLayer || childLayer->ancestorCompositingLayer() == parentLayer);
ASSERT(childLayer->isComposited());
// It's possible to be called with a parent that isn't yet composited when we're doing
// partial updates as required by painting or hit testing. Just bail in that case;
// we'll do a full layer update soon.
if (!parentLayer || !parentLayer->isComposited())
return;
if (parentLayer) {
GraphicsLayer* hostingLayer = parentLayer->backing()->parentForSublayers();
GraphicsLayer* hostedLayer = childLayer->backing()->childForSuperlayers();
hostingLayer->addChild(hostedLayer);
} else
childLayer->backing()->childForSuperlayers()->removeFromParent();
}
示例3: updateOverflowControlsLayers
void PaintLayerCompositor::updateOverflowControlsLayers()
{
GraphicsLayer* controlsParent = m_overflowControlsHostLayer.get();
// Main frame scrollbars should always be stuck to the sides of the screen (in overscroll and in pinch-zoom), so
// make the parent for the scrollbars be the viewport container layer.
if (m_layoutView.frame()->isMainFrame()) {
VisualViewport& visualViewport = m_layoutView.frameView()->page()->frameHost().visualViewport();
controlsParent = visualViewport.containerLayer();
}
if (requiresHorizontalScrollbarLayer()) {
if (!m_layerForHorizontalScrollbar) {
m_layerForHorizontalScrollbar = GraphicsLayer::create(graphicsLayerFactory(), this);
}
if (m_layerForHorizontalScrollbar->parent() != controlsParent) {
controlsParent->addChild(m_layerForHorizontalScrollbar.get());
if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(m_layoutView.frameView(), HorizontalScrollbar);
}
} else if (m_layerForHorizontalScrollbar) {
m_layerForHorizontalScrollbar->removeFromParent();
m_layerForHorizontalScrollbar = nullptr;
if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(m_layoutView.frameView(), HorizontalScrollbar);
}
if (requiresVerticalScrollbarLayer()) {
if (!m_layerForVerticalScrollbar) {
m_layerForVerticalScrollbar = GraphicsLayer::create(graphicsLayerFactory(), this);
}
if (m_layerForVerticalScrollbar->parent() != controlsParent) {
controlsParent->addChild(m_layerForVerticalScrollbar.get());
if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(m_layoutView.frameView(), VerticalScrollbar);
}
} else if (m_layerForVerticalScrollbar) {
m_layerForVerticalScrollbar->removeFromParent();
m_layerForVerticalScrollbar = nullptr;
if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(m_layoutView.frameView(), VerticalScrollbar);
}
if (requiresScrollCornerLayer()) {
if (!m_layerForScrollCorner)
m_layerForScrollCorner = GraphicsLayer::create(graphicsLayerFactory(), this);
if (m_layerForScrollCorner->parent() != controlsParent)
controlsParent->addChild(m_layerForScrollCorner.get());
} else if (m_layerForScrollCorner) {
m_layerForScrollCorner->removeFromParent();
m_layerForScrollCorner = nullptr;
}
m_layoutView.frameView()->positionScrollbarLayers();
}
示例4: computeCompositingRequirements
//.........这里部分代码省略.........
childState.m_fixedSibling = true;
break;
}
}
#endif
for (size_t i = 0; i < listSize; ++i) {
RenderLayer* curLayer = negZOrderList->at(i);
computeCompositingRequirements(curLayer, overlapMap, childState, layersChanged);
// If we have to make a layer for this child, make one now so we can have a contents layer
// (since we need to ensure that the -ve z-order child renders underneath our contents).
if (!willBeComposited && childState.m_subtreeIsCompositing) {
// make layer compositing
layer->setMustOverlapCompositedLayers(true);
childState.m_compositingAncestor = layer;
if (overlapMap)
addToOverlapMap(*overlapMap, layer, absBounds, haveComputedBounds);
}
}
}
}
ASSERT(!layer->m_normalFlowListDirty);
if (Vector<RenderLayer*>* normalFlowList = layer->normalFlowList()) {
size_t listSize = normalFlowList->size();
#if ENABLE(COMPOSITED_FIXED_ELEMENTS)
childState.m_fixedSibling = false;
#endif
for (size_t i = 0; i < listSize; ++i) {
RenderLayer* curLayer = normalFlowList->at(i);
computeCompositingRequirements(curLayer, overlapMap, childState, layersChanged);
}
}
if (layer->isStackingContext()) {
if (Vector<RenderLayer*>* posZOrderList = layer->posZOrderList()) {
size_t listSize = posZOrderList->size();
#if ENABLE(COMPOSITED_FIXED_ELEMENTS)
childState.m_fixedSibling = false;
#endif
for (size_t i = 0; i < listSize; ++i) {
RenderLayer* curLayer = posZOrderList->at(i);
computeCompositingRequirements(curLayer, overlapMap, childState, layersChanged);
}
}
}
// If we have a software transform, and we have layers under us, we need to also
// be composited. Also, if we have opacity < 1, then we need to be a layer so that
// the child layers are opaque, then rendered with opacity on this layer.
if (!willBeComposited && childState.m_subtreeIsCompositing && requiresCompositingWhenDescendantsAreCompositing(layer->renderer())) {
layer->setMustOverlapCompositedLayers(true);
if (overlapMap)
addToOverlapMap(*overlapMap, layer, absBounds, haveComputedBounds);
}
if (layer->reflectionLayer())
layer->reflectionLayer()->setMustOverlapCompositedLayers(needsToBeComposited(layer));
// Subsequent layers in the parent stacking context also need to composite.
if (childState.m_subtreeIsCompositing)
compositingState.m_subtreeIsCompositing = true;
// If the layer is going into compositing mode, repaint its old location.
if (!layer->isComposited() && needsToBeComposited(layer))
repaintOnCompositingChange(layer);
// Set the flag to say that this SC has compositing children.
// this can affect the answer to needsToBeComposited() when clipping,
// but that's ok here.
layer->setHasCompositingDescendant(childState.m_subtreeIsCompositing);
// Update backing now, so that we can use isComposited() reliably during tree traversal in rebuildCompositingLayerTree().
if (updateBacking(layer, CompositingChangeRepaintNow))
layersChanged = true;
if (layer->reflectionLayer() && updateLayerCompositingState(layer->reflectionLayer(), CompositingChangeRepaintNow))
layersChanged = true;
}
void RenderLayerCompositor::setCompositingParent(RenderLayer* childLayer, RenderLayer* parentLayer)
{
ASSERT(!parentLayer || childLayer->ancestorCompositingLayer() == parentLayer);
ASSERT(childLayer->isComposited());
// It's possible to be called with a parent that isn't yet composited when we're doing
// partial updates as required by painting or hit testing. Just bail in that case;
// we'll do a full layer update soon.
if (!parentLayer || !parentLayer->isComposited())
return;
if (parentLayer) {
GraphicsLayer* hostingLayer = parentLayer->backing()->parentForSublayers();
GraphicsLayer* hostedLayer = childLayer->backing()->childForSuperlayers();
hostingLayer->addChild(hostedLayer);
} else
childLayer->backing()->childForSuperlayers()->removeFromParent();
}