OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) |
4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> |
7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. | 8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. |
9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
10 * | 10 * |
(...skipping 2207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2218 | 2218 |
2219 // The slop built in to this mask rect matches the heuristic used in FontCGW
in.cpp for GDI text. | 2219 // The slop built in to this mask rect matches the heuristic used in FontCGW
in.cpp for GDI text. |
2220 TextRunPaintInfo textRunPaintInfo(textRun); | 2220 TextRunPaintInfo textRunPaintInfo(textRun); |
2221 textRunPaintInfo.bounds = FloatRect(location.x() - fontMetrics.height() / 2, | 2221 textRunPaintInfo.bounds = FloatRect(location.x() - fontMetrics.height() / 2, |
2222 location.y() - fontMetrics.ascent() - fo
ntMetrics.lineGap(), | 2222 location.y() - fontMetrics.ascent() - fo
ntMetrics.lineGap(), |
2223 width + fontMetrics.height(), | 2223 width + fontMetrics.height(), |
2224 fontMetrics.lineSpacing()); | 2224 fontMetrics.lineSpacing()); |
2225 if (!fill) | 2225 if (!fill) |
2226 inflateStrokeRect(textRunPaintInfo.bounds); | 2226 inflateStrokeRect(textRunPaintInfo.bounds); |
2227 | 2227 |
2228 FloatRect dirtyRect; | 2228 c->setTextDrawingMode(fill ? TextModeFill : TextModeStroke); |
2229 if (!computeDirtyRect(textRunPaintInfo.bounds, &dirtyRect)) | |
2230 return; | |
2231 | 2229 |
2232 c->setTextDrawingMode(fill ? TextModeFill : TextModeStroke); | 2230 GraphicsContextStateSaver stateSaver(*c); |
2233 if (useMaxWidth) { | 2231 if (useMaxWidth) { |
2234 GraphicsContextStateSaver stateSaver(*c); | |
2235 c->translate(location.x(), location.y()); | 2232 c->translate(location.x(), location.y()); |
2236 // We draw when fontWidth is 0 so compositing operations (eg, a "copy" o
p) still work. | 2233 // We draw when fontWidth is 0 so compositing operations (eg, a "copy" o
p) still work. |
2237 c->scale(FloatSize((fontWidth > 0 ? (width / fontWidth) : 0), 1)); | 2234 c->scale(FloatSize((fontWidth > 0 ? (width / fontWidth) : 0), 1)); |
2238 c->drawBidiText(font, textRunPaintInfo, FloatPoint(0, 0), Font::UseFallb
ackIfFontNotReady); | 2235 location = FloatPoint(); |
2239 } else | 2236 } |
| 2237 |
| 2238 FloatRect clipBounds; |
| 2239 if (!c->getTransformedClipBounds(&clipBounds)) { |
| 2240 return; |
| 2241 } |
| 2242 |
| 2243 if (isFullCanvasCompositeMode(state().m_globalComposite)) { |
| 2244 c->beginLayer(1, state().m_globalComposite); |
| 2245 CompositeOperator previousOperator = c->compositeOperation(); |
| 2246 c->setCompositeOperation(CompositeSourceOver); |
2240 c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackIfFon
tNotReady); | 2247 c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackIfFon
tNotReady); |
2241 | 2248 c->setCompositeOperation(previousOperator); |
2242 didDraw(dirtyRect); | 2249 c->endLayer(); |
| 2250 didDraw(clipBounds); |
| 2251 } else if (state().m_globalComposite == CompositeCopy) { |
| 2252 clearCanvas(); |
| 2253 c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackIfFon
tNotReady); |
| 2254 didDraw(clipBounds); |
| 2255 } else { |
| 2256 FloatRect dirtyRect; |
| 2257 if (computeDirtyRect(textRunPaintInfo.bounds, clipBounds, &dirtyRect)) { |
| 2258 c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackI
fFontNotReady); |
| 2259 didDraw(dirtyRect); |
| 2260 } |
| 2261 } |
2243 } | 2262 } |
2244 | 2263 |
2245 void CanvasRenderingContext2D::inflateStrokeRect(FloatRect& rect) const | 2264 void CanvasRenderingContext2D::inflateStrokeRect(FloatRect& rect) const |
2246 { | 2265 { |
2247 // Fast approximation of the stroke's bounding rect. | 2266 // Fast approximation of the stroke's bounding rect. |
2248 // This yields a slightly oversized rect but is very fast | 2267 // This yields a slightly oversized rect but is very fast |
2249 // compared to Path::strokeBoundingRect(). | 2268 // compared to Path::strokeBoundingRect(). |
2250 static const float root2 = sqrtf(2); | 2269 static const float root2 = sqrtf(2); |
2251 float delta = state().m_lineWidth / 2; | 2270 float delta = state().m_lineWidth / 2; |
2252 if (state().m_lineJoin == MiterJoin) | 2271 if (state().m_lineJoin == MiterJoin) |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2411 c->setAlphaAsFloat(1.0); | 2430 c->setAlphaAsFloat(1.0); |
2412 c->clearShadow(); | 2431 c->clearShadow(); |
2413 c->setCompositeOperation(CompositeSourceOver, blink::WebBlendModeNormal); | 2432 c->setCompositeOperation(CompositeSourceOver, blink::WebBlendModeNormal); |
2414 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); | 2433 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); |
2415 c->restore(); | 2434 c->restore(); |
2416 | 2435 |
2417 didDraw(dirtyRect); | 2436 didDraw(dirtyRect); |
2418 } | 2437 } |
2419 | 2438 |
2420 } // namespace WebCore | 2439 } // namespace WebCore |
OLD | NEW |