diff options
Diffstat (limited to 'WebCore/svg')
31 files changed, 167 insertions, 431 deletions
diff --git a/WebCore/svg/SVGAnimateMotionElement.cpp b/WebCore/svg/SVGAnimateMotionElement.cpp index b6422f5..861f353 100644 --- a/WebCore/svg/SVGAnimateMotionElement.cpp +++ b/WebCore/svg/SVGAnimateMotionElement.cpp @@ -150,7 +150,7 @@ void SVGAnimateMotionElement::resetToBaseValue(const String&) TransformationMatrix* transform = target->supplementalTransform(); if (!transform) return; - transform->reset(); + transform->makeIdentity(); } bool SVGAnimateMotionElement::calculateFromAndToValues(const String& fromString, const String& toString) @@ -179,7 +179,7 @@ void SVGAnimateMotionElement::calculateAnimatedValue(float percentage, unsigned, return; if (!isAdditive()) - transform->reset(); + transform->makeIdentity(); // FIXME: Implement accumulate. diff --git a/WebCore/svg/SVGElementInstance.h b/WebCore/svg/SVGElementInstance.h index 261d34a..f5c6ca9 100644 --- a/WebCore/svg/SVGElementInstance.h +++ b/WebCore/svg/SVGElementInstance.h @@ -55,7 +55,7 @@ namespace WebCore { virtual ScriptExecutionContext* scriptExecutionContext() const; - virtual EventTargetNode* toNode() { return shadowTreeElement(); } + virtual Node* toNode() { return shadowTreeElement(); } virtual SVGElementInstance* toSVGElementInstance() { return this; } virtual void addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture); diff --git a/WebCore/svg/SVGFont.cpp b/WebCore/svg/SVGFont.cpp index 3dae585..9b36f87 100644 --- a/WebCore/svg/SVGFont.cpp +++ b/WebCore/svg/SVGFont.cpp @@ -253,8 +253,8 @@ struct SVGTextRunWalker { bool haveAltGlyph = false; SVGGlyphIdentifier altGlyphIdentifier; if (RenderObject* renderObject = run.referencingRenderObject()) { - if (renderObject->element() && renderObject->element()->hasTagName(SVGNames::altGlyphTag)) { - SVGGlyphElement* glyphElement = static_cast<SVGAltGlyphElement*>(renderObject->element())->glyphElement(); + if (renderObject->node() && renderObject->node()->hasTagName(SVGNames::altGlyphTag)) { + SVGGlyphElement* glyphElement = static_cast<SVGAltGlyphElement*>(renderObject->node())->glyphElement(); if (glyphElement) { haveAltGlyph = true; altGlyphIdentifier = glyphElement->buildGlyphIdentifier(); @@ -407,7 +407,7 @@ static float floatWidthOfSubStringUsingSVGFont(const Font* font, const TextRun& if (RenderObject* renderObject = run.referencingRenderObject()) { isVerticalText = isVerticalWritingMode(renderObject->style()->svgStyle()); - if (SVGElement* element = static_cast<SVGElement*>(renderObject->element())) + if (SVGElement* element = static_cast<SVGElement*>(renderObject->node())) language = element->getAttribute(XMLNames::langAttr); } @@ -496,7 +496,7 @@ void Font::drawTextUsingSVGFont(GraphicsContext* context, const TextRun& run, if (run.referencingRenderObject()) { isVerticalText = isVerticalWritingMode(run.referencingRenderObject()->style()->svgStyle()); - if (SVGElement* element = static_cast<SVGElement*>(run.referencingRenderObject()->element())) + if (SVGElement* element = static_cast<SVGElement*>(run.referencingRenderObject()->node())) language = element->getAttribute(XMLNames::langAttr); } diff --git a/WebCore/svg/SVGImageLoader.cpp b/WebCore/svg/SVGImageLoader.cpp index 6e0915d..4b15acb 100644 --- a/WebCore/svg/SVGImageLoader.cpp +++ b/WebCore/svg/SVGImageLoader.cpp @@ -42,16 +42,12 @@ SVGImageLoader::~SVGImageLoader() void SVGImageLoader::dispatchLoadEvent() { - if (!haveFiredLoadEvent() && image()) { - setHaveFiredLoadEvent(true); - - if (image()->errorOccurred()) - element()->dispatchEventForType(eventNames().errorEvent, false, false); - else { - SVGImageElement* imageElement = static_cast<SVGImageElement*>(element()); - if (imageElement->externalResourcesRequiredBaseValue()) - imageElement->sendSVGLoadEventIfPossible(true); - } + if (image()->errorOccurred()) + element()->dispatchEventForType(eventNames().errorEvent, false, false); + else { + SVGImageElement* imageElement = static_cast<SVGImageElement*>(element()); + if (imageElement->externalResourcesRequiredBaseValue()) + imageElement->sendSVGLoadEventIfPossible(true); } } diff --git a/WebCore/svg/SVGLength.cpp b/WebCore/svg/SVGLength.cpp index d1b8856..ca3bac3 100644 --- a/WebCore/svg/SVGLength.cpp +++ b/WebCore/svg/SVGLength.cpp @@ -285,7 +285,7 @@ float SVGLength::PercentageOfViewport(float value, const SVGElement* context, SV Document* doc = context->document(); if (doc->documentElement() == context) { // We have to ask the canvas for the full "canvas size"... - RenderView* view = static_cast<RenderView*>(doc->renderer()); + RenderView* view = toRenderView(doc->renderer()); if (view && view->frameView()) { width = view->frameView()->visibleWidth(); // TODO: recheck! height = view->frameView()->visibleHeight(); // TODO: recheck! diff --git a/WebCore/svg/SVGLinearGradientElement.cpp b/WebCore/svg/SVGLinearGradientElement.cpp index ac2b6b1..d2d1798 100644 --- a/WebCore/svg/SVGLinearGradientElement.cpp +++ b/WebCore/svg/SVGLinearGradientElement.cpp @@ -87,6 +87,7 @@ void SVGLinearGradientElement::buildGradient() const FloatPoint endPoint = FloatPoint::narrowPrecision(attributes.x2(), attributes.y2()); RefPtr<Gradient> gradient = Gradient::create(startPoint, endPoint); + gradient->setSpreadMethod(attributes.spreadMethod()); Vector<SVGGradientStop> m_stops = attributes.stops(); float previousOffset = 0.0f; @@ -107,7 +108,6 @@ void SVGLinearGradientElement::buildGradient() const linearGradient->setGradientStops(attributes.stops()); // These should possibly be supported on Gradient - linearGradient->setGradientSpreadMethod(attributes.spreadMethod()); linearGradient->setGradientTransform(attributes.gradientTransform()); linearGradient->setGradientStart(startPoint); linearGradient->setGradientEnd(endPoint); diff --git a/WebCore/svg/SVGPathSegList.idl b/WebCore/svg/SVGPathSegList.idl index f55167e..8c67bd3 100644 --- a/WebCore/svg/SVGPathSegList.idl +++ b/WebCore/svg/SVGPathSegList.idl @@ -29,19 +29,19 @@ module svg { interface [Conditional=SVG] SVGPathSegList { readonly attribute unsigned long numberOfItems; - [Custom] void clear() + [JSCCustom] void clear() raises(DOMException); - [Custom] SVGPathSeg initialize(in SVGPathSeg newItem) + [JSCCustom] SVGPathSeg initialize(in SVGPathSeg newItem) raises(DOMException, SVGException); - [Custom] SVGPathSeg getItem(in unsigned long index) + [JSCCustom] SVGPathSeg getItem(in unsigned long index) raises(DOMException); - [Custom] SVGPathSeg insertItemBefore(in SVGPathSeg newItem, in unsigned long index) + [JSCCustom] SVGPathSeg insertItemBefore(in SVGPathSeg newItem, in unsigned long index) raises(DOMException, SVGException); - [Custom] SVGPathSeg replaceItem(in SVGPathSeg newItem, in unsigned long index) + [JSCCustom] SVGPathSeg replaceItem(in SVGPathSeg newItem, in unsigned long index) raises(DOMException, SVGException); - [Custom] SVGPathSeg removeItem(in unsigned long index) + [JSCCustom] SVGPathSeg removeItem(in unsigned long index) raises(DOMException); - [Custom] SVGPathSeg appendItem(in SVGPathSeg newItem) + [JSCCustom] SVGPathSeg appendItem(in SVGPathSeg newItem) raises(DOMException, SVGException); }; diff --git a/WebCore/svg/SVGPointList.idl b/WebCore/svg/SVGPointList.idl index 3ac8b1a..cf82dff 100644 --- a/WebCore/svg/SVGPointList.idl +++ b/WebCore/svg/SVGPointList.idl @@ -28,19 +28,19 @@ module svg { interface [Conditional=SVG] SVGPointList { readonly attribute unsigned long numberOfItems; - [Custom] void clear() + [JSCCustom] void clear() raises(DOMException); - [Custom] SVGPoint initialize(in SVGPoint item) + [JSCCustom] SVGPoint initialize(in SVGPoint item) raises(DOMException, SVGException); - [Custom] SVGPoint getItem(in unsigned long index) + [JSCCustom] SVGPoint getItem(in unsigned long index) raises(DOMException); - [Custom] SVGPoint insertItemBefore(in SVGPoint item, in unsigned long index) + [JSCCustom] SVGPoint insertItemBefore(in SVGPoint item, in unsigned long index) raises(DOMException, SVGException); - [Custom] SVGPoint replaceItem(in SVGPoint item, in unsigned long index) + [JSCCustom] SVGPoint replaceItem(in SVGPoint item, in unsigned long index) raises(DOMException, SVGException); - [Custom] SVGPoint removeItem(in unsigned long index) + [JSCCustom] SVGPoint removeItem(in unsigned long index) raises(DOMException); - [Custom] SVGPoint appendItem(in SVGPoint item) + [JSCCustom] SVGPoint appendItem(in SVGPoint item) raises(DOMException, SVGException); }; diff --git a/WebCore/svg/SVGPreserveAspectRatio.cpp b/WebCore/svg/SVGPreserveAspectRatio.cpp index 9c9e110..5793976 100644 --- a/WebCore/svg/SVGPreserveAspectRatio.cpp +++ b/WebCore/svg/SVGPreserveAspectRatio.cpp @@ -178,10 +178,10 @@ TransformationMatrix SVGPreserveAspectRatio::getCTM(double logicX, double logicY double svgar = physWidth / physHeight; if (align() == SVG_PRESERVEASPECTRATIO_NONE) { - temp.scale(physWidth / logicWidth, physHeight / logicHeight); + temp.scaleNonUniform(physWidth / logicWidth, physHeight / logicHeight); temp.translate(-logicX, -logicY); } else if (vpar < svgar && (meetOrSlice() == SVG_MEETORSLICE_MEET) || vpar >= svgar && (meetOrSlice() == SVG_MEETORSLICE_SLICE)) { - temp.scale(physHeight / logicHeight, physHeight / logicHeight); + temp.scaleNonUniform(physHeight / logicHeight, physHeight / logicHeight); if (align() == SVG_PRESERVEASPECTRATIO_XMINYMIN || align() == SVG_PRESERVEASPECTRATIO_XMINYMID || align() == SVG_PRESERVEASPECTRATIO_XMINYMAX) temp.translate(-logicX, -logicY); @@ -190,7 +190,7 @@ TransformationMatrix SVGPreserveAspectRatio::getCTM(double logicX, double logicY else temp.translate(-logicX - (logicWidth - physWidth * logicHeight / physHeight), -logicY); } else { - temp.scale(physWidth / logicWidth, physWidth / logicWidth); + temp.scaleNonUniform(physWidth / logicWidth, physWidth / logicWidth); if (align() == SVG_PRESERVEASPECTRATIO_XMINYMIN || align() == SVG_PRESERVEASPECTRATIO_XMIDYMIN || align() == SVG_PRESERVEASPECTRATIO_XMAXYMIN) temp.translate(-logicX, -logicY); diff --git a/WebCore/svg/SVGRadialGradientElement.cpp b/WebCore/svg/SVGRadialGradientElement.cpp index 4f4fd8f..abc11fb 100644 --- a/WebCore/svg/SVGRadialGradientElement.cpp +++ b/WebCore/svg/SVGRadialGradientElement.cpp @@ -114,6 +114,7 @@ void SVGRadialGradientElement::buildGradient() const 0.f, // SVG does not support a "focus radius" centerPoint, narrowPrecisionToFloat(attributes.r())); + gradient->setSpreadMethod(attributes.spreadMethod()); Vector<SVGGradientStop> stops = attributes.stops(); float previousOffset = 0.0f; @@ -129,7 +130,6 @@ void SVGRadialGradientElement::buildGradient() const return; radialGradient->setBoundingBoxMode(attributes.boundingBoxMode()); - radialGradient->setGradientSpreadMethod(attributes.spreadMethod()); radialGradient->setGradientTransform(attributes.gradientTransform()); radialGradient->setGradientCenter(centerPoint); radialGradient->setGradientFocal(focalPoint); diff --git a/WebCore/svg/SVGSVGElement.cpp b/WebCore/svg/SVGSVGElement.cpp index 27f11aa..e66a16e 100644 --- a/WebCore/svg/SVGSVGElement.cpp +++ b/WebCore/svg/SVGSVGElement.cpp @@ -125,8 +125,8 @@ FloatRect SVGSVGElement::viewport() const TransformationMatrix viewBox = viewBoxToViewTransform(w, h); double wDouble = w; double hDouble = h; - viewBox.map(_x, _y, &_x, &_y); - viewBox.map(w, h, &wDouble, &hDouble); + viewBox.map(_x, _y, _x, _y); + viewBox.map(w, h, wDouble, hDouble); return FloatRect::narrowPrecision(_x, _y, wDouble, hDouble); } @@ -387,7 +387,7 @@ TransformationMatrix SVGSVGElement::getCTM() const if (!isOutermostSVG()) mat.translate(x().value(this), y().value(this)); - if (attributes()->getNamedItem(SVGNames::viewBoxAttr)) { + if (attributes()->getAttributeItem(SVGNames::viewBoxAttr)) { TransformationMatrix viewBox = viewBoxToViewTransform(width().value(this), height().value(this)); mat = viewBox * mat; } @@ -414,7 +414,7 @@ TransformationMatrix SVGSVGElement::getScreenCTM() const TransformationMatrix mat = SVGStyledLocatableElement::getScreenCTM(); mat.translate(rootLocation.x(), rootLocation.y()); - if (attributes()->getNamedItem(SVGNames::viewBoxAttr)) { + if (attributes()->getAttributeItem(SVGNames::viewBoxAttr)) { TransformationMatrix viewBox = viewBoxToViewTransform(width().value(this), height().value(this)); mat = viewBox * mat; } diff --git a/WebCore/svg/SVGStyledElement.cpp b/WebCore/svg/SVGStyledElement.cpp index 466ce3c..76303a9 100644 --- a/WebCore/svg/SVGStyledElement.cpp +++ b/WebCore/svg/SVGStyledElement.cpp @@ -240,7 +240,7 @@ PassRefPtr<RenderStyle> SVGStyledElement::resolveStyle(RenderStyle* parentStyle) PassRefPtr<CSSValue> SVGStyledElement::getPresentationAttribute(const String& name) { - Attribute* attr = mappedAttributes()->getAttributeItem(name, false); + Attribute* attr = mappedAttributes()->getAttributeItem(QualifiedName(nullAtom, name, nullAtom)); if (!attr || !attr->isMappedAttribute() || !attr->style()) return 0; diff --git a/WebCore/svg/SVGTextContentElement.cpp b/WebCore/svg/SVGTextContentElement.cpp index 6057da8..8b34c2c 100644 --- a/WebCore/svg/SVGTextContentElement.cpp +++ b/WebCore/svg/SVGTextContentElement.cpp @@ -65,7 +65,7 @@ static inline float cumulativeCharacterRangeLength(const Vector<SVGChar>::iterat return 0.0f; float textLength = 0.0f; - RenderStyle* style = textBox->textObject()->style(); + RenderStyle* style = textBox->textRenderer()->style(); bool usesFullRange = (startPosition == -1 && length == -1); @@ -128,7 +128,7 @@ struct SVGInlineTextBoxQueryWalker { void chunkPortionCallback(SVGInlineTextBox* textBox, int startOffset, const TransformationMatrix&, const Vector<SVGChar>::iterator& start, const Vector<SVGChar>::iterator& end) { - RenderStyle* style = textBox->textObject()->style(); + RenderStyle* style = textBox->textRenderer()->style(); bool isVerticalText = style->svgStyle()->writingMode() == WM_TBRL || style->svgStyle()->writingMode() == WM_TB; switch (m_mode) { @@ -309,7 +309,7 @@ static Vector<SVGInlineTextBox*> findInlineTextBoxInTextChunks(const SVGTextCont for (; boxIt != boxEnd; ++boxIt) { SVGInlineTextBox* textBox = static_cast<SVGInlineTextBox*>(boxIt->box); - Node* textElement = textBox->textObject()->parent()->element(); + Node* textElement = textBox->textRenderer()->parent()->node(); ASSERT(textElement); if (textElement == element || textElement->parent() == element) @@ -480,7 +480,7 @@ void SVGTextContentElement::selectSubString(long charnum, long nchars, Exception for (long i = 0; i < nchars; ++i) end = end.next(); - controller->setSelection(Selection(start, end)); + controller->setSelection(VisibleSelection(start, end)); } void SVGTextContentElement::parseMappedAttribute(MappedAttribute* attr) diff --git a/WebCore/svg/SVGTransform.cpp b/WebCore/svg/SVGTransform.cpp index fac88bd..17d9b8f 100644 --- a/WebCore/svg/SVGTransform.cpp +++ b/WebCore/svg/SVGTransform.cpp @@ -96,7 +96,7 @@ void SVGTransform::setTranslate(float tx, float ty) m_type = SVG_TRANSFORM_TRANSLATE; m_angle = 0; - m_matrix.reset(); + m_matrix.makeIdentity(); m_matrix.translate(tx, ty); } @@ -111,8 +111,8 @@ void SVGTransform::setScale(float sx, float sy) m_angle = 0; m_center = FloatPoint(); - m_matrix.reset(); - m_matrix.scale(sx, sy); + m_matrix.makeIdentity(); + m_matrix.scaleNonUniform(sx, sy); } FloatSize SVGTransform::scale() const @@ -127,7 +127,7 @@ void SVGTransform::setRotate(float angle, float cx, float cy) m_center = FloatPoint(cx, cy); // TODO: toString() implementation, which can show cx, cy (need to be stored?) - m_matrix.reset(); + m_matrix.makeIdentity(); m_matrix.translate(cx, cy); m_matrix.rotate(angle); m_matrix.translate(-cx, -cy); @@ -138,7 +138,7 @@ void SVGTransform::setSkewX(float angle) m_type = SVG_TRANSFORM_SKEWX; m_angle = angle; - m_matrix.reset(); + m_matrix.makeIdentity(); m_matrix.skewX(angle); } @@ -147,7 +147,7 @@ void SVGTransform::setSkewY(float angle) m_type = SVG_TRANSFORM_SKEWY; m_angle = angle; - m_matrix.reset(); + m_matrix.makeIdentity(); m_matrix.skewY(angle); } diff --git a/WebCore/svg/SVGTransformDistance.cpp b/WebCore/svg/SVGTransformDistance.cpp index b46370b..34adc63 100644 --- a/WebCore/svg/SVGTransformDistance.cpp +++ b/WebCore/svg/SVGTransformDistance.cpp @@ -79,7 +79,7 @@ SVGTransformDistance::SVGTransformDistance(const SVGTransform& fromSVGTransform, { float scaleX = toSVGTransform.scale().width() - fromSVGTransform.scale().width(); float scaleY = toSVGTransform.scale().height() - fromSVGTransform.scale().height(); - m_transform.scale(scaleX, scaleY); + m_transform.scaleNonUniform(scaleX, scaleY); return; } case SVGTransform::SVG_TRANSFORM_SKEWX: @@ -188,7 +188,7 @@ void SVGTransformDistance::addSVGTransform(const SVGTransform& transform, bool a { float scaleX = absoluteValue ? fabsf(transform.scale().width()) : transform.scale().width(); float scaleY = absoluteValue ? fabsf(transform.scale().height()) : transform.scale().height(); - m_transform.scale(scaleX, scaleY); + m_transform.scaleNonUniform(scaleX, scaleY); return; } case SVGTransform::SVG_TRANSFORM_SKEWX: diff --git a/WebCore/svg/SVGTransformList.idl b/WebCore/svg/SVGTransformList.idl index 67968ff..8c9c86e 100644 --- a/WebCore/svg/SVGTransformList.idl +++ b/WebCore/svg/SVGTransformList.idl @@ -29,19 +29,19 @@ module svg { interface [Conditional=SVG] SVGTransformList { readonly attribute unsigned long numberOfItems; - [Custom] void clear() + [JSCCustom] void clear() raises(DOMException); - [Custom] SVGTransform initialize(in SVGTransform item) + [JSCCustom] SVGTransform initialize(in SVGTransform item) raises(DOMException, SVGException); - [Custom] SVGTransform getItem(in unsigned long index) + [JSCCustom] SVGTransform getItem(in unsigned long index) raises(DOMException); - [Custom] SVGTransform insertItemBefore(in SVGTransform item, in unsigned long index) + [JSCCustom] SVGTransform insertItemBefore(in SVGTransform item, in unsigned long index) raises(DOMException, SVGException); - [Custom] SVGTransform replaceItem(in SVGTransform item, in unsigned long index) + [JSCCustom] SVGTransform replaceItem(in SVGTransform item, in unsigned long index) raises(DOMException, SVGException); - [Custom] SVGTransform removeItem(in unsigned long index) + [JSCCustom] SVGTransform removeItem(in unsigned long index) raises(DOMException); - [Custom] SVGTransform appendItem(in SVGTransform item) + [JSCCustom] SVGTransform appendItem(in SVGTransform item) raises(DOMException, SVGException); SVGTransform createSVGTransformFromMatrix(in SVGMatrix matrix); SVGTransform consolidate(); diff --git a/WebCore/svg/SVGUseElement.cpp b/WebCore/svg/SVGUseElement.cpp index 4eb2d9f..4ae0f5c 100644 --- a/WebCore/svg/SVGUseElement.cpp +++ b/WebCore/svg/SVGUseElement.cpp @@ -564,10 +564,10 @@ void SVGUseElement::buildShadowTree(SVGElement* target, SVGElementInstance* targ if (isDisallowedElement(target)) return; - RefPtr<Node> newChild = targetInstance->correspondingElement()->cloneNode(true); + RefPtr<Element> newChild = targetInstance->correspondingElement()->cloneElementWithChildren(); // We don't walk the target tree element-by-element, and clone each element, - // but instead use cloneNode(deep=true). This is an optimization for the common + // but instead use cloneElementWithChildren(). This is an optimization for the common // case where <use> doesn't contain disallowed elements (ie. <foreignObject>). // Though if there are disallowed elements in the subtree, we have to remove them. // For instance: <use> on <g> containing <foreignObject> (indirect case). @@ -643,10 +643,10 @@ void SVGUseElement::expandUseElementsInShadowTree(Node* element) return; } - RefPtr<Node> newChild = target->cloneNode(true); + RefPtr<Element> newChild = target->cloneElementWithChildren(); // We don't walk the target tree element-by-element, and clone each element, - // but instead use cloneNode(deep=true). This is an optimization for the common + // but instead use cloneElementWithChildren(). This is an optimization for the common // case where <use> doesn't contain disallowed elements (ie. <foreignObject>). // Though if there are disallowed elements in the subtree, we have to remove them. // For instance: <use> on <g> containing <foreignObject> (indirect case). diff --git a/WebCore/svg/graphics/SVGImage.cpp b/WebCore/svg/graphics/SVGImage.cpp index d315dfa..067f645 100644 --- a/WebCore/svg/graphics/SVGImage.cpp +++ b/WebCore/svg/graphics/SVGImage.cpp @@ -103,7 +103,7 @@ void SVGImage::setContainerSize(const IntSize& containerSize) if (containerSize.width() <= 0 || containerSize.height() <= 0) return; - if (!m_frame || !m_frame->document()) + if (!m_frame) return; SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement(); if (!rootElement) @@ -114,7 +114,7 @@ void SVGImage::setContainerSize(const IntSize& containerSize) bool SVGImage::usesContainerSize() const { - if (!m_frame || !m_frame->document()) + if (!m_frame) return false; SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement(); if (!rootElement) @@ -125,7 +125,7 @@ bool SVGImage::usesContainerSize() const IntSize SVGImage::size() const { - if (!m_frame || !m_frame->document()) + if (!m_frame) return IntSize(); SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement(); @@ -151,7 +151,7 @@ IntSize SVGImage::size() const bool SVGImage::hasRelativeWidth() const { - if (!m_frame || !m_frame->document()) + if (!m_frame) return false; SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement(); if (!rootElement) @@ -162,7 +162,7 @@ bool SVGImage::hasRelativeWidth() const bool SVGImage::hasRelativeHeight() const { - if (!m_frame || !m_frame->document()) + if (!m_frame) return false; SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement(); if (!rootElement) diff --git a/WebCore/svg/graphics/SVGPaintServer.cpp b/WebCore/svg/graphics/SVGPaintServer.cpp index 4e7a8cf..0fcd722 100644 --- a/WebCore/svg/graphics/SVGPaintServer.cpp +++ b/WebCore/svg/graphics/SVGPaintServer.cpp @@ -37,6 +37,10 @@ #include "SVGStyledElement.h" #include "SVGURIReference.h" +#if PLATFORM(SKIA) +#include "PlatformContextSkia.h" +#endif + namespace WebCore { SVGPaintServer::SVGPaintServer() @@ -82,7 +86,7 @@ SVGPaintServer* SVGPaintServer::fillPaintServer(const RenderStyle* style, const AtomicString id(SVGURIReference::getTarget(fill->uri())); fillPaintServer = getPaintServerById(item->document(), id); - SVGElement* svgElement = static_cast<SVGElement*>(item->element()); + SVGElement* svgElement = static_cast<SVGElement*>(item->node()); ASSERT(svgElement && svgElement->document() && svgElement->isStyled()); if (item->isRenderPath() && fillPaintServer) @@ -123,7 +127,7 @@ SVGPaintServer* SVGPaintServer::strokePaintServer(const RenderStyle* style, cons AtomicString id(SVGURIReference::getTarget(stroke->uri())); strokePaintServer = getPaintServerById(item->document(), id); - SVGElement* svgElement = static_cast<SVGElement*>(item->element()); + SVGElement* svgElement = static_cast<SVGElement*>(item->node()); ASSERT(svgElement && svgElement->document() && svgElement->isStyled()); if (item->isRenderPath() && strokePaintServer) @@ -179,9 +183,9 @@ void SVGPaintServer::renderPath(GraphicsContext*& context, const RenderObject* p context->strokePath(); } -void SVGPaintServer::teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool) const -{ #if PLATFORM(SKIA) +void SVGPaintServer::teardown(GraphicsContext*& context, const RenderObject*, SVGPaintTargetType, bool) const +{ // FIXME: Move this into the GraphicsContext // WebKit implicitly expects us to reset the path. // For example in fillAndStrokePath() of RenderPath.cpp the path is @@ -190,8 +194,12 @@ void SVGPaintServer::teardown(GraphicsContext*&, const RenderObject*, SVGPaintTa context->beginPath(); context->platformContext()->setGradient(0); context->platformContext()->setPattern(0); -#endif } +#else +void SVGPaintServer::teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool) const +{ +} +#endif DashArray dashArrayFromRenderingStyle(const RenderStyle* style) { diff --git a/WebCore/svg/graphics/SVGPaintServerGradient.cpp b/WebCore/svg/graphics/SVGPaintServerGradient.cpp index b06eca1..eb0d80b 100644 --- a/WebCore/svg/graphics/SVGPaintServerGradient.cpp +++ b/WebCore/svg/graphics/SVGPaintServerGradient.cpp @@ -40,11 +40,6 @@ #include "SVGRenderSupport.h" #include "SVGRenderTreeAsText.h" -#if PLATFORM(CG) -#include <wtf/MathExtras.h> -#include <wtf/RetainPtr.h> -#endif - using namespace std; namespace WebCore { @@ -76,10 +71,8 @@ static TextStream& operator<<(TextStream& ts, const Vector<SVGGradientStop>& l) } SVGPaintServerGradient::SVGPaintServerGradient(const SVGGradientElement* owner) - : m_spreadMethod(SpreadMethodPad) - , m_boundingBoxMode(true) + : m_boundingBoxMode(true) , m_ownerElement(owner) - #if PLATFORM(CG) , m_savedContext(0) , m_imageBuffer(0) @@ -102,16 +95,6 @@ void SVGPaintServerGradient::setGradient(PassRefPtr<Gradient> gradient) m_gradient = gradient; } -GradientSpreadMethod SVGPaintServerGradient::spreadMethod() const -{ - return m_spreadMethod; -} - -void SVGPaintServerGradient::setGradientSpreadMethod(const GradientSpreadMethod& method) -{ - m_spreadMethod = method; -} - bool SVGPaintServerGradient::boundingBoxMode() const { return m_boundingBoxMode; @@ -133,8 +116,6 @@ void SVGPaintServerGradient::setGradientTransform(const TransformationMatrix& tr } #if PLATFORM(CG) -// Helper function for text painting in CG -// This Cg specific code should move to GraphicsContext and Font* in a next step. static inline const RenderObject* findTextRootObject(const RenderObject* start) { while (start && !start->isSVGText()) @@ -174,7 +155,7 @@ static inline bool createMaskAndSwapContextForTextGradient( return true; } -static inline void clipToTextMask(GraphicsContext* context, +static inline TransformationMatrix clipToTextMask(GraphicsContext* context, OwnPtr<ImageBuffer>& imageBuffer, const RenderObject* object, const SVGPaintServerGradient* gradientServer) { @@ -193,11 +174,13 @@ static inline void clipToTextMask(GraphicsContext* context, context->clipToImageBuffer(textBoundary, imageBuffer.get()); context->concatCTM(transform); + TransformationMatrix matrix; if (gradientServer->boundingBoxMode()) { - context->translate(maskBBox.x(), maskBBox.y()); - context->scale(FloatSize(maskBBox.width(), maskBBox.height())); + matrix.translate(maskBBox.x(), maskBBox.y()); + matrix.scaleNonUniform(maskBBox.width(), maskBBox.height()); } - context->concatCTM(gradientServer->gradientTransform()); + matrix.multiply(gradientServer->gradientTransform()); + return matrix; } #endif @@ -234,25 +217,29 @@ bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject applyStrokeStyleToContext(context, object->style(), object); } + TransformationMatrix matrix; + // CG platforms will handle the gradient space transform for text in + // teardown, so we 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 (boundingBoxMode() && !isPaintingText) { +#else + if (boundingBoxMode()) { +#endif FloatRect bbox = object->relativeBBox(false); - // Don't use gradientes for 1d objects like horizontal/vertical + // Don't use gradients for 1d objects like horizontal/vertical // lines or rectangles without width or height. if (bbox.width() == 0 || bbox.height() == 0) { Color color(0, 0, 0); context->setStrokeColor(color); return true; } - context->translate(bbox.x(), bbox.y()); - context->scale(FloatSize(bbox.width(), bbox.height())); - - // With scaling the context, the strokeThickness is scaled too. We have to - // undo this. - float strokeThickness = std::max((context->strokeThickness() / ((bbox.width() + bbox.height()) / 2) - 0.001f), 0.f); - context->setStrokeThickness(strokeThickness); + matrix.translate(bbox.x(), bbox.y()); + matrix.scaleNonUniform(bbox.width(), bbox.height()); } - context->concatCTM(gradientTransform()); - context->setSpreadMethod(spreadMethod()); + matrix.multiply(gradientTransform()); + m_gradient->setGradientSpaceTransform(matrix); return true; } @@ -262,15 +249,19 @@ void SVGPaintServerGradient::teardown(GraphicsContext*& context, const RenderObj #if PLATFORM(CG) // renderPath() is not used when painting text, so we paint the gradient during teardown() if (isPaintingText && m_savedContext) { + // Restore on-screen drawing context context = m_savedContext; m_savedContext = 0; - clipToTextMask(context, m_imageBuffer, object, this); + TransformationMatrix matrix = clipToTextMask(context, m_imageBuffer, object, this); + m_gradient->setGradientSpaceTransform(matrix); + context->setFillGradient(m_gradient); + + FloatRect maskBBox = const_cast<RenderObject*>(findTextRootObject(object))->relativeBBox(false); + + context->fillRect(maskBBox); - // finally fill the text clip with the shading - CGContextDrawShading(context->platformContext(), m_gradient->platformGradient()); - m_imageBuffer.clear(); // we're done with our text mask buffer } #endif @@ -284,8 +275,8 @@ TextStream& SVGPaintServerGradient::externalRepresentation(TextStream& ts) const // abstract, don't stream type ts << "[stops=" << gradientStops() << "]"; - if (spreadMethod() != SpreadMethodPad) - ts << "[method=" << spreadMethod() << "]"; + if (m_gradient->spreadMethod() != SpreadMethodPad) + ts << "[method=" << m_gradient->spreadMethod() << "]"; if (!boundingBoxMode()) ts << " [bounding box mode=" << boundingBoxMode() << "]"; if (!gradientTransform().isIdentity()) diff --git a/WebCore/svg/graphics/SVGPaintServerGradient.h b/WebCore/svg/graphics/SVGPaintServerGradient.h index 16dab0b..b24c417 100644 --- a/WebCore/svg/graphics/SVGPaintServerGradient.h +++ b/WebCore/svg/graphics/SVGPaintServerGradient.h @@ -52,9 +52,6 @@ namespace WebCore { void setGradient(PassRefPtr<Gradient>); Gradient* gradient() const; - GradientSpreadMethod spreadMethod() const; - void setGradientSpreadMethod(const GradientSpreadMethod&); - // Gradient start and end points are percentages when used in boundingBox mode. // For instance start point with value (0,0) is top-left and end point with // value (100, 100) is bottom-right. BoundingBox mode is enabled by default. @@ -78,7 +75,6 @@ namespace WebCore { private: Vector<SVGGradientStop> m_stops; RefPtr<Gradient> m_gradient; - GradientSpreadMethod m_spreadMethod; bool m_boundingBoxMode; TransformationMatrix m_gradientTransform; const SVGGradientElement* m_ownerElement; diff --git a/WebCore/svg/graphics/SVGPaintServerPattern.cpp b/WebCore/svg/graphics/SVGPaintServerPattern.cpp index 5926aad..a2ac5df 100644 --- a/WebCore/svg/graphics/SVGPaintServerPattern.cpp +++ b/WebCore/svg/graphics/SVGPaintServerPattern.cpp @@ -115,8 +115,6 @@ bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* return false; context->save(); - context->translate(patternBoundaries().x(), patternBoundaries().y()); - context->concatCTM(patternTransform()); ASSERT(!m_pattern); @@ -160,6 +158,11 @@ bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* applyStrokeStyleToContext(context, object->style(), object); } + TransformationMatrix matrix; + matrix.translate(patternBoundaries().x(), patternBoundaries().y()); + matrix.multiply(patternTransform()); + m_pattern->setPatternSpaceTransform(matrix); + if (isPaintingText) { context->setTextDrawingMode(isFilled ? cTextFill : cTextStroke); #if PLATFORM(CG) diff --git a/WebCore/svg/graphics/SVGResourceClipper.cpp b/WebCore/svg/graphics/SVGResourceClipper.cpp index 51bda0d..5998afb 100644 --- a/WebCore/svg/graphics/SVGResourceClipper.cpp +++ b/WebCore/svg/graphics/SVGResourceClipper.cpp @@ -72,7 +72,7 @@ void SVGResourceClipper::applyClip(GraphicsContext* context, const FloatRect& bo if (clipData.bboxUnits) { TransformationMatrix transform; transform.translate(boundingBox.x(), boundingBox.y()); - transform.scale(boundingBox.width(), boundingBox.height()); + transform.scaleNonUniform(boundingBox.width(), boundingBox.height()); clipPath.transform(transform); } context->addPath(clipPath); diff --git a/WebCore/svg/graphics/SVGResourceMarker.cpp b/WebCore/svg/graphics/SVGResourceMarker.cpp index c50f5e3..112e4d6 100644 --- a/WebCore/svg/graphics/SVGResourceMarker.cpp +++ b/WebCore/svg/graphics/SVGResourceMarker.cpp @@ -82,14 +82,14 @@ void SVGResourceMarker::draw(GraphicsContext* context, const FloatRect& rect, do // the translation performed on the viewport itself. TransformationMatrix viewportTransform; if (m_useStrokeWidth) - viewportTransform.scale(strokeWidth, strokeWidth); + viewportTransform.scaleNonUniform(strokeWidth, strokeWidth); viewportTransform *= m_marker->viewportTransform(); double refX, refY; - viewportTransform.map(m_refX, m_refY, &refX, &refY); + viewportTransform.map(m_refX, m_refY, refX, refY); transform.translate(-refX, -refY); if (m_useStrokeWidth) - transform.scale(strokeWidth, strokeWidth); + transform.scaleNonUniform(strokeWidth, strokeWidth); // FIXME: PaintInfo should be passed into this method instead of being created here // FIXME: bounding box fractions are lost diff --git a/WebCore/svg/graphics/SVGResourceMasker.cpp b/WebCore/svg/graphics/SVGResourceMasker.cpp index 842f04f..8642e1e 100644 --- a/WebCore/svg/graphics/SVGResourceMasker.cpp +++ b/WebCore/svg/graphics/SVGResourceMasker.cpp @@ -28,9 +28,18 @@ #if ENABLE(SVG) #include "SVGResourceMasker.h" +#include "CanvasPixelArray.h" +#include "Image.h" #include "ImageBuffer.h" +#include "ImageData.h" +#include "GraphicsContext.h" +#include "SVGMaskElement.h" +#include "SVGRenderSupport.h" +#include "SVGRenderStyle.h" #include "TextStream.h" +#include <wtf/ByteArray.h> + using namespace std; namespace WebCore { @@ -51,6 +60,44 @@ void SVGResourceMasker::invalidate() m_mask.clear(); } +void SVGResourceMasker::applyMask(GraphicsContext* context, const FloatRect& boundingBox) +{ + if (!m_mask) + m_mask.set(m_ownerElement->drawMaskerContent(boundingBox, m_maskRect).release()); + + if (!m_mask) + return; + + IntSize imageSize(m_mask->size()); + IntRect intImageRect(0, 0, imageSize.width(), imageSize.height()); + + // Create new ImageBuffer to apply luminance + auto_ptr<ImageBuffer> luminancedImage(ImageBuffer::create(imageSize, false)); + if (!luminancedImage.get()) + return; + + PassRefPtr<CanvasPixelArray> srcPixelArray(m_mask->getImageData(intImageRect)->data()); + PassRefPtr<ImageData> destImageData(luminancedImage->getImageData(intImageRect)); + + for (unsigned pixelOffset = 0; pixelOffset < srcPixelArray->length(); pixelOffset++) { + unsigned pixelByteOffset = pixelOffset * 4; + + unsigned char r = 0, g = 0, b = 0, a = 0; + srcPixelArray->get(pixelByteOffset, r); + srcPixelArray->get(pixelByteOffset + 1, g); + srcPixelArray->get(pixelByteOffset + 2, b); + srcPixelArray->get(pixelByteOffset + 3, a); + + double luma = (r * 0.2125 + g * 0.7154 + b * 0.0721) * ((double)a / 255.0); + + destImageData->data()->set(pixelByteOffset + 3, luma); + } + + luminancedImage->putImageData(destImageData.get(), intImageRect, IntPoint(0, 0)); + + context->clipToImageBuffer(m_maskRect, luminancedImage.get()); +} + TextStream& SVGResourceMasker::externalRepresentation(TextStream& ts) const { ts << "[type=MASKER]"; diff --git a/WebCore/svg/graphics/cairo/SVGResourceMaskerCairo.cpp b/WebCore/svg/graphics/cairo/SVGResourceMaskerCairo.cpp deleted file mode 100644 index 1f690b5..0000000 --- a/WebCore/svg/graphics/cairo/SVGResourceMaskerCairo.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2007 Alp Toker <alp@atoker.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGResourceMasker.h" -#include "Image.h" -#include "ImageBuffer.h" -#include "GraphicsContext.h" - -#include <cairo.h> - -namespace WebCore { - -void SVGResourceMasker::applyMask(GraphicsContext* context, const FloatRect& boundingBox) -{ - if (!m_mask) - return; - - cairo_t* cr = context->platformContext(); - cairo_surface_t* surface = m_mask->image()->nativeImageForCurrentFrame(); - if (!surface) - return; - cairo_pattern_t* mask = cairo_pattern_create_for_surface(surface); - cairo_mask(cr, mask); - cairo_pattern_destroy(mask); -} - -} // namespace WebCore - -#endif diff --git a/WebCore/svg/graphics/cg/SVGResourceMaskerCg.cpp b/WebCore/svg/graphics/cg/SVGResourceMaskerCg.cpp deleted file mode 100644 index 4d2100b..0000000 --- a/WebCore/svg/graphics/cg/SVGResourceMaskerCg.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGResourceMasker.h" -#include "NotImplemented.h" - -namespace WebCore { - -void SVGResourceMasker::applyMask(GraphicsContext*, const FloatRect&) -{ - notImplemented(); -} - -} // namespace WebCore - -#endif // ENABLE(SVG) diff --git a/WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm b/WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm deleted file mode 100644 index 9793ba0..0000000 --- a/WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2005, 2006 Alexander Kellett <lypanov@kde.org> - * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(SVG) -#import "SVGResourceMasker.h" - -#import "BlockExceptions.h" -#import "GraphicsContext.h" -#import "ImageBuffer.h" -#import "SVGMaskElement.h" -#import "SVGRenderSupport.h" -#import "SVGRenderStyle.h" -#import "SVGResourceFilter.h" -#import <QuartzCore/CIFilter.h> -#import <QuartzCore/CoreImage.h> - -using namespace std; - -namespace WebCore { - -static CIImage* applyLuminanceToAlphaFilter(CIImage* inputImage) -{ - CIFilter* luminanceToAlpha = [CIFilter filterWithName:@"CIColorMatrix"]; - [luminanceToAlpha setDefaults]; - CGFloat alpha[4] = {0.2125f, 0.7154f, 0.0721f, 0.0f}; - CGFloat zero[4] = {0.0f, 0.0f, 0.0f, 0.0f}; - [luminanceToAlpha setValue:inputImage forKey:@"inputImage"]; - [luminanceToAlpha setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputRVector"]; - [luminanceToAlpha setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputGVector"]; - [luminanceToAlpha setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputBVector"]; - [luminanceToAlpha setValue:[CIVector vectorWithValues:alpha count:4] forKey:@"inputAVector"]; - [luminanceToAlpha setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputBiasVector"]; - return [luminanceToAlpha valueForKey:@"outputImage"]; -} - -static CIImage* applyExpandAlphatoGrayscaleFilter(CIImage* inputImage) -{ - CIFilter* alphaToGrayscale = [CIFilter filterWithName:@"CIColorMatrix"]; - CGFloat zero[4] = {0, 0, 0, 0}; - [alphaToGrayscale setDefaults]; - [alphaToGrayscale setValue:inputImage forKey:@"inputImage"]; - [alphaToGrayscale setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputRVector"]; - [alphaToGrayscale setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputGVector"]; - [alphaToGrayscale setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputBVector"]; - [alphaToGrayscale setValue:[CIVector vectorWithX:0.0f Y:0.0f Z:0.0f W:1.0f] forKey:@"inputAVector"]; - [alphaToGrayscale setValue:[CIVector vectorWithX:1.0f Y:1.0f Z:1.0f W:0.0f] forKey:@"inputBiasVector"]; - return [alphaToGrayscale valueForKey:@"outputImage"]; -} - -static CIImage* transformImageIntoGrayscaleMask(CIImage* inputImage) -{ - CIFilter* blackBackground = [CIFilter filterWithName:@"CIConstantColorGenerator"]; - [blackBackground setValue:[CIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:1.0f] forKey:@"inputColor"]; - - CIFilter* layerOverBlack = [CIFilter filterWithName:@"CISourceOverCompositing"]; - [layerOverBlack setValue:[blackBackground valueForKey:@"outputImage"] forKey:@"inputBackgroundImage"]; - [layerOverBlack setValue:inputImage forKey:@"inputImage"]; - - CIImage* luminanceAlpha = applyLuminanceToAlphaFilter([layerOverBlack valueForKey:@"outputImage"]); - CIImage* luminanceAsGrayscale = applyExpandAlphatoGrayscaleFilter(luminanceAlpha); - CIImage* alphaAsGrayscale = applyExpandAlphatoGrayscaleFilter(inputImage); - - CIFilter* multipliedGrayscale = [CIFilter filterWithName:@"CIMultiplyCompositing"]; - [multipliedGrayscale setValue:luminanceAsGrayscale forKey:@"inputBackgroundImage"]; - [multipliedGrayscale setValue:alphaAsGrayscale forKey:@"inputImage"]; - return [multipliedGrayscale valueForKey:@"outputImage"]; -} - -void SVGResourceMasker::applyMask(GraphicsContext* context, const FloatRect& boundingBox) -{ - if (!m_mask) - m_mask.set(m_ownerElement->drawMaskerContent(boundingBox, m_maskRect).release()); - - if (!m_mask) - return; - - IntSize maskSize(static_cast<int>(m_maskRect.width()), static_cast<int>(m_maskRect.height())); - clampImageBufferSizeToViewport(m_ownerElement->document()->renderer(), maskSize); - - // Create new graphics context in gray scale mode for image rendering - auto_ptr<ImageBuffer> grayScaleImage(ImageBuffer::create(maskSize, true)); - if (!grayScaleImage.get()) - return; - - BEGIN_BLOCK_OBJC_EXCEPTIONS - CGContextRef grayScaleContext = grayScaleImage->context()->platformContext(); - CIContext* ciGrayscaleContext = [CIContext contextWithCGContext:grayScaleContext options:nil]; - - // Transform colorized mask to gray scale - CIImage* colorMask = [CIImage imageWithCGImage:m_mask->image()->getCGImageRef()]; - if (!colorMask) - return; - - CIImage* grayScaleMask = transformImageIntoGrayscaleMask(colorMask); - [ciGrayscaleContext drawImage:grayScaleMask atPoint:CGPointZero fromRect:CGRectMake(0, 0, maskSize.width(), maskSize.height())]; - - CGContextClipToMask(context->platformContext(), m_maskRect, grayScaleImage->image()->getCGImageRef()); - END_BLOCK_OBJC_EXCEPTIONS -} - -} // namespace WebCore - -#endif // ENABLE(SVG) diff --git a/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.mm index 0f2eb75..399d4c1 100644 --- a/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.mm +++ b/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.mm @@ -59,7 +59,7 @@ CIVector* getVectorForChannel(ChannelSelectorType channel) CIColor* ciColor(const Color& c) { - CGColorRef colorCG = cgColor(c); + CGColorRef colorCG = createCGColor(c); CIColor* colorCI = [CIColor colorWithCGColor:colorCG]; CGColorRelease(colorCG); return colorCI; diff --git a/WebCore/svg/graphics/qt/SVGResourceMaskerQt.cpp b/WebCore/svg/graphics/qt/SVGResourceMaskerQt.cpp deleted file mode 100644 index 2b89bac..0000000 --- a/WebCore/svg/graphics/qt/SVGResourceMaskerQt.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org> - - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGResourceMasker.h" - -namespace WebCore { - -void SVGResourceMasker::applyMask(GraphicsContext*, const FloatRect&) -{ - // FIXME: implement me :-) -} - -} // namespace WebCore - -#endif - -// vim:ts=4:noet diff --git a/WebCore/svg/graphics/skia/SVGResourceMaskerSkia.cpp b/WebCore/svg/graphics/skia/SVGResourceMaskerSkia.cpp deleted file mode 100644 index 06e6833..0000000 --- a/WebCore/svg/graphics/skia/SVGResourceMaskerSkia.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2008, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGResourceMasker.h" -#include "ImageBuffer.h" -#include "GraphicsContext.h" - -#include "NotImplemented.h" - -namespace WebCore { - -void SVGResourceMasker::applyMask(GraphicsContext*, const FloatRect& boundingBox) -{ - notImplemented(); -} - -} // namespace WebCore - -#endif |