| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 float WebFontImpl::xHeight() const | 87 float WebFontImpl::xHeight() const |
| 88 { | 88 { |
| 89 return m_font.fontMetrics().xHeight(); | 89 return m_font.fontMetrics().xHeight(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void WebFontImpl::drawText(WebCanvas* canvas, const WebTextRun& run, const WebFl
oatPoint& leftBaseline, | 92 void WebFontImpl::drawText(WebCanvas* canvas, const WebTextRun& run, const WebFl
oatPoint& leftBaseline, |
| 93 WebColor color, const WebRect& clip, bool canvasIsOpa
que, | 93 WebColor color, const WebRect& clip, bool canvasIsOpa
que, |
| 94 int from, int to) const | 94 int from, int to) const |
| 95 { | 95 { |
| 96 FontCachePurgePreventer fontCachePurgePreventer; | 96 FontCachePurgePreventer fontCachePurgePreventer; |
| 97 WebCore::FloatRect textClipRect(clip); |
| 98 TextRunPaintInfo runInfo(run); |
| 99 runInfo.from = from; |
| 100 runInfo.to = to; |
| 101 runInfo.bounds = textClipRect; |
| 97 | 102 |
| 98 GraphicsContextBuilder builder(canvas); | 103 GraphicsContextBuilder builder(canvas); |
| 99 GraphicsContext& gc = builder.context(); | 104 GraphicsContext& gc = builder.context(); |
| 100 | 105 |
| 101 gc.save(); | 106 gc.save(); |
| 102 gc.setShouldSmoothFonts(canvasIsOpaque); | 107 gc.setShouldSmoothFonts(canvasIsOpaque); |
| 103 gc.setFillColor(color, ColorSpaceDeviceRGB); | 108 gc.setFillColor(color, ColorSpaceDeviceRGB); |
| 104 gc.clip(WebCore::FloatRect(clip)); | 109 gc.clip(textClipRect); |
| 105 m_font.drawText(&gc, run, leftBaseline, from, to); | 110 m_font.drawText(&gc, runInfo, leftBaseline); |
| 106 gc.restore(); | 111 gc.restore(); |
| 107 | 112 |
| 108 #if defined(WIN32) | 113 #if defined(WIN32) |
| 109 if (canvasIsOpaque && SkColorGetA(color) == 0xFF && !canvas->isDrawingToLaye
r()) { | 114 if (canvasIsOpaque && SkColorGetA(color) == 0xFF && !canvas->isDrawingToLaye
r()) { |
| 110 // The text drawing logic on Windows ignores the alpha component | 115 // The text drawing logic on Windows ignores the alpha component |
| 111 // intentionally, for performance reasons. | 116 // intentionally, for performance reasons. |
| 112 // (Please see TransparencyAwareFontPainter::initializeForGDI in | 117 // (Please see TransparencyAwareFontPainter::initializeForGDI in |
| 113 // FontChromiumWin.cpp.) | 118 // FontChromiumWin.cpp.) |
| 114 const SkBitmap& bitmap = canvas->getTopDevice()->accessBitmap(true); | 119 const SkBitmap& bitmap = canvas->getTopDevice()->accessBitmap(true); |
| 115 IntRect textBounds = estimateTextBounds(run, leftBaseline); | 120 IntRect textBounds = estimateTextBounds(run, leftBaseline); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 FontCachePurgePreventer fontCachePurgePreventer; | 152 FontCachePurgePreventer fontCachePurgePreventer; |
| 148 int totalWidth = m_font.width(run, 0); | 153 int totalWidth = m_font.width(run, 0); |
| 149 const WebCore::FontMetrics& fontMetrics = m_font.fontMetrics(); | 154 const WebCore::FontMetrics& fontMetrics = m_font.fontMetrics(); |
| 150 return WebRect(leftBaseline.x - (fontMetrics.ascent() + fontMetrics.descent(
)) / 2, | 155 return WebRect(leftBaseline.x - (fontMetrics.ascent() + fontMetrics.descent(
)) / 2, |
| 151 leftBaseline.y - fontMetrics.ascent() - fontMetrics.lineGap()
, | 156 leftBaseline.y - fontMetrics.ascent() - fontMetrics.lineGap()
, |
| 152 totalWidth + fontMetrics.ascent() + fontMetrics.descent(), | 157 totalWidth + fontMetrics.ascent() + fontMetrics.descent(), |
| 153 fontMetrics.lineSpacing()); | 158 fontMetrics.lineSpacing()); |
| 154 } | 159 } |
| 155 | 160 |
| 156 } // namespace WebKit | 161 } // namespace WebKit |
| OLD | NEW |