Changeset 114679 in webkit
- Timestamp:
- Apr 19, 2012 3:05:38 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r114678 r114679 1 2012-04-19 Huang Dongsung <luxtella@company100.net> 2 3 Canvas more precisely makes the bounding rect for stroke rendering. 4 https://bugs.webkit.org/show_bug.cgi?id=75792 5 6 Reviewed by Simon Fraser. 7 8 * html/canvas/CanvasRenderingContext2D.cpp: 9 (WebCore::CanvasRenderingContext2D::stroke): 10 (WebCore::CanvasRenderingContext2D::drawTextInternal): 11 (WebCore::CanvasRenderingContext2D::inflateStrokeRect): 12 (WebCore): 13 * html/canvas/CanvasRenderingContext2D.h: 14 (CanvasRenderingContext2D): 15 1 16 2012-04-19 Luke Macpherson <macpherson@chromium.org> 2 17 -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
r114437 r114679 950 950 if (!m_path.isEmpty()) { 951 951 FloatRect dirtyRect = m_path.fastBoundingRect(); 952 // Fast approximation of the stroke's bounding rect. 953 // This yields a slightly oversized rect but is very fast 954 // compared to Path::strokeBoundingRect(). 955 dirtyRect.inflate(state().m_miterLimit + state().m_lineWidth); 952 inflateStrokeRect(dirtyRect); 956 953 957 954 c->strokePath(m_path); … … 2103 2100 width + fontMetrics.height(), fontMetrics.lineSpacing()); 2104 2101 if (!fill) 2105 textRect.inflate(c->strokeThickness() / 2);2102 inflateStrokeRect(textRect); 2106 2103 2107 2104 #if USE(CG) 2108 2105 CanvasStyle* drawStyle = fill ? state().m_fillStyle.get() : state().m_strokeStyle.get(); 2109 2106 if (drawStyle->canvasGradient() || drawStyle->canvasPattern()) { 2110 // FIXME: The rect is not big enough for miters on stroked text.2111 2107 IntRect maskRect = enclosingIntRect(textRect); 2112 2108 … … 2163 2159 c->drawBidiText(font, textRun, location); 2164 2160 2165 if (fill) 2166 didDraw(textRect); 2167 else { 2168 // When stroking text, pointy miters can extend outside of textRect, so we 2169 // punt and dirty the whole canvas. 2170 didDraw(FloatRect(0, 0, canvas()->width(), canvas()->height())); 2171 } 2161 didDraw(textRect); 2172 2162 2173 2163 #if PLATFORM(QT) … … 2176 2166 } 2177 2167 2168 void CanvasRenderingContext2D::inflateStrokeRect(FloatRect& rect) const 2169 { 2170 // Fast approximation of the stroke's bounding rect. 2171 // This yields a slightly oversized rect but is very fast 2172 // compared to Path::strokeBoundingRect(). 2173 static const float root2 = sqrt(2); 2174 float delta = state().m_lineWidth / 2; 2175 if (state().m_lineJoin == MiterJoin) 2176 delta *= state().m_miterLimit; 2177 else if (state().m_lineCap == SquareCap) 2178 delta *= root2; 2179 2180 rect.inflate(delta); 2181 } 2182 2178 2183 const Font& CanvasRenderingContext2D::accessFont() 2179 2184 { -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h
r114150 r114679 313 313 void compositeBuffer(ImageBuffer*, const IntRect&, CompositeOperator); 314 314 315 void inflateStrokeRect(FloatRect&) const; 316 315 317 template<class T> void fullCanvasCompositedFill(const T&); 316 318 template<class T> void fullCanvasCompositedDrawImage(T*, ColorSpace, const FloatRect&, const FloatRect&, CompositeOperator);
Note: See TracChangeset
for help on using the changeset viewer.