本文整理汇总了C++中SVGPatternElement类的典型用法代码示例。如果您正苦于以下问题:C++ SVGPatternElement类的具体用法?C++ SVGPatternElement怎么用?C++ SVGPatternElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SVGPatternElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clearInvalidationMask
SVGPaintServer LayoutSVGResourcePattern::preparePaintServer(const LayoutObject& object)
{
clearInvalidationMask();
SVGPatternElement* patternElement = toSVGPatternElement(element());
if (!patternElement)
return SVGPaintServer::invalid();
if (m_shouldCollectPatternAttributes) {
patternElement->synchronizeAnimatedSVGAttribute(anyQName());
#if ENABLE(OILPAN)
m_attributesWrapper->set(PatternAttributes());
#else
m_attributes = PatternAttributes();
#endif
patternElement->collectPatternAttributes(mutableAttributes());
m_shouldCollectPatternAttributes = false;
}
// Spec: When the geometry of the applicable element has no width or height and objectBoundingBox is specified,
// then the given effect (e.g. a gradient or a filter) will be ignored.
FloatRect objectBoundingBox = object.objectBoundingBox();
if (attributes().patternUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX && objectBoundingBox.isEmpty())
return SVGPaintServer::invalid();
PatternData* patternData = patternForLayoutObject(object);
if (!patternData || !patternData->pattern)
return SVGPaintServer::invalid();
patternData->pattern->setPatternSpaceTransform(patternData->transform);
return SVGPaintServer(patternData->pattern);
}
示例2: jsSVGPatternElementClassName
JSValue jsSVGPatternElementClassName(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
UNUSED_PARAM(exec);
SVGPatternElement* imp = static_cast<SVGPatternElement*>(static_cast<JSSVGPatternElement*>(asObject(slot.slotBase()))->impl());
RefPtr<SVGAnimatedString> obj = imp->classNameAnimated();
return toJS(exec, obj.get(), imp);
}
示例3: jsSVGPatternElementPreserveAspectRatio
JSValue jsSVGPatternElementPreserveAspectRatio(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
UNUSED_PARAM(exec);
SVGPatternElement* imp = static_cast<SVGPatternElement*>(static_cast<JSSVGPatternElement*>(asObject(slot.slotBase()))->impl());
RefPtr<SVGAnimatedPreserveAspectRatio> obj = imp->preserveAspectRatioAnimated();
return toJS(exec, obj.get(), imp);
}
示例4: jsSVGPatternElementExternalResourcesRequired
JSValue jsSVGPatternElementExternalResourcesRequired(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
UNUSED_PARAM(exec);
SVGPatternElement* imp = static_cast<SVGPatternElement*>(static_cast<JSSVGPatternElement*>(asObject(slot.slotBase()))->impl());
RefPtr<SVGAnimatedBoolean> obj = imp->externalResourcesRequiredAnimated();
return toJS(exec, obj.get(), imp);
}
示例5: jsSVGPatternElementPrototypeFunctionGetPresentationAttribute
JSValue JSC_HOST_CALL jsSVGPatternElementPrototypeFunctionGetPresentationAttribute(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
UNUSED_PARAM(args);
if (!thisValue.isObject(&JSSVGPatternElement::s_info))
return throwError(exec, TypeError);
JSSVGPatternElement* castedThisObj = static_cast<JSSVGPatternElement*>(asObject(thisValue));
SVGPatternElement* imp = static_cast<SVGPatternElement*>(castedThisObj->impl());
const UString& name = args.at(0).toString(exec);
JSC::JSValue result = toJS(exec, WTF::getPtr(imp->getPresentationAttribute(name)));
return result;
}
示例6: jsSVGPatternElementPrototypeFunctionHasExtension
JSValue JSC_HOST_CALL jsSVGPatternElementPrototypeFunctionHasExtension(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
UNUSED_PARAM(args);
if (!thisValue.isObject(&JSSVGPatternElement::s_info))
return throwError(exec, TypeError);
JSSVGPatternElement* castedThisObj = static_cast<JSSVGPatternElement*>(asObject(thisValue));
SVGPatternElement* imp = static_cast<SVGPatternElement*>(castedThisObj->impl());
const UString& extension = args.at(0).toString(exec);
JSC::JSValue result = jsBoolean(imp->hasExtension(extension));
return result;
}
示例7: switch
void JSSVGPatternElement::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)
{
switch (token) {
case XmllangAttrNum: {
SVGPatternElement* imp = static_cast<SVGPatternElement*>(impl());
imp->setXmllang(value->toString(exec));
break;
}
case XmlspaceAttrNum: {
SVGPatternElement* imp = static_cast<SVGPatternElement*>(impl());
imp->setXmlspace(value->toString(exec));
break;
}
}
}
示例8: throwError
JSValue* JSSVGPatternElementPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
{
if (!thisObj->inherits(&JSSVGPatternElement::info))
return throwError(exec, TypeError);
SVGPatternElement* imp = static_cast<SVGPatternElement*>(static_cast<JSSVGPatternElement*>(thisObj)->impl());
switch (id) {
case JSSVGPatternElement::HasExtensionFuncNum: {
String extension = args[0]->toString(exec);
KJS::JSValue* result = jsBoolean(imp->hasExtension(extension));
return result;
}
}
return 0;
}
示例9: ASSERT
bool RenderSVGResourcePattern::applyResource(RenderObject* object, RenderStyle* style, GraphicsContext*& context, unsigned short resourceMode)
{
ASSERT(object);
ASSERT(style);
ASSERT(context);
ASSERT(resourceMode != ApplyToDefaultMode);
// Be sure to synchronize all SVG properties on the patternElement _before_ processing any further.
// Otherwhise the call to collectPatternAttributes() below, may cause the SVG DOM property
// synchronization to kick in, which causes removeAllClientsFromCache() to be called, which in turn deletes our
// PatternData object! Leaving out the line below will cause svg/dynamic-updates/SVGPatternElement-svgdom* to crash.
SVGPatternElement* patternElement = static_cast<SVGPatternElement*>(node());
if (!patternElement)
return false;
if (m_shouldCollectPatternAttributes) {
patternElement->updateAnimatedSVGAttribute(anyQName());
m_attributes = PatternAttributes();
patternElement->collectPatternAttributes(m_attributes);
m_shouldCollectPatternAttributes = false;
}
// Spec: When the geometry of the applicable element has no width or height and objectBoundingBox is specified,
// then the given effect (e.g. a gradient or a filter) will be ignored.
FloatRect objectBoundingBox = object->objectBoundingBox();
if (m_attributes.patternUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX && objectBoundingBox.isEmpty())
return false;
OwnPtr<PatternData>& patternData = m_patternMap.add(object, nullptr).iterator->second;
if (!patternData)
patternData = adoptPtr(new PatternData);
if (!patternData->pattern) {
// If we couldn't determine the pattern content element root, stop here.
if (!m_attributes.patternContentElement())
return false;
// Compute all necessary transformations to build the tile image & the pattern.
FloatRect tileBoundaries;
AffineTransform tileImageTransform;
if (!buildTileImageTransform(object, m_attributes, patternElement, tileBoundaries, tileImageTransform))
return false;
AffineTransform absoluteTransformIgnoringRotation;
SVGRenderingContext::calculateTransformationToOutermostSVGCoordinateSystem(object, absoluteTransformIgnoringRotation);
// Ignore 2D rotation, as it doesn't affect the size of the tile.
SVGRenderingContext::clear2DRotation(absoluteTransformIgnoringRotation);
FloatRect absoluteTileBoundaries = absoluteTransformIgnoringRotation.mapRect(tileBoundaries);
FloatRect clampedAbsoluteTileBoundaries;
// Scale the tile size to match the scale level of the patternTransform.
absoluteTileBoundaries.scale(static_cast<float>(m_attributes.patternTransform().xScale()),
static_cast<float>(m_attributes.patternTransform().yScale()));
// Build tile image.
OwnPtr<ImageBuffer> tileImage = createTileImage(m_attributes, tileBoundaries, absoluteTileBoundaries, tileImageTransform, clampedAbsoluteTileBoundaries);
if (!tileImage)
return false;
RefPtr<Image> copiedImage = tileImage->copyImage(CopyBackingStore);
if (!copiedImage)
return false;
// Build pattern.
patternData->pattern = Pattern::create(copiedImage, true, true);
if (!patternData->pattern)
return false;
// Compute pattern space transformation.
patternData->transform.translate(tileBoundaries.x(), tileBoundaries.y());
patternData->transform.scale(tileBoundaries.width() / clampedAbsoluteTileBoundaries.width(), tileBoundaries.height() / clampedAbsoluteTileBoundaries.height());
AffineTransform patternTransform = m_attributes.patternTransform();
if (!patternTransform.isIdentity())
patternData->transform = patternTransform * patternData->transform;
// Account for text drawing resetting the context to non-scaled, see SVGInlineTextBox::paintTextWithShadows.
if (resourceMode & ApplyToTextMode) {
AffineTransform additionalTextTransformation;
if (shouldTransformOnTextPainting(object, additionalTextTransformation))
patternData->transform *= additionalTextTransformation;
}
patternData->pattern->setPatternSpaceTransform(patternData->transform);
}
// Draw pattern
context->save();
const SVGRenderStyle* svgStyle = style->svgStyle();
ASSERT(svgStyle);
if (resourceMode & ApplyToFillMode) {
context->setAlpha(svgStyle->fillOpacity());
context->setFillPattern(patternData->pattern);
context->setFillRule(svgStyle->fillRule());
} else if (resourceMode & ApplyToStrokeMode) {
if (svgStyle->vectorEffect() == VE_NON_SCALING_STROKE)
patternData->pattern->setPatternSpaceTransform(transformOnNonScalingStroke(object, patternData->transform));
//.........这里部分代码省略.........
示例10: buildPattern
PatternData* RenderSVGResourcePattern::buildPattern(RenderObject* object, unsigned short resourceMode)
{
PatternData* currentData = m_patternMap.get(object);
if (currentData && currentData->pattern)
return currentData;
SVGPatternElement* patternElement = static_cast<SVGPatternElement*>(node());
if (!patternElement)
return 0;
if (m_shouldCollectPatternAttributes) {
patternElement->updateAnimatedSVGAttribute(anyQName());
m_attributes = PatternAttributes();
patternElement->collectPatternAttributes(m_attributes);
m_shouldCollectPatternAttributes = false;
}
// If we couldn't determine the pattern content element root, stop here.
if (!m_attributes.patternContentElement())
return 0;
// Compute all necessary transformations to build the tile image & the pattern.
FloatRect tileBoundaries;
AffineTransform tileImageTransform;
if (!buildTileImageTransform(object, m_attributes, patternElement, tileBoundaries, tileImageTransform))
return 0;
AffineTransform absoluteTransformIgnoringRotation;
SVGRenderingContext::calculateTransformationToOutermostSVGCoordinateSystem(object, absoluteTransformIgnoringRotation);
// Ignore 2D rotation, as it doesn't affect the size of the tile.
SVGRenderingContext::clear2DRotation(absoluteTransformIgnoringRotation);
FloatRect absoluteTileBoundaries = absoluteTransformIgnoringRotation.mapRect(tileBoundaries);
FloatRect clampedAbsoluteTileBoundaries;
// Scale the tile size to match the scale level of the patternTransform.
absoluteTileBoundaries.scale(static_cast<float>(m_attributes.patternTransform().xScale()),
static_cast<float>(m_attributes.patternTransform().yScale()));
// Build tile image.
OwnPtr<ImageBuffer> tileImage = createTileImage(m_attributes, tileBoundaries, absoluteTileBoundaries, tileImageTransform, clampedAbsoluteTileBoundaries);
if (!tileImage)
return 0;
RefPtr<Image> copiedImage = tileImage->copyImage(CopyBackingStore);
if (!copiedImage)
return 0;
// Build pattern.
OwnPtr<PatternData> patternData = adoptPtr(new PatternData);
patternData->pattern = Pattern::create(copiedImage, true, true);
// Compute pattern space transformation.
const IntSize tileImageSize = tileImage->logicalSize();
patternData->transform.translate(tileBoundaries.x(), tileBoundaries.y());
patternData->transform.scale(tileBoundaries.width() / tileImageSize.width(), tileBoundaries.height() / tileImageSize.height());
AffineTransform patternTransform = m_attributes.patternTransform();
if (!patternTransform.isIdentity())
patternData->transform = patternTransform * patternData->transform;
// Account for text drawing resetting the context to non-scaled, see SVGInlineTextBox::paintTextWithShadows.
if (resourceMode & ApplyToTextMode) {
AffineTransform additionalTextTransformation;
if (shouldTransformOnTextPainting(object, additionalTextTransformation))
patternData->transform *= additionalTextTransformation;
}
patternData->pattern->setPatternSpaceTransform(patternData->transform);
// Various calls above may trigger invalidations in some fringe cases (ImageBuffer allocation
// failures in the SVG image cache for example). To avoid having our PatternData deleted by
// removeAllClientsFromCache(), we only make it visible in the cache at the very end.
return m_patternMap.set(object, patternData.release()).iterator->value.get();
}
示例11: setJSSVGPatternElementXmlspace
void setJSSVGPatternElementXmlspace(ExecState* exec, JSObject* thisObject, JSValue value)
{
SVGPatternElement* imp = static_cast<SVGPatternElement*>(static_cast<JSSVGPatternElement*>(thisObject)->impl());
imp->setXmlspace(value.toString(exec));
}
示例12: jsSVGPatternElementStyle
JSValue jsSVGPatternElementStyle(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
UNUSED_PARAM(exec);
SVGPatternElement* imp = static_cast<SVGPatternElement*>(static_cast<JSSVGPatternElement*>(asObject(slot.slotBase()))->impl());
return toJS(exec, WTF::getPtr(imp->style()));
}
示例13: jsSVGPatternElementXmlspace
JSValue jsSVGPatternElementXmlspace(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
UNUSED_PARAM(exec);
SVGPatternElement* imp = static_cast<SVGPatternElement*>(static_cast<JSSVGPatternElement*>(asObject(slot.slotBase()))->impl());
return jsString(exec, imp->xmlspace());
}
示例14: setPatternAttributes
static void setPatternAttributes(const SVGPatternElement& element, PatternAttributes& attributes)
{
if (!attributes.hasX() && element.hasAttribute(SVGNames::xAttr))
attributes.setX(element.x());
if (!attributes.hasY() && element.hasAttribute(SVGNames::yAttr))
attributes.setY(element.y());
if (!attributes.hasWidth() && element.hasAttribute(SVGNames::widthAttr))
attributes.setWidth(element.width());
if (!attributes.hasHeight() && element.hasAttribute(SVGNames::heightAttr))
attributes.setHeight(element.height());
if (!attributes.hasViewBox() && element.hasAttribute(SVGNames::viewBoxAttr) && element.viewBoxIsValid())
attributes.setViewBox(element.viewBox());
if (!attributes.hasPreserveAspectRatio() && element.hasAttribute(SVGNames::preserveAspectRatioAttr))
attributes.setPreserveAspectRatio(element.preserveAspectRatio());
if (!attributes.hasPatternUnits() && element.hasAttribute(SVGNames::patternUnitsAttr))
attributes.setPatternUnits(element.patternUnits());
if (!attributes.hasPatternContentUnits() && element.hasAttribute(SVGNames::patternContentUnitsAttr))
attributes.setPatternContentUnits(element.patternContentUnits());
if (!attributes.hasPatternTransform() && element.hasAttribute(SVGNames::patternTransformAttr)) {
AffineTransform transform;
element.patternTransform().concatenate(transform);
attributes.setPatternTransform(transform);
}
if (!attributes.hasPatternContentElement() && element.childElementCount())
attributes.setPatternContentElement(&element);
}
示例15: ASSERT
bool RenderSVGResourcePattern::applyResource(RenderObject* object, RenderStyle* style, GraphicsContext*& context, unsigned short resourceMode)
{
ASSERT(object);
ASSERT(style);
ASSERT(context);
ASSERT(resourceMode != ApplyToDefaultMode);
// Be sure to synchronize all SVG properties on the patternElement _before_ processing any further.
// Otherwhise the call to collectPatternAttributes() below, may cause the SVG DOM property
// synchronization to kick in, which causes removeAllClientsFromCache() to be called, which in turn deletes our
// PatternData object! Leaving out the line below will cause svg/dynamic-updates/SVGPatternElement-svgdom* to crash.
SVGPatternElement* patternElement = static_cast<SVGPatternElement*>(node());
if (!patternElement)
return false;
if (m_shouldCollectPatternAttributes) {
patternElement->updateAnimatedSVGAttribute(anyQName());
m_attributes = PatternAttributes();
patternElement->collectPatternAttributes(m_attributes);
m_shouldCollectPatternAttributes = false;
}
// Spec: When the geometry of the applicable element has no width or height and objectBoundingBox is specified,
// then the given effect (e.g. a gradient or a filter) will be ignored.
FloatRect objectBoundingBox = object->objectBoundingBox();
if (m_attributes.boundingBoxMode() && objectBoundingBox.isEmpty())
return false;
if (!m_pattern.contains(object))
m_pattern.set(object, new PatternData);
PatternData* patternData = m_pattern.get(object);
if (!patternData->pattern) {
// If we couldn't determine the pattern content element root, stop here.
if (!m_attributes.patternContentElement())
return false;
// Compute all necessary transformations to build the tile image & the pattern.
FloatRect tileBoundaries;
AffineTransform tileImageTransform;
if (!buildTileImageTransform(object, m_attributes, patternElement, tileBoundaries, tileImageTransform))
return false;
AffineTransform absoluteTransform;
SVGImageBufferTools::calculateTransformationToOutermostSVGCoordinateSystem(object, absoluteTransform);
FloatRect absoluteTileBoundaries = absoluteTransform.mapRect(tileBoundaries);
// Build tile image.
OwnPtr<ImageBuffer> tileImage = createTileImage(object, m_attributes, tileBoundaries, absoluteTileBoundaries, tileImageTransform);
if (!tileImage)
return false;
RefPtr<Image> copiedImage = tileImage->copyImage();
if (!copiedImage)
return false;
// Build pattern.
patternData->pattern = Pattern::create(copiedImage, true, true);
if (!patternData->pattern)
return false;
// Compute pattern space transformation.
patternData->transform.translate(tileBoundaries.x(), tileBoundaries.y());
patternData->transform.scale(tileBoundaries.width() / absoluteTileBoundaries.width(), tileBoundaries.height() / absoluteTileBoundaries.height());
AffineTransform patternTransform = m_attributes.patternTransform();
if (!patternTransform.isIdentity())
patternData->transform = patternTransform * patternData->transform;
patternData->pattern->setPatternSpaceTransform(patternData->transform);
}
// Draw pattern
context->save();
const SVGRenderStyle* svgStyle = style->svgStyle();
ASSERT(svgStyle);
if (resourceMode & ApplyToFillMode) {
context->setAlpha(svgStyle->fillOpacity());
context->setFillPattern(patternData->pattern);
context->setFillRule(svgStyle->fillRule());
} else if (resourceMode & ApplyToStrokeMode) {
if (svgStyle->vectorEffect() == VE_NON_SCALING_STROKE)
patternData->pattern->setPatternSpaceTransform(transformOnNonScalingStroke(object, patternData->transform));
context->setAlpha(svgStyle->strokeOpacity());
context->setStrokePattern(patternData->pattern);
SVGRenderSupport::applyStrokeStyleToContext(context, style, object);
}
if (resourceMode & ApplyToTextMode) {
if (resourceMode & ApplyToFillMode) {
context->setTextDrawingMode(TextModeFill);
#if PLATFORM(CG)
context->applyFillPattern();
#endif
} else if (resourceMode & ApplyToStrokeMode) {
//.........这里部分代码省略.........