当前位置: 首页>>代码示例>>C++>>正文


C++ SVGGradientElement类代码示例

本文整理汇总了C++中SVGGradientElement的典型用法代码示例。如果您正苦于以下问题:C++ SVGGradientElement类的具体用法?C++ SVGGradientElement怎么用?C++ SVGGradientElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SVGGradientElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setGradientAttributes

bool SVGLinearGradientElement::collectGradientAttributes(LinearGradientAttributes& attributes)
{
    if (!renderer())
        return false;

    HashSet<SVGGradientElement*> processedGradients;
    SVGGradientElement* current = this;

    setGradientAttributes(current, attributes);
    processedGradients.add(current);

    while (true) {
        // Respect xlink:href, take attributes from referenced element
        Node* refNode = SVGURIReference::targetElementFromIRIString(current->href()->currentValue()->value(), treeScope());
        if (refNode && isSVGGradientElement(*refNode)) {
            current = toSVGGradientElement(refNode);

            // Cycle detection
            if (processedGradients.contains(current))
                return true;

            if (!current->renderer())
                return false;

            setGradientAttributes(current, attributes, isSVGLinearGradientElement(*current));
            processedGradients.add(current);
        } else {
            return true;
        }
    }

    ASSERT_NOT_REACHED();
    return false;
}
开发者ID:dp7,项目名称:blink-crosswalk,代码行数:34,代码来源:SVGLinearGradientElement.cpp

示例2: setGradientAttributes

bool SVGLinearGradientElement::collectGradientAttributes(LinearGradientAttributes& attributes)
{
    if (!renderer())
        return false;

    HashSet<SVGGradientElement*> processedGradients;
    SVGGradientElement* current = this;

    setGradientAttributes(*current, attributes);
    processedGradients.add(current);

    while (true) {
        // Respect xlink:href, take attributes from referenced element
        Node* refNode = SVGURIReference::targetElementFromIRIString(current->href(), document());
        if (is<SVGGradientElement>(refNode)) {
            current = downcast<SVGGradientElement>(refNode);

            // Cycle detection
            if (processedGradients.contains(current))
                return true;

            if (!current->renderer())
                return false;

            setGradientAttributes(*current, attributes, current->hasTagName(SVGNames::linearGradientTag));
            processedGradients.add(current);
        } else
            return true;
    }

    ASSERT_NOT_REACHED();
    return false;
}
开发者ID:eocanha,项目名称:webkit,代码行数:33,代码来源:SVGLinearGradientElement.cpp

示例3: jsSVGGradientElementStyle

JSValue jsSVGGradientElementStyle(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSSVGGradientElement* castedThis = static_cast<JSSVGGradientElement*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    SVGGradientElement* imp = static_cast<SVGGradientElement*>(castedThis->impl());
    JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->style()));
    return result;
}
开发者ID:Xertz,项目名称:EAWebKit,代码行数:8,代码来源:JSSVGGradientElement.cpp

示例4: jsSVGGradientElementSpreadMethod

JSValue jsSVGGradientElementSpreadMethod(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSSVGGradientElement* castedThis = static_cast<JSSVGGradientElement*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    SVGGradientElement* imp = static_cast<SVGGradientElement*>(castedThis->impl());
    RefPtr<SVGAnimatedEnumeration> obj = imp->spreadMethodAnimated();
    JSValue result =  toJS(exec, castedThis->globalObject(), obj.get());
    return result;
}
开发者ID:Xertz,项目名称:EAWebKit,代码行数:9,代码来源:JSSVGGradientElement.cpp

示例5: jsSVGGradientElementExternalResourcesRequired

