Changeset 92022 in webkit
- Timestamp:
- Jul 29, 2011, 3:17:56 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r92005 r92022 1 2011-07-29 Mike Reed <reed@google.com> 2 3 [skia] never draw with GDI, so that all text can be gpu-accelerated 4 https://bugs.webkit.org/show_bug.cgi?id=65203 5 6 Reviewed by Kenneth Russell. 7 8 * platform/chromium/test_expectations.txt: 9 1 10 2011-07-29 Dan Bernstein <mitz@apple.com> 2 11 -
trunk/LayoutTests/platform/chromium/test_expectations.txt
r92003 r92022 1833 1833 1834 1834 BUGWK38705 : http/tests/security/sandbox-inherit-to-initial-document-2.html = TEXT 1835 1836 // Switching windows over from GDI to Skia for all text rendering. 1837 // When that lands, we will rebaseline these images. 1838 BUGWK65203 WIN : fast/borders/border-antialiasing.html = IMAGE 1839 BUGWK65203 WIN : fast/reflections/reflection-overflow-hidden.html = IMAGE 1840 BUGWK65203 WIN : fast/repaint/reflection-redraw.html = IMAGE 1841 BUGWK65203 WIN : fast/text/atsui-spacing-features.html = IMAGE 1842 BUGWK65203 WIN : fast/text/cg-vs-atsui.html = IMAGE 1843 BUGWK65203 WIN : fast/text/complex-text-opacity.html = IMAGE 1844 BUGWK65203 WIN : fast/text/international/complex-character-based-fallback.html = IMAGE 1845 BUGWK65203 WIN : fast/text/international/danda-space.html = IMAGE 1846 BUGWK65203 WIN : fast/text/international/thai-baht-space.html = IMAGE 1847 BUGWK65203 WIN : fast/text/international/thai-line-breaks.html = IMAGE 1848 BUGWK65203 WIN : media/audio-repaint.html = IMAGE 1849 BUGWK65203 WIN : platform/win/fast/text/uniscribe-missing-glyph.html = IMAGE 1850 BUGWK65203 WIN : svg/W3C-SVG-1.1-SE/text-intro-05-t.svg = IMAGE 1851 BUGWK65203 WIN : svg/W3C-SVG-1.1/animate-elem-37-t.svg = IMAGE 1852 BUGWK65203 WIN : svg/W3C-SVG-1.1/animate-elem-39-t.svg = IMAGE 1853 BUGWK65203 WIN : svg/W3C-SVG-1.1/animate-elem-40-t.svg = IMAGE 1854 BUGWK65203 WIN : svg/W3C-SVG-1.1/animate-elem-41-t.svg = IMAGE 1855 BUGWK65203 WIN : svg/W3C-SVG-1.1/animate-elem-46-t.svg = IMAGE 1856 BUGWK65203 WIN : svg/W3C-SVG-1.1/animate-elem-60-t.svg = IMAGE 1857 BUGWK65203 WIN : svg/W3C-SVG-1.1/animate-elem-61-t.svg = IMAGE 1858 BUGWK65203 WIN : svg/W3C-SVG-1.1/animate-elem-62-t.svg = IMAGE 1859 BUGWK65203 WIN : svg/W3C-SVG-1.1/animate-elem-63-t.svg = IMAGE 1860 BUGWK65203 WIN : svg/W3C-SVG-1.1/animate-elem-64-t.svg = IMAGE 1861 BUGWK65203 WIN : svg/W3C-SVG-1.1/animate-elem-65-t.svg = IMAGE 1862 BUGWK65203 WIN : svg/W3C-SVG-1.1/animate-elem-66-t.svg = IMAGE 1863 BUGWK65203 WIN : svg/W3C-SVG-1.1/animate-elem-67-t.svg = IMAGE 1864 BUGWK65203 WIN : svg/W3C-SVG-1.1/animate-elem-68-t.svg = IMAGE 1865 BUGWK65203 WIN : svg/W3C-SVG-1.1/animate-elem-69-t.svg = IMAGE 1866 BUGWK65203 WIN : svg/W3C-SVG-1.1/animate-elem-70-t.svg = IMAGE 1867 BUGWK65203 WIN : svg/W3C-SVG-1.1/animate-elem-81-t.svg = IMAGE 1868 BUGWK65203 WIN : svg/W3C-SVG-1.1/animate-elem-82-t.svg = IMAGE 1869 BUGWK65203 WIN : svg/W3C-SVG-1.1/animate-elem-83-t.svg = IMAGE 1870 BUGWK65203 WIN : svg/W3C-SVG-1.1/pservers-grad-07-b.svg = IMAGE 1871 BUGWK65203 WIN : svg/W3C-SVG-1.1/struct-frag-02-t.svg = IMAGE 1872 BUGWK65203 WIN : svg/W3C-SVG-1.1/text-align-04-b.svg = IMAGE 1873 BUGWK65203 WIN : svg/W3C-SVG-1.1/text-align-05-b.svg = IMAGE 1874 BUGWK65203 WIN : svg/W3C-SVG-1.1/text-align-06-b.svg = IMAGE 1875 BUGWK65203 WIN : svg/W3C-SVG-1.1/text-path-01-b.svg = IMAGE 1876 BUGWK65203 WIN : svg/W3C-SVG-1.1/text-text-05-t.svg = IMAGE 1877 BUGWK65203 WIN : svg/as-background-image/animated-svg-as-background.html = IMAGE 1878 BUGWK65203 WIN : svg/as-image/animated-svg-as-image.html = IMAGE 1879 BUGWK65203 WIN : svg/batik/filters/feTile.svg = IMAGE 1880 BUGWK65203 WIN : svg/batik/filters/filterRegions.svg = IMAGE 1881 BUGWK65203 WIN : svg/batik/text/longTextOnPath.svg = IMAGE 1882 BUGWK65203 WIN : svg/batik/text/textAnchor.svg = IMAGE 1883 BUGWK65203 WIN : svg/batik/text/textFeatures.svg = IMAGE 1884 BUGWK65203 WIN : svg/batik/text/textLayout.svg = IMAGE 1885 BUGWK65203 WIN : svg/batik/text/textPCDATA.svg = IMAGE 1886 BUGWK65203 WIN : svg/batik/text/textProperties.svg = IMAGE 1887 BUGWK65203 WIN : svg/batik/text/textProperties2.svg = IMAGE 1888 BUGWK65203 WIN : svg/batik/text/textStyles.svg = IMAGE 1889 BUGWK65203 WIN : svg/carto.net/textbox.svg = IMAGE 1890 BUGWK65203 WIN : svg/carto.net/window.svg = IMAGE 1891 BUGWK65203 WIN : svg/custom/js-late-clipPath-and-object-creation.svg = IMAGE 1892 BUGWK65203 WIN : svg/custom/js-late-clipPath-creation.svg = IMAGE 1893 BUGWK65203 WIN : svg/custom/linking-a-03-b-viewBox.svg = IMAGE 1894 BUGWK65203 WIN : svg/custom/linking-uri-01-b.svg = IMAGE 1895 BUGWK65203 WIN : svg/custom/svg-fonts-fallback.xhtml = IMAGE 1896 BUGWK65203 WIN : svg/dynamic-updates/SVGTextElement-dom-lengthAdjust-attr.html = IMAGE 1897 BUGWK65203 WIN : svg/dynamic-updates/SVGTextElement-svgdom-lengthAdjust-prop.html = IMAGE 1898 BUGWK65203 WIN : svg/hixie/mixed/009.xml = IMAGE 1899 BUGWK65203 WIN : svg/text/foreignObject-text-clipping-bug.xml = IMAGE 1900 BUGWK65203 WIN : svg/text/scaling-font-with-geometric-precision.html = IMAGE 1901 BUGWK65203 WIN : svg/text/text-align-01-b.svg = IMAGE 1902 BUGWK65203 WIN : svg/text/text-align-05-b.svg = IMAGE 1903 BUGWK65203 WIN : svg/text/text-align-06-b.svg = IMAGE 1904 BUGWK65203 WIN : svg/text/text-intro-05-t.svg = IMAGE 1905 BUGWK65203 WIN : svg/text/text-path-01-b.svg = IMAGE 1906 BUGWK65203 WIN : svg/text/textPathBoundsBug.svg = IMAGE 1907 BUGWK65203 WIN : svg/zoom/page/zoom-coords-viewattr-01-b.svg = IMAGE 1908 BUGWK65203 WIN : svg/zoom/page/zoom-hixie-mixed-008.xml = IMAGE 1909 BUGWK65203 WIN : svg/zoom/page/zoom-hixie-mixed-009.xml = IMAGE 1910 BUGWK65203 WIN : svg/zoom/text/zoom-coords-viewattr-01-b.svg = IMAGE 1911 BUGWK65203 WIN : svg/zoom/text/zoom-hixie-mixed-009.xml = IMAGE 1835 1912 1836 1913 // WebKit roll 58791:58807 -
trunk/Source/WebCore/ChangeLog
r92014 r92022 1 2011-07-29 Mike Reed <reed@google.com> 2 3 [skia] never draw with GDI, so that all text can be gpu-accelerated 4 https://bugs.webkit.org/show_bug.cgi?id=65203 5 6 Reviewed by Kenneth Russell. 7 8 * platform/graphics/chromium/FontChromiumWin.cpp: 9 (WebCore::TransparencyAwareFontPainter::TransparencyAwareFontPainter::TransparencyAwareFontPainter): 10 (WebCore::TransparencyAwareFontPainter::TransparencyAwareGlyphPainter::TransparencyAwareGlyphPainter): 11 (WebCore::TransparencyAwareFontPainter::TransparencyAwareGlyphPainter::drawGlyphs): 12 (WebCore::TransparencyAwareFontPainter::TransparencyAwareUniscribePainter::TransparencyAwareUniscribePainter): 13 (WebCore::drawGlyphsWin): 14 (WebCore::Font::drawComplexText): 15 * platform/graphics/chromium/UniscribeHelper.cpp: 16 (WebCore::UniscribeHelper::draw): 17 * platform/graphics/skia/PlatformContextSkia.cpp: 18 * platform/graphics/skia/PlatformContextSkia.h: 19 * platform/graphics/skia/SkiaFontWin.cpp: 20 * platform/graphics/skia/SkiaFontWin.h: 21 1 22 2011-07-29 Sam Weinig <sam@webkit.org> 2 23 -
trunk/Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp
r91822 r92022 63 63 public: 64 64 TransparencyAwareFontPainter(GraphicsContext*, const FloatPoint&); 65 ~TransparencyAwareFontPainter();66 65 67 66 protected: 68 // Called by our subclass' constructor to initialize GDI if necessary. This69 // is a separate function so it can be called after the subclass finishes70 // construction (it calls virtual functions).71 void init();72 73 67 virtual IntRect estimateTextBounds() = 0; 74 68 … … 79 73 80 74 FloatPoint m_point; 81 82 // Set when Windows can handle the type of drawing we're doing.83 bool m_useGDI;84 85 // These members are valid only when m_useGDI is set.86 HDC m_hdc;87 TransparencyWin m_transparency;88 89 private:90 // Call when we're using GDI mode to initialize the TransparencyWin to help91 // us draw GDI text.92 void initializeForGDI();93 94 bool m_createdTransparencyLayer; // We created a layer to give the font some alpha.95 75 }; 96 76 … … 100 80 , m_platformContext(context->platformContext()) 101 81 , m_point(point) 102 , m_useGDI(windowsCanHandleTextDrawing(context)) 103 , m_hdc(0) 104 , m_createdTransparencyLayer(false) 105 { 106 } 107 108 void TransparencyAwareFontPainter::init() 109 { 110 if (m_useGDI) 111 initializeForGDI(); 112 } 113 114 void TransparencyAwareFontPainter::initializeForGDI() 115 { 116 m_graphicsContext->save(); 117 SkColor color = m_platformContext->effectiveFillColor(); 118 // Used only when m_createdTransparencyLayer is true. 119 float layerAlpha = 0.0f; 120 if (SkColorGetA(color) != 0xFF) { 121 // When the font has some transparency, apply it by creating a new 122 // transparency layer with that opacity applied. We'll actually create 123 // a new transparency layer after we calculate the bounding box. 124 m_createdTransparencyLayer = true; 125 layerAlpha = SkColorGetA(color) / 255.0f; 126 // The color should be opaque now. 127 color = SkColorSetRGB(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color)); 128 } 129 130 TransparencyWin::LayerMode layerMode; 131 IntRect layerRect; 132 if (m_platformContext->isDrawingToImageBuffer()) { 133 // Assume if we're drawing to an image buffer that the background 134 // is not opaque and we have to undo ClearType. We may want to 135 // enhance this to actually check, since it will often be opaque 136 // and we could do ClearType in that case. 137 layerMode = TransparencyWin::TextComposite; 138 layerRect = estimateTextBounds(); 139 m_graphicsContext->clip(layerRect); 140 if (m_createdTransparencyLayer) 141 m_graphicsContext->beginTransparencyLayer(layerAlpha); 142 143 // The transparency helper requires that we draw text in black in 144 // this mode and it will apply the color. 145 m_transparency.setTextCompositeColor(color); 146 color = SkColorSetRGB(0, 0, 0); 147 } else if (m_createdTransparencyLayer || canvasHasMultipleLayers(m_platformContext->canvas())) { 148 // When we're drawing a web page, we know the background is opaque, 149 // but if we're drawing to a layer, we still need extra work. 150 layerMode = TransparencyWin::OpaqueCompositeLayer; 151 layerRect = estimateTextBounds(); 152 m_graphicsContext->clip(layerRect); 153 if (m_createdTransparencyLayer) 154 m_graphicsContext->beginTransparencyLayer(layerAlpha); 155 } else { 156 // Common case of drawing onto the bottom layer of a web page: we 157 // know everything is opaque so don't need to do anything special. 158 layerMode = TransparencyWin::NoLayer; 159 } 160 161 // Bug 26088 - init() might fail if layerRect is invalid. Given this, we 162 // need to be careful to check for null pointers everywhere after this call 163 m_transparency.init(m_graphicsContext, layerMode, 164 TransparencyWin::KeepTransform, layerRect); 165 166 // Set up the DC, using the one from the transparency helper. 167 if (m_transparency.platformContext()) { 168 m_hdc = skia::BeginPlatformPaint(m_transparency.platformContext()->canvas()); 169 SetTextColor(m_hdc, skia::SkColorToCOLORREF(color)); 170 SetBkMode(m_hdc, TRANSPARENT); 171 } 172 } 173 174 TransparencyAwareFontPainter::~TransparencyAwareFontPainter() 175 { 176 if (!m_useGDI || !m_graphicsContext || !m_platformContext) 177 return; // Nothing to do. 178 m_transparency.composite(); 179 if (m_createdTransparencyLayer) 180 m_graphicsContext->endTransparencyLayer(); 181 m_graphicsContext->restore(); 182 if (m_transparency.platformContext()) 183 skia::EndPlatformPaint(m_transparency.platformContext()->canvas()); 82 { 184 83 } 185 84 … … 192 91 int from, int numGlyphs, 193 92 const FloatPoint&); 194 ~TransparencyAwareGlyphPainter();195 93 196 94 // Draws the partial string of glyphs, starting at |startAdvance| to the 197 // left of m_point. We express it this way so that if we're using the Skia 198 // drawing path we can use floating-point positioning, even though we have 199 // to use integer positioning in the GDI path. 200 bool drawGlyphs(int numGlyphs, const WORD* glyphs, const int* advances, float startAdvance) const; 95 // left of m_point. 96 void drawGlyphs(int numGlyphs, const WORD* glyphs, const int* advances, float startAdvance) const; 201 97 202 98 private: … … 207 103 int m_from; 208 104 int m_numGlyphs; 209 210 // When m_useGdi is set, this stores the previous HFONT selected into the211 // m_hdc so we can restore it.212 HGDIOBJ m_oldFont; // For restoring the DC to its original state.213 105 }; 214 106 … … 224 116 , m_from(from) 225 117 , m_numGlyphs(numGlyphs) 226 , m_oldFont(0) 227 { 228 init(); 229 230 if (m_hdc) 231 m_oldFont = ::SelectObject(m_hdc, m_font->platformData().hfont()); 232 } 233 234 TransparencyAwareGlyphPainter::~TransparencyAwareGlyphPainter() 235 { 236 if (m_useGDI && m_hdc) 237 ::SelectObject(m_hdc, m_oldFont); 238 } 239 118 { 119 } 240 120 241 121 // Estimates the bounding box of the given text. This is copied from … … 255 135 } 256 136 257 boolTransparencyAwareGlyphPainter::drawGlyphs(int numGlyphs,137 void TransparencyAwareGlyphPainter::drawGlyphs(int numGlyphs, 258 138 const WORD* glyphs, 259 139 const int* advances, 260 140 float startAdvance) const 261 141 { 262 if (!m_useGDI) { 263 SkPoint origin = m_point; 264 origin.fX += SkFloatToScalar(startAdvance); 265 paintSkiaText(m_graphicsContext, m_font->platformData().hfont(), 266 numGlyphs, glyphs, advances, 0, &origin); 267 return true; 268 } 269 270 if (!m_graphicsContext || !m_hdc) 271 return true; 272 273 // Windows' origin is the top-left of the bounding box, so we have 274 // to subtract off the font ascent to get it. 275 int x = lroundf(m_point.x() + startAdvance); 276 int y = lroundf(m_point.y() - m_font->fontMetrics().ascent()); 277 278 // If there is a non-blur shadow and both the fill color and shadow color 279 // are opaque, handle without skia. 280 FloatSize shadowOffset; 281 float shadowBlur; 282 Color shadowColor; 283 ColorSpace shadowColorSpace; 284 if (m_graphicsContext->getShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace)) { 285 // If there is a shadow and this code is reached, windowsCanHandleDrawTextShadow() 286 // will have already returned true during the ctor initiatization of m_useGDI 287 ASSERT(shadowColor.alpha() == 255); 288 ASSERT(m_graphicsContext->fillColor().alpha() == 255); 289 ASSERT(shadowBlur == 0); 290 COLORREF textColor = skia::SkColorToCOLORREF(SkColorSetARGB(255, shadowColor.red(), shadowColor.green(), shadowColor.blue())); 291 COLORREF savedTextColor = GetTextColor(m_hdc); 292 SetTextColor(m_hdc, textColor); 293 ExtTextOut(m_hdc, x + shadowOffset.width(), y + shadowOffset.height(), ETO_GLYPH_INDEX, 0, reinterpret_cast<const wchar_t*>(&glyphs[0]), numGlyphs, &advances[0]); 294 SetTextColor(m_hdc, savedTextColor); 295 } 296 297 return !!ExtTextOut(m_hdc, x, y, ETO_GLYPH_INDEX, 0, reinterpret_cast<const wchar_t*>(&glyphs[0]), numGlyphs, &advances[0]); 142 SkPoint origin = m_point; 143 origin.fX += SkFloatToScalar(startAdvance); 144 paintSkiaText(m_graphicsContext, m_font->platformData().hfont(), 145 numGlyphs, glyphs, advances, 0, &origin); 298 146 } 299 147 … … 305 153 int from, int to, 306 154 const FloatPoint&); 307 ~TransparencyAwareUniscribePainter();308 309 // Uniscibe will draw directly into our buffer, so we need to expose our DC.310 HDC hdc() const { return m_hdc; }311 155 312 156 private: … … 330 174 , m_from(from) 331 175 , m_to(to) 332 {333 init();334 }335 336 TransparencyAwareUniscribePainter::~TransparencyAwareUniscribePainter()337 176 { 338 177 } … … 426 265 } 427 266 428 // Actually draw the glyphs (with retry on failure). 429 bool success = false; 430 for (int executions = 0; executions < 2; ++executions) { 431 success = painter.drawGlyphs(curLen, &glyphs[0], &advances[0], horizontalOffset - point.x() - currentWidth); 432 if (!success && executions == 0) { 433 // Ask the browser to load the font for us and retry. 434 PlatformBridge::ensureFontLoaded(font->platformData().hfont()); 435 continue; 436 } 437 break; 438 } 439 440 if (!success) 441 LOG_ERROR("Unable to draw the glyphs after second attempt"); 267 painter.drawGlyphs(curLen, &glyphs[0], &advances[0], horizontalOffset - point.x() - currentWidth); 442 268 } 443 269 } … … 493 319 return; 494 320 495 TransparencyAwareUniscribePainter painter(graphicsContext, this, run, from, to, point);496 497 HDC hdc = painter.hdc();498 if (windowsCanHandleTextDrawing(graphicsContext) && !hdc)499 return;500 501 // TODO(maruel): http://b/700464 SetTextColor doesn't support transparency.502 // Enforce non-transparent color.503 color = SkColorSetRGB(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color));504 if (hdc) {505 SetTextColor(hdc, skia::SkColorToCOLORREF(color));506 SetBkMode(hdc, TRANSPARENT);507 }508 509 // If there is a non-blur shadow and both the fill color and shadow color510 // are opaque, handle without skia.511 FloatSize shadowOffset;512 float shadowBlur;513 Color shadowColor;514 ColorSpace shadowColorSpace;515 if (graphicsContext->getShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace) && windowsCanHandleDrawTextShadow(graphicsContext)) {516 COLORREF textColor = skia::SkColorToCOLORREF(SkColorSetARGB(255, shadowColor.red(), shadowColor.green(), shadowColor.blue()));517 COLORREF savedTextColor = GetTextColor(hdc);518 SetTextColor(hdc, textColor);519 state.draw(graphicsContext, hdc, static_cast<int>(point.x()) + shadowOffset.width(),520 static_cast<int>(point.y() - fontMetrics().ascent()) + shadowOffset.height(), from, to);521 SetTextColor(hdc, savedTextColor);522 }523 524 321 // Uniscribe counts the coordinates from the upper left, while WebKit uses 525 322 // the baseline, so we have to subtract off the ascent. 323 HDC hdc = 0; 526 324 state.draw(graphicsContext, hdc, lroundf(point.x()), lroundf(point.y() - fontMetrics().ascent()), from, to); 527 325 } -
trunk/Source/WebCore/platform/graphics/chromium/UniscribeHelper.cpp
r91822 r92022 270 270 int curX = x; 271 271 bool firstRun = true; 272 bool useWindowsDrawing = windowsCanHandleTextDrawing(graphicsContext);273 272 274 273 for (size_t screenIndex = 0; screenIndex < m_runs.size(); screenIndex++) { … … 349 348 const int* justify = shaping.m_justify.size() == 0 ? 0 : &shaping.m_justify[fromGlyph]; 350 349 351 if (useWindowsDrawing) {352 if (firstRun) {353 oldFont = SelectObject(dc, shaping.m_hfont);354 firstRun = false;355 } else356 SelectObject(dc, shaping.m_hfont);357 }358 359 350 // Fonts with different ascents can be used to render different 360 351 // runs. 'Across-runs' y-coordinate correction needs to be … … 362 353 bool textOutOk = false; 363 354 for (int executions = 0; executions < 2; ++executions) { 364 if (useWindowsDrawing) { 365 HRESULT hr = ScriptTextOut(dc, shaping.m_scriptCache, 366 curX + innerOffset, 367 y - shaping.m_ascentOffset, 368 0, 0, &item.a, 0, 0, 369 &shaping.m_glyphs[fromGlyph], 370 glyphCount, 371 &shaping.m_advance[fromGlyph], 372 justify, 373 &shaping.m_offsets[fromGlyph]); 374 textOutOk = (hr == S_OK); 375 } else { 376 SkPoint origin; 377 origin.fX = curX + + innerOffset; 378 origin.fY = y + m_ascent; 379 paintSkiaText(graphicsContext, 380 shaping.m_hfont, 381 glyphCount, 382 &shaping.m_glyphs[fromGlyph], 383 &shaping.m_advance[fromGlyph], 384 &shaping.m_offsets[fromGlyph], 385 &origin); 386 textOutOk = true; 387 } 355 SkPoint origin; 356 origin.fX = curX + + innerOffset; 357 origin.fY = y + m_ascent; 358 paintSkiaText(graphicsContext, 359 shaping.m_hfont, 360 glyphCount, 361 &shaping.m_glyphs[fromGlyph], 362 &shaping.m_advance[fromGlyph], 363 &shaping.m_offsets[fromGlyph], 364 &origin); 365 textOutOk = true; 388 366 389 367 if (!textOutOk && 0 == executions) { -
trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
r91822 r92022 570 570 } 571 571 572 bool PlatformContextSkia::isNativeFontRenderingAllowed()573 {574 #if ENABLE(SKIA_TEXT)575 return false;576 #else577 if (useSkiaGPU())578 return false;579 return skia::SupportsPlatformPaint(m_canvas);580 #endif581 }582 583 572 void PlatformContextSkia::getImageResamplingHint(IntSize* srcSize, FloatSize* dstSize) const 584 573 { -
trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h
r91835 r92022 168 168 void setPrinting(bool p) { m_printing = p; } 169 169 170 // Returns if the context allows rendering of fonts using native platform171 // APIs. If false is returned font rendering is performed using the skia172 // text drawing APIs.173 bool isNativeFontRenderingAllowed();174 175 170 void getImageResamplingHint(IntSize* srcSize, FloatSize* dstSize) const; 176 171 void setImageResamplingHint(const IntSize& srcSize, const FloatSize& dstSize); -
trunk/Source/WebCore/platform/graphics/skia/SkiaFontWin.cpp
r91822 r92022 43 43 44 44 namespace WebCore { 45 46 bool windowsCanHandleDrawTextShadow(GraphicsContext *context)47 {48 FloatSize shadowOffset;49 float shadowBlur;50 Color shadowColor;51 ColorSpace shadowColorSpace;52 53 bool hasShadow = context->getShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);54 return !hasShadow || (!shadowBlur && (shadowColor.alpha() == 255) && (context->fillColor().alpha() == 255));55 }56 57 bool windowsCanHandleTextDrawing(GraphicsContext* context)58 {59 if (!windowsCanHandleTextDrawingWithoutShadow(context))60 return false;61 62 // Check for shadow effects.63 if (!windowsCanHandleDrawTextShadow(context))64 return false;65 66 return true;67 }68 69 bool windowsCanHandleTextDrawingWithoutShadow(GraphicsContext* context)70 {71 // Check for non-translation transforms. Sometimes zooms will look better in72 // Skia, and sometimes better in Windows. The main problem is that zooming73 // in using Skia will show you the hinted outlines for the smaller size,74 // which look weird. All else being equal, it's better to use Windows' text75 // drawing, so we don't check for zooms.76 const AffineTransform& matrix = context->getCTM();77 if (matrix.b() != 0 || matrix.c() != 0) // Check for skew.78 return false;79 80 // Check for stroke effects.81 if (context->platformContext()->getTextDrawingMode() != TextModeFill)82 return false;83 84 // Check for gradients.85 if (context->fillGradient() || context->strokeGradient())86 return false;87 88 // Check for patterns.89 if (context->fillPattern() || context->strokePattern())90 return false;91 92 if (!context->platformContext()->isNativeFontRenderingAllowed())93 return false;94 95 return true;96 }97 45 98 46 static void skiaDrawText(SkCanvas* canvas, -
trunk/Source/WebCore/platform/graphics/skia/SkiaFontWin.h
r91822 r92022 40 40 41 41 class GraphicsContext; 42 class PlatformContextSkia;43 44 // The functions below are used for more complex font drawing (effects such as45 // stroking and more complex transforms) than Windows supports directly. Since46 // Windows drawing is faster you should use windowsCanHandleTextDrawing first to47 // check if using Skia is required at all.48 // Note that the text will look different (no ClearType) so this should only be49 // used when necessary.50 //51 // When you call a Skia* text drawing function, various glyph outlines will be52 // cached. As a result, you should call SkiaWinOutlineCache::removePathsForFont53 // when the font is destroyed so that the cache does not outlive the font (since54 // the HFONTs are recycled).55 //56 // Remember that Skia's text drawing origin is the baseline, like WebKit, not57 // the top, like Windows.58 59 // Returns true if the fillColor and shadowColor are opaque and the text-shadow60 // is not blurred.61 bool windowsCanHandleDrawTextShadow(GraphicsContext*);62 63 // Returns true if advanced font rendering is recommended.64 bool windowsCanHandleTextDrawing(GraphicsContext*);65 66 // Returns true if advanced font rendering is recommended if shadows are67 // disregarded.68 bool windowsCanHandleTextDrawingWithoutShadow(GraphicsContext*);69 42 70 43 // Note that the offsets parameter is optional. If not NULL it represents a
Note:
See TracChangeset
for help on using the changeset viewer.