本文整理汇总了C++中SVGStyledElement::pushAttributeContext方法的典型用法代码示例。如果您正苦于以下问题:C++ SVGStyledElement::pushAttributeContext方法的具体用法?C++ SVGStyledElement::pushAttributeContext怎么用?C++ SVGStyledElement::pushAttributeContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVGStyledElement
的用法示例。
在下文中一共展示了SVGStyledElement::pushAttributeContext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawPatternContentIntoTile
void SVGPatternElement::drawPatternContentIntoTile(const SVGPatternElement* target, const IntSize& newSize, KCanvasMatrix patternTransformMatrix) const
{
KRenderingDevice* device = renderingDevice();
SVGStyledElement* activeElement = static_cast<SVGStyledElement*>(m_paintServer->activeClient()->element());
bool bbox = (patternUnits()->baseVal() == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX);
const SVGStyledElement* savedContext = 0;
if (bbox) {
if (width()->baseVal()->unitType() != SVGLength::SVG_LENGTHTYPE_PERCENTAGE)
width()->baseVal()->newValueSpecifiedUnits(SVGLength::SVG_LENGTHTYPE_PERCENTAGE, width()->baseVal()->value() * 100.);
if (height()->baseVal()->unitType() != SVGLength::SVG_LENGTHTYPE_PERCENTAGE)
height()->baseVal()->newValueSpecifiedUnits(SVGLength::SVG_LENGTHTYPE_PERCENTAGE, height()->baseVal()->value() * 100.);
if (activeElement)
savedContext = const_cast<SVGPatternElement* >(this)->pushAttributeContext(activeElement);
}
delete m_tile;
m_tile = static_cast<KCanvasImage*>(device->createResource(RS_IMAGE));
m_tile->init(newSize);
KRenderingDeviceContext* patternContext = device->contextForImage(m_tile);
device->pushContext(patternContext);
FloatRect rect(x()->baseVal()->value(), y()->baseVal()->value(), width()->baseVal()->value(), height()->baseVal()->value());
m_paintServer->setBbox(rect);
m_paintServer->setPatternTransform(patternTransformMatrix);
m_paintServer->setTile(m_tile);
OwnPtr<GraphicsContext> context(patternContext->createGraphicsContext());
for(Node *n = target->firstChild(); n != 0; n = n->nextSibling())
{
SVGElement* elem = svg_dynamic_cast(n);
if (!elem || !elem->isStyled())
continue;
SVGStyledElement* e = static_cast<SVGStyledElement* >(elem);
RenderObject *item = e->renderer();
if (!item)
continue;
#if 0
// FIXME: None of this code seems to be necessary
// to pass the w3c tests (and infact breaks them)
// However, I'm leaving it #if 0'd for now until
// I can quiz WildFox on the subject -- ecs 11/24/05
// It's possible that W3C-SVG-1.1/coords-units-01-b
// is failing due to lack of this code.
KCanvasMatrix savedMatrix = item->localTransform();
const SVGStyledElement* savedContext = 0;
if (patternContentUnits()->baseVal() == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
{
if (activeElement)
savedContext = e->pushAttributeContext(activeElement);
}
// Take into account viewportElement's viewBox, if existant...
if (viewportElement() && viewportElement()->hasTagName(SVGNames::svgTag))
{
SVGSVGElement* svgElement = static_cast<SVGSVGElement* >(viewportElement());
RefPtr<SVGMatrix> svgCTM = svgElement->getCTM();
RefPtr<SVGMatrix> ctm = getCTM();
KCanvasMatrix newMatrix(svgCTM->matrix());
newMatrix.multiply(savedMatrix);
newMatrix.scale(1.0 / ctm->a(), 1.0 / ctm->d());
item->setLocalTransform(newMatrix.matrix());
}
#endif
RenderObject::PaintInfo info(context.get(), IntRect(), PaintPhaseForeground, 0, 0, 0);
item->paint(info, 0, 0);
#if 0
if (savedContext)
e->pushAttributeContext(savedContext);
item->setLocalTransform(savedMatrix.matrix());
#endif
}
if (savedContext)
const_cast<SVGPatternElement* >(this)->pushAttributeContext(savedContext);
device->popContext();
delete patternContext;
}