本文整理汇总了C++中PaintLayer类的典型用法代码示例。如果您正苦于以下问题:C++ PaintLayer类的具体用法?C++ PaintLayer怎么用?C++ PaintLayer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PaintLayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shouldCreateSubsequence
static bool shouldCreateSubsequence(const PaintLayer& paintLayer, GraphicsContext& context, const PaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
{
// Caching is not needed during printing.
if (context.printing())
return false;
// Don't create subsequence for a composited layer because if it can be cached,
// we can skip the whole painting in GraphicsLayer::paint() with CachedDisplayItemList.
// This also avoids conflict of PaintLayer::previousXXX() when paintLayer is composited
// scrolling and is painted twice for GraphicsLayers of container and scrolling contents.
if (paintLayer.compositingState() == PaintsIntoOwnBacking)
return false;
// Don't create subsequence during special painting to avoid cache conflict with normal painting.
if (paintingInfo.globalPaintFlags() & GlobalPaintFlattenCompositingLayers)
return false;
if (paintFlags & (PaintLayerPaintingReflection | PaintLayerPaintingRootBackgroundOnly | PaintLayerPaintingOverlayScrollbars | PaintLayerUncachedClipRects))
return false;
// Create subsequence for only stacking contexts whose painting are atomic.
if (!paintLayer.stackingNode()->isStackingContext())
return false;
// The layer doesn't have children. Subsequence caching is not worth because normally the actual painting will be cheap.
if (!PaintLayerStackingNodeIterator(*paintLayer.stackingNode(), AllChildren).next())
return false;
return true;
}
示例2: TEST_F
TEST_F(PaintLayerClipperTest, NestedContainPaintClip) {
setBodyInnerHTML(
"<div style='contain: paint; width: 200px; height: 200px; overflow: "
"auto'>"
" <div id='target' style='contain: paint; height: 400px'>"
" </div>"
"</div>");
LayoutRect infiniteRect(LayoutRect::infiniteIntRect());
PaintLayer* layer =
toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer();
ClipRectsContext context(layer->parent(),
PaintingClipRectsIgnoringOverflowClip);
LayoutRect layerBounds;
ClipRect backgroundRect, foregroundRect;
layer->clipper().calculateRects(context, infiniteRect, layerBounds,
backgroundRect, foregroundRect);
EXPECT_EQ(LayoutRect(0, 0, 200, 400), backgroundRect.rect());
EXPECT_EQ(LayoutRect(0, 0, 200, 400), foregroundRect.rect());
EXPECT_EQ(LayoutRect(0, 0, 200, 400), layerBounds);
ClipRectsContext contextClip(layer->parent(), PaintingClipRects);
layer->clipper().calculateRects(contextClip, infiniteRect, layerBounds,
backgroundRect, foregroundRect);
EXPECT_EQ(LayoutRect(0, 0, 200, 200), backgroundRect.rect());
EXPECT_EQ(LayoutRect(0, 0, 200, 200), foregroundRect.rect());
EXPECT_EQ(LayoutRect(0, 0, 200, 400), layerBounds);
}
示例3: idForNode
void InspectorLayerTreeAgent::buildLayerIdToNodeIdMap(
PaintLayer* root,
LayerIdToNodeIdMap& layerIdToNodeIdMap) {
if (root->hasCompositedLayerMapping()) {
if (Node* node = root->layoutObject()->generatingNode()) {
GraphicsLayer* graphicsLayer =
root->compositedLayerMapping()->childForSuperlayers();
layerIdToNodeIdMap.set(graphicsLayer->platformLayer()->id(),
idForNode(node));
}
}
for (PaintLayer* child = root->firstChild(); child;
child = child->nextSibling())
buildLayerIdToNodeIdMap(child, layerIdToNodeIdMap);
if (!root->layoutObject()->isLayoutIFrame())
return;
FrameView* childFrameView =
toFrameView(toLayoutPart(root->layoutObject())->widget());
LayoutViewItem childLayoutViewItem = childFrameView->layoutViewItem();
if (!childLayoutViewItem.isNull()) {
if (PaintLayerCompositor* childCompositor =
childLayoutViewItem.compositor())
buildLayerIdToNodeIdMap(childCompositor->rootLayer(), layerIdToNodeIdMap);
}
}
示例4: toLayoutBoxModelObject
void PaintPropertyTreeBuilder::updatePaintOffsetTranslation(const LayoutObject& object, PaintPropertyTreeBuilderContext& context)
{
if (object.isBoxModelObject()) {
// TODO(trchen): Eliminate PaintLayer dependency.
PaintLayer* layer = toLayoutBoxModelObject(object).layer();
if (!layer || !layer->paintsWithTransform(GlobalPaintNormalPhase))
return;
}
if (context.paintOffset == LayoutPoint())
return;
// We should use the same subpixel paint offset values for snapping regardless of whether a
// transform is present. If there is a transform we round the paint offset but keep around
// the residual fractional component for the transformed content to paint with.
// In spv1 this was called "subpixel accumulation". For more information, see
// PaintLayer::subpixelAccumulation() and PaintLayerPainter::paintFragmentByApplyingTransform.
IntPoint roundedPaintOffset = roundedIntPoint(context.paintOffset);
LayoutPoint fractionalPaintOffset = LayoutPoint(context.paintOffset - roundedPaintOffset);
RefPtr<TransformPaintPropertyNode> paintOffsetTranslation = TransformPaintPropertyNode::create(
TransformationMatrix().translate(roundedPaintOffset.x(), roundedPaintOffset.y()),
FloatPoint3D(), context.currentTransform);
context.currentTransform = paintOffsetTranslation.get();
context.paintOffset = fractionalPaintOffset;
object.getMutableForPainting().ensureObjectPaintProperties().setPaintOffsetTranslation(paintOffsetTranslation.release());
}
示例5: setIndexToLastItem
PaintLayerStackingNode* PaintLayerStackingNodeReverseIterator::next()
{
if (m_remainingChildren & NegativeZOrderChildren) {
Vector<PaintLayerStackingNode*>* negZOrderList = m_root.negZOrderList();
if (negZOrderList && m_index >= 0)
return negZOrderList->at(m_index--);
m_remainingChildren &= ~NegativeZOrderChildren;
setIndexToLastItem();
}
if (m_remainingChildren & NormalFlowChildren) {
for (; m_currentNormalFlowChild; m_currentNormalFlowChild = m_currentNormalFlowChild->previousSibling()) {
if (!m_currentNormalFlowChild->stackingNode()->isStacked() && !m_currentNormalFlowChild->isReflection()) {
PaintLayer* normalFlowChild = m_currentNormalFlowChild;
m_currentNormalFlowChild = m_currentNormalFlowChild->previousSibling();
return normalFlowChild->stackingNode();
}
}
m_remainingChildren &= ~NormalFlowChildren;
setIndexToLastItem();
}
if (m_remainingChildren & PositiveZOrderChildren) {
Vector<PaintLayerStackingNode*>* posZOrderList = m_root.posZOrderList();
if (posZOrderList && m_index >= 0)
return posZOrderList->at(m_index--);
m_remainingChildren &= ~PositiveZOrderChildren;
setIndexToLastItem();
}
return 0;
}
示例6: ASSERT
bool CompositorAnimations::startAnimationOnCompositor(const Element& element, int group, double startTime, double timeOffset, const Timing& timing, const Animation& animation, const EffectModel& effect, Vector<int>& startedAnimationIds, double animationPlaybackRate)
{
ASSERT(startedAnimationIds.isEmpty());
ASSERT(isCandidateForAnimationOnCompositor(timing, element, &animation, effect, animationPlaybackRate));
ASSERT(canStartAnimationOnCompositor(element));
const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(effect);
PaintLayer* layer = toLayoutBoxModelObject(element.layoutObject())->layer();
ASSERT(layer);
Vector<OwnPtr<WebCompositorAnimation>> animations;
CompositorAnimationsImpl::getAnimationOnCompositor(timing, group, startTime, timeOffset, keyframeEffect, animations, animationPlaybackRate);
ASSERT(!animations.isEmpty());
for (auto& compositorAnimation : animations) {
int id = compositorAnimation->id();
if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) {
WebCompositorAnimationPlayer* compositorPlayer = animation.compositorPlayer();
ASSERT(compositorPlayer);
compositorPlayer->addAnimation(compositorAnimation.leakPtr());
} else if (!layer->compositedLayerMapping()->mainGraphicsLayer()->addAnimation(compositorAnimation.release())) {
// FIXME: We should know ahead of time whether these animations can be started.
for (int startedAnimationId : startedAnimationIds)
cancelAnimationOnCompositor(element, animation, startedAnimationId);
startedAnimationIds.clear();
return false;
}
startedAnimationIds.append(id);
}
ASSERT(!startedAnimationIds.isEmpty());
return true;
}
示例7: TEST_F
TEST_F(PaintLayerScrollableAreaTest, OpaqueLayersDepromotedOnStyleChange) {
RuntimeEnabledFeatures::setCompositeOpaqueScrollersEnabled(true);
setBodyInnerHTML(
"<style>"
"#scroller { overflow: scroll; height: 200px; width: 200px; background: "
"white local content-box; }"
"#scrolled { height: 300px; }"
"</style>"
"<div id=\"scroller\"><div id=\"scrolled\"></div></div>");
document().view()->updateAllLifecyclePhases();
EXPECT_TRUE(RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled());
Element* scroller = document().getElementById("scroller");
PaintLayer* paintLayer =
toLayoutBoxModelObject(scroller->layoutObject())->layer();
ASSERT_TRUE(paintLayer);
EXPECT_TRUE(paintLayer->needsCompositedScrolling());
// Change the background to transparent
scroller->setAttribute(
HTMLNames::styleAttr,
"background: rgba(255,255,255,0.5) local content-box;");
document().view()->updateAllLifecyclePhases();
paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
ASSERT_TRUE(paintLayer);
EXPECT_FALSE(paintLayer->needsCompositedScrolling());
EXPECT_FALSE(paintLayer->graphicsLayerBacking());
EXPECT_FALSE(paintLayer->graphicsLayerBackingForScrolling());
}
示例8: adjustClipRectsForChildren
void PaintLayerClipper::calculateClipRects(const ClipRectsContext& context, ClipRects& clipRects) const
{
bool rootLayerScrolls = m_layoutObject.document().settings() && m_layoutObject.document().settings()->rootLayerScrolls();
if (!m_layoutObject.layer()->parent() && !rootLayerScrolls) {
// The root layer's clip rect is always infinite.
clipRects.reset(LayoutRect(LayoutRect::infiniteIntRect()));
return;
}
bool isClippingRoot = m_layoutObject.layer() == context.rootLayer;
// For transformed layers, the root layer was shifted to be us, so there is no need to
// examine the parent. We want to cache clip rects with us as the root.
PaintLayer* parentLayer = !isClippingRoot ? m_layoutObject.layer()->parent() : 0;
// Ensure that our parent's clip has been calculated so that we can examine the values.
if (parentLayer) {
// FIXME: Why don't we just call getClipRects here?
if (context.usesCache() && parentLayer->clipper().cachedClipRects(context)) {
clipRects = *parentLayer->clipper().cachedClipRects(context);
} else {
parentLayer->clipper().calculateClipRects(context, clipRects);
}
} else {
clipRects.reset(LayoutRect(LayoutRect::infiniteIntRect()));
}
adjustClipRectsForChildren(m_layoutObject, clipRects);
if ((m_layoutObject.hasOverflowClip() && shouldRespectOverflowClip(context)) || m_layoutObject.hasClip()) {
// This offset cannot use convertToLayerCoords, because sometimes our rootLayer may be across
// some transformed layer boundary, for example, in the PaintLayerCompositor overlapMap, where
// clipRects are needed in view space.
applyClipRects(context, m_layoutObject, roundedLayoutPoint(m_layoutObject.localToContainerPoint(FloatPoint(), context.rootLayer->layoutObject())), clipRects);
}
}
示例9: while
AffineTransform SVGLayoutSupport::deprecatedCalculateTransformToLayer(
const LayoutObject* layoutObject) {
AffineTransform transform;
while (layoutObject) {
transform = layoutObject->localToSVGParentTransform() * transform;
if (layoutObject->isSVGRoot())
break;
layoutObject = layoutObject->parent();
}
// Continue walking up the layer tree, accumulating CSS transforms.
// FIXME: this queries layer compositing state - which is not
// supported during layout. Hence, the result may not include all CSS
// transforms.
PaintLayer* layer = layoutObject ? layoutObject->enclosingLayer() : 0;
while (layer && layer->isAllowedToQueryCompositingState()) {
// We can stop at compositing layers, to match the backing resolution.
// FIXME: should we be computing the transform to the nearest composited
// layer, or the nearest composited layer that does not paint into its
// ancestor? I think this is the nearest composited ancestor since we will
// inherit its transforms in the composited layer tree.
if (layer->compositingState() != NotComposited)
break;
if (TransformationMatrix* layerTransform = layer->transform())
transform = layerTransform->toAffineTransform() * transform;
layer = layer->parent();
}
return transform;
}
示例10: updateDescendantDependentFlagsForEntireSubtree
// The descendant-dependent flags system is badly broken because we clean dirty
// bits in upward tree walks, which means we need to call updateDescendantDependentFlags
// at every node in the tree to fully clean all the dirty bits. While we'll in
// the process of fixing this issue, updateDescendantDependentFlagsForEntireSubtree
// provides a big hammer for actually cleaning all the dirty bits in a subtree.
//
// FIXME: Remove this function once the descendant-dependent flags system keeps
// its dirty bits scoped to subtrees.
void updateDescendantDependentFlagsForEntireSubtree(PaintLayer& layer)
{
layer.updateDescendantDependentFlags();
for (PaintLayer* child = layer.firstChild(); child; child = child->nextSibling())
updateDescendantDependentFlagsForEntireSubtree(*child);
}
示例11: clearClipRectsIncludingDescendants
void PaintLayerClipper::clearClipRectsIncludingDescendants()
{
m_cache = nullptr;
for (PaintLayer* layer = m_layoutObject.layer()->firstChild(); layer; layer = layer->nextSibling()) {
layer->clipper().clearClipRectsIncludingDescendants();
}
}
示例12: boxReflectionForPaintLayer
BoxReflection boxReflectionForPaintLayer(const PaintLayer& layer,
const ComputedStyle& style) {
const StyleReflection* reflectStyle = style.boxReflect();
LayoutRect frameLayoutRect = toLayoutBox(layer.layoutObject())->frameRect();
FloatRect frameRect(frameLayoutRect);
BoxReflection::ReflectionDirection direction =
BoxReflection::VerticalReflection;
float offset = 0;
switch (reflectStyle->direction()) {
case ReflectionAbove:
direction = BoxReflection::VerticalReflection;
offset = -floatValueForLength(reflectStyle->offset(), frameRect.height());
break;
case ReflectionBelow:
direction = BoxReflection::VerticalReflection;
offset = 2 * frameRect.height() +
floatValueForLength(reflectStyle->offset(), frameRect.height());
break;
case ReflectionLeft:
direction = BoxReflection::HorizontalReflection;
offset = -floatValueForLength(reflectStyle->offset(), frameRect.width());
break;
case ReflectionRight:
direction = BoxReflection::HorizontalReflection;
offset = 2 * frameRect.width() +
floatValueForLength(reflectStyle->offset(), frameRect.width());
break;
}
sk_sp<SkPicture> mask;
const NinePieceImage& maskNinePiece = reflectStyle->mask();
if (maskNinePiece.hasImage()) {
LayoutRect maskRect(LayoutPoint(), frameLayoutRect.size());
LayoutRect maskBoundingRect(maskRect);
maskBoundingRect.expand(style.imageOutsets(maskNinePiece));
FloatRect maskBoundingFloatRect(maskBoundingRect);
// TODO(jbroman): SkPictureBuilder + DrawingRecorder seems excessive.
// If NinePieceImagePainter operated on SkCanvas, we'd only need an
// SkPictureRecorder here.
SkPictureBuilder recorder(maskBoundingFloatRect);
{
GraphicsContext& context = recorder.context();
DrawingRecorder drawingRecorder(context, *layer.layoutObject(),
DisplayItem::kReflectionMask,
maskBoundingFloatRect);
NinePieceImagePainter(*layer.layoutObject())
.paint(recorder.context(), maskRect, style, maskNinePiece,
SkXfermode::kSrcOver_Mode);
}
mask = recorder.endRecording();
}
return BoxReflection(direction, offset, std::move(mask));
}
示例13: clearClipRectsIncludingDescendants
void PaintLayerClipper::clearClipRectsIncludingDescendants() {
if (m_geometryMapper)
m_geometryMapper.reset(new GeometryMapper);
m_layer.clearClipRectsCache();
for (PaintLayer* layer = m_layer.firstChild(); layer;
layer = layer->nextSibling()) {
layer->clipper().clearClipRectsIncludingDescendants();
}
}
示例14: ancestorStackingContextNode
PaintLayerStackingNode* PaintLayerStackingNode::ancestorStackingContextNode()
const {
for (PaintLayer* ancestor = layer()->parent(); ancestor;
ancestor = ancestor->parent()) {
PaintLayerStackingNode* stackingNode = ancestor->stackingNode();
if (stackingNode->isStackingContext())
return stackingNode;
}
return 0;
}
示例15: fullyInvalidatePaintRecursive
static void fullyInvalidatePaintRecursive(PaintLayer* layer)
{
if (layer->compositingState() == PaintsIntoOwnBacking) {
layer->compositedLayerMapping()->setContentsNeedDisplay();
layer->compositedLayerMapping()->setSquashingContentsNeedDisplay();
}
for (PaintLayer* child = layer->firstChild(); child; child = child->nextSibling())
fullyInvalidatePaintRecursive(child);
}