+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.
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"
ksvg2/events/JSSVGLazyEventListener.cpp
ksvg2/events/SVGZoomEvent.cpp
kcanvas/KCanvasCreator.cpp
- kcanvas/KCanvasPath.cpp
kcanvas/KCanvasTreeDebug.cpp
kcanvas/KCanvasFilters.cpp
kcanvas/RenderSVGText.cpp
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.
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 */; };
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 */; };
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>"; };
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; };
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; };
A8C0FB7E089701F800BA5114 /* KCanvasFilters.cpp */,
A8C0FB7F089701F800BA5114 /* KCanvasFilters.h */,
A8C0FB81089701F800BA5114 /* KCanvasImage.h */,
- 4758C44308C5F217009BAF05 /* KCanvasPath.cpp */,
- A8C0FB86089701F800BA5114 /* KCanvasPath.h */,
A8C0FB89089701F800BA5114 /* KCanvasResourceListener.h */,
A8C0FB8A089701F800BA5114 /* KCanvasResources.cpp */,
A8C0FB8B089701F800BA5114 /* KCanvasResources.h */,
A8C0FB6C089701F800BA5114 /* KCanvasItemQuartz.mm */,
A81655D2096BBEAC00601058 /* KCanvasMaskerQuartz.h */,
A81655D3096BBEAC00601058 /* KCanvasMaskerQuartz.mm */,
- A8ABC99909445EC00013945F /* KCanvasPathQuartz.h */,
- A8ABC99A09445EC00013945F /* KCanvasPathQuartz.mm */,
A8C0FB6D089701F800BA5114 /* KCanvasResourcesQuartz.h */,
A8C0FB6E089701F800BA5114 /* KCanvasResourcesQuartz.mm */,
A8C0FB71089701F800BA5114 /* KRenderingDeviceQuartz.h */,
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 */,
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 */,
#include "KRenderingDevice.h"
#include "RenderSVGContainer.h"
+#include "Path.h"
namespace WebCore {
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;
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
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;
}
#define KCanvasCreator_H
#ifdef SVG_SUPPORT
-#include <kcanvas/KCanvasPath.h>
-
namespace WebCore {
+class Path;
+class FloatPoint;
+class FloatRect;
+class FloatSize;
+
class KCanvasCreator
{
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;
+++ /dev/null
-/*
- * 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
+++ /dev/null
-/*
- 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;
- clipData.m_windRule = windRule;
- clipData.bboxUnits = bboxUnits;
- clipData.path = pathData;
- append(clipData);
- }
-};
-
-TextStream &operator<<(TextStream &ts, KCWindRule rule);
-TextStream &operator<<(TextStream &ts, const KCClipData &d);
-
-}
-
-#endif // SVG_SUPPORT
-#endif
-
-// vim:ts=4:noet
return r.externalRepresentation(ts);
}
+//WindRule
+TextStream &operator<<(TextStream &ts, WindRule 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=" << d.path.debugString() << "]";
+ return ts;
+}
+
// KCanvasResource
KCanvasResource::KCanvasResource()
{
m_clients.append(item);
}
-const KCanvasItemList &KCanvasResource::clients() const
+const RenderPathList &KCanvasResource::clients() const
{
return m_clients;
}
void KCanvasResource::invalidate()
{
- KCanvasItemList::ConstIterator it = m_clients.begin();
- KCanvasItemList::ConstIterator end = m_clients.end();
+ RenderPathList::ConstIterator it = m_clients.begin();
+ RenderPathList::ConstIterator end = m_clients.end();
for(; it != end; ++it)
const_cast<RenderPath *>(*it)->repaint();
m_clipData.clear();
}
-void KCanvasClipper::addClipData(KCanvasPath* path, KCWindRule rule, bool bboxUnits)
+void KCanvasClipper::addClipData(const Path& path, WindRule rule, bool bboxUnits)
{
m_clipData.addPath(path, rule, bboxUnits);
}
#define KCanvasResources_H
#ifdef SVG_SUPPORT
-#include <kcanvas/RenderPath.h>
-#include <kcanvas/KCanvasPath.h>
+#include "DeprecatedValueList.h"
+#include "Path.h"
+#include "RenderPath.h"
#include <kcanvas/KCanvasResourceListener.h>
namespace WebCore {
+typedef DeprecatedValueList<const RenderPath *> RenderPathList;
+
class TextStream;
// Enumerations
virtual void invalidate();
void addClient(const RenderPath *item);
- const KCanvasItemList &clients() const;
+ const RenderPathList &clients() const;
DeprecatedString idInRegistry() const;
void setIdInRegistry(const DeprecatedString& newId);
virtual TextStream& externalRepresentation(TextStream &) const;
private:
- KCanvasItemList m_clients;
+ RenderPathList m_clients;
DeprecatedString registryId;
};
+// Clipping paths
+struct KCClipData
+{
+ WindRule windRule() const { return m_windRule; }
+ WindRule m_windRule;
+ bool bboxUnits : 1;
+ Path path;
+};
+
+class KCClipDataList : public DeprecatedValueList<KCClipData>
+{
+public:
+ KCClipDataList() { }
+
+ inline void addPath(const Path& pathData, WindRule windRule, bool bboxUnits)
+ {
+ KCClipData clipData;
+ clipData.bboxUnits = bboxUnits;
+ clipData.m_windRule = windRule;
+ clipData.path = pathData;
+ append(clipData);
+ }
+};
+
class KCanvasClipper : public KCanvasResource
{
public:
virtual bool isClipper() const { return true; }
void resetClipData();
- void addClipData(KCanvasPath *path, KCWindRule rule, bool bboxUnits);
+ void addClipData(const Path& path, WindRule rule, bool bboxUnits);
virtual void applyClip(const FloatRect& boundingBox) const = 0;
bool m_useStrokeWidth;
};
+
+
KCanvasResource *getResourceById(Document *document, const AtomicString &id);
KCanvasMarker *getMarkerById(Document *document, const AtomicString &id);
KCanvasClipper *getClipperById(Document *document, const AtomicString &id);
KRenderingPaintServer *getPaintServerById(Document *document, const AtomicString &id);
TextStream &operator<<(TextStream &ts, const KCanvasResource &r);
+TextStream &operator<<(TextStream &ts, WindRule rule);
+TextStream &operator<<(TextStream &ts, const KCClipData &d);
}
writeStyle(ts, o);
- ts << " [data=\"" << renderingDevice()->stringForPath(o.path()) << "\"]";
+ ts << " [data=\"" << o.path().debugString() << "\"]";
return ts;
}
class RenderPath::Private {
public:
- RefPtr<KCanvasPath> path;
+ Path path;
FloatRect fillBBox;
FloatRect strokeBbox;
bool RenderPath::fillContains(const FloatPoint& point) const
{
- if (!d->path)
+ if (d->path.isEmpty())
return false;
if (!KSVGPainterFactory::fillPaintServer(style(), this))
return false;
- return path()->containsPoint(mapAbsolutePointToLocal(point),
- KSVGPainterFactory::fillPainter(style(), this).fillRule());
-}
-
-bool RenderPath::strokeContains(const FloatPoint& point) const
-{
- if (!d->path)
- return false;
-
- if (!KSVGPainterFactory::strokePaintServer(style(), this))
- return false;
-
- return path()->strokeContainsPoint(mapAbsolutePointToLocal(point));
-}
-
-FloatRect RenderPath::strokeBBox() const
-{
- if (KSVGPainterFactory::isStroked(style())) {
- KRenderingStrokePainter strokePainter = KSVGPainterFactory::strokePainter(style(), this);
- return path()->strokeBoundingBox(strokePainter);
- }
-
- return path()->boundingBox();
+ return path().contains(mapAbsolutePointToLocal(point),
+ KSVGPainterFactory::fillPainter(style(), this).fillRule());
}
FloatRect RenderPath::relativeBBox(bool includeStroke) const
{
- if (!d->path)
+ if (d->path.isEmpty())
return FloatRect();
if (includeStroke) {
}
if (d->fillBBox.isEmpty())
- d->fillBBox = path()->boundingBox();
+ d->fillBBox = path().boundingRect();
return d->fillBBox;
}
-void RenderPath::setPath(KCanvasPath* newPath)
+void RenderPath::setPath(const Path& newPath)
{
d->path = newPath;
d->strokeBbox = FloatRect();
d->fillBBox = FloatRect();
}
-KCanvasPath* RenderPath::path() const
+const Path& RenderPath::path() const
{
- return d->path.get();
+ return d->path;
}
void RenderPath::layout()
//ASSERT(parentX == 0);
//ASSERT(parentY == 0);
- if (paintInfo.p->paintingDisabled() || (paintInfo.phase != PaintPhaseForeground) || style()->visibility() == HIDDEN || !path())
+ if (paintInfo.p->paintingDisabled() || (paintInfo.phase != PaintPhaseForeground) || style()->visibility() == HIDDEN || path().isEmpty())
return;
KRenderingDevice* device = renderingDevice();
// We only draw in the forground phase, so we only hit-test then.
if (hitTestAction != HitTestForeground)
return false;
-
PointerEventsHitRules hitRules = pointerEventsHitRules();
bool isVisible = (style()->visibility() == VISIBLE);
class FloatPoint;
class SVGStyledElement;
-class KCanvasPath;
+class Path;
class RenderSVGContainer;
class RenderPath : public RenderObject
// Hit-detection seperated for the fill and the stroke
virtual bool fillContains(const FloatPoint &p) const;
- virtual bool strokeContains(const FloatPoint &p) const;
+ virtual bool strokeContains(const FloatPoint &p) const = 0;
// Returns an unscaled bounding box (not even including localTransform()) for this vector path
virtual FloatRect relativeBBox(bool includeStroke = true) const;
- void setPath(KCanvasPath* newPath);
- KCanvasPath* path() const;
+ void setPath(const Path& newPath);
+ const Path& path() const;
virtual bool isRenderPath() const { return true; }
virtual const char *renderName() const { return "KCanvasItem"; }
};
protected:
- virtual void drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const KCanvasPath*) const = 0;
+ virtual void drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const Path&) const = 0;
+ virtual FloatRect strokeBBox() const = 0;
private:
- FloatRect strokeBBox() const;
FloatPoint mapAbsolutePointToLocal(const FloatPoint&) const;
PointerEventsHitRules pointerEventsHitRules();
Private *d;
};
-// Helper data structure
-typedef DeprecatedValueList<const RenderPath *> KCanvasItemList;
-
}
#endif // SVG_SUPPORT
virtual AffineTransform ctm() const = 0;
virtual void clearPath() = 0;
- virtual void addPath(const KCanvasPath*) = 0;
+ virtual void addPath(const Path&) = 0;
virtual GraphicsContext* createGraphicsContext() = 0;
};
virtual void pushContext(KRenderingDeviceContext *context);
virtual KRenderingDeviceContext *contextForImage(KCanvasImage *image) const = 0;
-
- virtual DeprecatedString stringForPath(const KCanvasPath* path) = 0;
// Creation tools
virtual KCanvasResource *createResource(const KCResourceType &type) const = 0;
virtual KCanvasFilterEffect *createFilterEffect(const KCFilterEffectType &type) const = 0;
virtual KRenderingPaintServer *createPaintServer(const KCPaintServerType &type) const = 0;
- virtual RenderPath *createItem(RenderArena *arena, RenderStyle *style, SVGStyledElement *node, KCanvasPath* path) const = 0;
- virtual KCanvasPath* createPath() const = 0;
+ virtual RenderPath *createItem(RenderArena *arena, RenderStyle *style, SVGStyledElement *node, const Path& path) const = 0;
private:
Vector<KRenderingDeviceContext*> m_contextStack;
}
float opacity;
- KCWindRule fillRule;
+ WindRule fillRule;
};
KRenderingFillPainter::KRenderingFillPainter() : d(new Private())
delete d;
}
-KCWindRule KRenderingFillPainter::fillRule() const
+WindRule KRenderingFillPainter::fillRule() const
{
return d->fillRule;
}
-void KRenderingFillPainter::setFillRule(KCWindRule rule)
+void KRenderingFillPainter::setFillRule(WindRule rule)
{
d->fillRule = rule;
}
#define KRenderingFillPainter_H
#ifdef SVG_SUPPORT
-#include <kcanvas/KCanvasPath.h>
+#include "Path.h"
namespace WebCore {
KRenderingFillPainter();
virtual ~KRenderingFillPainter();
- KCWindRule fillRule() const;
- void setFillRule(KCWindRule rule);
+ WindRule fillRule() const;
+ void setFillRule(WindRule rule);
float opacity() const;
void setOpacity(float opacity);
#include "config.h"
-#include "KCanvasPathQt.h"
#include "KCanvasClipperQt.h"
#include "KRenderingDeviceQt.h"
QPainterPath newPath;
bool heterogenousClipRules = false;
- KCWindRule clipRule = m_clipData[0].windRule();
+ WindRule clipRule = m_clipData[0].windRule();
for (unsigned int x = 0; x < m_clipData.count(); x++) {
KCClipData clipData = m_clipData[x];
if (clipData.windRule() != clipRule)
heterogenousClipRules = true;
- QPainterPath path = static_cast<KCanvasPathQt*>(clipData.path.get())->qtPath();
+ QPainterPath path = *(clipData.path.platformPath());
if (path.isEmpty())
continue;
+++ /dev/null
-/*
- Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <wildfox@kde.org>
- 2004, 2005, 2006 Rob Buis <buis@kde.org>
- 2005 Apple Computer, Inc.
-
- 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.
-*/
-
-#include "config.h"
-#include "KCanvasPathQt.h"
-
-namespace WebCore {
-
-KCanvasPathQt::KCanvasPathQt()
-{
-}
-
-KCanvasPathQt::~KCanvasPathQt()
-{
-}
-
-bool KCanvasPathQt::isEmpty() const
-{
- return m_path.isEmpty();
-}
-
-void KCanvasPathQt::moveTo(float x, float y)
-{
- m_path.moveTo(x, y);
-}
-
-void KCanvasPathQt::lineTo(float x, float y)
-{
- m_path.lineTo(x, y);
-}
-
-void KCanvasPathQt::curveTo(float x1, float y1, float x2, float y2, float x3, float y3)
-{
- m_path.cubicTo(x1, y1, x2, y2, x3, y3);
-}
-
-void KCanvasPathQt::closeSubpath()
-{
- m_path.closeSubpath();
-}
-
-FloatRect KCanvasPathQt::boundingBox()
-{
- return FloatRect(m_path.boundingRect());
-}
-
-FloatRect KCanvasPathQt::strokeBoundingBox(const KRenderingStrokePainter& strokePainter)
-{
- qDebug("KCanvasPathQt::strokeBoundingBox() TODO!");
- return boundingBox();
-}
-
-bool KCanvasPathQt::strokeContainsPoint(const FloatPoint& point)
-{
- qDebug("KCanvasPathQt::strokeContainsPoint() TODO!");
- return containsPoint(point, RULE_EVENODD);
-}
-
-bool KCanvasPathQt::containsPoint(const FloatPoint& point, KCWindRule rule)
-{
- Qt::FillRule savedRule = m_path.fillRule();
- m_path.setFillRule(rule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
-
- bool contains = m_path.contains(point);
-
- m_path.setFillRule(savedRule);
- return contains;
-}
-
-}
-
-// vim:ts=4:noet
+++ /dev/null
-/*
- Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <wildfox@kde.org>
- 2004, 2005, 2006 Rob Buis <buis@kde.org>
- 2005 Apple Computer, Inc.
-
- 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 KCanvasPathQt_H
-#define KCanvasPathQt_H
-
-#include <QPainterPath>
-
-#include "KCanvasPath.h"
-
-namespace WebCore {
-
-class KCanvasPathQt : public KCanvasPath
-{
-public:
- KCanvasPathQt();
- virtual ~KCanvasPathQt();
-
- virtual bool isEmpty() const;
-
- virtual void moveTo(float x, float y);
- virtual void lineTo(float x, float y);
- virtual void curveTo(float x1, float y1, float x2, float y2, float x3, float y3);
- virtual void closeSubpath();
-
- virtual FloatRect boundingBox();
- virtual FloatRect strokeBoundingBox(const KRenderingStrokePainter&);
- virtual bool strokeContainsPoint(const FloatPoint&);
- virtual bool containsPoint(const FloatPoint&, KCWindRule);
-
- // Qt specific stuff
- const QPainterPath &qtPath() const { return m_path; }
-
-private:
- QPainterPath m_path;
-};
-
-}
-
-#endif
-
-// vim:ts=4:noet
#include "IntRect.h"
#include "RenderPathQt.h"
-#include "KCanvasPathQt.h"
#include "AffineTransform.h"
#include "GraphicsContext.h"
#include "KCanvasClipperQt.h"
m_path = QPainterPath();
}
-void KRenderingDeviceContextQt::addPath(const KCanvasPath* path)
+void KRenderingDeviceContextQt::addPath(const Path& path)
{
- m_path.addPath(static_cast<const KCanvasPathQt*>(path)->qtPath());
+ m_path.addPath(*(path.platformPath()));
}
GraphicsContext* KRenderingDeviceContextQt::createGraphicsContext()
return m_path.boundingRect();
}
-void KRenderingDeviceContextQt::setFillRule(KCWindRule rule)
+void KRenderingDeviceContextQt::setFillRule(WindRule rule)
{
m_path.setFillRule(rule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
}
return 0;
}
-DeprecatedString KRenderingDeviceQt::stringForPath(const KCanvasPath* path)
-{
- qDebug("KRenderingDeviceQt::stringForPath() TODO!");
- return 0;
-}
-
// Resource creation
KCanvasResource* KRenderingDeviceQt::createResource(const KCResourceType& type) const
{
return 0;
}
-KCanvasPath* KRenderingDeviceQt::createPath() const
-{
- return new KCanvasPathQt();
-}
-
// item creation
-RenderPath* KRenderingDeviceQt::createItem(RenderArena* arena, RenderStyle* style, SVGStyledElement* node, KCanvasPath* path) const
+RenderPath* KRenderingDeviceQt::createItem(RenderArena* arena, RenderStyle* style, SVGStyledElement* node, const Path& path) const
{
RenderPath* item = new (arena) RenderPathQt(style, node);
item->setPath(path);
virtual IntRect mapToVisual(const IntRect&);
virtual void clearPath();
- virtual void addPath(const KCanvasPath*);
+ virtual void addPath(const Path&);
virtual GraphicsContext* createGraphicsContext();
QPainter& painter();
QRectF pathBBox() const;
- void setFillRule(KCWindRule);
+ void setFillRule(WindRule);
void fillPath();
void strokePath();
KRenderingDeviceContextQt* qtContext() const;
virtual KRenderingDeviceContext* contextForImage(KCanvasImage*) const;
- virtual DeprecatedString stringForPath(const KCanvasPath*);
-
// Resource creation
virtual KCanvasResource* createResource(const KCResourceType&) const;
virtual KRenderingPaintServer* createPaintServer(const KCPaintServerType&) const;
virtual KCanvasFilterEffect* createFilterEffect(const KCFilterEffectType&) const;
- virtual KCanvasPath* createPath() const;
// item creation
- virtual RenderPath* createItem(RenderArena*, RenderStyle*, SVGStyledElement*, KCanvasPath*) const;
+ virtual RenderPath* createItem(RenderArena*, RenderStyle*, SVGStyledElement*, const Path&) const;
};
}
#include "config.h"
#include "RenderPathQt.h"
+#include "KCanvasRenderingStyle.h"
+#include "KRenderingStrokePainter.h"
#include <QDebug>
+#include <QPainterPathStroker>
namespace WebCore {
{
}
-void RenderPathQt::drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const KCanvasPath*) const
+void RenderPathQt::drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const Path&) const
{
qDebug("RenderPathQt::drawMarkersIfNeeded() TODO!");
}
+bool RenderPathQt::strokeContains(const FloatPoint& point) const
+{
+ if (path().isEmpty())
+ return false;
+
+ if (!KSVGPainterFactory::strokePaintServer(style(), this))
+ return false;
+
+ return false;
+}
+
+static QPainterPath getPathStroke(const QPainterPath &path, const KRenderingStrokePainter &strokePainter)
+{
+ QPainterPathStroker s;
+ s.setWidth(strokePainter.strokeWidth());
+ if(strokePainter.strokeCapStyle() == CAP_BUTT)
+ s.setCapStyle(Qt::FlatCap);
+ else if(strokePainter.strokeCapStyle() == CAP_ROUND)
+ s.setCapStyle(Qt::RoundCap);
+
+ if(strokePainter.strokeJoinStyle() == JOIN_MITER) {
+ s.setJoinStyle(Qt::MiterJoin);
+ s.setMiterLimit((qreal)strokePainter.strokeMiterLimit());
+ } else if(strokePainter.strokeJoinStyle() == JOIN_ROUND)
+ s.setJoinStyle(Qt::RoundJoin);
+
+ KCDashArray dashes = strokePainter.dashArray();
+ unsigned int dashLength = !dashes.isEmpty() ? dashes.count() : 0;
+ if(dashLength) {
+ QVector<qreal> pattern;
+ unsigned int count = (dashLength % 2) == 0 ? dashLength : dashLength * 2;
+
+ for(unsigned int i = 0; i < count; i++)
+ pattern.append(dashes[i % dashLength] / (float)s.width());
+
+ s.setDashPattern(pattern);
+ // TODO: dash-offset, does/will qt4 API allow it? (Rob)
+ }
+
+ return s.createStroke(path);
+}
+
+FloatRect RenderPathQt::strokeBBox() const
+{
+ KRenderingStrokePainter strokePainter = KSVGPainterFactory::strokePainter(style(), this);
+ QPainterPath outline = getPathStroke(*(path().platformPath()), strokePainter);
+ return outline.boundingRect();
+}
+
}
// vim:ts=4:noet
public:
RenderPathQt(RenderStyle*, SVGStyledElement*);
+ virtual bool strokeContains(const FloatPoint& point) const;
+ virtual FloatRect strokeBBox() const;
+
protected:
- virtual void drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const KCanvasPath*) const;
+ virtual void drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const Path&) const;
};
}
KCanvasItemQuartz(RenderStyle*, SVGStyledElement*);
virtual ~KCanvasItemQuartz() { }
- virtual void drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const KCanvasPath*) const;
+ virtual bool strokeContains(const FloatPoint& point) const;
+ virtual void drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const Path&) const;
+ virtual FloatRect strokeBBox() const;
};
}
#import "KRenderingFillPainter.h"
#import "KRenderingStrokePainter.h"
-#import "KCanvasPathQuartz.h"
#import "KRenderingDeviceQuartz.h"
#import "KCanvasFilterQuartz.h"
#import "KCanvasResourcesQuartz.h"
data.elementIndex++;
}
-void KCanvasItemQuartz::drawMarkersIfNeeded(GraphicsContext* context, const FloatRect& rect, const KCanvasPath *path) const
+void KCanvasItemQuartz::drawMarkersIfNeeded(GraphicsContext* context, const FloatRect& rect, const Path& path) const
{
Document *doc = document();
const SVGRenderStyle *svgStyle = style()->svgStyle();
DrawMarkersData data(context, startMarker, midMarker, strokeWidth);
- CGPathRef cgPath = static_cast<const KCanvasPathQuartz*>(path)->cgPath();
+ CGPathRef cgPath = path.platformPath();
CGPathApply(cgPath, &data, drawStartAndMidMarkers);
data.previousMarkerData.marker = endMarker;
drawMarkerWithData(context, data.previousMarkerData);
}
+FloatRect KCanvasItemQuartz::strokeBBox() const
+{
+ if (KSVGPainterFactory::isStroked(style())) {
+ KRenderingStrokePainter strokePainter = KSVGPainterFactory::strokePainter(style(), this);
+ return strokeBoundingBox(path(), strokePainter);
+ }
+
+ return path().boundingRect();
+}
+
+
+bool KCanvasItemQuartz::strokeContains(const FloatPoint& point) const
+{
+ if (path().isEmpty())
+ return false;
+
+ if (!KSVGPainterFactory::strokePaintServer(style(), this))
+ return false;
+
+ CGMutablePathRef cgPath = path().platformPath();
+ return pathContainsPoint(cgPath, point, kCGPathStroke);
+}
+
}
#endif // SVG_SUPPORT
+++ /dev/null
-/*
- * Copyright (C) 2005 Apple Computer, 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:
- * 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.
- */
-
-#ifndef KCanvasPathQuartz_h
-#define KCanvasPathQuartz_h
-
-#include <kcanvas/KCanvasPath.h>
-
-typedef struct CGPath *CGMutablePathRef;
-typedef const struct CGPath *CGPathRef;
-
-namespace WebCore {
-
-class KCanvasPathQuartz : public KCanvasPath {
-public:
- KCanvasPathQuartz();
- virtual ~KCanvasPathQuartz();
-
- virtual bool isEmpty() const;
-
- virtual void moveTo(float x, float y);
- virtual void lineTo(float x, float y);
- virtual void curveTo(float x1, float y1, float x2, float y2, float x3, float y3);
- virtual void closeSubpath();
-
- virtual FloatRect boundingBox();
- virtual FloatRect strokeBoundingBox(const KRenderingStrokePainter&);
- virtual bool containsPoint(const FloatPoint&, KCWindRule);
- virtual bool strokeContainsPoint(const FloatPoint&);
-
- CGPathRef cgPath() const { return m_cgPath; }
-
-private:
- CGMutablePathRef m_cgPath;
-};
-
-}
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 2005 Apple Computer, 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:
- * 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"
-#ifdef SVG_SUPPORT
-#include "KCanvasPathQuartz.h"
-#include "QuartzSupport.h"
-
-namespace WebCore {
-
-KCanvasPathQuartz::KCanvasPathQuartz()
-{
- m_cgPath = CGPathCreateMutable();
-}
-
-KCanvasPathQuartz::~KCanvasPathQuartz()
-{
- CGPathRelease(m_cgPath);
-}
-
-bool KCanvasPathQuartz::isEmpty() const
-{
- return CGPathIsEmpty(m_cgPath);
-}
-
-void KCanvasPathQuartz::moveTo(float x, float y)
-{
- CGPathMoveToPoint(m_cgPath, 0, x, y);
-}
-
-void KCanvasPathQuartz::lineTo(float x, float y)
-{
- CGPathAddLineToPoint(m_cgPath, 0, x, y);
-}
-
-void KCanvasPathQuartz::curveTo(float x1, float y1, float x2, float y2, float x3, float y3)
-{
- CGPathAddCurveToPoint(m_cgPath, 0, x1, y1, x2, y2, x3, y3);
-}
-
-void KCanvasPathQuartz::closeSubpath()
-{
- CGPathCloseSubpath(m_cgPath);
-}
-
-FloatRect KCanvasPathQuartz::boundingBox()
-{
- return CGPathGetBoundingBox(m_cgPath);
-}
-
-CGContextRef scratchContext()
-{
- static CGContextRef scratch = 0;
- if (!scratch) {
- CFMutableDataRef empty = CFDataCreateMutable(NULL, 0);
- CGDataConsumerRef consumer = CGDataConsumerCreateWithCFData(empty);
- scratch = CGPDFContextCreate(consumer, NULL, NULL);
- CGDataConsumerRelease(consumer);
- CFRelease(empty);
-
- CGFloat black[4] = {0, 0, 0, 1};
- CGContextSetFillColor(scratch, black);
- CGContextSetStrokeColor(scratch, black);
- }
- return scratch;
-}
-
-FloatRect KCanvasPathQuartz::strokeBoundingBox(const KRenderingStrokePainter& strokePainter)
-{
- // the bbox might grow if the path is stroked.
- // and CGPathGetBoundingBox doesn't support that, so we'll have
- // to make an alternative call...
-
- // FIXME: since this is mainly used to decide what to repaint,
- // perhaps it would be sufficien to just outset the fill bbox by
- // the stroke width - that should be way cheaper and simpler than
- // what we do here.
- if (isEmpty())
- return CGRectNull;
-
- CGContextRef context = scratchContext();
- CGContextSaveGState(context);
-
- CGContextBeginPath(context);
- CGContextAddPath(context, m_cgPath);
- applyStrokeStyleToContext(context, strokePainter);
- CGContextReplacePathWithStrokedPath(context);
- CGRect box = CGContextGetPathBoundingBox(context);
-
- CGContextRestoreGState(context);
-
- return FloatRect(box);
-}
-
-static bool pathContainsPoint(CGMutablePathRef cgPath, const FloatPoint& point, CGPathDrawingMode drawMode)
-{
- CGContextRef context = scratchContext();
- CGContextSaveGState(context);
-
- CGContextBeginPath(context);
- CGContextAddPath(context, cgPath);
- bool hitSuccess = CGContextPathContainsPoint(context, point, drawMode);
-
- CGContextRestoreGState(context);
-
- return hitSuccess;
-}
-
-bool KCanvasPathQuartz::containsPoint(const FloatPoint& point, KCWindRule fillRule)
-{
- return pathContainsPoint(m_cgPath, point, fillRule == RULE_EVENODD ? kCGPathEOFill : kCGPathFill);
-}
-
-bool KCanvasPathQuartz::strokeContainsPoint(const FloatPoint& point)
-{
- return pathContainsPoint(m_cgPath, point, kCGPathStroke);
-}
-
-}
-
-#endif // SVG_SUPPORT
-
#import "GraphicsContext.h"
#import "KCanvasFilterQuartz.h"
#import "KCanvasMaskerQuartz.h"
-#import "KCanvasPathQuartz.h"
#import "KRenderingDeviceQuartz.h"
#import "QuartzSupport.h"
return;
BOOL heterogenousClipRules = NO;
- KCWindRule clipRule = m_clipData[0].windRule();
+ WindRule clipRule = m_clipData[0].windRule();
context->clearPath();
if (data.windRule() != clipRule)
heterogenousClipRules = YES;
- KCanvasPathQuartz *path = static_cast<KCanvasPathQuartz*>(data.path.get());
- CGPathRef clipPath = static_cast<KCanvasPathQuartz*>(path)->cgPath();
+ CGPathRef clipPath = data.path.platformPath();
if (data.bboxUnits) {
CGMutablePathRef transformedPath = CGPathCreateMutable();
KRenderingDeviceContextQuartz(CGContextRef context);
virtual ~KRenderingDeviceContextQuartz();
- virtual AffineTransform concatCTM(const AffineTransform&);
+ virtual AffineTransform concatCTM(const AffineTransform &);
virtual AffineTransform ctm() const;
virtual void clearPath();
- virtual void addPath(const KCanvasPath*);
+ virtual void addPath(const Path&);
virtual GraphicsContext* createGraphicsContext();
CGContextRef currentCGContext() const;
virtual KRenderingDeviceContext *contextForImage(KCanvasImage *) const;
- virtual DeprecatedString stringForPath(const KCanvasPath* path);
-
// Resource creation
virtual KCanvasResource *createResource(const KCResourceType &type) const;
virtual KRenderingPaintServer *createPaintServer(const KCPaintServerType &type) const;
virtual KCanvasFilterEffect *createFilterEffect(const KCFilterEffectType &type) const;
- virtual KCanvasPath* createPath() const;
// item creation
- virtual RenderPath *createItem(RenderArena *arena, RenderStyle *style, SVGStyledElement *node, KCanvasPath* path) const;
+ virtual RenderPath *createItem(RenderArena *arena, RenderStyle *style, SVGStyledElement *node, const Path& path) const;
// filters (mostly debugging)
static bool filtersEnabled();
#import "KCanvasFilterQuartz.h"
#import "KCanvasItemQuartz.h"
#import "KCanvasMaskerQuartz.h"
-#import "KCanvasPathQuartz.h"
#import "KCanvasResourcesQuartz.h"
#import "KRenderingFillPainter.h"
#import "KRenderingPaintServerQuartz.h"
CGContextBeginPath(m_cgContext);
}
-void KRenderingDeviceContextQuartz::addPath(const KCanvasPath *path)
+void KRenderingDeviceContextQuartz::addPath(const Path& path)
{
- CGContextAddPath(m_cgContext, static_cast<const KCanvasPathQuartz*>(path)->cgPath());
+ CGContextAddPath(m_cgContext, path.platformPath());
}
NSGraphicsContext *KRenderingDeviceContextQuartz::nsGraphicsContext()
return new KRenderingDeviceContextQuartz(CGLayerGetContext(cgLayer));
}
-#pragma mark -
-#pragma mark Path Management
-
-KCanvasPath* KRenderingDeviceQuartz::createPath() const
-{
- return new KCanvasPathQuartz();
-}
-
-DeprecatedString KRenderingDeviceQuartz::stringForPath(const KCanvasPath *path)
-{
- DeprecatedString result;
- if (path) {
- CGPathRef cgPath = static_cast<const KCanvasPathQuartz *>(path)->cgPath();
- CFStringRef pathString = CFStringFromCGPath(cgPath);
- result = DeprecatedString::fromCFString(pathString);
- CFRelease(pathString);
- }
- return result;
-}
-
#pragma mark -
#pragma mark Resource Creation
return newServer;
}
-RenderPath *KRenderingDeviceQuartz::createItem(RenderArena *arena, RenderStyle *style, SVGStyledElement *node, KCanvasPath* path) const
+RenderPath *KRenderingDeviceQuartz::createItem(RenderArena *arena, RenderStyle *style, SVGStyledElement *node, const Path& path) const
{
RenderPath *item = new (arena) KCanvasItemQuartz(style, node);
item->setPath(path);
namespace WebCore {
+typedef struct CGPath *CGMutablePathRef;
+
+class Path;
class IntRect;
+class FloatRect;
+class FloatPoint;
class RenderStyle;
class RenderObject;
+class KRenderingStrokePainter;
#ifndef NDEBUG
void debugDumpCGImageToFile(NSString *filename, CGImageRef image, int width, int height);
void applyStrokeStyleToContext(CGContextRef, const KRenderingStrokePainter&);
void applyStrokeStyleToContext(CGContextRef, RenderStyle*, const RenderObject*);
+FloatRect strokeBoundingBox(const Path& path, const KRenderingStrokePainter& strokePainter);
+bool pathContainsPoint(CGMutablePathRef cgPath, const FloatPoint& point, CGPathDrawingMode drawMode);
+
static inline CGLineCap CGLineCapFromKC(KCCapStyle cap)
{
if (cap == CAP_BUTT)
applyStrokeStyleToContext(context, strokePainter);
}
-void CGPathToCFStringApplierFunction(void *info, const CGPathElement *element)
+CGContextRef scratchContext()
{
- CFMutableStringRef string = (CFMutableStringRef)info;
- CFStringRef typeString = CFSTR("");
- CGPoint *points = element->points;
- switch(element->type) {
- case kCGPathElementMoveToPoint:
- CFStringAppendFormat(string, 0, CFSTR("M%.2f,%.2f"), points[0].x, points[0].y);
- break;
- case kCGPathElementAddLineToPoint:
- CFStringAppendFormat(string, 0, CFSTR("L%.2f,%.2f"), points[0].x, points[0].y);
- break;
- case kCGPathElementAddQuadCurveToPoint:
- CFStringAppendFormat(string, 0, CFSTR("Q%.2f,%.2f,%.2f,%.2f"),
- points[0].x, points[0].y, points[1].x, points[1].y);
- break;
- case kCGPathElementAddCurveToPoint:
- CFStringAppendFormat(string, 0, CFSTR("C%.2f,%.2f,%.2f,%.2f,%.2f,%.2f"),
- points[0].x, points[0].y, points[1].x, points[1].y,
- points[2].x, points[2].y);
- break;
- case kCGPathElementCloseSubpath:
- typeString = CFSTR("X"); break;
- }
+ static CGContextRef scratch = 0;
+ if (!scratch) {
+ CFMutableDataRef empty = CFDataCreateMutable(NULL, 0);
+ CGDataConsumerRef consumer = CGDataConsumerCreateWithCFData(empty);
+ scratch = CGPDFContextCreate(consumer, NULL, NULL);
+ CGDataConsumerRelease(consumer);
+ CFRelease(empty);
+
+ CGFloat black[4] = {0, 0, 0, 1};
+ CGContextSetFillColor(scratch, black);
+ CGContextSetStrokeColor(scratch, black);
+ }
+ return scratch;
+}
+
+FloatRect strokeBoundingBox(const Path& path, const KRenderingStrokePainter& strokePainter)
+ {
+ // the bbox might grow if the path is stroked.
+ // and CGPathGetBoundingBox doesn't support that, so we'll have
+ // to make an alternative call...
+
+ // FIXME: since this is mainly used to decide what to repaint,
+ // perhaps it would be sufficien to just outset the fill bbox by
+ // the stroke width - that should be way cheaper and simpler than
+ // what we do here.
+
+ CGPathRef cgPath = path.platformPath();
+
+ CGContextRef context = scratchContext();
+ CGContextSaveGState(context);
+
+ CGContextBeginPath(context);
+ CGContextAddPath(context, cgPath);
+ applyStrokeStyleToContext(context, strokePainter);
+ CGContextReplacePathWithStrokedPath(context);
+ CGRect box = CGContextGetPathBoundingBox(context);
+
+ CGContextRestoreGState(context);
+
+ return FloatRect(box);
}
-CFStringRef CFStringFromCGPath(CGPathRef path)
+bool pathContainsPoint(CGMutablePathRef cgPath, const FloatPoint& point, CGPathDrawingMode drawMode)
{
- if (!path)
- return 0;
+ CGContextRef context = scratchContext();
+ CGContextSaveGState(context);
+
+ CGContextBeginPath(context);
+ CGContextAddPath(context, cgPath);
+ bool hitSuccess = CGContextPathContainsPoint(context, point, drawMode);
- CFMutableStringRef string = CFStringCreateMutable(NULL, 0);
- CGPathApply(path, string, CGPathToCFStringApplierFunction);
+ CGContextRestoreGState(context);
- return string;
+ return hitSuccess;
}
}
*/
case SVGCSS_PROP_POINTER_EVENTS:
- // visiblePainted | visibleFill | visibleStroke | visible |
+ // none | visiblePainted | visibleFill | visibleStroke | visible |
// painted | fill | stroke | none | all | inherit
if (id == CSS_VAL_VISIBLE || id == CSS_VAL_NONE ||
(id >= SVGCSS_VAL_VISIBLEPAINTED && id <= SVGCSS_VAL_ALL))
switch (primitiveValue->getIdent())
{
case SVGCSS_VAL_NONZERO:
- svgstyle->setClipRule(WR_NONZERO);
+ svgstyle->setClipRule(RULE_NONZERO);
break;
case SVGCSS_VAL_EVENODD:
- svgstyle->setClipRule(WR_EVENODD);
+ svgstyle->setClipRule(RULE_EVENODD);
break;
default:
break;
switch (primitiveValue->getIdent())
{
case SVGCSS_VAL_NONZERO:
- svgstyle->setFillRule(WR_NONZERO);
+ svgstyle->setFillRule(RULE_NONZERO);
break;
case SVGCSS_VAL_EVENODD:
- svgstyle->setFillRule(WR_EVENODD);
+ svgstyle->setFillRule(RULE_EVENODD);
default:
return;
}
SVG_RS_DEFINE_ATTRIBUTE(EDominantBaseline, DominantBaseline, dominantBaseline, DB_AUTO)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(ECapStyle, CapStyle, capStyle, CS_BUTT)
- SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EWindRule, ClipRule, clipRule, WR_NONZERO)
+ SVG_RS_DEFINE_ATTRIBUTE_INHERITED(WindRule, ClipRule, clipRule, RULE_NONZERO)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EColorInterpolation, ColorInterpolation, colorInterpolation, CI_SRGB)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EColorInterpolation, ColorInterpolationFilters, colorInterpolationFilters, CI_LINEARRGB)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EColorRendering, ColorRendering, colorRendering, CR_AUTO)
- SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EWindRule, FillRule, fillRule, WR_NONZERO)
+ SVG_RS_DEFINE_ATTRIBUTE_INHERITED(WindRule, FillRule, fillRule, RULE_NONZERO)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EImageRendering, ImageRendering, imageRendering, IR_AUTO)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EJoinStyle, JoinStyle, joinStyle, JS_MITER)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EPointerEvents, PointerEvents, pointerEvents, PE_VISIBLE_PAINTED)
unsigned _imageRendering : 2; // EImageRendering
unsigned _shapeRendering : 2; // EShapeRendering
unsigned _textRendering : 2; // ETextRendering
- unsigned _clipRule : 1; // EWindRule
- unsigned _fillRule : 1; // EWindRule
+ unsigned _clipRule : 1; // WindRule
+ unsigned _fillRule : 1; // WindRule
unsigned _capStyle : 2; // ECapStyle
unsigned _joinStyle : 2; // EJoinStyle
unsigned _textAnchor : 2; // ETextAnchor
#ifdef SVG_SUPPORT
#include "DeprecatedString.h"
+#include "Path.h"
// Helper macros for 'SVGRenderStyle'
#define SVG_RS_DEFINE_ATTRIBUTE(Data, Type, Name, Initial) \
namespace WebCore {
- enum EWindRule {
- WR_NONZERO = 0, WR_EVENODD = 1
- };
-
enum ECapStyle {
CS_BUTT = 1, CS_ROUND = 2, CS_SQUARE = 3
};
#include "CSSValueList.h"
#include "Document.h"
-#include "KCanvasPath.h"
#include "KCanvasRenderingStyle.h"
#include "KRenderingDevice.h"
#include "KRenderingFillPainter.h"
{
KRenderingFillPainter fillPainter;
- fillPainter.setFillRule(style->svgStyle()->fillRule() == WR_NONZERO ? RULE_NONZERO : RULE_EVENODD);
+ fillPainter.setFillRule(style->svgStyle()->fillRule());
fillPainter.setOpacity(style->svgStyle()->fillOpacity());
return fillPainter;
#ifdef SVG_SUPPORT
#include "Attr.h"
+#include "FloatPoint.h"
+
#include "SVGNames.h"
#include "SVGHelper.h"
#include "SVGCircleElement.h"
}
}
-KCanvasPath* SVGCircleElement::toPathData() const
+Path SVGCircleElement::toPathData() const
{
float _cx = cx()->baseVal()->value(), _cy = cy()->baseVal()->value();
float _r = r()->baseVal()->value();
- return KCanvasCreator::self()->createCircle(_cx, _cy, _r);
+ return KCanvasCreator::self()->createCircle(FloatPoint(_cx, _cy), _r);
}
const SVGStyledElement *SVGCircleElement::pushAttributeContext(const SVGStyledElement *context)
virtual void parseMappedAttribute(MappedAttribute *attr);
virtual bool rendererIsNeeded(RenderStyle *style) { return StyledElement::rendererIsNeeded(style); }
- virtual KCanvasPath* toPathData() const;
+ virtual Path toPathData() const;
virtual const SVGStyledElement *pushAttributeContext(const SVGStyledElement *context);
#include "SVGRenderStyle.h"
#include "cssstyleselector.h"
#include "ksvg.h"
-#include <kcanvas/KCanvasPath.h>
#include <kcanvas/device/KRenderingDevice.h>
using namespace WebCore;
if (e && e->isStyled()) {
SVGStyledElement *styled = static_cast<SVGStyledElement *>(e);
RenderStyle *pathStyle = document()->styleSelector()->styleForElement(styled, clipPathStyle);
- if (KCanvasPath* pathData = styled->toPathData())
- m_clipper->addClipData(pathData, (KCWindRule) pathStyle->svgStyle()->clipRule(), bbox);
+ Path pathData = styled->toPathData();
+ if (!pathData.isEmpty())
+ m_clipper->addClipData(pathData, pathStyle->svgStyle()->clipRule(), bbox);
pathStyle->deref(view()->renderArena());
}
}
#ifdef SVG_SUPPORT
#include "Attr.h"
+#include "FloatPoint.h"
+
#include "SVGNames.h"
#include "SVGHelper.h"
#include "SVGEllipseElement.h"
}
}
-KCanvasPath* SVGEllipseElement::toPathData() const
+Path SVGEllipseElement::toPathData() const
{
float _cx = cx()->baseVal()->value(), _cy = cy()->baseVal()->value();
float _rx = rx()->baseVal()->value(), _ry = ry()->baseVal()->value();
- return KCanvasCreator::self()->createEllipse(_cx, _cy, _rx, _ry);
+ return KCanvasCreator::self()->createEllipse(FloatPoint(_cx, _cy), _rx, _ry);
}
const SVGStyledElement *SVGEllipseElement::pushAttributeContext(const SVGStyledElement *context)
virtual void parseMappedAttribute(MappedAttribute *attr);
virtual bool rendererIsNeeded(RenderStyle *style) { return StyledElement::rendererIsNeeded(style); }
- virtual KCanvasPath* toPathData() const;
+ virtual Path toPathData() const;
virtual const SVGStyledElement *pushAttributeContext(const SVGStyledElement *context);
m_resource->invalidate(); // should this be added to build gradient?
- const KCanvasItemList &clients = m_resource->clients();
- for(KCanvasItemList::ConstIterator it = clients.begin(); it != clients.end(); ++it)
+ const RenderPathList &clients = m_resource->clients();
+ for(RenderPathList::ConstIterator it = clients.begin(); it != clients.end(); ++it)
{
const RenderPath *current = (*it);
SVGStyledElement *styled = (current ? static_cast<SVGStyledElement *>(current->element()) : 0);
#include <kcanvas/RenderSVGContainer.h>
#include <kcanvas/KCanvasCreator.h>
#include <kcanvas/KCanvasImage.h>
-#include <kcanvas/KCanvasPath.h>
#include <wtf/Assertions.h>
using namespace WebCore;
#ifdef SVG_SUPPORT
#include "Attr.h"
+#include "FloatPoint.h"
+
#include "SVGNames.h"
#include "SVGHelper.h"
#include "SVGLineElement.h"
}
}
-KCanvasPath* SVGLineElement::toPathData() const
+Path SVGLineElement::toPathData() const
{
float _x1 = x1()->baseVal()->value(), _y1 = y1()->baseVal()->value();
float _x2 = x2()->baseVal()->value(), _y2 = y2()->baseVal()->value();
- return KCanvasCreator::self()->createLine(_x1, _y1, _x2, _y2);
+ return KCanvasCreator::self()->createLine(FloatPoint(_x1, _y1), FloatPoint(_x2, _y2));
}
const SVGStyledElement *SVGLineElement::pushAttributeContext(const SVGStyledElement *context)
virtual void parseMappedAttribute(MappedAttribute *attr);
virtual bool rendererIsNeeded(RenderStyle *style) { return StyledElement::rendererIsNeeded(style); }
- virtual KCanvasPath* toPathData() const;
+ virtual Path toPathData() const;
virtual const SVGStyledElement *pushAttributeContext(const SVGStyledElement *context);
#include "GraphicsContext.h"
#include "RenderSVGContainer.h"
#include "KCanvasImage.h"
-#include "KCanvasPath.h"
#include "KRenderingDevice.h"
#include "SVGAnimatedLength.h"
#include "SVGHelper.h"
}
// FIXME: This probably belongs on SVGPathSegList instead. -- ecs 12/5/05
-KCanvasPath* SVGPathElement::toPathData() const
+Path SVGPathElement::toPathData() const
{
+ Path pathData;
// TODO : also support non-normalized mode, at least in dom structure
int len = pathSegList()->numberOfItems();
if(len < 1)
- return 0;
+ return pathData;
- KCanvasPath* pathData = renderingDevice()->createPath();
for(int i = 0; i < len; ++i)
{
SVGPathSeg *p = pathSegList()->getItem(i);
case PATHSEG_MOVETO_ABS:
{
SVGPathSegMovetoAbs *moveTo = static_cast<SVGPathSegMovetoAbs *>(p);
- pathData->moveTo(moveTo->x(), moveTo->y());
+ pathData.moveTo(FloatPoint(moveTo->x(), moveTo->y()));
break;
}
case PATHSEG_LINETO_ABS:
{
SVGPathSegLinetoAbs *lineTo = static_cast<SVGPathSegLinetoAbs *>(p);
- pathData->lineTo(lineTo->x(), lineTo->y());
+ pathData.addLineTo(FloatPoint(lineTo->x(), lineTo->y()));
break;
}
case PATHSEG_CURVETO_CUBIC_ABS:
{
SVGPathSegCurvetoCubicAbs *curveTo = static_cast<SVGPathSegCurvetoCubicAbs *>(p);
- pathData->curveTo(curveTo->x1(), curveTo->y1(),
- curveTo->x2(), curveTo->y2(),
- curveTo->x(), curveTo->y());
+ pathData.addBezierCurveTo(FloatPoint(curveTo->x1(), curveTo->y1()),
+ FloatPoint(curveTo->x2(), curveTo->y2()),
+ FloatPoint(curveTo->x(), curveTo->y()));
break;
}
case PATHSEG_CLOSEPATH:
- pathData->closeSubpath();
+ pathData.closeSubpath();
default:
break;
}
virtual void parseMappedAttribute(MappedAttribute *attr);
virtual bool rendererIsNeeded(RenderStyle *style) { return StyledElement::rendererIsNeeded(style); }
- virtual KCanvasPath* toPathData() const;
+ virtual Path toPathData() const;
private:
mutable RefPtr<SVGPathSegList> m_pathSegList;
void SVGPatternElement::notifyClientsToRepaint() const
{
- const KCanvasItemList &clients = m_paintServer->clients();
+ const RenderPathList &clients = m_paintServer->clients();
- KCanvasItemList::ConstIterator it = clients.begin();
- KCanvasItemList::ConstIterator end = clients.end();
+ RenderPathList::ConstIterator it = clients.begin();
+ RenderPathList::ConstIterator end = clients.end();
for(; it != end; ++it)
{
{
}
-KCanvasPath* SVGPolygonElement::toPathData() const
+Path SVGPolygonElement::toPathData() const
{
+ Path polyData;
int len = points()->numberOfItems();
if(len < 1)
- return 0;
+ return polyData;
- KCanvasPath* polyData = renderingDevice()->createPath();
- polyData->moveTo(points()->getItem(0)->x(), points()->getItem(0)->y());
+ polyData.moveTo(FloatPoint(points()->getItem(0)->x(), points()->getItem(0)->y()));
for (int i = 1; i < len; ++i) {
SVGPoint *p = points()->getItem(i);
- polyData->lineTo(p->x(), p->y());
+ polyData.addLineTo(FloatPoint(p->x(), p->y()));
}
- polyData->closeSubpath();
+ polyData.closeSubpath();
+
return polyData;
}
SVGPolygonElement(const QualifiedName&, Document*);
virtual ~SVGPolygonElement();
- virtual KCanvasPath* toPathData() const;
+ virtual Path toPathData() const;
};
} // namespace WebCore
{
}
-KCanvasPath* SVGPolylineElement::toPathData() const
+Path SVGPolylineElement::toPathData() const
{
+ Path polyData;
int len = points()->numberOfItems();
if(len < 1)
- return 0;
+ return polyData;
- KCanvasPath* polyData = renderingDevice()->createPath();
- polyData->moveTo(points()->getItem(0)->x(), points()->getItem(0)->y());
+ polyData.moveTo(FloatPoint(points()->getItem(0)->x(), points()->getItem(0)->y()));
for (int i = 1; i < len; ++i) {
SVGPoint *p = points()->getItem(i);
- polyData->lineTo(p->x(), p->y());
+ polyData.addLineTo(FloatPoint(p->x(), p->y()));
}
-
return polyData;
}
SVGPolylineElement(const QualifiedName&, Document*);
virtual ~SVGPolylineElement();
- virtual KCanvasPath* toPathData() const;
+ virtual Path toPathData() const;
};
} // namespace WebCore
}
}
-KCanvasPath* SVGRectElement::toPathData() const
+Path SVGRectElement::toPathData() const
{
float _x = x()->baseVal()->value(), _y = y()->baseVal()->value();
float _width = width()->baseVal()->value(), _height = height()->baseVal()->value();
{
float _rx = hasRx ? rx()->baseVal()->value() : ry()->baseVal()->value();
float _ry = hasRy ? ry()->baseVal()->value() : rx()->baseVal()->value();
- return KCanvasCreator::self()->createRoundedRectangle(_x, _y, _width, _height, _rx, _ry);
+ return KCanvasCreator::self()->createRoundedRectangle(FloatRect(_x, _y, _width, _height), FloatSize(_rx, _ry));
}
- return KCanvasCreator::self()->createRectangle(_x, _y, _width, _height);
+ return KCanvasCreator::self()->createRectangle(FloatRect(_x, _y, _width, _height));
}
const SVGStyledElement *SVGRectElement::pushAttributeContext(const SVGStyledElement *context)
virtual void parseMappedAttribute(MappedAttribute *attr);
virtual bool rendererIsNeeded(RenderStyle *style) { return StyledElement::rendererIsNeeded(style); }
- virtual KCanvasPath* toPathData() const;
+ virtual Path toPathData() const;
virtual const SVGStyledElement *pushAttributeContext(const SVGStyledElement *context);
RenderObject* SVGStyledElement::createRenderer(RenderArena* arena, RenderStyle* style)
{
- RefPtr<KCanvasPath> pathData = toPathData();
- if (!pathData)
+ Path pathData = toPathData();
+ if (pathData.isEmpty())
return 0;
- return renderingDevice()->createItem(arena, style, this, pathData.get());
+ return renderingDevice()->createItem(arena, style, this, pathData);
}
void SVGStyledElement::parseMappedAttribute(MappedAttribute* attr)
#include "RenderStyle.h"
#include "SVGElement.h"
#include "SVGStylable.h"
-#include <kcanvas/KCanvasPath.h>
+#include "Path.h"
namespace WebCore {
// These need to be implemented.
virtual bool rendererIsNeeded(RenderStyle*) { return false; }
- virtual KCanvasPath* toPathData() const { return 0; }
+ virtual Path toPathData() const { return Path(); }
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
virtual KCanvasResource* canvasResource() { return 0; }
#include "SVGTextContentElement.h"
#include "SVGAnimatedLength.h"
#include "SVGAnimatedEnumeration.h"
+#include "FloatPoint.h"
+#include "FloatRect.h"
using namespace WebCore;
#include "RenderStyle.h"
#include <kcanvas/KCanvasCreator.h>
#include <kcanvas/RenderSVGText.h>
+#include "FloatRect.h"
namespace WebCore {
/*
* Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
+ * 2006 Rob Buis <buis@kde.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
namespace WebCore {
+ enum WindRule {
+ RULE_NONZERO = 0,
+ RULE_EVENODD = 1
+ };
+
class FloatPoint;
class FloatSize;
class FloatRect;
+ class String;
class Path {
public:
Path(const Path&);
Path& operator=(const Path&);
- bool contains(const FloatPoint&) const;
+ bool contains(const FloatPoint&, WindRule rule = RULE_NONZERO) const;
FloatRect boundingRect() const;
void clear();
+ bool isEmpty() const;
void moveTo(const FloatPoint&);
void addLineTo(const FloatPoint&);
void translate(const FloatSize&);
+ void setWindingRule(WindRule rule) { m_rule = rule; }
+ WindRule windingRule() const { return m_rule; }
+
+ String debugString() const;
+
PlatformPath* platformPath() const { return m_path; }
private:
PlatformPath* m_path;
+ WindRule m_rule;
};
}
/*
* Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
+ * 2006 Rob Buis <buis@kde.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#if PLATFORM(CG)
#include "FloatRect.h"
+#include "PlatformString.h"
#include <ApplicationServices/ApplicationServices.h>
namespace WebCore {
return *this;
}
-bool Path::contains(const FloatPoint& point) const
+bool Path::contains(const FloatPoint &point, WindRule rule) const
{
- return CGPathContainsPoint(m_path, 0, point, false);
+ return CGPathContainsPoint(m_path, 0, point, rule == RULE_EVENODD ? true : false);
}
void Path::translate(const FloatSize& size)
m_path = CGPathCreateMutable();
}
+bool Path::isEmpty() const
+{
+ return CGPathIsEmpty(m_path);
+ }
+
+void CGPathToCFStringApplierFunction(void *info, const CGPathElement *element)
+{
+ CFMutableStringRef string = (CFMutableStringRef)info;
+ CFStringRef typeString = CFSTR("");
+ CGPoint *points = element->points;
+ switch(element->type) {
+ case kCGPathElementMoveToPoint:
+ CFStringAppendFormat(string, 0, CFSTR("M%.2f,%.2f"), points[0].x, points[0].y);
+ break;
+ case kCGPathElementAddLineToPoint:
+ CFStringAppendFormat(string, 0, CFSTR("L%.2f,%.2f"), points[0].x, points[0].y);
+ break;
+ case kCGPathElementAddQuadCurveToPoint:
+ CFStringAppendFormat(string, 0, CFSTR("Q%.2f,%.2f,%.2f,%.2f"),
+ points[0].x, points[0].y, points[1].x, points[1].y);
+ break;
+ case kCGPathElementAddCurveToPoint:
+ CFStringAppendFormat(string, 0, CFSTR("C%.2f,%.2f,%.2f,%.2f,%.2f,%.2f"),
+ points[0].x, points[0].y, points[1].x, points[1].y,
+ points[2].x, points[2].y);
+ break;
+ case kCGPathElementCloseSubpath:
+ typeString = CFSTR("X"); break;
+ }
+}
+
+CFStringRef CFStringFromCGPath(CGPathRef path)
+{
+ if (!path)
+ return 0;
+
+ CFMutableStringRef string = CFStringCreateMutable(NULL, 0);
+ CGPathApply(path, string, CGPathToCFStringApplierFunction);
+
+ return string;
+}
+
+
+#pragma mark -
+#pragma mark Path Management
+
+String Path::debugString() const
+{
+ String result;
+ if (!isEmpty()) {
+ CFStringRef pathString = CFStringFromCGPath(m_path);
+ result = String(pathString);
+ CFRelease(pathString);
+ }
+ return result;
+}
+
}
#endif // PLATFORM(CG)
/*
* Copyright (C) 2006 Zack Rusin <zack@kde.org>
+ * 2006 Rob Buis <buis@kde.org>
*
* All rights reserved.
*
#include "Path.h"
#include "FloatRect.h"
+#include "PlatformString.h"
#include <QPainterPath>
#include <QMatrix>
+#include <QString>
#include <math.h>
return *this;
}
-bool Path::contains(const FloatPoint& point) const
+bool Path::contains(const FloatPoint& point, WindRule rule) const
{
- return m_path->contains(point);
+ Qt::FillRule savedRule = m_path->fillRule();
+ m_path->setFillRule(rule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
+
+ bool contains = m_path->contains(point);
+
+ m_path->setFillRule(savedRule);
+ return contains;
}
void Path::translate(const FloatSize& size)
*m_path = QPainterPath();
}
+bool Path::isEmpty() const
+{
+ return m_path->isEmpty();
+}
+
+String Path::debugString() const
+{
+ QString ret;
+ for (int i = 0; i < m_path->elementCount(); ++i) {
+ const QPainterPath::Element &cur = m_path->elementAt(i);
+
+ switch (cur.type) {
+ case QPainterPath::MoveToElement:
+ ret += QString("M %1 %2").arg(cur.x).arg(cur.y);
+ break;
+ case QPainterPath::LineToElement:
+ ret += QString("L %1 %2").arg(cur.x).arg(cur.y);
+ break;
+ case QPainterPath::CurveToElement:
+ {
+ const QPainterPath::Element &c1 = m_path->elementAt(i + 1);
+ const QPainterPath::Element &c2 = m_path->elementAt(i + 2);
+
+ Q_ASSERT(c1.type == QPainterPath::CurveToDataElement);
+ Q_ASSERT(c2.type == QPainterPath::CurveToDataElement);
+
+ ret += QString("C %1 %2 %3 %4 %5 %6").arg(cur.x).arg(cur.y).arg(c1.x).arg(c1.y).arg(c2.x).arg(c2.y);
+
+ i += 2;
+ break;
+ }
+ case QPainterPath::CurveToDataElement:
+ Q_ASSERT(false);
+ break;
+ }
+ }
+
+ return ret;
+}
+
}
// vim: ts=4 sw=4 et