Commit 04c7b59f authored by rwlbuis's avatar rwlbuis

Reviewed by Eric.

        http://bugzilla.opendarwin.org/show_bug.cgi?id=10557
        KCanvasPath should be replace by platform/Path

        Refactoring out the KCanvasPath class.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@16054 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 59e92ca2
2006-08-27 Rob Buis <buis@kde.org>
Reviewed by Eric.
Changed test result because of:
http://bugzilla.opendarwin.org/show_bug.cgi?id=10557
KCanvasPath should be replace by platform/Path
* svg/W3C-SVG-1.1/struct-dom-06-b-expected.txt:
2006-08-26 Eric Seidel <eric@eseidel.com>
Reviewed by hyatt.
......@@ -2,7 +2,7 @@ layer at (0,0) size 480x360
RenderView at (0,0) size 480x360
KCanvasContainer {svg} at (0.50,0.50) size 479x359
KCanvasContainer {g} at (0,0) size 0x0
KCanvasItem {rect} at (inf,inf) size 0x0 [fill={[type=SOLID] [color=#FF0000]}] [data=""]
KCanvasItem {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FF0000]}] [data="M0.00,0.00L0.00,0.00L0.00,0.00L0.00,0.00"]
RenderSVGText {text} at (0,0) size 465x18
RenderText {#text} at (0,0) size 148x18
text run at (0,0) width 148: "DOM API is supported"
......
......@@ -494,7 +494,6 @@ set (SVG_STUFF
ksvg2/events/JSSVGLazyEventListener.cpp
ksvg2/events/SVGZoomEvent.cpp
kcanvas/KCanvasCreator.cpp
kcanvas/KCanvasPath.cpp
kcanvas/KCanvasTreeDebug.cpp
kcanvas/KCanvasFilters.cpp
kcanvas/RenderSVGText.cpp
......@@ -505,7 +504,6 @@ set (SVG_STUFF
kcanvas/device/KRenderingPaintServerPattern.cpp
kcanvas/device/KRenderingDevice.cpp
kcanvas/device/qt/RenderPathQt.cpp
kcanvas/device/qt/KCanvasPathQt.cpp
kcanvas/device/qt/KRenderingDeviceQt.cpp
kcanvas/device/qt/KRenderingPaintServerSolidQt.cpp
kcanvas/device/qt/KRenderingPaintServerGradientQt.cpp
......
2006-08-27 Rob Buis <buis@kde.org>
Reviewed by Eric.
http://bugzilla.opendarwin.org/show_bug.cgi?id=10557
KCanvasPath should be replace by platform/Path
Refactoring out the KCanvasPath class.
* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* kcanvas/KCanvasCreator.cpp:
(WebCore::KCanvasCreator::createRoundedRectangle):
(WebCore::KCanvasCreator::createRectangle):
(WebCore::KCanvasCreator::createEllipse):
(WebCore::KCanvasCreator::createCircle):
(WebCore::KCanvasCreator::createLine):
* kcanvas/KCanvasCreator.h:
* kcanvas/KCanvasPath.cpp: Removed.
* kcanvas/KCanvasPath.h: Removed.
* kcanvas/KCanvasResources.cpp:
(WebCore::operator<<):
(WebCore::KCanvasResource::clients):
(WebCore::KCanvasResource::invalidate):
(WebCore::KCanvasClipper::addClipData):
* kcanvas/KCanvasResources.h:
(WebCore::KCClipData::windRule):
(WebCore::KCClipDataList::KCClipDataList):
(WebCore::KCClipDataList::addPath):
* kcanvas/KCanvasTreeDebug.cpp:
(WebCore::operator<<):
* kcanvas/RenderPath.cpp:
(WebCore::RenderPath::fillContains):
(WebCore::RenderPath::relativeBBox):
(WebCore::RenderPath::setPath):
(WebCore::RenderPath::path):
(WebCore::RenderPath::paint):
(WebCore::RenderPath::nodeAtPoint):
* kcanvas/RenderPath.h:
* kcanvas/device/KRenderingDevice.h:
* kcanvas/device/KRenderingFillPainter.cpp:
(WebCore::KRenderingFillPainter::fillRule):
(WebCore::KRenderingFillPainter::setFillRule):
* kcanvas/device/KRenderingFillPainter.h:
* kcanvas/device/qt/KCanvasClipperQt.cpp:
(WebCore::KCanvasClipperQt::applyClip):
* kcanvas/device/qt/KCanvasPathQt.cpp: Removed.
* kcanvas/device/qt/KCanvasPathQt.h: Removed.
* kcanvas/device/qt/KRenderingDeviceQt.cpp:
(WebCore::KRenderingDeviceContextQt::addPath):
(WebCore::KRenderingDeviceContextQt::setFillRule):
(WebCore::KRenderingDeviceQt::createItem):
* kcanvas/device/qt/KRenderingDeviceQt.h:
* kcanvas/device/qt/RenderPathQt.cpp:
(WebCore::RenderPathQt::drawMarkersIfNeeded):
(WebCore::RenderPathQt::strokeContains):
(WebCore::getPathStroke):
(WebCore::RenderPathQt::strokeBBox):
* kcanvas/device/qt/RenderPathQt.h:
* kcanvas/device/quartz/KCanvasItemQuartz.h:
* kcanvas/device/quartz/KCanvasItemQuartz.mm:
(WebCore::KCanvasItemQuartz::drawMarkersIfNeeded):
(WebCore::KCanvasItemQuartz::strokeBBox):
(WebCore::KCanvasItemQuartz::strokeContains):
* kcanvas/device/quartz/KCanvasPathQuartz.h: Removed.
* kcanvas/device/quartz/KCanvasPathQuartz.mm: Removed.
* kcanvas/device/quartz/KCanvasResourcesQuartz.mm:
(WebCore::KCanvasClipperQuartz::applyClip):
* kcanvas/device/quartz/KRenderingDeviceQuartz.h:
* kcanvas/device/quartz/KRenderingDeviceQuartz.mm:
(WebCore::KRenderingDeviceContextQuartz::addPath):
(WebCore::KRenderingDeviceQuartz::createItem):
* kcanvas/device/quartz/QuartzSupport.h:
* kcanvas/device/quartz/QuartzSupport.mm:
(WebCore::scratchContext):
(WebCore::strokeBoundingBox):
(WebCore::pathContainsPoint):
* ksvg2/css/SVGCSSParser.cpp:
(WebCore::CSSParser::parseSVGValue):
* ksvg2/css/SVGCSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applySVGProperty):
* ksvg2/css/SVGRenderStyle.h:
(WebCore::SVGRenderStyle::InheritedFlags::):
* ksvg2/css/SVGRenderStyleDefs.h:
* ksvg2/misc/KCanvasRenderingStyle.cpp:
(WebCore::KSVGPainterFactory::fillPainter):
* ksvg2/svg/SVGCircleElement.cpp:
(SVGCircleElement::toPathData):
* ksvg2/svg/SVGCircleElement.h:
* ksvg2/svg/SVGClipPathElement.cpp:
(SVGClipPathElement::canvasResource):
* ksvg2/svg/SVGEllipseElement.cpp:
(WebCore::SVGEllipseElement::toPathData):
* ksvg2/svg/SVGEllipseElement.h:
* ksvg2/svg/SVGGradientElement.cpp:
(SVGGradientElement::notifyAttributeChange):
* ksvg2/svg/SVGImageElement.cpp:
* ksvg2/svg/SVGLineElement.cpp:
(SVGLineElement::toPathData):
* ksvg2/svg/SVGLineElement.h:
* ksvg2/svg/SVGMaskElement.cpp:
* ksvg2/svg/SVGPathElement.cpp:
(WebCore::SVGPathElement::toPathData):
* ksvg2/svg/SVGPathElement.h:
* ksvg2/svg/SVGPatternElement.cpp:
(WebCore::SVGPatternElement::notifyClientsToRepaint):
* ksvg2/svg/SVGPolygonElement.cpp:
(SVGPolygonElement::toPathData):
* ksvg2/svg/SVGPolygonElement.h:
* ksvg2/svg/SVGPolylineElement.cpp:
(SVGPolylineElement::toPathData):
* ksvg2/svg/SVGPolylineElement.h:
* ksvg2/svg/SVGRectElement.cpp:
(WebCore::SVGRectElement::toPathData):
* ksvg2/svg/SVGRectElement.h:
* ksvg2/svg/SVGStyledElement.cpp:
(WebCore::SVGStyledElement::createRenderer):
* ksvg2/svg/SVGStyledElement.h:
(WebCore::SVGStyledElement::toPathData):
* ksvg2/svg/SVGTextContentElement.cpp:
* ksvg2/svg/SVGTextElement.cpp:
* platform/Path.h:
(WebCore::):
(WebCore::Path::setWindingRule):
(WebCore::Path::windingRule):
* platform/cg/PathCG.cpp:
(WebCore::Path::contains):
(WebCore::Path::isEmpty):
(WebCore::CGPathToCFStringApplierFunction):
(WebCore::CFStringFromCGPath):
(WebCore::Path::debugString):
* platform/qt/FrameQt.cpp:
(WebCore::FrameQt::openURL):
* platform/qt/PathQt.cpp:
(WebCore::Path::contains):
(WebCore::Path::isEmpty):
(WebCore::Path::debugString):
2006-08-26 Eric Seidel <eric@eseidel.com>
Reviewed by hyatt.
......
......@@ -969,8 +969,6 @@
A88AD3B40952486E001DD196 /* KRenderingPaintServerQuartz.mm in Sources */ = {isa = PBXBuildFile; fileRef = A8C0FB75089701F800BA5114 /* KRenderingPaintServerQuartz.mm */; };
A88AD3B50952486E001DD196 /* QuartzSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0FB76089701F800BA5114 /* QuartzSupport.h */; };
A88AD3B60952486E001DD196 /* QuartzSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = A8C0FB77089701F800BA5114 /* QuartzSupport.mm */; };
A88AD3B70952486E001DD196 /* KCanvasPathQuartz.h in Headers */ = {isa = PBXBuildFile; fileRef = A8ABC99909445EC00013945F /* KCanvasPathQuartz.h */; };
A88AD3B80952486E001DD196 /* KCanvasPathQuartz.mm in Sources */ = {isa = PBXBuildFile; fileRef = A8ABC99A09445EC00013945F /* KCanvasPathQuartz.mm */; };
A88AD3B90952486E001DD196 /* RenderSVGContainer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C0FB7A089701F800BA5114 /* RenderSVGContainer.cpp */; };
A88AD3BA0952486E001DD196 /* RenderSVGContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0FB7B089701F800BA5114 /* RenderSVGContainer.h */; };
A88AD3BB0952486E001DD196 /* KCanvasCreator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C0FB7C089701F800BA5114 /* KCanvasCreator.cpp */; };
......@@ -980,8 +978,6 @@
A88AD3C00952486E001DD196 /* KCanvasImage.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0FB81089701F800BA5114 /* KCanvasImage.h */; };
A88AD3C10952486E001DD196 /* RenderPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C0FB82089701F800BA5114 /* RenderPath.cpp */; };
A88AD3C20952486E001DD196 /* RenderPath.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0FB83089701F800BA5114 /* RenderPath.h */; };
A88AD3C50952486E001DD196 /* KCanvasPath.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0FB86089701F800BA5114 /* KCanvasPath.h */; };
A88AD3C60952486E001DD196 /* KCanvasPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4758C44308C5F217009BAF05 /* KCanvasPath.cpp */; };
A88AD3C70952486E001DD196 /* KCanvasResourceListener.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0FB89089701F800BA5114 /* KCanvasResourceListener.h */; };
A88AD3C80952486E001DD196 /* KCanvasResources.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C0FB8A089701F800BA5114 /* KCanvasResources.cpp */; };
A88AD3C90952486E001DD196 /* KCanvasResources.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0FB8B089701F800BA5114 /* KCanvasResources.h */; };
......@@ -1846,7 +1842,6 @@
448A29BD0A46D9CB0030759F /* JSHTMLOptionsCollection.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLOptionsCollection.h; sourceTree = "<group>"; };
448A29BE0A46D9CB0030759F /* JSHTMLOptionsCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLOptionsCollection.cpp; sourceTree = "<group>"; };
448AD27A0A4813790023D179 /* JSHTMLOptionsCollectionCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLOptionsCollectionCustom.cpp; sourceTree = "<group>"; };
4758C44308C5F217009BAF05 /* KCanvasPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KCanvasPath.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
4E19591F0A39DABA00220FE5 /* MediaFeatureNames.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MediaFeatureNames.cpp; sourceTree = "<group>"; };
4E1959200A39DABA00220FE5 /* MediaFeatureNames.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MediaFeatureNames.h; sourceTree = "<group>"; };
4E1959230A39DACC00220FE5 /* MediaQuery.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MediaQuery.cpp; sourceTree = "<group>"; };
......@@ -2696,8 +2691,6 @@
A890DF1C0930974800513F88 /* SVGStyledTransformableElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGStyledTransformableElement.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
A890DF1D0930974800513F88 /* SVGStyledLocatableElement.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = SVGStyledLocatableElement.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
A890DF1E0930974800513F88 /* SVGStyledLocatableElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGStyledLocatableElement.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
A8ABC99909445EC00013945F /* KCanvasPathQuartz.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KCanvasPathQuartz.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
A8ABC99A09445EC00013945F /* KCanvasPathQuartz.mm */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = KCanvasPathQuartz.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
A8C0F6EB089701F100BA5114 /* KCanvasRenderingStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KCanvasRenderingStyle.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
A8C0F6EC089701F100BA5114 /* KCanvasRenderingStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KCanvasRenderingStyle.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
A8C0F6EF089701F100BA5114 /* KSVGTimeScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KSVGTimeScheduler.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
......@@ -2980,7 +2973,6 @@
A8C0FB81089701F800BA5114 /* KCanvasImage.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KCanvasImage.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
A8C0FB82089701F800BA5114 /* RenderPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderPath.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
A8C0FB83089701F800BA5114 /* RenderPath.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = RenderPath.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
A8C0FB86089701F800BA5114 /* KCanvasPath.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KCanvasPath.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
A8C0FB89089701F800BA5114 /* KCanvasResourceListener.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KCanvasResourceListener.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
A8C0FB8A089701F800BA5114 /* KCanvasResources.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KCanvasResources.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
A8C0FB8B089701F800BA5114 /* KCanvasResources.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KCanvasResources.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
......@@ -4830,8 +4822,6 @@
A8C0FB7E089701F800BA5114 /* KCanvasFilters.cpp */,
A8C0FB7F089701F800BA5114 /* KCanvasFilters.h */,
A8C0FB81089701F800BA5114 /* KCanvasImage.h */,
4758C44308C5F217009BAF05 /* KCanvasPath.cpp */,
A8C0FB86089701F800BA5114 /* KCanvasPath.h */,
A8C0FB89089701F800BA5114 /* KCanvasResourceListener.h */,
A8C0FB8A089701F800BA5114 /* KCanvasResources.cpp */,
A8C0FB8B089701F800BA5114 /* KCanvasResources.h */,
......@@ -4880,8 +4870,6 @@
A8C0FB6C089701F800BA5114 /* KCanvasItemQuartz.mm */,
A81655D2096BBEAC00601058 /* KCanvasMaskerQuartz.h */,
A81655D3096BBEAC00601058 /* KCanvasMaskerQuartz.mm */,
A8ABC99909445EC00013945F /* KCanvasPathQuartz.h */,
A8ABC99A09445EC00013945F /* KCanvasPathQuartz.mm */,
A8C0FB6D089701F800BA5114 /* KCanvasResourcesQuartz.h */,
A8C0FB6E089701F800BA5114 /* KCanvasResourcesQuartz.mm */,
A8C0FB71089701F800BA5114 /* KRenderingDeviceQuartz.h */,
......@@ -5724,13 +5712,11 @@
A88AD3B00952486E001DD196 /* KRenderingDeviceQuartz.h in Headers */,
A88AD3B30952486E001DD196 /* KRenderingPaintServerQuartz.h in Headers */,
A88AD3B50952486E001DD196 /* QuartzSupport.h in Headers */,
A88AD3B70952486E001DD196 /* KCanvasPathQuartz.h in Headers */,
A88AD3BA0952486E001DD196 /* RenderSVGContainer.h in Headers */,
A88AD3BC0952486E001DD196 /* KCanvasCreator.h in Headers */,
A88AD3BE0952486E001DD196 /* KCanvasFilters.h in Headers */,
A88AD3C00952486E001DD196 /* KCanvasImage.h in Headers */,
A88AD3C20952486E001DD196 /* RenderPath.h in Headers */,
A88AD3C50952486E001DD196 /* KCanvasPath.h in Headers */,
A88AD3C70952486E001DD196 /* KCanvasResourceListener.h in Headers */,
A88AD3C90952486E001DD196 /* KCanvasResources.h in Headers */,
A88AD3CB0952486E001DD196 /* KCanvasTreeDebug.h in Headers */,
......@@ -6647,12 +6633,10 @@
A88AD3B20952486E001DD196 /* KRenderingPaintServerGradientQuartz.mm in Sources */,
A88AD3B40952486E001DD196 /* KRenderingPaintServerQuartz.mm in Sources */,
A88AD3B60952486E001DD196 /* QuartzSupport.mm in Sources */,
A88AD3B80952486E001DD196 /* KCanvasPathQuartz.mm in Sources */,
A88AD3B90952486E001DD196 /* RenderSVGContainer.cpp in Sources */,
A88AD3BB0952486E001DD196 /* KCanvasCreator.cpp in Sources */,
A88AD3BD0952486E001DD196 /* KCanvasFilters.cpp in Sources */,
A88AD3C10952486E001DD196 /* RenderPath.cpp in Sources */,
A88AD3C60952486E001DD196 /* KCanvasPath.cpp in Sources */,
A88AD3C80952486E001DD196 /* KCanvasResources.cpp in Sources */,
A88AD3CC0952486E001DD196 /* KCanvasTreeDebug.cpp in Sources */,
A88AD401095248F0001DD196 /* SVGRenderStyle.cpp in Sources */,
......
......@@ -28,6 +28,7 @@
#include "KRenderingDevice.h"
#include "RenderSVGContainer.h"
#include "Path.h"
namespace WebCore {
......@@ -49,11 +50,16 @@ KCanvasCreator *KCanvasCreator::self()
return s_creator;
}
KCanvasPath* KCanvasCreator::createRoundedRectangle(float x, float y, float width, float height, float rx, float ry) const
Path KCanvasCreator::createRoundedRectangle(const FloatRect& box, const FloatSize& roundingRadii) const
{
KCanvasPath* path = renderingDevice()->createPath();
if (width <= 0.0f || height <= 0.0f || !path)
Path path;
float x = box.x();
float y = box.y();
float width = box.width();
float height = box.height();
float rx = roundingRadii.width();
float ry = roundingRadii.height();
if (width <= 0.0f || height <= 0.0f)
return path;
double nrx = rx, nry = ry;
......@@ -67,52 +73,58 @@ KCanvasPath* KCanvasCreator::createRoundedRectangle(float x, float y, float widt
if (nry > height / 2)
nry = height / 2;
path->moveTo(x + nrx, y);
path.moveTo(FloatPoint(x + nrx, y));
if (nrx < width / 2)
path->lineTo(x + width - rx, y);
path.addLineTo(FloatPoint(x + width - rx, y));
path->curveTo(x + width - nrx * (1 - 0.552), y, x + width, y + nry * (1 - 0.552), x + width, y + nry);
path.addBezierCurveTo(FloatPoint(x + width - nrx * (1 - 0.552), y), FloatPoint(x + width, y + nry * (1 - 0.552)), FloatPoint(x + width, y + nry));
if (nry < height / 2)
path->lineTo(x + width, y + height - nry);
path.addLineTo(FloatPoint(x + width, y + height - nry));
path->curveTo(x + width, y + height - nry * (1 - 0.552), x + width - nrx * (1 - 0.552), y + height, x + width - nrx, y + height);
path.addBezierCurveTo(FloatPoint(x + width, y + height - nry * (1 - 0.552)), FloatPoint(x + width - nrx * (1 - 0.552), y + height), FloatPoint(x + width - nrx, y + height));
if (nrx < width / 2)
path->lineTo(x + nrx, y + height);
path.addLineTo(FloatPoint(x + nrx, y + height));
path->curveTo(x + nrx * (1 - 0.552), y + height, x, y + height - nry * (1 - 0.552), x, y + height - nry);
path.addBezierCurveTo(FloatPoint(x + nrx * (1 - 0.552), y + height), FloatPoint(x, y + height - nry * (1 - 0.552)), FloatPoint(x, y + height - nry));
if (nry < height / 2)
path->lineTo(x, y + nry);
path.addLineTo(FloatPoint(x, y + nry));
path.addBezierCurveTo(FloatPoint(x, y + nry * (1 - 0.552)), FloatPoint(x + nrx * (1 - 0.552), y), FloatPoint(x + nrx, y));
path->curveTo(x, y + nry * (1 - 0.552), x + nrx * (1 - 0.552), y, x + nrx, y);
path.closeSubpath();
path->closeSubpath();
return path;
}
KCanvasPath* KCanvasCreator::createRectangle(float x, float y, float width, float height) const
Path KCanvasCreator::createRectangle(const FloatRect& box) const
{
KCanvasPath* path = renderingDevice()->createPath();
if (width <= 0.0f || height <= 0.0f || !path)
Path path;
float x = box.x();
float y = box.y();
float width = box.width();
float height = box.height();
if (width < 0.0f || height < 0.0f)
return path;
path->moveTo(x, y);
path->lineTo(x + width, y);
path->lineTo(x + width, y + height);
path->lineTo(x, y + height);
path->closeSubpath();
path.moveTo(FloatPoint(x, y));
path.addLineTo(FloatPoint(x + width, y));
path.addLineTo(FloatPoint(x + width, y + height));
path.addLineTo(FloatPoint(x, y + height));
path.closeSubpath();
return path;
}
KCanvasPath* KCanvasCreator::createEllipse(float cx, float cy, float rx, float ry) const
Path KCanvasCreator::createEllipse(const FloatPoint&c, float rx, float ry) const
{
KCanvasPath* path = renderingDevice()->createPath();
if (rx <= 0.0f || ry <= 0.0f || !path)
float cx = c.x();
float cy = c.y();
Path path;
if (rx <= 0.0f || ry <= 0.0f)
return path;
// Ellipse creation - nice & clean agg2 code
......@@ -134,29 +146,30 @@ KCanvasPath* KCanvasCreator::createEllipse(float cx, float cy, float rx, float r
step++;
if(step == 1)
path->moveTo(x, y);
path.moveTo(FloatPoint(x, y));
else
path->lineTo(x, y);
path.addLineTo(FloatPoint(x, y));
}
path->closeSubpath();
path.closeSubpath();
return path;
}
KCanvasPath* KCanvasCreator::createCircle(float cx, float cy, float r) const
Path KCanvasCreator::createCircle(const FloatPoint& c, float r) const
{
return createEllipse(cx, cy, r, r);
return createEllipse(c, r, r);
}
KCanvasPath* KCanvasCreator::createLine(float x1, float y1, float x2, float y2) const
Path KCanvasCreator::createLine(const FloatPoint& start, const FloatPoint& end) const
{
KCanvasPath* path = renderingDevice()->createPath();
if ((x1 == x2 && y1 == y2) || !path)
Path path;
if (start.x() == end.x() && start.y() == end.y())
return path;
path->moveTo(x1, y1);
path->lineTo(x2, y2);
path.moveTo(start);
path.addLineTo(end);
return path;
}
......
......@@ -24,10 +24,13 @@
#define KCanvasCreator_H
#ifdef SVG_SUPPORT
#include <kcanvas/KCanvasPath.h>
namespace WebCore {
class Path;
class FloatPoint;
class FloatRect;
class FloatSize;
class KCanvasCreator
{
public:
......@@ -37,11 +40,11 @@ public:
static KCanvasCreator *self();
// Canvas path creation
KCanvasPath* createRoundedRectangle(float x, float y, float width, float height, float rx, float ry) const;
KCanvasPath* createRectangle(float x, float y, float width, float height) const;
KCanvasPath* createEllipse(float cx, float cy, float rx, float ry) const;
KCanvasPath* createCircle(float cx, float cy, float r) const;
KCanvasPath* createLine(float x1, float y1, float x2, float y2) const;
Path createRoundedRectangle(const FloatRect&, const FloatSize&) const;
Path createRectangle(const FloatRect&) const;
Path createEllipse(const FloatPoint&, float rx, float ry) const;
Path createCircle(const FloatPoint&, float r) const;
Path createLine(const FloatPoint&, const FloatPoint&) const;
private:
static KCanvasCreator *s_creator;
......
/*
* Copyright (C) 2005 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. All rights reserved.
*
* 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 THE AUTHOR ``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 AUTHOR 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"
#ifdef SVG_SUPPORT
#include "TextStream.h"
#include "KCanvasPath.h"
#include "KCanvasTreeDebug.h"
#include "KRenderingDevice.h"
namespace WebCore {
//KCWindRule
TextStream &operator<<(TextStream &ts, KCWindRule rule)
{
switch (rule)
{
case RULE_NONZERO:
ts << "NON-ZERO"; break;
case RULE_EVENODD:
ts << "EVEN-ODD"; break;
}
return ts;
}
//KCClipData
TextStream &operator<<(TextStream &ts, const KCClipData &d)
{
ts << "[winding=" << d.windRule() << "]";
if (d.bboxUnits)
ts << " [bounding box mode=" << d.bboxUnits << "]";
ts << " [path=" << renderingDevice()->stringForPath(d.path.get()) << "]";
return ts;
}
}
#endif // SVG_SUPPORT
/*
Copyright (C) 2005 Apple Computer, Inc.
Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
2004, 2005 Rob Buis <buis@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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef KCanvasPath_H
#define KCanvasPath_H
#ifdef SVG_SUPPORT
#include "DeprecatedValueList.h"
#include <wtf/Assertions.h>
#include "Shared.h"
#include "FloatRect.h"
namespace WebCore {
class KRenderingStrokePainter;
class RenderStyle;
class TextStream;
enum KCWindRule {
RULE_NONZERO = 0,
RULE_EVENODD = 1
};
// Path related data structures
typedef enum
{
CMD_MOVE = 0,
CMD_LINE = 1,
CMD_CURVE = 2,
CMD_CLOSE_SUBPATH = 3
} KCPathCommand;
class KCanvasPath : public Shared<KCanvasPath>
{
public:
virtual ~KCanvasPath() { }
virtual bool isEmpty() const = 0;
virtual void moveTo(float x, float y) = 0;
virtual void lineTo(float x, float y) = 0;
virtual void curveTo(float x1, float y1, float x2, float y2, float x3, float y3) = 0;
virtual void closeSubpath() = 0;
virtual FloatRect boundingBox() = 0;
virtual FloatRect strokeBoundingBox(const KRenderingStrokePainter&) = 0;
virtual bool strokeContainsPoint(const FloatPoint&) = 0;
virtual bool containsPoint(const FloatPoint&, KCWindRule) = 0;
};
// Clipping paths
struct KCClipData
{
KCWindRule windRule() const { return static_cast<KCWindRule>(m_windRule); }
unsigned m_windRule : 1; // KCWindRule
bool bboxUnits : 1;
RefPtr<KCanvasPath> path;
};
class KCClipDataList : public DeprecatedValueList<KCClipData>
{
public:
KCClipDataList() { }
inline void addPath(KCanvasPath *pathData, KCWindRule windRule, bool bboxUnits)
{
ASSERT(pathData);
KCClipData clipData;