本文整理汇总了C++中SVGUseElement::rendererClipChild方法的典型用法代码示例。如果您正苦于以下问题:C++ SVGUseElement::rendererClipChild方法的具体用法?C++ SVGUseElement::rendererClipChild怎么用?C++ SVGUseElement::rendererClipChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVGUseElement
的用法示例。
在下文中一共展示了SVGUseElement::rendererClipChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT
PassRefPtr<DisplayList> RenderSVGResourceClipper::asDisplayList(GraphicsContext* context,
const AffineTransform& contentTransformation)
{
ASSERT(context);
ASSERT(frame());
context->beginRecording(repaintRectInLocalCoordinates());
// Switch to a paint behavior where all children of this <clipPath> will be rendered using special constraints:
// - fill-opacity/stroke-opacity/opacity set to 1
// - masker/filter not applied when rendering the children
// - fill is set to the initial fill paint server (solid, black)
// - stroke is set to the initial stroke paint server (none)
PaintBehavior oldBehavior = frame()->view()->paintBehavior();
frame()->view()->setPaintBehavior(oldBehavior | PaintBehaviorRenderingSVGMask);
for (Node* childNode = element()->firstChild(); childNode; childNode = childNode->nextSibling()) {
RenderObject* renderer = childNode->renderer();
if (!childNode->isSVGElement() || !renderer)
continue;
RenderStyle* style = renderer->style();
if (!style || style->display() == NONE || style->visibility() != VISIBLE)
continue;
WindRule newClipRule = style->svgStyle()->clipRule();
bool isUseElement = childNode->hasTagName(SVGNames::useTag);
if (isUseElement) {
SVGUseElement* useElement = toSVGUseElement(childNode);
renderer = useElement->rendererClipChild();
if (!renderer)
continue;
if (!useElement->hasAttribute(SVGNames::clip_ruleAttr))
newClipRule = renderer->style()->svgStyle()->clipRule();
}
// Only shapes, paths and texts are allowed for clipping.
if (!renderer->isSVGShape() && !renderer->isSVGText())
continue;
context->setFillRule(newClipRule);
if (isUseElement)
renderer = childNode->renderer();
SVGRenderingContext::renderSubtree(context, renderer, contentTransformation);
}
frame()->view()->setPaintBehavior(oldBehavior);
return context->endRecording();
}
示例2: drawContentIntoMaskImage
bool RenderSVGResourceClipper::drawContentIntoMaskImage(ClipperData* clipperData, const FloatRect& objectBoundingBox)
{
ASSERT(clipperData);
ASSERT(clipperData->clipMaskImage);
GraphicsContext* maskContext = clipperData->clipMaskImage->context();
ASSERT(maskContext);
AffineTransform maskContentTransformation;
SVGClipPathElement* clipPath = static_cast<SVGClipPathElement*>(node());
if (clipPath->clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
maskContentTransformation.translate(objectBoundingBox.x(), objectBoundingBox.y());
maskContentTransformation.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.height());
maskContext->concatCTM(maskContentTransformation);
}
// Draw all clipPath children into a global mask.
for (Node* childNode = node()->firstChild(); childNode; childNode = childNode->nextSibling()) {
RenderObject* renderer = childNode->renderer();
if (!childNode->isSVGElement() || !static_cast<SVGElement*>(childNode)->isStyled() || !renderer)
continue;
RenderStyle* style = renderer->style();
if (!style || style->display() == NONE || style->visibility() != VISIBLE)
continue;
WindRule newClipRule = style->svgStyle()->clipRule();
bool isUseElement = renderer->isSVGShadowTreeRootContainer();
if (isUseElement) {
SVGUseElement* useElement = static_cast<SVGUseElement*>(childNode);
renderer = useElement->rendererClipChild();
if (!renderer)
continue;
if (!useElement->hasAttribute(SVGNames::clip_ruleAttr))
newClipRule = renderer->style()->svgStyle()->clipRule();
}
// Only shapes, paths and texts are allowed for clipping.
if (!renderer->isSVGPath() && !renderer->isSVGText())
continue;
// Save the old RenderStyle of the current object for restoring after drawing
// it to the MaskImage. The new intermediate RenderStyle needs to inherit from
// the old one.
RefPtr<RenderStyle> oldRenderStyle = renderer->style();
RefPtr<RenderStyle> newRenderStyle = RenderStyle::clone(oldRenderStyle.get());
SVGRenderStyle* svgStyle = newRenderStyle.get()->accessSVGStyle();
svgStyle->setFillPaint(SVGPaint::defaultFill());
svgStyle->setStrokePaint(SVGPaint::defaultStroke());
svgStyle->setFillRule(newClipRule);
newRenderStyle.get()->setOpacity(1.0f);
svgStyle->setFillOpacity(1.0f);
svgStyle->setStrokeOpacity(1.0f);
svgStyle->setFilterResource(String());
svgStyle->setMaskerResource(String());
// The setStyle() call results in a styleDidChange() call, which in turn invalidations the resources.
// As we're mutating the resource on purpose, block updates until we've resetted the style again.
m_invalidationBlocked = true;
renderer->setStyle(newRenderStyle.release());
// In the case of a <use> element, we obtained its renderere above, to retrieve its clipRule.
// We have to pass the <use> renderer itself to renderSubtreeToImageBuffer() to apply it's x/y/transform/etc. values when rendering.
// So if isUseElement is true, refetch the childNode->renderer(), as renderer got overriden above.
SVGImageBufferTools::renderSubtreeToImageBuffer(clipperData->clipMaskImage.get(), isUseElement ? childNode->renderer() : renderer, maskContentTransformation);
renderer->setStyle(oldRenderStyle.release());
m_invalidationBlocked = false;
}
return true;
}