JSValue jsSVGGradientElementExternalResourcesRequired(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSSVGGradientElement* castedThis = static_cast<JSSVGGradientElement*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    SVGGradientElement* imp = static_cast<SVGGradientElement*>(castedThis->impl());
    RefPtr<SVGAnimatedBoolean> obj = imp->externalResourcesRequiredAnimated();
    JSValue result =  toJS(exec, castedThis->globalObject(), obj.get());
    return result;
}
开发者ID:Xertz,项目名称:EAWebKit,代码行数:9,代码来源:JSSVGGradientElement.cpp

示例6: jsSVGGradientElementClassName

JSValue jsSVGGradientElementClassName(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSSVGGradientElement* castedThis = static_cast<JSSVGGradientElement*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    SVGGradientElement* imp = static_cast<SVGGradientElement*>(castedThis->impl());
    RefPtr<SVGAnimatedString> obj = imp->classNameAnimated();
    JSValue result =  toJS(exec, castedThis->globalObject(), obj.get());
    return result;
}
开发者ID:Xertz,项目名称:EAWebKit,代码行数:9,代码来源:JSSVGGradientElement.cpp

示例7: jsSVGGradientElementPrototypeFunctionGetPresentationAttribute

JSValue* jsSVGGradientElementPrototypeFunctionGetPresentationAttribute(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
    if (!thisValue->isObject(&JSSVGGradientElement::s_info))
        return throwError(exec, TypeError);
    JSSVGGradientElement* castedThisObj = static_cast<JSSVGGradientElement*>(thisValue);
    SVGGradientElement* imp = static_cast<SVGGradientElement*>(castedThisObj->impl());
    const UString& name = args.at(exec, 0)->toString(exec);


    JSC::JSValue* result = toJS(exec, WTF::getPtr(imp->getPresentationAttribute(name)));
    return result;
}
开发者ID:achellies,项目名称:ISeeBrowser,代码行数:12,代码来源:JSSVGGradientElement.cpp

示例8: jsSVGGradientElementPrototypeFunctionGetPresentationAttribute

JSValue JSC_HOST_CALL jsSVGGradientElementPrototypeFunctionGetPresentationAttribute(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
    UNUSED_PARAM(args);
    if (!thisValue.inherits(&JSSVGGradientElement::s_info))
        return throwError(exec, TypeError);
    JSSVGGradientElement* castedThisObj = static_cast<JSSVGGradientElement*>(asObject(thisValue));
    SVGGradientElement* imp = static_cast<SVGGradientElement*>(castedThisObj->impl());
    const UString& name = args.at(0).toString(exec);


    JSC::JSValue result = toJS(exec, castedThisObj->globalObject(), WTF::getPtr(imp->getPresentationAttribute(name)));
    return result;
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:13,代码来源:JSSVGGradientElement.cpp

示例9: jsSVGGradientElementPrototypeFunctionGetPresentationAttribute

EncodedJSValue JSC_HOST_CALL jsSVGGradientElementPrototypeFunctionGetPresentationAttribute(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSSVGGradientElement::s_info))
        return throwVMTypeError(exec);
    JSSVGGradientElement* castedThis = static_cast<JSSVGGradientElement*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSSVGGradientElement::s_info);
    SVGGradientElement* imp = static_cast<SVGGradientElement*>(castedThis->impl());
    const String& name(ustringToString(exec->argument(0).toString(exec)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());


    JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->getPresentationAttribute(name)));
    return JSValue::encode(result);
}
开发者ID:Xertz,项目名称:EAWebKit,代码行数:16,代码来源:JSSVGGradientElement.cpp

示例10: gradientElement

void RenderSVGGradientStop::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
{
    RenderObject::styleDidChange(diff, oldStyle);
    if (!diff.hasDifference())
        return;

    // <stop> elements should only be allowed to make renderers under gradient elements
    // but I can imagine a few cases we might not be catching, so let's not crash if our parent isn't a gradient.
    SVGGradientElement* gradient = gradientElement();
    if (!gradient)
        return;

    RenderObject* renderer = gradient->renderer();
    if (!renderer)
        return;

    RenderSVGResourceContainer* container = toRenderSVGResourceContainer(renderer);
    container->removeAllClientsFromCache();
}
开发者ID:335969568,项目名称:Blink-1,代码行数:19,代码来源:RenderSVGGradientStop.cpp

