本文整理汇总了C++中SVGResources::filter方法的典型用法代码示例。如果您正苦于以下问题:C++ SVGResources::filter方法的具体用法?C++ SVGResources::filter怎么用?C++ SVGResources::filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVGResources
的用法示例。
在下文中一共展示了SVGResources::filter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: finishRenderSVGContent
void SVGRenderSupport::finishRenderSVGContent(RenderObject* object, PaintInfo& paintInfo, GraphicsContext* savedContext)
{
#if !ENABLE(FILTERS)
UNUSED_PARAM(savedContext);
#endif
ASSERT(object);
const RenderStyle* style = object->style();
ASSERT(style);
const SVGRenderStyle* svgStyle = style->svgStyle();
ASSERT(svgStyle);
#if ENABLE(FILTERS)
SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(object);
if (resources) {
if (RenderSVGResourceFilter* filter = resources->filter()) {
filter->postApplyResource(object, paintInfo.context, ApplyToDefaultMode, /* path */0);
paintInfo.context = savedContext;
}
}
#endif
if (style->opacity() < 1)
paintInfo.context->endTransparencyLayer();
if (svgStyle->shadow())
paintInfo.context->endTransparencyLayer();
}
示例2: intersectRepaintRectWithResources
void SVGRenderSupport::intersectRepaintRectWithResources(const RenderObject* object, FloatRect& repaintRect)
{
ASSERT(object);
RenderStyle* style = object->style();
ASSERT(style);
const SVGRenderStyle* svgStyle = style->svgStyle();
ASSERT(svgStyle);
RenderObject* renderer = const_cast<RenderObject*>(object);
SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(renderer);
if (!resources) {
if (const ShadowData* shadow = svgStyle->shadow())
shadow->adjustRectForShadow(repaintRect);
return;
}
#if ENABLE(FILTERS)
if (RenderSVGResourceFilter* filter = resources->filter())
repaintRect = filter->resourceBoundingBox(renderer);
#endif
if (RenderSVGResourceClipper* clipper = resources->clipper())
repaintRect.intersect(clipper->resourceBoundingBox(renderer));
if (RenderSVGResourceMasker* masker = resources->masker())
repaintRect.intersect(masker->resourceBoundingBox(renderer));
if (const ShadowData* shadow = svgStyle->shadow())
shadow->adjustRectForShadow(repaintRect);
}
示例3: selfWillPaint
bool RenderSVGRoot::selfWillPaint()
{
#if ENABLE(FILTERS)
SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(this);
return resources && resources->filter();
#else
return false;
#endif
}
示例4: paintReplaced
void RenderSVGRoot::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
// An empty viewport disables rendering.
if (pixelSnappedBorderBoxRect().isEmpty())
return;
// Don't paint, if the context explicitly disabled it.
if (paintInfo.context->paintingDisabled())
return;
// SVG outlines are painted during PaintPhaseForeground.
if (paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline)
return;
// An empty viewBox also disables rendering.
// (http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute)
SVGSVGElement* svg = toSVGSVGElement(node());
ASSERT(svg);
if (svg->hasEmptyViewBox())
return;
// Don't paint if we don't have kids, except if we have filters we should paint those.
if (!firstChild()) {
SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(this);
if (!resources || !resources->filter())
return;
}
// Make a copy of the PaintInfo because applyTransform will modify the damage rect.
PaintInfo childPaintInfo(paintInfo);
childPaintInfo.context->save();
// Apply initial viewport clip
if (shouldApplyViewportClip())
childPaintInfo.context->clip(pixelSnappedIntRect(overflowClipRect(paintOffset)));
// Convert from container offsets (html renderers) to a relative transform (svg renderers).
// Transform from our paint container's coordinate system to our local coords.
IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset);
childPaintInfo.applyTransform(AffineTransform::translation(adjustedPaintOffset.x(), adjustedPaintOffset.y()) * localToBorderBoxTransform());
// SVGRenderingContext must be destroyed before we restore the childPaintInfo.context, because a filter may have
// changed the context and it is only reverted when the SVGRenderingContext destructor finishes applying the filter.
{
SVGRenderingContext renderingContext;
bool continueRendering = true;
if (childPaintInfo.phase == PaintPhaseForeground) {
renderingContext.prepareToRenderSVGContent(this, childPaintInfo);
continueRendering = renderingContext.isRenderingPrepared();
}
if (continueRendering)
RenderBox::paint(childPaintInfo, LayoutPoint());
}
childPaintInfo.context->restore();
}
示例5: prepareToRenderSVGContent
bool SVGRenderSupport::prepareToRenderSVGContent(RenderObject* object, PaintInfo& paintInfo)
{
ASSERT(object);
RenderStyle* style = object->style();
ASSERT(style);
const SVGRenderStyle* svgStyle = style->svgStyle();
ASSERT(svgStyle);
// Setup transparency layers before setting up SVG resources!
float opacity = style->opacity();
const ShadowData* shadow = svgStyle->shadow();
if (opacity < 1 || shadow) {
FloatRect repaintRect = object->repaintRectInLocalCoordinates();
if (opacity < 1) {
paintInfo.context->clip(repaintRect);
paintInfo.context->beginTransparencyLayer(opacity);
}
if (shadow) {
paintInfo.context->clip(repaintRect);
paintInfo.context->setShadow(IntSize(shadow->x(), shadow->y()), shadow->blur(), shadow->color(), style->colorSpace());
paintInfo.context->beginTransparencyLayer(1);
}
}
SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(object);
if (!resources) {
#if ENABLE(FILTERS)
if (svgStyle->hasFilter())
return false;
#endif
return true;
}
if (RenderSVGResourceMasker* masker = resources->masker()) {
if (!masker->applyResource(object, style, paintInfo.context, ApplyToDefaultMode))
return false;
}
if (RenderSVGResourceClipper* clipper = resources->clipper()) {
if (!clipper->applyResource(object, style, paintInfo.context, ApplyToDefaultMode))
return false;
}
#if ENABLE(FILTERS)
if (RenderSVGResourceFilter* filter = resources->filter()) {
if (!filter->applyResource(object, style, paintInfo.context, ApplyToDefaultMode))
return false;
}
#endif
return true;
}
示例6: paintReplaced
void RenderSVGRoot::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
// An empty viewport disables rendering.
if (pixelSnappedBorderBoxRect().isEmpty())
return;
// Don't paint, if the context explicitely disabled it.
if (paintInfo.context->paintingDisabled())
return;
Page* page = 0;
if (Frame* frame = this->frame())
page = frame->page();
// Don't paint if we don't have kids, except if we have filters we should paint those.
if (!firstChild()) {
SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(this);
if (!resources || !resources->filter()) {
if (page && paintInfo.phase == PaintPhaseForeground)
page->addRelevantUnpaintedObject(this, visualOverflowRect());
return;
}
}
if (page && paintInfo.phase == PaintPhaseForeground)
page->addRelevantRepaintedObject(this, visualOverflowRect());
// Make a copy of the PaintInfo because applyTransform will modify the damage rect.
PaintInfo childPaintInfo(paintInfo);
childPaintInfo.context->save();
// Apply initial viewport clip - not affected by overflow handling
childPaintInfo.context->clip(pixelSnappedIntRect(overflowClipRect(paintOffset, paintInfo.renderRegion)));
// Convert from container offsets (html renderers) to a relative transform (svg renderers).
// Transform from our paint container's coordinate system to our local coords.
IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset);
childPaintInfo.applyTransform(AffineTransform::translation(adjustedPaintOffset.x(), adjustedPaintOffset.y()) * localToBorderBoxTransform());
// SVGRenderingContext must be destroyed before we restore the childPaintInfo.context, because a filter may have
// changed the context and it is only reverted when the SVGRenderingContext destructor finishes applying the filter.
{
SVGRenderingContext renderingContext;
bool continueRendering = true;
if (childPaintInfo.phase == PaintPhaseForeground) {
renderingContext.prepareToRenderSVGContent(this, childPaintInfo);
continueRendering = renderingContext.isRenderingPrepared();
}
if (continueRendering)
RenderBox::paint(childPaintInfo, LayoutPoint());
}
childPaintInfo.context->restore();
}
示例7: clientLayoutChanged
void SVGResourcesCache::clientLayoutChanged(LayoutObject* object)
{
SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(object);
if (!resources)
return;
// Invalidate the resources if either the LayoutObject itself changed,
// or we have filter resources, which could depend on the layout of children.
if (object->selfNeedsLayout() || resources->filter())
resources->removeClientFromCache(object);
}
示例8: filtersForceContainerLayout
bool SVGRenderSupport::filtersForceContainerLayout(RenderObject* object)
{
// If any of this container's children need to be laid out, and a filter is applied
// to the container, we need to repaint the entire container.
if (!object->normalChildNeedsLayout())
return false;
SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(object);
if (!resources || !resources->filter())
return false;
return true;
}
示例9: clientUpdatedFromElement
void SVGResourcesCache::clientUpdatedFromElement(RenderObject* renderer, const RenderStyle* newStyle)
{
ASSERT(renderer);
ASSERT(renderer->parent());
SVGResourcesCache* cache = resourcesCacheFromRenderObject(renderer);
cache->removeResourcesFromRenderObject(renderer);
cache->addResourcesFromRenderObject(renderer, newStyle);
#if ENABLE(FILTERS)
SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(renderer);
if (resources && resources->filter())
resources->removeClientFromCache(renderer);
#endif
}
示例10: intersectPaintInvalidationRectWithResources
void SVGLayoutSupport::intersectPaintInvalidationRectWithResources(const LayoutObject* layoutObject, FloatRect& paintInvalidationRect)
{
ASSERT(layoutObject);
SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(layoutObject);
if (!resources)
return;
if (LayoutSVGResourceFilter* filter = resources->filter())
paintInvalidationRect = filter->resourceBoundingBox(layoutObject);
if (LayoutSVGResourceClipper* clipper = resources->clipper())
paintInvalidationRect.intersect(clipper->resourceBoundingBox(layoutObject));
if (LayoutSVGResourceMasker* masker = resources->masker())
paintInvalidationRect.intersect(masker->resourceBoundingBox(layoutObject));
}
示例11: intersectRepaintRectWithResources
void SVGRenderSupport::intersectRepaintRectWithResources(const RenderObject* renderer, FloatRect& repaintRect)
{
ASSERT(renderer);
SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(renderer);
if (!resources)
return;
if (RenderSVGResourceFilter* filter = resources->filter())
repaintRect = filter->resourceBoundingBox(renderer);
if (RenderSVGResourceClipper* clipper = resources->clipper())
repaintRect.intersect(clipper->resourceBoundingBox(renderer));
if (RenderSVGResourceMasker* masker = resources->masker())
repaintRect.intersect(masker->resourceBoundingBox(renderer));
}
示例12: intersectRepaintRectWithResources
void SVGRenderSupport::intersectRepaintRectWithResources(const RenderElement& renderer, FloatRect& repaintRect)
{
SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(&renderer);
if (!resources)
return;
#if ENABLE(FILTERS)
if (RenderSVGResourceFilter* filter = resources->filter())
repaintRect = filter->resourceBoundingBox(renderer);
#endif
if (RenderSVGResourceClipper* clipper = resources->clipper())
repaintRect.intersect(clipper->resourceBoundingBox(renderer));
if (RenderSVGResourceMasker* masker = resources->masker())
repaintRect.intersect(masker->resourceBoundingBox(renderer));
}
示例13: paint
void SVGRootPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
// An empty viewport disables rendering.
if (m_layoutSVGRoot.pixelSnappedBorderBoxRect().isEmpty())
return;
// SVG outlines are painted during PaintPhaseForeground.
if (shouldPaintSelfOutline(paintInfo.phase))
return;
// An empty viewBox also disables rendering.
// (http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute)
SVGSVGElement* svg = toSVGSVGElement(m_layoutSVGRoot.node());
ASSERT(svg);
if (svg->hasEmptyViewBox())
return;
// Don't paint if we don't have kids, except if we have filters we should paint those.
if (!m_layoutSVGRoot.firstChild()) {
SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(&m_layoutSVGRoot);
if (!resources || !resources->filter())
return;
}
PaintInfo paintInfoBeforeFiltering(paintInfo);
// At the HTML->SVG boundary, SVGRoot will have a paint offset transform
// paint property but may not have a PaintLayer, so we need to update the
// paint properties here since they will not be updated by PaintLayer
// (See: PaintPropertyTreeBuilder::createPaintOffsetTranslationIfNeeded).
Optional<ScopedPaintChunkProperties> paintOffsetTranslationPropertyScope;
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && !m_layoutSVGRoot.hasLayer()) {
const auto* objectProperties = m_layoutSVGRoot.objectPaintProperties();
if (objectProperties && objectProperties->paintOffsetTranslation()) {
auto& paintController = paintInfoBeforeFiltering.context.paintController();
PaintChunkProperties properties(paintController.currentPaintChunkProperties());
properties.transform = objectProperties->paintOffsetTranslation();
paintOffsetTranslationPropertyScope.emplace(paintController, properties);
}
}
// Apply initial viewport clip.
Optional<ClipRecorder> clipRecorder;
if (m_layoutSVGRoot.shouldApplyViewportClip()) {
// TODO(pdr): Clip the paint info cull rect here.
clipRecorder.emplace(paintInfoBeforeFiltering.context, m_layoutSVGRoot, paintInfoBeforeFiltering.displayItemTypeForClipping(), LayoutRect(pixelSnappedIntRect(m_layoutSVGRoot.overflowClipRect(paintOffset))));
}
// Convert from container offsets (html layoutObjects) to a relative transform (svg layoutObjects).
// Transform from our paint container's coordinate system to our local coords.
IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset);
AffineTransform paintOffsetToBorderBox = AffineTransform::translation(adjustedPaintOffset.x(), adjustedPaintOffset.y()) * m_layoutSVGRoot.localToBorderBoxTransform();
paintInfoBeforeFiltering.updateCullRect(paintOffsetToBorderBox);
TransformRecorder transformRecorder(paintInfoBeforeFiltering.context, m_layoutSVGRoot, paintOffsetToBorderBox);
SVGPaintContext paintContext(m_layoutSVGRoot, paintInfoBeforeFiltering);
if (paintContext.paintInfo().phase == PaintPhaseForeground && !paintContext.applyClipMaskAndFilterIfNecessary())
return;
BoxPainter(m_layoutSVGRoot).paint(paintContext.paintInfo(), LayoutPoint());
PaintTiming& timing = PaintTiming::from(m_layoutSVGRoot.node()->document().topDocument());
timing.markFirstContentfulPaint();
}
示例14: selfWillPaint
bool RenderSVGContainer::selfWillPaint()
{
SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(this);
return resources && resources->filter();
}
示例15: hasFilterResource
bool SVGLayoutSupport::hasFilterResource(const LayoutObject& object) {
SVGResources* resources =
SVGResourcesCache::cachedResourcesForLayoutObject(&object);
return resources && resources->filter();
}