本文整理汇总了C++中RenderElement::strokeBoundingBox方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderElement::strokeBoundingBox方法的具体用法?C++ RenderElement::strokeBoundingBox怎么用?C++ RenderElement::strokeBoundingBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderElement
的用法示例。
在下文中一共展示了RenderElement::strokeBoundingBox方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prepareToRenderSVGContent
void SVGRenderingContext::prepareToRenderSVGContent(RenderElement& renderer, PaintInfo& paintInfo, NeedsGraphicsContextSave needsGraphicsContextSave)
{
#ifndef NDEBUG
// This function must not be called twice!
ASSERT(!(m_renderingFlags & PrepareToRenderSVGContentWasCalled));
m_renderingFlags |= PrepareToRenderSVGContentWasCalled;
#endif
m_renderer = &renderer;
m_paintInfo = &paintInfo;
m_filter = 0;
// We need to save / restore the context even if the initialization failed.
if (needsGraphicsContextSave == SaveGraphicsContext) {
m_paintInfo->context().save();
m_renderingFlags |= RestoreGraphicsContext;
}
auto& style = m_renderer->style();
const SVGRenderStyle& svgStyle = style.svgStyle();
// Setup transparency layers before setting up SVG resources!
bool isRenderingMask = isRenderingMaskImage(*m_renderer);
// RenderLayer takes care of root opacity.
float opacity = (renderer.isSVGRoot() || isRenderingMask) ? 1 : style.opacity();
const ShadowData* shadow = svgStyle.shadow();
bool hasBlendMode = style.hasBlendMode();
bool hasIsolation = style.hasIsolation();
bool isolateMaskForBlending = false;
#if ENABLE(CSS_COMPOSITING)
if (svgStyle.hasMasker() && is<SVGGraphicsElement>(downcast<SVGElement>(*renderer.element()))) {
SVGGraphicsElement& graphicsElement = downcast<SVGGraphicsElement>(*renderer.element());
isolateMaskForBlending = graphicsElement.shouldIsolateBlending();
}
#endif
if (opacity < 1 || shadow || hasBlendMode || isolateMaskForBlending || hasIsolation) {
FloatRect repaintRect = m_renderer->repaintRectInLocalCoordinates();
m_paintInfo->context().clip(repaintRect);
if (opacity < 1 || hasBlendMode || isolateMaskForBlending || hasIsolation) {
if (hasBlendMode)
m_paintInfo->context().setCompositeOperation(m_paintInfo->context().compositeOperation(), style.blendMode());
m_paintInfo->context().beginTransparencyLayer(opacity);
if (hasBlendMode)
m_paintInfo->context().setCompositeOperation(m_paintInfo->context().compositeOperation(), BlendModeNormal);
m_renderingFlags |= EndOpacityLayer;
}
if (shadow) {
m_paintInfo->context().setShadow(IntSize(roundToInt(shadow->x()), roundToInt(shadow->y())), shadow->radius(), shadow->color());
m_paintInfo->context().beginTransparencyLayer(1);
m_renderingFlags |= EndShadowLayer;
}
}
ClipPathOperation* clipPathOperation = style.clipPath();
if (is<ShapeClipPathOperation>(clipPathOperation)) {
auto& clipPath = downcast<ShapeClipPathOperation>(*clipPathOperation);
FloatRect referenceBox;
if (clipPath.referenceBox() == Stroke)
// FIXME: strokeBoundingBox() takes dasharray into account but shouldn't.
referenceBox = renderer.strokeBoundingBox();
else if (clipPath.referenceBox() == ViewBox && renderer.element()) {
FloatSize viewportSize;
SVGLengthContext(downcast<SVGElement>(renderer.element())).determineViewport(viewportSize);
referenceBox.setWidth(viewportSize.width());
referenceBox.setHeight(viewportSize.height());
} else
referenceBox = renderer.objectBoundingBox();
m_paintInfo->context().clipPath(clipPath.pathForReferenceRect(referenceBox), clipPath.windRule());
}
auto* resources = SVGResourcesCache::cachedResourcesForRenderer(*m_renderer);
if (!resources) {
if (style.hasReferenceFilterOnly())
return;
m_renderingFlags |= RenderingPrepared;
return;
}
if (!isRenderingMask) {
if (RenderSVGResourceMasker* masker = resources->masker()) {
GraphicsContext* contextPtr = &m_paintInfo->context();
bool result = masker->applyResource(*m_renderer, style, contextPtr, ApplyToDefaultMode);
m_paintInfo->setContext(*contextPtr);
if (!result)
return;
}
}
RenderSVGResourceClipper* clipper = resources->clipper();
if (!clipPathOperation && clipper) {
//.........这里部分代码省略.........
示例2: applyResource
bool RenderSVGResourceFilter::applyResource(RenderElement& renderer, const RenderStyle&, GraphicsContext*& context, unsigned short resourceMode)
{
ASSERT(context);
ASSERT_UNUSED(resourceMode, resourceMode == ApplyToDefaultMode);
if (m_filter.contains(&renderer)) {
FilterData* filterData = m_filter.get(&renderer);
if (filterData->state == FilterData::PaintingSource || filterData->state == FilterData::Applying)
filterData->state = FilterData::CycleDetected;
return false; // Already built, or we're in a cycle, or we're marked for removal. Regardless, just do nothing more now.
}
auto filterData = std::make_unique<FilterData>();
FloatRect targetBoundingBox = renderer.objectBoundingBox();
filterData->boundaries = SVGLengthContext::resolveRectangle<SVGFilterElement>(&filterElement(), filterElement().filterUnits(), targetBoundingBox);
if (filterData->boundaries.isEmpty())
return false;
// Determine absolute transformation matrix for filter.
AffineTransform absoluteTransform;
SVGRenderingContext::calculateTransformationToOutermostCoordinateSystem(renderer, absoluteTransform);
if (!absoluteTransform.isInvertible())
return false;
// Eliminate shear of the absolute transformation matrix, to be able to produce unsheared tile images for feTile.
filterData->shearFreeAbsoluteTransform = AffineTransform(absoluteTransform.xScale(), 0, 0, absoluteTransform.yScale(), 0, 0);
// Determine absolute boundaries of the filter and the drawing region.
FloatRect absoluteFilterBoundaries = filterData->shearFreeAbsoluteTransform.mapRect(filterData->boundaries);
filterData->drawingRegion = renderer.strokeBoundingBox();
filterData->drawingRegion.intersect(filterData->boundaries);
FloatRect absoluteDrawingRegion = filterData->shearFreeAbsoluteTransform.mapRect(filterData->drawingRegion);
// Create the SVGFilter object.
bool primitiveBoundingBoxMode = filterElement().primitiveUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX;
filterData->filter = SVGFilter::create(filterData->shearFreeAbsoluteTransform, absoluteDrawingRegion, targetBoundingBox, filterData->boundaries, primitiveBoundingBoxMode);
// Create all relevant filter primitives.
filterData->builder = buildPrimitives(filterData->filter.get());
if (!filterData->builder)
return false;
// Calculate the scale factor for the use of filterRes.
// Also see http://www.w3.org/TR/SVG/filters.html#FilterEffectsRegion
FloatSize scale(1, 1);
if (filterElement().hasAttribute(SVGNames::filterResAttr)) {
scale.setWidth(filterElement().filterResX() / absoluteFilterBoundaries.width());
scale.setHeight(filterElement().filterResY() / absoluteFilterBoundaries.height());
}
if (scale.isEmpty())
return false;
// Determine scale factor for filter. The size of intermediate ImageBuffers shouldn't be bigger than kMaxFilterSize.
FloatRect tempSourceRect = absoluteDrawingRegion;
tempSourceRect.scale(scale.width(), scale.height());
fitsInMaximumImageSize(tempSourceRect.size(), scale);
// Set the scale level in SVGFilter.
filterData->filter->setFilterResolution(scale);
static const unsigned maxTotalOfEffectInputs = 100;
FilterEffect* lastEffect = filterData->builder->lastEffect();
if (!lastEffect || lastEffect->totalNumberOfEffectInputs() > maxTotalOfEffectInputs)
return false;
RenderSVGResourceFilterPrimitive::determineFilterPrimitiveSubregion(*lastEffect);
FloatRect subRegion = lastEffect->maxEffectRect();
// At least one FilterEffect has a too big image size,
// recalculate the effect sizes with new scale factors.
if (!fitsInMaximumImageSize(subRegion.size(), scale)) {
filterData->filter->setFilterResolution(scale);
RenderSVGResourceFilterPrimitive::determineFilterPrimitiveSubregion(*lastEffect);
}
// If the drawingRegion is empty, we have something like <g filter=".."/>.
// Even if the target objectBoundingBox() is empty, we still have to draw the last effect result image in postApplyResource.
if (filterData->drawingRegion.isEmpty()) {
ASSERT(!m_filter.contains(&renderer));
filterData->savedContext = context;
m_filter.set(&renderer, WTF::move(filterData));
return false;
}
// Change the coordinate transformation applied to the filtered element to reflect the resolution of the filter.
AffineTransform effectiveTransform;
effectiveTransform.scale(scale.width(), scale.height());
effectiveTransform.multiply(filterData->shearFreeAbsoluteTransform);
std::unique_ptr<ImageBuffer> sourceGraphic;
RenderingMode renderingMode = renderer.frame().settings().acceleratedFiltersEnabled() ? Accelerated : Unaccelerated;
if (!SVGRenderingContext::createImageBuffer(filterData->drawingRegion, effectiveTransform, sourceGraphic, ColorSpaceLinearRGB, renderingMode)) {
ASSERT(!m_filter.contains(&renderer));
filterData->savedContext = context;
m_filter.set(&renderer, WTF::move(filterData));
return false;
}
// Set the rendering mode from the page's settings.
//.........这里部分代码省略.........