示例11: setGradientAttributes

bool SVGRadialGradientElement::collectGradientAttributes(RadialGradientAttributes& attributes)
{
    if (!renderer())
        return false;

    WillBeHeapHashSet<RawPtrWillBeMember<SVGGradientElement> > processedGradients;
    SVGGradientElement* current = this;

    setGradientAttributes(current, attributes);
    processedGradients.add(current);

    while (true) {
        // Respect xlink:href, take attributes from referenced element
        Node* refNode = SVGURIReference::targetElementFromIRIString(current->href()->currentValue()->value(), treeScope());
        if (refNode && isSVGGradientElement(*refNode)) {
            current = toSVGGradientElement(refNode);

            // Cycle detection
            if (processedGradients.contains(current))
                break;

            if (!current->renderer())
                return false;

            setGradientAttributes(current, attributes, isSVGRadialGradientElement(*current));
            processedGradients.add(current);
        } else {
            break;
        }
    }

    // Handle default values for fx/fy
    if (!attributes.hasFx())
        attributes.setFx(attributes.cx());

    if (!attributes.hasFy())
        attributes.setFy(attributes.cy());

    return true;
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:40,代码来源:SVGRadialGradientElement.cpp

示例12: setGradientAttributes

bool SVGRadialGradientElement::collectGradientAttributes(RadialGradientAttributes& attributes)
{
    if (!renderer())
        return false;

    HashSet<SVGGradientElement*> processedGradients;
    SVGGradientElement* current = this;

    setGradientAttributes(*current, attributes);
    processedGradients.add(current);

    while (true) {
        // Respect xlink:href, take attributes from referenced element
        Node* refNode = SVGURIReference::targetElementFromIRIString(current->href(), document());
        if (is<SVGGradientElement>(refNode)) {
            current = downcast<SVGGradientElement>(refNode);

            // Cycle detection
            if (processedGradients.contains(current))
                break;

            if (!current->renderer())
                return false;

            setGradientAttributes(*current, attributes, current->hasTagName(SVGNames::radialGradientTag));
            processedGradients.add(current);
        } else
            break;
    }

    // Handle default values for fx/fy
    if (!attributes.hasFx())
        attributes.setFx(attributes.cx());

    if (!attributes.hasFy())
        attributes.setFy(attributes.cy());

    return true;
}
开发者ID:Comcast,项目名称:WebKitForWayland,代码行数:39,代码来源:SVGRadialGradientElement.cpp

示例13: switch

JSValue* JSSVGGradientElement::getValueProperty(ExecState* exec, int token) const
{
    switch (token) {
    case GradientUnitsAttrNum: {
        SVGGradientElement* imp = static_cast<SVGGradientElement*>(impl());
        RefPtr<SVGAnimatedEnumeration> obj = imp->gradientUnitsAnimated();
        return toJS(exec, obj.get(), imp);
    }
    case GradientTransformAttrNum: {
        SVGGradientElement* imp = static_cast<SVGGradientElement*>(impl());
        RefPtr<SVGAnimatedTransformList> obj = imp->gradientTransformAnimated();
        return toJS(exec, obj.get(), imp);
    }
    case SpreadMethodAttrNum: {
        SVGGradientElement* imp = static_cast<SVGGradientElement*>(impl());
        RefPtr<SVGAnimatedEnumeration> obj = imp->spreadMethodAnimated();
        return toJS(exec, obj.get(), imp);
    }
    case HrefAttrNum: {
        SVGGradientElement* imp = static_cast<SVGGradientElement*>(impl());
        RefPtr<SVGAnimatedString> obj = imp->hrefAnimated();
        return toJS(exec, obj.get(), imp);
    }
    case ExternalResourcesRequiredAttrNum: {
        SVGGradientElement* imp = static_cast<SVGGradientElement*>(impl());
        RefPtr<SVGAnimatedBoolean> obj = imp->externalResourcesRequiredAnimated();
        return toJS(exec, obj.get(), imp);
    }
    case ClassNameAttrNum: {
        SVGGradientElement* imp = static_cast<SVGGradientElement*>(impl());
        RefPtr<SVGAnimatedString> obj = imp->classNameAnimated();
        return toJS(exec, obj.get(), imp);
    }
    case StyleAttrNum: {
        SVGGradientElement* imp = static_cast<SVGGradientElement*>(impl());
        return toJS(exec, WTF::getPtr(imp->style()));
    }
    case ConstructorAttrNum:
        return getConstructor(exec);
    }
    return 0;
}
开发者ID:achellies,项目名称:ISeeBrowser,代码行数:42,代码来源:JSSVGGradientElement.cpp

示例14: ASSERT

bool RenderSVGResourceGradient::applyResource(RenderObject* object, RenderStyle* style, GraphicsContext*& context, unsigned short resourceMode)
{
    ASSERT(object);
    ASSERT(style);
    ASSERT(context);
    ASSERT(resourceMode != ApplyToDefaultMode);

    clearInvalidationMask();

    // Be sure to synchronize all SVG properties on the gradientElement _before_ processing any further.
    // Otherwhise the call to collectGradientAttributes() in createTileImage(), may cause the SVG DOM property
    // synchronization to kick in, which causes removeAllClientsFromCache() to be called, which in turn deletes our
    // GradientData object! Leaving out the line below will cause svg/dynamic-updates/SVG*GradientElement-svgdom* to crash.
    SVGGradientElement* gradientElement = toSVGGradientElement(element());
    if (!gradientElement)
        return false;

    if (m_shouldCollectGradientAttributes) {
        gradientElement->synchronizeAnimatedSVGAttribute(anyQName());
        if (!collectGradientAttributes(gradientElement))
            return false;

        m_shouldCollectGradientAttributes = 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 (gradientUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX && objectBoundingBox.isEmpty())
        return false;

    OwnPtr<GradientData>& gradientData = m_gradientMap.add(object, nullptr).storedValue->value;
    if (!gradientData)
        gradientData = adoptPtr(new GradientData);

    // Create gradient object
    if (!gradientData->gradient) {
        buildGradient(gradientData.get());

        // We want the text bounding box applied to the gradient space transform now, so the gradient shader can use it.
        if (gradientUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX && !objectBoundingBox.isEmpty()) {
            gradientData->userspaceTransform.translate(objectBoundingBox.x(), objectBoundingBox.y());
            gradientData->userspaceTransform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.height());
        }

        AffineTransform gradientTransform;
        calculateGradientTransform(gradientTransform);

        gradientData->userspaceTransform *= gradientTransform;
    }

    if (!gradientData->gradient)
        return false;

    const SVGRenderStyle* svgStyle = style->svgStyle();
    ASSERT(svgStyle);

    AffineTransform computedGradientSpaceTransform = computeResourceSpaceTransform(object, gradientData->userspaceTransform, svgStyle, resourceMode);
    gradientData->gradient->setGradientSpaceTransform(computedGradientSpaceTransform);

    // Draw gradient
    context->save();

    if (resourceMode & ApplyToTextMode)
        context->setTextDrawingMode(resourceMode & ApplyToFillMode ? TextModeFill : TextModeStroke);

    if (resourceMode & ApplyToFillMode) {
        context->setAlphaAsFloat(svgStyle->fillOpacity());
        context->setFillGradient(gradientData->gradient);
        context->setFillRule(svgStyle->fillRule());
    } else if (resourceMode & ApplyToStrokeMode) {
        context->setAlphaAsFloat(svgStyle->strokeOpacity());
        context->setStrokeGradient(gradientData->gradient);
        SVGRenderSupport::applyStrokeStyleToContext(context, style, object);
    }

    return true;
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:78,代码来源:RenderSVGResourceGradient.cpp

示例15: ASSERT

bool RenderSVGResourceGradient::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 gradientElement _before_ processing any further.
    // Otherwhise the call to collectGradientAttributes() in createTileImage(), may cause the SVG DOM property
    // synchronization to kick in, which causes invalidateClients() to be called, which in turn deletes our
    // GradientData object! Leaving out the line below will cause svg/dynamic-updates/SVG*GradientElement-svgdom* to crash.
    SVGGradientElement* gradientElement = static_cast<SVGGradientElement*>(node());
    if (!gradientElement)
        return false;

    gradientElement->updateAnimatedSVGAttribute(anyQName());

    if (!m_gradient.contains(object))
        m_gradient.set(object, new GradientData);

    GradientData* gradientData = m_gradient.get(object);

    // Create gradient object
    if (!gradientData->gradient)
        buildGradient(gradientData, gradientElement);

    if (!gradientData->gradient)
        return false;

    // Draw gradient
    context->save();

    bool isPaintingText = resourceMode & ApplyToTextMode;
    if (isPaintingText) {
#if PLATFORM(CG)
        if (!createMaskAndSwapContextForTextGradient(context, m_savedContext, m_imageBuffer, object)) {
            context->restore();
            return false;
        }
#endif

        context->setTextDrawingMode(resourceMode & ApplyToFillMode ? cTextFill : cTextStroke);
    }

    AffineTransform transform;

    // CG platforms will handle the gradient space transform for text after applying the
    // resource, so don't apply it here. For non-CG platforms, we want the text bounding
    // box applied to the gradient space transform now, so the gradient shader can use it.
#if PLATFORM(CG)
    if (gradientData->boundingBoxMode && !isPaintingText) {
#else
    if (gradientData->boundingBoxMode) {
#endif
        FloatRect objectBoundingBox = object->objectBoundingBox();
        transform.translate(objectBoundingBox.x(), objectBoundingBox.y());
        transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.height());
    }

    transform.multiply(gradientData->transform);
    gradientData->gradient->setGradientSpaceTransform(transform);

    const SVGRenderStyle* svgStyle = style->svgStyle();
    ASSERT(svgStyle);

    if (resourceMode & ApplyToFillMode) {
        context->setAlpha(svgStyle->fillOpacity());
        context->setFillGradient(gradientData->gradient);
        context->setFillRule(svgStyle->fillRule());
    } else if (resourceMode & ApplyToStrokeMode) {
        context->setAlpha(svgStyle->strokeOpacity());
        context->setStrokeGradient(gradientData->gradient);
        applyStrokeStyleToContext(context, style, object);
    }

    return true;
}

void RenderSVGResourceGradient::postApplyResource(RenderObject* object, GraphicsContext*& context, unsigned short resourceMode)
{
    ASSERT(context);
    ASSERT(resourceMode != ApplyToDefaultMode);

    if (resourceMode & ApplyToTextMode) {
#if PLATFORM(CG)
        // CG requires special handling for gradient on text
        if (m_savedContext && m_gradient.contains(object)) {
            GradientData* gradientData = m_gradient.get(object);

            // Restore on-screen drawing context
            context = m_savedContext;
            m_savedContext = 0;

            gradientData->gradient->setGradientSpaceTransform(clipToTextMask(context, m_imageBuffer, object, gradientData));
            context->setFillGradient(gradientData->gradient);

            const RenderObject* textRootBlock = findTextRootObject(object);
            context->fillRect(textRootBlock->repaintRectInLocalCoordinates());

            m_imageBuffer.clear();
//.........这里部分代码省略.........
开发者ID:UIKit0,项目名称:WebkitAIR,代码行数:101,代码来源:RenderSVGResourceGradient.cpp


注:本文中的SVGGradientElement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。