Changeset 18306 in webkit
- Timestamp:
- Dec 19, 2006 12:54:00 AM (17 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r18305 r18306 1 2006-12-19 David Hyatt <hyatt@apple.com> 2 3 Convert stroke thickness to a float. This allows the thickness argument to strokeArc to be eliminated. 4 5 Reviewed by olliej 6 7 * platform/graphics/GraphicsContext.cpp: 8 (WebCore::GraphicsContext::setStrokeThickness): 9 (WebCore::GraphicsContext::strokeThickness): 10 (WebCore::GraphicsContext::setPlatformStrokeThickness): 11 * platform/graphics/GraphicsContext.h: 12 * platform/graphics/cg/GraphicsContextCG.cpp: 13 (WebCore::GraphicsContext::drawEllipse): 14 (WebCore::GraphicsContext::strokeArc): 15 * platform/graphics/qt/GraphicsContextQt.cpp: 16 (WebCore::GraphicsContext::strokeArc): 17 (WebCore::GraphicsContext::setPlatformStrokeThickness): 18 * rendering/RenderObject.cpp: 19 (WebCore::RenderObject::drawBorderArc): 20 1 21 2006-12-19 David Hyatt <hyatt@apple.com> 2 22 -
trunk/WebCore/platform/graphics/GraphicsContext.cpp
r18294 r18306 46 46 Font font; 47 47 StrokeStyle strokeStyle; 48 unsignedstrokeThickness;48 float strokeThickness; 49 49 Color strokeColor; 50 50 Color fillColor; … … 118 118 } 119 119 120 void GraphicsContext::setStrokeThickness( unsignedthickness)120 void GraphicsContext::setStrokeThickness(float thickness) 121 121 { 122 122 m_common->state.strokeThickness = thickness; … … 136 136 } 137 137 138 unsignedGraphicsContext::strokeThickness() const138 float GraphicsContext::strokeThickness() const 139 139 { 140 140 return m_common->state.strokeThickness; … … 352 352 } 353 353 354 void GraphicsContext::setPlatformStrokeThickness( unsigned)354 void GraphicsContext::setPlatformStrokeThickness(float) 355 355 { 356 356 } -
trunk/WebCore/platform/graphics/GraphicsContext.h
r18305 r18306 88 88 void setFont(const Font&); 89 89 90 unsignedstrokeThickness() const;91 void setStrokeThickness( unsigned);90 float strokeThickness() const; 91 void setStrokeThickness(float); 92 92 StrokeStyle strokeStyle() const; 93 93 void setStrokeStyle(const StrokeStyle& style); … … 107 107 void drawConvexPolygon(size_t numPoints, const FloatPoint*, bool shouldAntialias = false); 108 108 109 // Arc drawing (used by border-radius in CSS) just supports stroking at the moment. It ignores 110 // the stroke thickness, relying instead on a passed-in argument (because of float vs. int issues). 111 // FIXME: Reconcile this method with stroke thickness by converting stroke thickness to a float. 112 void strokeArc(const IntRect&, float thickness, int startAngle, int angleSpan); 109 // Arc drawing (used by border-radius in CSS) just supports stroking at the moment. 110 void strokeArc(const IntRect&, int startAngle, int angleSpan); 113 111 114 112 void fillRect(const IntRect&, const Color&); … … 207 205 void setPlatformStrokeColor(const Color&); 208 206 void setPlatformStrokeStyle(const StrokeStyle&); 209 void setPlatformStrokeThickness( unsigned);207 void setPlatformStrokeThickness(float); 210 208 void setPlatformFillColor(const Color&); 211 209 void setPlatformFont(const Font& font); -
trunk/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
r18305 r18306 267 267 if (strokeStyle() != NoStroke) { 268 268 // stroke and fill 269 unsigned penWidth = max(strokeThickness(), 1U);270 CGContextSetLineWidth(context, penWidth);269 unsigned strokeWidth = max(strokeThickness(), 1.0f); 270 CGContextSetLineWidth(context, strokeWidth); 271 271 CGContextDrawPath(context, kCGPathFillStroke); 272 272 } else 273 273 CGContextFillPath(context); 274 274 } else if (strokeStyle() != NoStroke) { 275 unsigned penWidth = max(strokeThickness(), 1U);276 CGContextSetLineWidth(context, penWidth);275 unsigned strokeWidth = max(strokeThickness(), 1.0f); 276 CGContextSetLineWidth(context, strokeWidth); 277 277 CGContextStrokePath(context); 278 278 } … … 280 280 281 281 282 void GraphicsContext::strokeArc(const IntRect& rect, float thickness,int startAngle, int angleSpan)282 void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan) 283 283 { 284 if (paintingDisabled() || strokeStyle() == NoStroke || thickness<= 0.0f || !strokeColor().alpha())284 if (paintingDisabled() || strokeStyle() == NoStroke || strokeThickness() <= 0.0f || !strokeColor().alpha()) 285 285 return; 286 286 … … 312 312 313 313 314 float width = max( thickness, 1.0f);314 float width = max(strokeThickness(), 1.0f); 315 315 int patWidth = 0; 316 316 -
trunk/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
r18305 r18306 440 440 } 441 441 442 void GraphicsContext::strokeArc(const IntRect& rect, float thickness, int startAngle, int angleSpan) 443 { 444 if (paintingDisabled() || strokeStyle() == NoStroke || thickness <= 0.0f || !strokeColor().alpha()) 445 return; 446 447 const QPen oldPen = m_data->p().pen(); 448 QPen nPen = oldPen; 449 nPen.setWidthF(thickness); 450 m_data->p().setPen(nPen); 442 void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan) 443 { 444 if (paintingDisabled() || strokeStyle() == NoStroke || strokeThickness() <= 0.0f || !strokeColor().alpha()) 445 return; 446 451 447 m_data->p().drawArc(rect, startAngle, angleSpan); 452 m_data->p().setPen(oldPen);453 448 } 454 449 … … 856 851 } 857 852 858 void GraphicsContext::setPlatformStrokeThickness( unsignedthickness)853 void GraphicsContext::setPlatformStrokeThickness(float thickness) 859 854 { 860 855 QPen newPen(m_data->p().pen()); 861 newPen.setWidth (thickness);856 newPen.setWidthF(thickness); 862 857 m_data->p().setPen(newPen); 863 858 } -
trunk/WebCore/rendering/RenderObject.cpp
r18305 r18306 878 878 graphicsContext->setStrokeColor(c); 879 879 graphicsContext->setStrokeStyle(style == DOTTED ? DottedStroke : DashedStroke); 880 graphicsContext->strokeArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), thickness, angleStart, angleSpan); 880 graphicsContext->setStrokeThickness(thickness); 881 graphicsContext->strokeArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), angleStart, angleSpan); 881 882 break; 882 883 case DOUBLE: { … … 897 898 898 899 graphicsContext->setStrokeStyle(SolidStroke); 899 graphicsContext->strokeArc(IntRect(x, outerY, radius.width() * 2, outerHeight), third, angleStart, angleSpan); 900 graphicsContext->strokeArc(IntRect(innerX, innerY, innerWidth, innerHeight), (innerThird > 2) ? innerThird - 1 : innerThird, 901 angleStart, angleSpan); 900 graphicsContext->setStrokeColor(c); 901 graphicsContext->setStrokeThickness(third); 902 graphicsContext->strokeArc(IntRect(x, outerY, radius.width() * 2, outerHeight), angleStart, angleSpan); 903 graphicsContext->setStrokeThickness(innerThird > 2 ? innerThird - 1 : innerThird); 904 graphicsContext->strokeArc(IntRect(innerX, innerY, innerWidth, innerHeight), angleStart, angleSpan); 902 905 break; 903 906 } … … 915 918 graphicsContext->setStrokeStyle(SolidStroke); 916 919 graphicsContext->setStrokeColor(c); 917 graphicsContext->strokeArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), thickness, angleStart, angleSpan); 920 graphicsContext->setStrokeThickness(thickness); 921 graphicsContext->strokeArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), angleStart, angleSpan); 918 922 919 923 float halfThickness = (thickness + 1.0f) / 4.0f; 920 924 int shiftForInner = static_cast<int>(halfThickness * 1.5f); 921 925 graphicsContext->setStrokeColor(c2); 926 graphicsContext->setStrokeThickness(halfThickness > 2 ? halfThickness - 1 : halfThickness); 922 927 graphicsContext->strokeArc(IntRect(x + shiftForInner, y + shiftForInner, (radius.width() - shiftForInner) * 2, 923 (radius.height() - shiftForInner) * 2), (halfThickness > 2) ? halfThickness - 1 : halfThickness, 924 angleStart, angleSpan); 928 (radius.height() - shiftForInner) * 2), angleStart, angleSpan); 925 929 break; 926 930 } … … 934 938 graphicsContext->setStrokeStyle(SolidStroke); 935 939 graphicsContext->setStrokeColor(c); 936 graphicsContext->strokeArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), thickness, angleStart, angleSpan); 940 graphicsContext->setStrokeThickness(thickness); 941 graphicsContext->strokeArc(IntRect(x, y, radius.width() * 2, radius.height() * 2), angleStart, angleSpan); 937 942 break; 938 943 }
Note: See TracChangeset
for help on using the changeset viewer.