Changeset 69517 in webkit
- Timestamp:
- Oct 11, 2010 12:19:05 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r69516 r69517 1 2010-10-11 Andreas Kling <kling@webkit.org> 2 3 Reviewed by Dirk Schulze. 4 5 SVG: Remove "create" methods and use port-specific "add" counterparts 6 https://bugs.webkit.org/show_bug.cgi?id=46052 7 8 Circles and ellipses will be significantly faster on platforms that 9 implement Path::addEllipse() in a sane fashion. 10 11 Also, a lot of Path copying has been factored out by changing functions 12 that would return Paths to take Path& arguments instead (toPathData, toClipPath) 13 14 * mathml/RenderMathMLRoot.cpp: 15 (WebCore::RenderMathMLRoot::paint): 16 * mathml/RenderMathMLSquareRoot.cpp: 17 (WebCore::RenderMathMLSquareRoot::paint): 18 * platform/graphics/GraphicsContext.cpp: 19 (WebCore::GraphicsContext::addRoundedRectClip): 20 (WebCore::GraphicsContext::clipOutRoundedRect): 21 * platform/graphics/Path.cpp: 22 (WebCore::pathLengthApplierFunction): 23 (WebCore::Path::addRoundedRect): 24 * platform/graphics/Path.h: 25 * platform/graphics/cairo/ContextShadowCairo.cpp: 26 (WebCore::ContextShadow::drawRectShadowWithoutTiling): 27 (WebCore::ContextShadow::drawRectShadow): 28 * platform/graphics/cairo/GraphicsContextCairo.cpp: 29 (WebCore::GraphicsContext::drawFocusRing): 30 (WebCore::GraphicsContext::drawTiledShadow): 31 (WebCore::GraphicsContext::fillRoundedRect): 32 * platform/graphics/cg/GraphicsContextCG.cpp: 33 (WebCore::GraphicsContext::fillRoundedRect): 34 * platform/graphics/qt/GraphicsContextQt.cpp: 35 (WebCore::GraphicsContext::fillRoundedRect): 36 * rendering/RenderBoxModelObject.cpp: 37 (WebCore::RenderBoxModelObject::paintBorder): 38 (WebCore::RenderBoxModelObject::paintBoxShadow): 39 * rendering/RenderEmbeddedObject.cpp: 40 (WebCore::RenderEmbeddedObject::getReplacementTextGeometry): 41 * rendering/RenderSVGResourceClipper.cpp: 42 (WebCore::RenderSVGResourceClipper::pathOnlyClipping): 43 * rendering/svg/RenderSVGPath.cpp: 44 (WebCore::RenderSVGPath::layout): 45 * rendering/svg/RenderSVGTextPath.cpp: 46 (WebCore::RenderSVGTextPath::layoutPath): 47 * rendering/svg/SVGInlineTextBox.cpp: 48 (WebCore::SVGInlineTextBox::paintDecorationWithStyle): 49 * svg/SVGAnimateMotionElement.cpp: 50 (WebCore::SVGAnimateMotionElement::animationPath): 51 * svg/SVGCircleElement.cpp: 52 (WebCore::SVGCircleElement::toPathData): 53 * svg/SVGCircleElement.h: 54 * svg/SVGEllipseElement.cpp: 55 (WebCore::SVGEllipseElement::toPathData): 56 * svg/SVGEllipseElement.h: 57 * svg/SVGLineElement.cpp: 58 (WebCore::SVGLineElement::toPathData): 59 * svg/SVGLineElement.h: 60 * svg/SVGPathElement.cpp: 61 (WebCore::SVGPathElement::getTotalLength): 62 (WebCore::SVGPathElement::getPointAtLength): 63 (WebCore::SVGPathElement::toPathData): 64 * svg/SVGPathElement.h: 65 * svg/SVGPolygonElement.cpp: 66 (WebCore::SVGPolygonElement::toPathData): 67 * svg/SVGPolygonElement.h: 68 * svg/SVGPolylineElement.cpp: 69 (WebCore::SVGPolylineElement::toPathData): 70 * svg/SVGPolylineElement.h: 71 * svg/SVGRectElement.cpp: 72 (WebCore::SVGRectElement::toPathData): 73 * svg/SVGRectElement.h: 74 * svg/SVGStyledTransformableElement.cpp: 75 (WebCore::SVGStyledTransformableElement::toClipPath): 76 * svg/SVGStyledTransformableElement.h: 77 (WebCore::SVGStyledTransformableElement::toPathData): 78 * svg/SVGUseElement.cpp: 79 (WebCore::SVGUseElement::toClipPath): 80 * svg/SVGUseElement.h: 81 1 82 2010-10-01 Oliver Hunt <oliver@apple.com> 2 83 -
trunk/WebCore/mathml/RenderMathMLRoot.cpp
r66403 r69517 191 191 192 192 Path line; 193 194 line = line.createLine(bottomLeft,topLeft);195 193 line.moveTo(bottomLeft); 194 line.addLineTo(topLeft); 195 196 196 info.context->beginPath(); 197 197 info.context->addPath(line); -
trunk/WebCore/mathml/RenderMathMLSquareRoot.cpp
r64596 r69517 157 157 158 158 Path line; 159 160 line = line.createLine(bottomLeft,topLeft);159 line.moveTo(bottomLeft); 160 line.addLineTo(topLeft); 161 161 162 162 info.context->beginPath(); -
trunk/WebCore/platform/graphics/GraphicsContext.cpp
r67799 r69517 501 501 return; 502 502 503 clip(Path::createRoundedRectangle(rect, topLeft, topRight, bottomLeft, bottomRight)); 503 Path path; 504 path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight); 505 clip(path); 504 506 } 505 507 … … 510 512 return; 511 513 512 clipOut(Path::createRoundedRectangle(rect, topLeft, topRight, bottomLeft, bottomRight)); 514 Path path; 515 path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight); 516 clipOut(path); 513 517 } 514 518 -
trunk/WebCore/platform/graphics/Path.cpp
r66979 r69517 36 36 #include <wtf/MathExtras.h> 37 37 38 static const float QUARTER = 0.552f; // approximation of control point positions on a bezier 39 // to simulate a quarter of a circle. 38 // Approximation of control point positions on a bezier to simulate a quarter of a circle. 39 static const float gCircleControlPoint = 1 - 0.552; 40 40 41 namespace WebCore { 41 42 … … 48 49 traversalState.m_previous = traversalState.m_current; 49 50 FloatPoint* points = element->points; 50 float segmentLength = 0 .0f;51 float segmentLength = 0; 51 52 switch (element->type) { 52 53 case PathElementMoveToPoint: … … 76 77 float offset = traversalState.m_desiredLength - traversalState.m_totalLength; 77 78 traversalState.m_current.move(offset * cosf(slope), offset * sinf(slope)); 78 } else { 79 static const float rad2deg = 180.0f / piFloat; 80 traversalState.m_normalAngle = slope * rad2deg; 81 } 79 } else 80 traversalState.m_normalAngle = rad2deg(slope); 82 81 83 82 traversalState.m_success = true; … … 111 110 #endif 112 111 113 Path Path::createRoundedRectangle(const FloatRect& rectangle, const FloatSize& roundingRadii)112 void Path::addRoundedRect(const FloatRect& rect, const FloatSize& roundingRadii) 114 113 { 115 Path path; 116 float x = rectangle.x(); 117 float y = rectangle.y(); 118 float width = rectangle.width(); 119 float height = rectangle.height(); 120 float rx = roundingRadii.width(); 121 float ry = roundingRadii.height(); 122 if (width <= 0.0f || height <= 0.0f) 123 return path; 114 if (rect.isEmpty()) 115 return; 124 116 125 float dx = rx, dy = ry; 117 FloatSize radius(roundingRadii); 118 FloatSize halfSize(rect.width() / 2, rect.height() / 2); 119 126 120 // If rx is greater than half of the width of the rectangle 127 121 // then set rx to half of the width (required in SVG spec) 128 if ( dx > width * 0.5f)129 dx = width * 0.5f;122 if (radius.width() > halfSize.width()) 123 radius.setWidth(halfSize.width()); 130 124 131 125 // If ry is greater than half of the height of the rectangle 132 126 // then set ry to half of the height (required in SVG spec) 133 if ( dy > height * 0.5f)134 dy = height * 0.5f;127 if (radius.height() > halfSize.height()) 128 radius.setHeight(halfSize.height()); 135 129 136 path.moveTo(FloatPoint(x + dx, y));130 moveTo(FloatPoint(rect.x() + radius.width(), rect.y())); 137 131 138 if ( dx < width * 0.5f)139 path.addLineTo(FloatPoint(x + width - rx, y));132 if (radius.width() < halfSize.width()) 133 addLineTo(FloatPoint(rect.x() + rect.width() - roundingRadii.width(), rect.y())); 140 134 141 path.addBezierCurveTo(FloatPoint(x + width - dx * (1 - QUARTER), y), FloatPoint(x + width, y + dy * (1 - QUARTER)), FloatPoint(x + width, y + dy));135 addBezierCurveTo(FloatPoint(rect.x() + rect.width() - radius.width() * gCircleControlPoint, rect.y()), FloatPoint(rect.x() + rect.width(), rect.y() + radius.height() * gCircleControlPoint), FloatPoint(rect.x() + rect.width(), rect.y() + radius.height())); 142 136 143 if ( dy < height * 0.5)144 path.addLineTo(FloatPoint(x + width, y + height - dy));137 if (radius.height() < halfSize.height()) 138 addLineTo(FloatPoint(rect.x() + rect.width(), rect.y() + rect.height() - radius.height())); 145 139 146 path.addBezierCurveTo(FloatPoint(x + width, y + height - dy * (1 - QUARTER)), FloatPoint(x + width - dx * (1 - QUARTER), y + height), FloatPoint(x + width - dx, y + height));140 addBezierCurveTo(FloatPoint(rect.x() + rect.width(), rect.y() + rect.height() - radius.height() * gCircleControlPoint), FloatPoint(rect.x() + rect.width() - radius.width() * gCircleControlPoint, rect.y() + rect.height()), FloatPoint(rect.x() + rect.width() - radius.width(), rect.y() + rect.height())); 147 141 148 if ( dx < width * 0.5)149 path.addLineTo(FloatPoint(x + dx, y + height));142 if (radius.width() < halfSize.width()) 143 addLineTo(FloatPoint(rect.x() + radius.width(), rect.y() + rect.height())); 150 144 151 path.addBezierCurveTo(FloatPoint(x + dx * (1 - QUARTER), y + height), FloatPoint(x, y + height - dy * (1 - QUARTER)), FloatPoint(x, y + height - dy));145 addBezierCurveTo(FloatPoint(rect.x() + radius.width() * gCircleControlPoint, rect.y() + rect.height()), FloatPoint(rect.x(), rect.y() + rect.height() - radius.height() * gCircleControlPoint), FloatPoint(rect.x(), rect.y() + rect.height() - radius.height())); 152 146 153 if ( dy < height * 0.5)154 path.addLineTo(FloatPoint(x, y + dy));147 if (radius.height() < halfSize.height()) 148 addLineTo(FloatPoint(rect.x(), rect.y() + radius.height())); 155 149 156 path.addBezierCurveTo(FloatPoint(x, y + dy * (1 - QUARTER)), FloatPoint(x + dx * (1 - QUARTER), y), FloatPoint(x + dx, y));150 addBezierCurveTo(FloatPoint(rect.x(), rect.y() + radius.height() * gCircleControlPoint), FloatPoint(rect.x() + radius.width() * gCircleControlPoint, rect.y()), FloatPoint(rect.x() + radius.width(), rect.y())); 157 151 158 path.closeSubpath(); 159 160 return path; 152 closeSubpath(); 161 153 } 162 154 163 Path Path::createRoundedRectangle(const FloatRect& rectangle, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius)155 void Path::addRoundedRect(const FloatRect& rect, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius) 164 156 { 165 Path path; 157 if (rect.isEmpty()) 158 return; 166 159 167 float width = rectangle.width(); 168 float height = rectangle.height(); 169 if (width <= 0.0 || height <= 0.0) 170 return path; 171 172 if (width < topLeftRadius.width() + topRightRadius.width() 173 || width < bottomLeftRadius.width() + bottomRightRadius.width() 174 || height < topLeftRadius.height() + bottomLeftRadius.height() 175 || height < topRightRadius.height() + bottomRightRadius.height()) 160 if (rect.width() < topLeftRadius.width() + topRightRadius.width() 161 || rect.width() < bottomLeftRadius.width() + bottomRightRadius.width() 162 || rect.height() < topLeftRadius.height() + bottomLeftRadius.height() 163 || rect.height() < topRightRadius.height() + bottomRightRadius.height()) { 176 164 // If all the radii cannot be accommodated, return a rect. 177 return createRectangle(rectangle); 178 179 float x = rectangle.x(); 180 float y = rectangle.y(); 181 182 path.moveTo(FloatPoint(x + topLeftRadius.width(), y)); 183 184 path.addLineTo(FloatPoint(x + width - topRightRadius.width(), y)); 185 186 path.addBezierCurveTo(FloatPoint(x + width - topRightRadius.width() * (1 - QUARTER), y), FloatPoint(x + width, y + topRightRadius.height() * (1 - QUARTER)), FloatPoint(x + width, y + topRightRadius.height())); 187 188 path.addLineTo(FloatPoint(x + width, y + height - bottomRightRadius.height())); 189 190 path.addBezierCurveTo(FloatPoint(x + width, y + height - bottomRightRadius.height() * (1 - QUARTER)), FloatPoint(x + width - bottomRightRadius.width() * (1 - QUARTER), y + height), FloatPoint(x + width - bottomRightRadius.width(), y + height)); 191 192 path.addLineTo(FloatPoint(x + bottomLeftRadius.width(), y + height)); 193 194 path.addBezierCurveTo(FloatPoint(x + bottomLeftRadius.width() * (1 - QUARTER), y + height), FloatPoint(x, y + height - bottomLeftRadius.height() * (1 - QUARTER)), FloatPoint(x, y + height - bottomLeftRadius.height())); 195 196 path.addLineTo(FloatPoint(x, y + topLeftRadius.height())); 197 198 path.addBezierCurveTo(FloatPoint(x, y + topLeftRadius.height() * (1 - QUARTER)), FloatPoint(x + topLeftRadius.width() * (1 - QUARTER), y), FloatPoint(x + topLeftRadius.width(), y)); 199 200 path.closeSubpath(); 201 202 return path; 203 } 204 205 Path Path::createRectangle(const FloatRect& rectangle) 206 { 207 Path path; 208 float x = rectangle.x(); 209 float y = rectangle.y(); 210 float width = rectangle.width(); 211 float height = rectangle.height(); 212 if (width <= 0.0f || height <= 0.0f) 213 return path; 214 215 path.moveTo(FloatPoint(x, y)); 216 path.addLineTo(FloatPoint(x + width, y)); 217 path.addLineTo(FloatPoint(x + width, y + height)); 218 path.addLineTo(FloatPoint(x, y + height)); 219 path.closeSubpath(); 220 221 return path; 222 } 223 224 Path Path::createEllipse(const FloatPoint& center, float rx, float ry) 225 { 226 float cx = center.x(); 227 float cy = center.y(); 228 Path path; 229 if (rx <= 0.0f || ry <= 0.0f) 230 return path; 231 232 float x = cx; 233 float y = cy; 234 235 unsigned step = 0, num = 100; 236 bool running = true; 237 while (running) 238 { 239 if (step == num) 240 { 241 running = false; 242 break; 243 } 244 245 float angle = static_cast<float>(step) / static_cast<float>(num) * 2.0f * piFloat; 246 x = cx + cosf(angle) * rx; 247 y = cy + sinf(angle) * ry; 248 249 step++; 250 if (step == 1) 251 path.moveTo(FloatPoint(x, y)); 252 else 253 path.addLineTo(FloatPoint(x, y)); 165 addRect(rect); 166 return; 254 167 } 255 168 256 path.closeSubpath();169 moveTo(FloatPoint(rect.x() + topLeftRadius.width(), rect.y())); 257 170 258 return path; 259 } 171 addLineTo(FloatPoint(rect.x() + rect.width() - topRightRadius.width(), rect.y())); 172 addBezierCurveTo(FloatPoint(rect.x() + rect.width() - topRightRadius.width() * gCircleControlPoint, rect.y()), 173 FloatPoint(rect.x() + rect.width(), rect.y() + topRightRadius.height() * gCircleControlPoint), 174 FloatPoint(rect.x() + rect.width(), rect.y() + topRightRadius.height())); 175 addLineTo(FloatPoint(rect.x() + rect.width(), rect.y() + rect.height() - bottomRightRadius.height())); 176 addBezierCurveTo(FloatPoint(rect.x() + rect.width(), rect.y() + rect.height() - bottomRightRadius.height() * gCircleControlPoint), 177 FloatPoint(rect.x() + rect.width() - bottomRightRadius.width() * gCircleControlPoint, rect.y() + rect.height()), 178 FloatPoint(rect.x() + rect.width() - bottomRightRadius.width(), rect.y() + rect.height())); 179 addLineTo(FloatPoint(rect.x() + bottomLeftRadius.width(), rect.y() + rect.height())); 180 addBezierCurveTo(FloatPoint(rect.x() + bottomLeftRadius.width() * gCircleControlPoint, rect.y() + rect.height()), 181 FloatPoint(rect.x(), rect.y() + rect.height() - bottomLeftRadius.height() * gCircleControlPoint), 182 FloatPoint(rect.x(), rect.y() + rect.height() - bottomLeftRadius.height())); 183 addLineTo(FloatPoint(rect.x(), rect.y() + topLeftRadius.height())); 184 addBezierCurveTo(FloatPoint(rect.x(), rect.y() + topLeftRadius.height() * gCircleControlPoint), 185 FloatPoint(rect.x() + topLeftRadius.width() * gCircleControlPoint, rect.y()), 186 FloatPoint(rect.x() + topLeftRadius.width(), rect.y())); 260 187 261 Path Path::createCircle(const FloatPoint& center, float r) 262 { 263 return createEllipse(center, r, r); 264 } 265 266 Path Path::createLine(const FloatPoint& start, const FloatPoint& end) 267 { 268 Path path; 269 270 path.moveTo(start); 271 path.addLineTo(end); 272 273 return path; 188 closeSubpath(); 274 189 } 275 190 -
trunk/WebCore/platform/graphics/Path.h
r69505 r69517 138 138 void addRect(const FloatRect&); 139 139 void addEllipse(const FloatRect&); 140 void addRoundedRect(const FloatRect&, const FloatSize& roundingRadii); 141 void addRoundedRect(const FloatRect&, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius); 140 142 141 143 void translate(const FloatSize&); 142 144 143 145 PlatformPathPtr platformPath() const { return m_path; } 144 145 static Path createRoundedRectangle(const FloatRect&, const FloatSize& roundingRadii);146 static Path createRoundedRectangle(const FloatRect&, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius);147 static Path createRectangle(const FloatRect&);148 static Path createEllipse(const FloatPoint& center, float rx, float ry);149 static Path createCircle(const FloatPoint& center, float r);150 static Path createLine(const FloatPoint&, const FloatPoint&);151 146 152 147 void apply(void* info, PathApplierFunction) const; -
trunk/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp
r69223 r69517 135 135 return; 136 136 137 appendWebCorePathToCairoContext(m_layerContext, Path::createRoundedRectangle(shadowRect, topLeftRadius, topRightRadius, 138 bottomLeftRadius, bottomRightRadius)); 137 Path path; 138 path.addRoundedRect(shadowRect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius); 139 140 appendWebCorePathToCairoContext(m_layerContext, path); 139 141 cairo_set_source_rgba(m_layerContext, 0, 0, 0, alpha); 140 142 cairo_fill(m_layerContext); … … 241 243 // Draw the rectangle. 242 244 IntRect templateRect = IntRect(m_blurDistance, m_blurDistance, shadowTemplateSize.width() - radiusTwice, shadowTemplateSize.height() - radiusTwice); 243 appendWebCorePathToCairoContext(m_layerContext, Path::createRoundedRectangle(templateRect, topLeftRadius, topRightRadius, 244 bottomLeftRadius, bottomRightRadius)); 245 Path path; 246 path.addRoundedRect(templateRect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius); 247 appendWebCorePathToCairoContext(m_layerContext, path); 245 248 246 249 cairo_set_source_rgba(m_layerContext, 0, 0, 0, context->getAlpha()); … … 264 267 if (!shadowRect.isEmpty()) { 265 268 cairo_save(cr); 266 appendWebCorePathToCairoContext(cr, Path::createRoundedRectangle(shadowRect, topLeftRadius, 267 topRightRadius, bottomLeftRadius, bottomRightRadius)); 269 path.clear(); 270 path.addRoundedRect(shadowRect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius); 271 appendWebCorePathToCairoContext(cr, path); 268 272 setSourceRGBAFromColor(cr, m_color); 269 273 cairo_fill(cr); -
trunk/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
r69187 r69517 704 704 #else 705 705 int radius = (width - 1) / 2; 706 for (unsigned i = 0; i < rectCount; i++) 707 appendWebCorePathToCairoContext(cr, Path::createRoundedRectangle(rects[i], FloatSize(radius, radius))); 706 Path path; 707 for (unsigned i = 0; i < rectCount; ++i) { 708 if (i > 0) 709 path.clear(); 710 path.addRoundedRect(rects[i], FloatSize(radius, radius)); 711 appendWebCorePathToCairoContext(cr, path); 712 } 708 713 709 714 // Force the alpha to 50%. This matches what the Mac does with outline rings. … … 1276 1281 cairo_t* smallBufferContext = smallBuffer->context()->platformContext(); 1277 1282 copyContextProperties(cr, smallBufferContext); 1278 appendWebCorePathToCairoContext(smallBuffer->context()->platformContext(), Path::createRoundedRectangle(smallRect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius)); 1283 1284 Path path; 1285 path.addRoundedRect(smallRect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius); 1286 appendWebCorePathToCairoContext(smallBuffer->context()->platformContext(), path); 1279 1287 setPlatformFill(this, smallBufferContext, m_common); 1280 1288 … … 1295 1303 if (!shadowRect.isEmpty()) { 1296 1304 cairo_save(cr); 1297 appendWebCorePathToCairoContext(cr, Path::createRoundedRectangle(shadowRect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius)); 1305 path.clear(); 1306 path.addRoundedRect(shadowRect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius); 1307 appendWebCorePathToCairoContext(cr, path); 1298 1308 setColor(cr, shadowColor); 1299 1309 cairo_fill(cr); … … 1374 1384 cairo_t* cr = m_data->cr; 1375 1385 cairo_save(cr); 1376 appendWebCorePathToCairoContext(cr, Path::createRoundedRectangle(r, topLeft, topRight, bottomLeft, bottomRight)); 1386 Path path; 1387 path.addRoundedRect(r, topLeft, topRight, bottomLeft, bottomRight); 1388 appendWebCorePathToCairoContext(cr, path); 1377 1389 setColor(cr, color); 1378 1390 drawPathShadow(this, m_common, true, false); -
trunk/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
r69259 r69517 668 668 setCGFillColor(context, color, colorSpace); 669 669 670 addPath(Path::createRoundedRectangle(rect, topLeft, topRight, bottomLeft, bottomRight)); 670 Path path; 671 path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight); 672 addPath(path); 671 673 fillPath(); 672 674 -
trunk/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
r69493 r69517 730 730 return; 731 731 732 Path path = Path::createRoundedRectangle(rect, topLeft, topRight, bottomLeft, bottomRight); 732 Path path; 733 path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight); 733 734 QPainter* p = m_data->p(); 734 735 if (m_data->hasShadow()) { -
trunk/WebCore/rendering/RenderBoxModelObject.cpp
r68817 r69517 1062 1062 graphicsContext->clipOutRoundedRect(innerBorderRect, innerTopLeftRadius, innerTopRightRadius, innerBottomLeftRadius, innerBottomRightRadius); 1063 1063 1064 roundedPath = Path::createRoundedRectangle(borderRect, topLeft, topRight, bottomLeft, bottomRight);1064 roundedPath.addRoundedRect(borderRect, topLeft, topRight, bottomLeft, bottomRight); 1065 1065 graphicsContext->addPath(roundedPath); 1066 1066 } … … 1753 1753 context->save(); 1754 1754 1755 if (hasBorderRadius) 1756 context->clip(Path::createRoundedRectangle(rect, topLeft, topRight, bottomLeft, bottomRight)); 1757 else 1755 Path path; 1756 if (hasBorderRadius) { 1757 path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight); 1758 context->clip(path); 1759 path.clear(); 1760 } else 1758 1761 context->clip(rect); 1759 1762 … … 1762 1765 shadowOffset -= extraOffset; 1763 1766 1764 context->beginPath(); 1765 context->addPath(Path::createRectangle(outerRect)); 1767 path.addRect(outerRect); 1766 1768 1767 1769 if (hasBorderRadius) { 1768 1770 if (shadowSpread > 0) 1769 1771 uniformlyExpandBorderRadii(-shadowSpread, topLeft, topRight, bottomLeft, bottomRight); 1770 context->addPath(Path::createRoundedRectangle(holeRect, topLeft, topRight, bottomLeft, bottomRight));1772 path.addRoundedRect(holeRect, topLeft, topRight, bottomLeft, bottomRight); 1771 1773 } else 1772 context->addPath(Path::createRectangle(holeRect)); 1774 path.addRect(holeRect); 1775 1776 context->beginPath(); 1777 context->addPath(path); 1773 1778 1774 1779 context->setFillRule(RULE_EVENODD); -
trunk/WebCore/rendering/RenderEmbeddedObject.cpp
r68238 r69517 207 207 replacementTextRect.setLocation(FloatPoint(x, y)); 208 208 209 path = Path::createRoundedRectangle(replacementTextRect, FloatSize(replacementTextRoundedRectRadius, replacementTextRoundedRectRadius));209 path.addRoundedRect(replacementTextRect, FloatSize(replacementTextRoundedRectRadius, replacementTextRoundedRectRadius)); 210 210 211 211 return true; -
trunk/WebCore/rendering/RenderSVGResourceClipper.cpp
r69279 r69517 137 137 // Fallback to masking, if there is more than one clipping path. 138 138 if (clipPath.isEmpty()) { 139 clipPath = styled->toClipPath();139 styled->toClipPath(clipPath); 140 140 clipRule = svgStyle->clipRule(); 141 141 } else -
trunk/WebCore/rendering/svg/RenderSVGPath.cpp
r69437 r69517 113 113 bool needsPathUpdate = m_needsPathUpdate; 114 114 if (needsPathUpdate) { 115 m_path = element->toPathData(); 115 m_path.clear(); 116 element->toPathData(m_path); 116 117 m_needsPathUpdate = false; 117 118 updateCachedBoundariesInParents = true; -
trunk/WebCore/rendering/svg/RenderSVGTextPath.cpp
r68874 r69517 54 54 SVGPathElement* pathElement = static_cast<SVGPathElement*>(targetElement); 55 55 56 Path pathData = pathElement->toPathData(); 56 Path pathData; 57 pathElement->toPathData(pathData); 57 58 // Spec: The transform attribute on the referenced 'path' element represents a 58 59 // supplemental transformation relative to the current user coordinate system for -
trunk/WebCore/rendering/svg/SVGInlineTextBox.cpp
r69413 r69517 491 491 // The initial y value refers to overline position. 492 492 float thickness = thicknessForDecoration(decoration, font); 493 494 if (fragment.width <= 0 && thickness <= 0) 495 return; 496 493 497 float y = fragment.y - font.ascent() + positionOffsetForDecoration(decoration, font, thickness); 498 499 Path path; 500 path.addRect(FloatRect(fragment.x, y, fragment.width, thickness)); 494 501 495 502 context->save(); 496 503 context->beginPath(); 497 context->addPath( Path::createRectangle(FloatRect(fragment.x, y, fragment.width, thickness)));504 context->addPath(path); 498 505 499 506 if (acquirePaintingResource(context, decorationRenderer, decorationStyle)) -
trunk/WebCore/svg/SVGAnimateMotionElement.cpp
r66836 r69517 113 113 SVGMPathElement* mPath = static_cast<SVGMPathElement*>(child); 114 114 SVGPathElement* pathElement = mPath->pathElement(); 115 Path path; 115 116 if (pathElement) 116 return pathElement->toPathData();117 return Path();117 pathElement->toPathData(path); 118 return path; 118 119 } 119 120 } -
trunk/WebCore/svg/SVGCircleElement.cpp
r69279 r69517 122 122 } 123 123 124 Path SVGCircleElement::toPathData() const124 void SVGCircleElement::toPathData(Path& path) const 125 125 { 126 return Path::createCircle(FloatPoint(cx().value(this), cy().value(this)), r().value(this)); 126 ASSERT(path.isEmpty()); 127 128 float radius = r().value(this); 129 130 if (radius <= 0) 131 return; 132 133 path.addEllipse(FloatRect(cx().value(this) - radius, cy().value(this) - radius, radius * 2, radius * 2)); 127 134 } 128 135 -
trunk/WebCore/svg/SVGCircleElement.h
r66397 r69517 46 46 virtual void synchronizeProperty(const QualifiedName&); 47 47 48 virtual Path toPathData() const;48 virtual void toPathData(Path&) const; 49 49 50 50 virtual bool selfHasRelativeLengths() const; -
trunk/WebCore/svg/SVGEllipseElement.cpp
r69279 r69517 131 131 } 132 132 133 Path SVGEllipseElement::toPathData() const133 void SVGEllipseElement::toPathData(Path& path) const 134 134 { 135 return Path::createEllipse(FloatPoint(cx().value(this), cy().value(this)), 136 rx().value(this), ry().value(this)); 135 ASSERT(path.isEmpty()); 136 137 float radiusX = rx().value(this); 138 if (radiusX <= 0) 139 return; 140 141 float radiusY = ry().value(this); 142 if (radiusY <= 0) 143 return; 144 145 path.addEllipse(FloatRect(cx().value(this) - radiusX, cy().value(this) - radiusY, radiusX * 2, radiusY * 2)); 137 146 } 138 147 -
trunk/WebCore/svg/SVGEllipseElement.h
r66397 r69517 46 46 virtual void synchronizeProperty(const QualifiedName&); 47 47 48 virtual Path toPathData() const;48 virtual void toPathData(Path&) const; 49 49 50 50 virtual bool selfHasRelativeLengths() const; -
trunk/WebCore/svg/SVGLineElement.cpp
r69279 r69517 127 127 } 128 128 129 Path SVGLineElement::toPathData() const129 void SVGLineElement::toPathData(Path& path) const 130 130 { 131 return Path::createLine(FloatPoint(x1().value(this), y1().value(this)), 132 FloatPoint(x2().value(this), y2().value(this))); 131 ASSERT(path.isEmpty()); 132 133 path.moveTo(FloatPoint(x1().value(this), y1().value(this))); 134 path.addLineTo(FloatPoint(x2().value(this), y2().value(this))); 133 135 } 134 136 -
trunk/WebCore/svg/SVGLineElement.h
r66397 r69517 48 48 virtual void synchronizeProperty(const QualifiedName&); 49 49 50 virtual Path toPathData() const;50 virtual void toPathData(Path&) const; 51 51 52 52 virtual bool supportsMarkers() const { return true; } -
trunk/WebCore/svg/SVGPathElement.cpp
r69279 r69517 58 58 { 59 59 // FIXME: this may wish to use the pathSegList instead of the pathdata if that's cheaper to build (or cached) 60 return toPathData().length(); 60 Path path; 61 toPathData(path); 62 return path.length(); 61 63 } 62 64 … … 65 67 // FIXME: this may wish to use the pathSegList instead of the pathdata if that's cheaper to build (or cached) 66 68 bool ok = false; 67 return toPathData().pointAtLength(length, ok); 69 Path path; 70 toPathData(path); 71 return path.pointAtLength(length, ok); 68 72 } 69 73 … … 263 267 } 264 268 265 Path SVGPathElement::toPathData() const 266 { 267 Path result; 269 void SVGPathElement::toPathData(Path& path) const 270 { 271 ASSERT(path.isEmpty()); 272 268 273 SVGPathParserFactory* factory = SVGPathParserFactory::self(); 269 factory->buildPathFromSVGPathSegList(pathSegList(), result); 270 return result; 274 factory->buildPathFromSVGPathSegList(pathSegList(), path); 271 275 } 272 276 -
trunk/WebCore/svg/SVGPathElement.h
r66397 r69517 90 90 virtual SVGPathSegList* animatedNormalizedPathSegList() const; 91 91 92 virtual Path toPathData() const;92 virtual void toPathData(Path&) const; 93 93 94 94 private: -
trunk/WebCore/svg/SVGPolygonElement.cpp
r66498 r69517 38 38 } 39 39 40 Path SVGPolygonElement::toPathData() const40 void SVGPolygonElement::toPathData(Path& path) const 41 41 { 42 Path polyData;42 ASSERT(path.isEmpty()); 43 43 44 44 int len = points()->numberOfItems(); 45 45 if (len < 1) 46 return polyData;46 return; 47 47 48 48 ExceptionCode ec = 0; 49 p olyData.moveTo(points()->getItem(0, ec));49 path.moveTo(points()->getItem(0, ec)); 50 50 51 51 for (int i = 1; i < len; ++i) 52 p olyData.addLineTo(points()->getItem(i, ec));52 path.addLineTo(points()->getItem(i, ec)); 53 53 54 polyData.closeSubpath(); 55 return polyData; 54 path.closeSubpath(); 56 55 } 57 56 -
trunk/WebCore/svg/SVGPolygonElement.h
r66397 r69517 34 34 SVGPolygonElement(const QualifiedName&, Document*); 35 35 36 virtual Path toPathData() const;36 virtual void toPathData(Path&) const; 37 37 }; 38 38 -
trunk/WebCore/svg/SVGPolylineElement.cpp
r66498 r69517 38 38 } 39 39 40 Path SVGPolylineElement::toPathData() const40 void SVGPolylineElement::toPathData(Path& path) const 41 41 { 42 Path polyData;42 ASSERT(path.isEmpty()); 43 43 44 44 int len = points()->numberOfItems(); 45 45 if (len < 1) 46 return polyData;46 return; 47 47 48 48 ExceptionCode ec = 0; 49 p olyData.moveTo(points()->getItem(0, ec));49 path.moveTo(points()->getItem(0, ec)); 50 50 51 51 for (int i = 1; i < len; ++i) 52 polyData.addLineTo(points()->getItem(i, ec)); 53 54 return polyData; 52 path.addLineTo(points()->getItem(i, ec)); 55 53 } 56 54 -
trunk/WebCore/svg/SVGPolylineElement.h
r66397 r69517 34 34 SVGPolylineElement(const QualifiedName&, Document*); 35 35 36 virtual Path toPathData() const;36 virtual void toPathData(Path&) const; 37 37 }; 38 38 -
trunk/WebCore/svg/SVGRectElement.cpp
r69279 r69517 148 148 } 149 149 150 Path SVGRectElement::toPathData() const150 void SVGRectElement::toPathData(Path& path) const 151 151 { 152 FloatRect rect(x().value(this), y().value(this), width().value(this), height().value(this)); 152 ASSERT(path.isEmpty()); 153 154 float widthValue = width().value(this); 155 if (widthValue <= 0) 156 return; 157 158 float heightValue = height().value(this); 159 if (heightValue <= 0) 160 return; 161 162 float xValue = x().value(this); 163 float yValue = y().value(this); 164 165 FloatRect rect(xValue, yValue, widthValue, heightValue); 153 166 154 167 bool hasRx = hasAttribute(SVGNames::rxAttr); 155 168 bool hasRy = hasAttribute(SVGNames::ryAttr); 156 169 if (hasRx || hasRy) { 157 float _rx = hasRx ? rx().value(this) : ry().value(this); 158 float _ry = hasRy ? ry().value(this) : rx().value(this); 159 return Path::createRoundedRectangle(rect, FloatSize(_rx, _ry)); 170 float rxValue = rx().value(this); 171 float ryValue = ry().value(this); 172 if (!hasRx) 173 rxValue = ryValue; 174 else if (!hasRy) 175 ryValue = rxValue; 176 path.addRoundedRect(rect, FloatSize(rxValue, ryValue)); 177 return; 160 178 } 161 179 162 return Path::createRectangle(rect);180 path.addRect(rect); 163 181 } 164 182 -
trunk/WebCore/svg/SVGRectElement.h
r66397 r69517 46 46 virtual void synchronizeProperty(const QualifiedName&); 47 47 48 virtual Path toPathData() const;48 virtual void toPathData(Path&) const; 49 49 50 50 virtual bool selfHasRelativeLengths() const; -
trunk/WebCore/svg/SVGStyledTransformableElement.cpp
r69437 r69517 112 112 } 113 113 114 Path SVGStyledTransformableElement::toClipPath() const114 void SVGStyledTransformableElement::toClipPath(Path& path) const 115 115 { 116 Path pathData = toPathData();116 toPathData(path); 117 117 // FIXME: How do we know the element has done a layout? 118 pathData.transform(animatedLocalTransform()); 119 return pathData; 118 path.transform(animatedLocalTransform()); 120 119 } 121 120 -
trunk/WebCore/svg/SVGStyledTransformableElement.h
r69437 r69517 50 50 51 51 // "base class" methods for all the elements which render as paths 52 virtual Path toPathData() const { return Path();}53 virtual Path toClipPath() const;52 virtual void toPathData(Path&) const { } 53 virtual void toClipPath(Path&) const; 54 54 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); 55 55 -
trunk/WebCore/svg/SVGUseElement.cpp
r66973 r69517 625 625 } 626 626 627 Path SVGUseElement::toClipPath() const 628 { 627 void SVGUseElement::toClipPath(Path& path) const 628 { 629 ASSERT(path.isEmpty()); 630 629 631 Node* n = m_targetElementInstance ? m_targetElementInstance->shadowTreeElement() : 0; 630 632 if (!n) 631 return Path();633 return; 632 634 633 635 if (n->isSVGElement() && static_cast<SVGElement*>(n)->isStyledTransformable()) { … … 636 638 document()->accessSVGExtensions()->reportError("Not allowed to use indirect reference in <clip-path>"); 637 639 else { 638 Path clipPath = static_cast<SVGStyledTransformableElement*>(n)->toClipPath(); 639 clipPath.translate(FloatSize(x().value(this), y().value(this))); 640 clipPath.transform(animatedLocalTransform()); 641 return clipPath; 640 static_cast<SVGStyledTransformableElement*>(n)->toClipPath(path); 641 path.translate(FloatSize(x().value(this), y().value(this))); 642 path.transform(animatedLocalTransform()); 642 643 } 643 644 } 644 645 return Path();646 645 } 647 646 -
trunk/WebCore/svg/SVGUseElement.h
r66397 r69517 68 68 virtual void detach(); 69 69 70 virtual Path toClipPath() const;70 virtual void toClipPath(Path&) const; 71 71 72 72 static void removeDisallowedElementsFromSubtree(Node* element);
Note: See TracChangeset
for help on using the changeset viewer.