本文整理汇总了C++中SVGStyledElement::renderer方法的典型用法代码示例。如果您正苦于以下问题:C++ SVGStyledElement::renderer方法的具体用法?C++ SVGStyledElement::renderer怎么用?C++ SVGStyledElement::renderer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVGStyledElement
的用法示例。
在下文中一共展示了SVGStyledElement::renderer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: invalidate
void SVGResource::invalidate()
{
HashSet<SVGStyledElement*>::const_iterator it = m_clients.begin();
const HashSet<SVGStyledElement*>::const_iterator end = m_clients.end();
for (; it != end; ++it) {
SVGStyledElement* cur = *it;
if (cur->renderer())
cur->renderer()->setNeedsLayout(true);
cur->invalidateResourcesInAncestorChain();
}
}
示例2: notifyClientsToRepaint
void SVGPatternElement::notifyClientsToRepaint() const
{
const KCanvasItemList &clients = m_paintServer->clients();
KCanvasItemList::ConstIterator it = clients.begin();
KCanvasItemList::ConstIterator end = clients.end();
for(; it != end; ++it)
{
const RenderPath *current = (*it);
SVGStyledElement* styled = (current ? static_cast<SVGStyledElement* >(current->element()) : 0);
if (styled)
{
styled->setChanged(true);
if (styled->renderer())
styled->renderer()->repaint();
}
}
}
示例3: imageSize
PassOwnPtr<ImageBuffer> SVGMaskElement::drawMaskerContent(const FloatRect& targetRect, FloatRect& maskDestRect) const
{
// Determine specified mask size
float xValue;
float yValue;
float widthValue;
float heightValue;
if (maskUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
xValue = x().valueAsPercentage() * targetRect.width();
yValue = y().valueAsPercentage() * targetRect.height();
widthValue = width().valueAsPercentage() * targetRect.width();
heightValue = height().valueAsPercentage() * targetRect.height();
} else {
xValue = x().value(this);
yValue = y().value(this);
widthValue = width().value(this);
heightValue = height().value(this);
}
IntSize imageSize(lroundf(widthValue), lroundf(heightValue));
clampImageBufferSizeToViewport(document()->view(), imageSize);
if (imageSize.width() < static_cast<int>(widthValue))
widthValue = imageSize.width();
if (imageSize.height() < static_cast<int>(heightValue))
heightValue = imageSize.height();
OwnPtr<ImageBuffer> maskImage = ImageBuffer::create(imageSize, false);
if (!maskImage)
return 0;
maskDestRect = FloatRect(xValue, yValue, widthValue, heightValue);
if (maskUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
maskDestRect.move(targetRect.x(), targetRect.y());
GraphicsContext* maskImageContext = maskImage->context();
ASSERT(maskImageContext);
maskImageContext->save();
maskImageContext->translate(-xValue, -yValue);
if (maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
maskImageContext->save();
maskImageContext->scale(FloatSize(targetRect.width(), targetRect.height()));
}
// Render subtree into ImageBuffer
for (Node* n = firstChild(); n; n = n->nextSibling()) {
SVGElement* elem = 0;
if (n->isSVGElement())
elem = static_cast<SVGElement*>(n);
if (!elem || !elem->isStyled())
continue;
SVGStyledElement* e = static_cast<SVGStyledElement*>(elem);
RenderObject* item = e->renderer();
if (!item)
continue;
renderSubtreeToImage(maskImage.get(), item);
}
if (maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
maskImageContext->restore();
maskImageContext->restore();
return maskImage.release();
}
示例4: imageSize
PassOwnPtr<ImageBuffer> SVGMaskElement::drawMaskerContent(const FloatRect& targetRect, FloatRect& maskDestRect) const
{
// Determine specified mask size
if (maskUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
maskDestRect = FloatRect(x().valueAsPercentage() * targetRect.width(),
y().valueAsPercentage() * targetRect.height(),
width().valueAsPercentage() * targetRect.width(),
height().valueAsPercentage() * targetRect.height());
else
maskDestRect = FloatRect(x().value(this),
y().value(this),
width().value(this),
height().value(this));
IntSize imageSize(lroundf(maskDestRect.width()), lroundf(maskDestRect.height()));
clampImageBufferSizeToViewport(document()->view(), imageSize);
if (imageSize.width() < static_cast<int>(maskDestRect.width()))
maskDestRect.setWidth(imageSize.width());
if (imageSize.height() < static_cast<int>(maskDestRect.height()))
maskDestRect.setHeight(imageSize.height());
// FIXME: This changes color space to linearRGB, the default color space
// for masking operations in SVG. We need a switch for the other color-space
// attribute values sRGB, inherit and auto.
OwnPtr<ImageBuffer> maskImage = ImageBuffer::create(imageSize, LinearRGB);
if (!maskImage)
return 0;
FloatPoint maskContextLocation = maskDestRect.location();
if (maskUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
maskDestRect.move(targetRect.x(), targetRect.y());
if (maskContentUnits() != SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
maskContextLocation.move(targetRect.x(), targetRect.y());
GraphicsContext* maskImageContext = maskImage->context();
ASSERT(maskImageContext);
maskImageContext->save();
maskImageContext->translate(-maskContextLocation.x(), -maskContextLocation.y());
if (maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
maskImageContext->save();
maskImageContext->scale(FloatSize(targetRect.width(), targetRect.height()));
}
// Render subtree into ImageBuffer
for (Node* n = firstChild(); n; n = n->nextSibling()) {
SVGElement* elem = 0;
if (n->isSVGElement())
elem = static_cast<SVGElement*>(n);
if (!elem || !elem->isStyled())
continue;
SVGStyledElement* e = static_cast<SVGStyledElement*>(elem);
RenderObject* item = e->renderer();
if (!item)
continue;
renderSubtreeToImage(maskImage.get(), item);
}
if (maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
maskImageContext->restore();
maskImageContext->restore();
return maskImage.release();
}
示例5: 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;
}