Changeset 91205 in webkit
- Timestamp:
- Jul 18, 2011 1:36:31 PM (13 years ago)
- Location:
- trunk/Source/WebKit/chromium
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/chromium/ChangeLog
r91161 r91205 1 2011-07-18 Yuzhu Shen <yzshen@chromium.com> 2 3 Reviewed by James Robinson. 4 5 [chromium] WebFontImpl::drawText needs to handle the canvasIsOpaque input. 6 https://bugs.webkit.org/show_bug.cgi?id=64555 7 8 This change handles canvasIsOpaque for the WEBKIT_USING_SKIA case. 9 10 * src/WebFontImpl.cpp: handled canvasIsOpaque. 11 * src/WebFontImpl.h: added method declaration. 12 1 13 2011-07-16 Simon Fraser <simon.fraser@apple.com> 2 14 -
trunk/Source/WebKit/chromium/src/WebFontImpl.cpp
r77383 r91205 92 92 int from, int to) const 93 93 { 94 // FIXME hook canvasIsOpaque up to the platform-specific indicators for95 // whether subpixel AA can be used for this draw. On Windows, this is96 // PlatformContextSkia::setDrawingToImageBuffer.97 98 94 GraphicsContextBuilder builder(canvas); 99 95 GraphicsContext& gc = builder.context(); 96 97 #if WEBKIT_USING_SKIA 98 gc.platformContext()->setDrawingToImageBuffer(!canvasIsOpaque); 99 #elif WEBKIT_USING_CG 100 // FIXME hook canvasIsOpaque up to the platform-specific indicators for 101 // whether subpixel AA can be used for this draw. 102 #endif 100 103 101 104 gc.save(); … … 104 107 m_font.drawText(&gc, run, leftBaseline, from, to); 105 108 gc.restore(); 109 110 #if defined(WIN32) 111 if (canvasIsOpaque && SkColorGetA(color) == 0xFF) { 112 SkCanvas::LayerIter iter(const_cast<SkCanvas*>(canvas), false); 113 iter.next(); // There is always at least one layer. 114 bool multipleLayers = !iter.done(); 115 if (!multipleLayers) { 116 // The text drawing logic on Windows ignores the alpha component 117 // intentionally, for performance reasons. 118 // (Please see TransparencyAwareFontPainter::initializeForGDI in 119 // FontChromiumWin.cpp.) 120 const SkBitmap& bitmap = canvas->getTopDevice()->accessBitmap(true); 121 IntRect textBounds = estimateTextBounds(run, leftBaseline); 122 IntRect destRect = gc.getCTM().mapRect(textBounds); 123 destRect.intersect(IntRect(0, 0, bitmap.width(), bitmap.height())); 124 for (int y = destRect.y(), maxY = destRect.maxY(); y < maxY; y++) { 125 uint32_t* row = bitmap.getAddr32(0, y); 126 for (int x = destRect.x(), maxX = destRect.maxX(); x < maxX; x++) 127 row[x] |= (0xFF << SK_A32_SHIFT); 128 } 129 } 130 } 131 #endif 106 132 } 107 133 … … 121 147 } 122 148 149 WebRect WebFontImpl::estimateTextBounds(const WebTextRun& run, const WebFloatPoint& leftBaseline) const 150 { 151 int totalWidth = m_font.width(run, 0); 152 const FontMetrics& fontMetrics = m_font.fontMetrics(); 153 return WebRect(leftBaseline.x - (fontMetrics.ascent() + fontMetrics.descent()) / 2, 154 leftBaseline.y - fontMetrics.ascent() - fontMetrics.lineGap(), 155 totalWidth + fontMetrics.ascent() + fontMetrics.descent(), 156 fontMetrics.lineSpacing()); 157 } 158 123 159 } // namespace WebKit -
trunk/Source/WebKit/chromium/src/WebFontImpl.h
r64160 r91205 59 59 60 60 private: 61 // Estimates the bounding box of the given text. 62 WebRect estimateTextBounds(const WebTextRun&, const WebFloatPoint& leftBaseline) const; 63 61 64 WebCore::Font m_font; 62 65 };
Note: See TracChangeset
for help on using the changeset viewer.