Commit 3918a51c authored by eseidel's avatar eseidel

Bug #: 5810

Submitted by: eseidel
Reviewed by: mjs
        No additional test cases needed, this fixes 5 existing tests.

        This patch fixes feImage (to scale and flip).
        Also fixes feColorMatrix (previously inadvertently disabled)
        Fixes <svg> in <svg> (sub-elements establishing viewports)
        Fixes clip-rule, by fixing style resolution on <clipPath> children

        * WebCore.xcodeproj/project.pbxproj: removed svgattr.[ch]
        * kcanvas/device/quartz/KCanvasFilterQuartz.mm:
        (KCanvasFEFloodQuartz::getCIFilter): respect subregion
        (KCanvasFEImageQuartz::getCIFilter): respect subregion, scale, flip
        * kcanvas/device/quartz/KCanvasResourcesQuartz.mm:
        (CGPathFromKCPathDataList): style/spacing update
        (KCanvasContainerQuartz::paint):  handle viewport, singular filters
        * khtml/rendering/render_object.cpp:
        (RenderObject::absoluteTransform): use QMatrix operator *
        * ksvg2/scripts/make_names.pl: allow FEColorMatrixElementImpl
        * ksvg2/svg/SVGClipPathElementImpl.cpp:
        (SVGClipPathElementImpl::canvasResource): resolve style manually
        * ksvg2/svg/SVGFEColorMatrixElementImpl.cpp:
        (SVGFEColorMatrixElementImpl::filterEffect): spacing fix
        * kwq/KWQWMatrix.h:
        * kwq/KWQWMatrix.mm:
        (QWMatrix::operator* ): added


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@11291 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1f8c7bfa
2005-11-26 Eric Seidel <eseidel@apple.com>
Reviewed by mjs.
No additional test cases needed, this fixes 5 existing tests.
This patch fixes feImage (to scale and flip).
Also fixes feColorMatrix (previously inadvertently disabled)
Fixes <svg> in <svg> (sub-elements establishing viewports)
Fixes clip-rule, by fixing style resolution on <clipPath> children
* WebCore.xcodeproj/project.pbxproj: removed svgattr.[ch]
* kcanvas/device/quartz/KCanvasFilterQuartz.mm:
(KCanvasFEFloodQuartz::getCIFilter): respect subregion
(KCanvasFEImageQuartz::getCIFilter): respect subregion, scale, flip
* kcanvas/device/quartz/KCanvasResourcesQuartz.mm:
(CGPathFromKCPathDataList): style/spacing update
(KCanvasContainerQuartz::paint): handle viewport, singular filters
* khtml/rendering/render_object.cpp:
(RenderObject::absoluteTransform): use QMatrix operator *
* ksvg2/scripts/make_names.pl: allow FEColorMatrixElementImpl
* ksvg2/svg/SVGClipPathElementImpl.cpp:
(SVGClipPathElementImpl::canvasResource): resolve style manually
* ksvg2/svg/SVGFEColorMatrixElementImpl.cpp:
(SVGFEColorMatrixElementImpl::filterEffect): spacing fix
* kwq/KWQWMatrix.h:
* kwq/KWQWMatrix.mm:
(QWMatrix::operator* ): added
2005-11-26 Eric Seidel <eseidel@apple.com>
Reviewed by darin.
......@@ -1485,7 +1485,6 @@
A8C0FD76089701FA00BA5114 /* SVGSwitchElementImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0F8CD089701F400BA5114 /* SVGSwitchElementImpl.h */; };
A8C0FD77089701FA00BA5114 /* SVGSymbolElementImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C0F8CE089701F400BA5114 /* SVGSymbolElementImpl.cpp */; };
A8C0FD78089701FA00BA5114 /* SVGSymbolElementImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0F8CF089701F400BA5114 /* SVGSymbolElementImpl.h */; };
A8C0FD7A089701FA00BA5114 /* svgtags.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0F8D1089701F400BA5114 /* svgtags.h */; };
A8C0FD7C089701FA00BA5114 /* SVGTestsImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C0F8D3089701F400BA5114 /* SVGTestsImpl.cpp */; };
A8C0FD7D089701FA00BA5114 /* SVGTestsImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0F8D4089701F400BA5114 /* SVGTestsImpl.h */; };
A8C0FD7E089701FA00BA5114 /* SVGTextContentElementImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C0F8D5089701F400BA5114 /* SVGTextContentElementImpl.cpp */; };
......@@ -2425,8 +2424,6 @@
A8C0F8CD089701F400BA5114 /* SVGSwitchElementImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGSwitchElementImpl.h; sourceTree = "<group>"; };
A8C0F8CE089701F400BA5114 /* SVGSymbolElementImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGSymbolElementImpl.cpp; sourceTree = "<group>"; };
A8C0F8CF089701F400BA5114 /* SVGSymbolElementImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGSymbolElementImpl.h; sourceTree = "<group>"; };
A8C0F8D0089701F400BA5114 /* svgtags.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = svgtags.c; sourceTree = "<group>"; };
A8C0F8D1089701F400BA5114 /* svgtags.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svgtags.h; sourceTree = "<group>"; };
A8C0F8D2089701F400BA5114 /* svgtags.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = svgtags.in; sourceTree = "<group>"; };
A8C0F8D3089701F400BA5114 /* SVGTestsImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGTestsImpl.cpp; sourceTree = "<group>"; };
A8C0F8D4089701F400BA5114 /* SVGTestsImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTestsImpl.h; sourceTree = "<group>"; };
......@@ -3823,8 +3820,6 @@
A8C0F8CD089701F400BA5114 /* SVGSwitchElementImpl.h */,
A8C0F8CE089701F400BA5114 /* SVGSymbolElementImpl.cpp */,
A8C0F8CF089701F400BA5114 /* SVGSymbolElementImpl.h */,
A8C0F8D0089701F400BA5114 /* svgtags.c */,
A8C0F8D1089701F400BA5114 /* svgtags.h */,
A8C0F8D2089701F400BA5114 /* svgtags.in */,
A8C0F8D3089701F400BA5114 /* SVGTestsImpl.cpp */,
A8C0F8D4089701F400BA5114 /* SVGTestsImpl.h */,
......@@ -5494,7 +5489,6 @@
A8C0FD74089701FA00BA5114 /* SVGSVGElementImpl.h in Headers */,
A8C0FD76089701FA00BA5114 /* SVGSwitchElementImpl.h in Headers */,
A8C0FD78089701FA00BA5114 /* SVGSymbolElementImpl.h in Headers */,
A8C0FD7A089701FA00BA5114 /* svgtags.h in Headers */,
A8C0FD7D089701FA00BA5114 /* SVGTestsImpl.h in Headers */,
A8C0FD7F089701FA00BA5114 /* SVGTextContentElementImpl.h in Headers */,
A8C0FD81089701FA00BA5114 /* SVGTextElementImpl.h in Headers */,
......
......@@ -465,23 +465,42 @@ CIFilter *KCanvasFEFloodQuartz::getCIFilter(KCanvasFilterQuartz *quartzFilter) c
CGColorRelease(withAlpha);
[filter setValue:inputColor forKey:@"inputColor"];
FE_QUARTZ_CROP_TO_RECT(CGRectMake(0,0,1000,1000)); // HACK
CGRect cropRect = CGRectMake(0,0,1000,1000); // HACK
if (subRegion().isValid())
cropRect = CGRect(subRegion());
FE_QUARTZ_CROP_TO_RECT(cropRect);
FE_QUARTZ_OUTPUT_RETURN;
}
CIFilter *KCanvasFEImageQuartz::getCIFilter(KCanvasFilterQuartz *quartzFilter) const
{
// FIXME: This is just a hack for now, and only support pixmaps
KWQ_BLOCK_EXCEPTIONS
// FIXME: This is only partially implemented (only supports pixmaps)
CIImage *ciImage = [CIImage imageWithCGImage:pixmap().imageRef()];
quartzFilter->setOutputImage(this, ciImage);
// FIXME: we really want a noop filter... or better design.
CIFilter *crop = [CIFilter filterWithName:@"CIExposureAdjust"];
[crop setDefaults];
[crop setValue:ciImage forKey:@"inputImage"];
[crop setValue:[NSNumber numberWithInt:0] forKey:@"inputEV"];
return crop;
// FIXME: There is probably a nicer way to perform both of these transforms.
CIFilter *filter = [CIFilter filterWithName:@"CIAffineTransform"];
[filter setDefaults];
[filter setValue:ciImage forKey:@"inputImage"];
CGAffineTransform cgTransform = CGAffineTransformMake(1,0,0,-1,0,pixmap().rect().bottom());
NSAffineTransform *nsTransform = [NSAffineTransform transform];
[nsTransform setTransformStruct:*((NSAffineTransformStruct *)&cgTransform)];
[filter setValue:nsTransform forKey:@"inputTransform"];
if (subRegion().isValid()) {
CIFilter *scaleImage = [CIFilter filterWithName:@"CIAffineTransform"];
[scaleImage setDefaults];
[scaleImage setValue:[filter valueForKey:@"outputImage"] forKey:@"inputImage"];
cgTransform = CGAffineTransformMakeMapBetweenRects(CGRect(pixmap().rect()), subRegion());
[nsTransform setTransformStruct:*((NSAffineTransformStruct *)&cgTransform)];
[scaleImage setValue:nsTransform forKey:@"inputTransform"];
filter = scaleImage;
}
FE_QUARTZ_OUTPUT_RETURN;
}
CIFilter *KCanvasFEGaussianBlurQuartz::getCIFilter(KCanvasFilterQuartz *quartzFilter) const
......
......@@ -39,25 +39,30 @@
CGPathRef CGPathFromKCPathDataList(KCPathDataList pathData)
{
CGMutablePathRef path = CGPathCreateMutable();
KCPathDataList::ConstIterator it = pathData.begin();
KCPathDataList::ConstIterator end = pathData.end();
for(; it != end; ++it)
{
KCPathData data = *it;
if(data.cmd == CMD_MOVE) {
CGPathMoveToPoint(path, NULL, data.x3, data.y3);
} else if(data.cmd == CMD_LINE) {
CGPathAddLineToPoint(path, NULL, data.x3, data.y3);
} else if(data.cmd == CMD_CLOSE_SUBPATH) {
CGPathCloseSubpath(path);
} else {
CGPathAddCurveToPoint(path, NULL, data.x1, data.y1, data.x2, data.y2, data.x3, data.y3);
}
}
return path;
CGMutablePathRef path = CGPathCreateMutable();
KCPathDataList::ConstIterator it = pathData.begin();
KCPathDataList::ConstIterator end = pathData.end();
for(; it != end; ++it)
{
KCPathData data = *it;
switch (data.cmd) {
case CMD_MOVE:
CGPathMoveToPoint(path, NULL, data.x3, data.y3);
break;
case CMD_LINE:
CGPathAddLineToPoint(path, NULL, data.x3, data.y3);
break;
case CMD_CURVE:
CGPathAddCurveToPoint(path, NULL, data.x1, data.y1, data.x2, data.y2, data.x3, data.y3);
break;
case CMD_CLOSE_SUBPATH:
CGPathCloseSubpath(path);
break;
}
}
return path;
}
void KCanvasContainerQuartz::calcMinMaxWidth()
......@@ -103,16 +108,23 @@ void KCanvasContainerQuartz::paint(PaintInfo &paintInfo, int parentX, int parent
if (paintInfo.phase == PaintActionOutline && style()->outlineWidth() && style()->visibility() == khtml::VISIBLE)
paintOutline(paintInfo.p, absoluteX, absoluteY, width(), height(), style());
if (paintInfo.phase != PaintActionForeground || !firstChild() || !drawsContents())
if (paintInfo.phase != PaintActionForeground || !drawsContents())
return;
KCanvasFilter *filter = getFilterById(document(), style()->svgStyle()->filter().mid(1));
if (!firstChild() && !filter)
return; // Spec: groups w/o children still may render filter content.
KRenderingDeviceQuartz *quartzDevice = static_cast<KRenderingDeviceQuartz *>(canvas()->renderingDevice());
quartzDevice->pushContext(paintInfo.p->createRenderingDeviceContext());
paintInfo.p->save();
CGContextRef context = paintInfo.p->currentContext();
if(!localTransform().isIdentity())
if (viewport().isValid())
CGContextConcatCTM(context, CGAffineTransformMakeTranslation(viewport().x(), viewport().y()));
if (!localTransform().isIdentity())
CGContextConcatCTM(context, CGAffineTransform(localTransform()));
QRect dirtyRect = paintInfo.r;
......@@ -126,12 +138,15 @@ void KCanvasContainerQuartz::paint(PaintInfo &paintInfo, int parentX, int parent
if (opacity < 1.0f)
paintInfo.p->beginTransparencyLayer(opacity);
KCanvasFilter *filter = getFilterById(document(), style()->svgStyle()->filter().mid(1));
if (filter)
filter->prepareFilter(quartzDevice, relativeBBox(true));
if (!viewBox().isNull())
CGContextConcatCTM(paintInfo.p->currentContext(), CGAffineTransform(getAspectRatio(viewBox(), QRect(viewport().x(), viewport().y(), width(), height())).qmatrix()));
if (!viewBox().isNull()) {
QRect viewportRect = viewport();
if (!parent()->isKCanvasContainer())
viewportRect = QRect(viewport().x(), viewport().y(), width(), height());
CGContextConcatCTM(paintInfo.p->currentContext(), CGAffineTransform(getAspectRatio(viewBox(), viewportRect).qmatrix()));
}
RenderContainer::paint(paintInfo, absoluteX, absoluteY);
......
......@@ -2568,11 +2568,9 @@ InlineBox *RenderObject::inlineBox(int offset, EAffinity affinity)
#if SVG_SUPPORT
QMatrix RenderObject::absoluteTransform() const
{
if (parent()) {
QMatrix transform = parent()->absoluteTransform();
transform *= localTransform();
return transform;
} else
if (parent())
return parent()->absoluteTransform() * localTransform();
else
return localTransform();
}
#endif
......@@ -151,7 +151,7 @@ sub elementsForTags
next if /tref/i;
next if /textpath/i;
next if /foreign/i;
next if /matrix/i;
next if /convolve/i;
next if /map/i;
next if /morph/i;
push(@filtered, $_);
......
......@@ -78,22 +78,22 @@ void SVGClipPathElementImpl::parseMappedAttribute(KDOM::MappedAttributeImpl *att
KCanvasClipper *SVGClipPathElementImpl::canvasResource()
{
if(!canvas())
if (!canvas())
return 0;
if(!m_clipper)
if (!m_clipper)
m_clipper = static_cast<KCanvasClipper *>(canvas()->renderingDevice()->createResource(RS_CLIPPER));
else
m_clipper->resetClipData();
bool bbox = clipPathUnits()->baseVal() == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX;
for(KDOM::NodeImpl *n = firstChild(); n != 0; n = n->nextSibling())
khtml::RenderStyle *clipPathStyle = styleForRenderer(parent()->renderer());
for (KDOM::NodeImpl *n = firstChild(); n != 0; n = n->nextSibling())
{
SVGElementImpl *e = svg_dynamic_cast(n);
if(e && e->isStyled())
{
if (e && e->isStyled()) {
SVGStyledElementImpl *styled = static_cast<SVGStyledElementImpl *>(e);
SVGRenderStyle *style = styleForRenderer(parentNode()->renderer())->svgStyle();
SVGRenderStyle *style = getDocument()->styleSelector()->styleForElement(styled, clipPathStyle)->svgStyle();
m_clipper->addClipData(styled->toPathData(), (KCWindRule) style->clipRule(), bbox);
}
}
......
......@@ -96,7 +96,7 @@ void SVGFEColorMatrixElementImpl::parseMappedAttribute(KDOM::MappedAttributeImpl
KCanvasFEColorMatrix *SVGFEColorMatrixElementImpl::filterEffect() const
{
if (!m_filterEffect)
m_filterEffect = static_cast<KCanvasFEColorMatrix *>(canvas()->renderingDevice()->createFilterEffect(FE_COLOR_MATRIX));
m_filterEffect = static_cast<KCanvasFEColorMatrix *>(canvas()->renderingDevice()->createFilterEffect(FE_COLOR_MATRIX));
if (!m_filterEffect)
return 0;
......
......@@ -64,6 +64,7 @@ public:
bool operator== (const QWMatrix &) const;
QWMatrix &operator*= (const QWMatrix &);
QWMatrix operator* (const QWMatrix &m2);
private:
CGAffineTransform m_transform;
......
......@@ -127,3 +127,8 @@ QWMatrix &QWMatrix::operator*= (const QWMatrix &m2)
m_transform = CGAffineTransformConcat(m_transform, CGAffineTransform(m2));
return *this;
}
QWMatrix QWMatrix::operator* (const QWMatrix &m2)
{
return CGAffineTransformConcat(m_transform, CGAffineTransform(m2));
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment